4

I am using the RPC API to submit automated transactions to my Bitcond, the user introduces the Amount and I check it against its balance before submitting the transaction.

I would like to also check if the user has enough balance to pay the network fee as well.

  • Is there a way to know the Bitcoin Network transaction fee BEFORE actually submitting the transaction?
  • Is there a way I can define the network fee?
4

Yes.

  • Use createrawtransaction with the outputs you want, but no inputs.
  • Use fundrawtransaction to make the wallet add inputs and a change output if necessary.
  • Check what fee the resulting unsubmitted raw transaction has. If you like the result, continue:
  • Call signrawtransaction to sign the inputs.
  • Call sendrawtransaction to broadcast it on the network, and as a side effect, list it in the wallet.

You can't control the network fee directly (as it is per byte, and you don't know the size beforehand), but you can set the feerate using -paytxfee. In a new release, you'll also be able to pass the feerate to fundrawtransaction.

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.