I'm using bitcoind
and for the transfer of tokens from one account to other, I'm using sendFrom
method. but there is a transaction fee calculation and on the bitcoin-qt panel, In the transactions screen, it is showing an fee amount(-0.00001215) was deducted.
Status: 2/unconfirmed, broadcast through 3 nodes
Date: 23-10-2017 11:25
To: EVR purchase
Total debit: -0.10000000 BTC
Total credit: 0.10000000 BTC
Transaction fee: -0.00001215 BTC
Net amount: -0.00001215 BTC
Comment:
addr
Transaction ID: c9f7c16c2f61818a6c6180ea2242e2139e4bb4400ab199e7c9f2b93802d6ed52
Transaction total size: 373 bytes
Output index: 0
Currently, I'm following http://bitcoinfees.21.co/api/v1/fees/recommended and getting the fastest fee from that api and then using bitcoin-cli commands, to set the transaction fee(settxfee
) and then doing the transfer. But instead of the given txFee, some random txfee is getting deducted from the wallet.
Can anyone help me, how to calculate the txFee properly?
My Code :
client.walletPassphrase(config.BTCWalletPassword, 600)
.then(function (transactionHash) {
client.setTxFee(txFee).then(function (successdata) {
client.sendFrom(fromAccountName, toAccountAddress, totalAmount, 0, 'comment1', 'comment2')
.then(function (transactionHash) {
console.log(transactionHash);
client.walletLock()
.then(function (locked) {
process.exit();
})
.catch(function (err) {
process.exit();
});
})
.catch(function (err) {
console.log(err);
process.exit();
});
})
.catch(function (err) {
console.log('settxfee error :'+ err);
process.exit();
});
})
.catch(function (err) {
console.log(err);
process.exit();
});