1

We're using bitcoind on our server.

When people withdraw from our system we want to have the correct miner fee.

I understand that we can get the good miner fee from txconfirmtarget or the API from: https://bitcoinfees.21.co/api

But when we send a transaction how do we know which miner fee to put if we want to enter it into the database?

EDIT: I do notice this: bitcoin-cli estimatefee 2 but then how do we find out how many bytes are being sent?

  • Are you using bitcoind's internal wallet or just using it to create and broadcast a raw transaction? – Andrew Chow Jul 5 '17 at 23:17
  • bitcoind on a centos server – Marc Alexander Jul 6 '17 at 16:25
  • That doesn't answer my question. Are you using bitcoind as a wallet (i.e. using sendtoaddress, sendmany, etc. RPCs) or just as a node to broadcast your transactions with? – Andrew Chow Jul 6 '17 at 16:31
  • as a wallet with RPCs – Marc Alexander Jul 6 '17 at 16:37
1

When you use bitcoind's internal wallet and its related RPCs, it will automatically calculate the transaction fee for you and include that in the transaction. You can then retrieve the transaction fee used by using the gettransaction command. If you want the fee rate that was used, you can use the fee from gettransaction and divide that by the size returned by gettransaction.

Edit: To get the fee before you send, you can create the transaction with only the outputs you want (i.e. no inputs) with createrawtransaction. Then you can use fundrawtransaction to fill out the transaction with inputs. That will also give you the fee that the transaction is paying. Then you sign it with signrawtransaction and send it with sendrawtransaction. There is no other way as the other send* RPCs create the transaction, select coins, sign, and send all in one command.

  • But I want to estimate the fee before the transaction is sent. – Marc Alexander Jul 6 '17 at 20:03
  • I've edited with further instructions to get the fee before the transaction is sent. – Andrew Chow Jul 6 '17 at 20:32
  • Thanks for the update. So basically I do createrawtransaction and fundrawtransaction and it returns the size of the transaction, then I can set a custom fee based on how many bytes it is.. then of course sendrawtransaction. – Marc Alexander Jul 6 '17 at 20:52
  • No, you can't set the fee after the transaction has been created. The fee has to be set when the transaction is being funded. fundrawtransaction has an option to set the fee rate. Just read the help text for it. – Andrew Chow Jul 6 '17 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.