1

To make a transaction of "max amount" with a given feerate, is there a shorter procedure than the following?

  • Craft transaction with with one output
  • Sign it
  • Consider the signed length - multiply it with the feerate
  • Subtract the difference
  • Set the dest amount
  • Re-sign it
4

No, you shouldn't need to sign the transaction until it's completely crafted. Bitcoin core can handle this for you!

An easier flow when creating a transaction is

  1. Create raw transaction. Don't add any inputs yet.
  2. Fund raw transaction. This will select inputs for you. Add subtractFeeFromOutputs of the output you want to subtract the final fee from. The docs on subtractFeeFromOutputs is a bit confusing, but it wants you to specify which output(vout) the fee should be deducted from. If you specify multiple outputs, the fee is spread equally across the outputs. Bitcoin core will amend the amount in the output(s) you specified.
  3. Sign your raw transcation. Voila, you're done!

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.