Bitcoin Transaction using API with Custom Fees
I want to transfer Bitcoin from one individual address to another using API. But I want to set Transaction fees as per my requirement. So How can I do it ?
Right now I am using blockchain-transaction - npm api for transfer bitcoin from one address to another. So please shade some lights on this.
var bitcoinTransaction = require('bitcoin-transaction');
//Send all my money from wallet1 to wallet2 on the bitcoin testnet
var from = "mm3gdVh8n6YtcNyaTKYkveB6yTME7aDWNJ";
var to = "mgPUfqJk4X6gE4P5Do5RfpkTFsYmsSjCya";
var privKeyWIF = "cNZi8iySqBToXMpcsQaHKD5uv7HExBQJBSi4dTg3ZPaEzeNAzvbj"; //Private key in WIF form (Can generate this from bitcoinlib-js)
bitcoinTransaction.getBalance(from, { network: "testnet" }).then((balanceInBTC) => {
return bitcoinTransaction.sendTransaction({
from: from,
to: to,
privKeyWIF: privKeyWIF,
btc: balanceInBTC,
network: "testnet"
});
});
Top Answer/Comment:
I have not tried this myself but having a look through the documentation on blockchain-transaction - npm api it looks like you can query fees, under the advanced section:
fees - Gets a list of current fees based on the BitCoin network going
rate.
https://www.npmjs.com/package/bitcoin-transaction
Looks like you can select a 'fastest' option or others:
Set the fee for the transaction. Can be either one of "fastest",
"halfHour" or "hour" in which case the actual fee numbers are fetched
from the fees provider. Or it can be just a plain number in which case
that will be used as the Fee per Byte value in Satoshis. It is
recommended to use one of the string aliases unless you know what you
are doing.
You might have to specify a feesProvider, not sure if they have a default selected when nothing set.
상단 광고의 [X] 버튼을 누르면 내용이 보입니다