<p>No, you shouldn't need to sign the transaction until it's completely crafted. Bitcoin core can handle this for you!</p>
<p>An easier flow when creating a transaction is</p>
<ol>
<li><a href="https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/createrawtransaction/" rel="nofollow noreferrer">Create raw transaction</a>. Don't add any inputs yet.</li>
<li><a href="https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/fundrawtransaction/" rel="nofollow noreferrer">Fund raw transaction</a>. This will select inputs for you. Add <code>subtractFeeFromOutputs</code> of the output you want to subtract the final fee from. The docs on <code>subtractFeeFromOutputs</code> 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.</li>
<li><a href="https://bitcoincore.org/en/doc/0.16.0/rpc/rawtransactions/signrawtransaction/" rel="nofollow noreferrer">Sign your raw transcation</a>. Voila, you're done!</li>
</ol>

CC BY-SA 4.0
2021-02-01T16:13:23.690Z
2021-02-01T19:59:20.893Z
2021-02-01T19:59:20.893Z
Bjørn Olav Jalborg
<p>To make a transaction of &quot;max amount&quot; with a given feerate, is there a shorter procedure than the following?</p>
<ul>
<li>Craft transaction with with one output</li>
<li>Sign it</li>
<li>Consider the signed length - multiply it with the feerate</li>
<li>Subtract the difference</li>
<li>Set the dest amount</li>
<li>Re-sign it</li>
</ul>

<transactions><fee-estimation>
Does sending the "max amount" with given feerate require crafting the transaction twice?
MCCCS
# Does sending the "max amount" with given feerate require crafting the transaction twice?

(Asked by: username_0 on 2021-02-01)

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

**Tags:** transactions, fee-estimation


---

## 1 answers

### Answer by username_1 on 2021-02-01. Score: 4 | Accepted answer

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](https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/createrawtransaction/). Don't add any inputs yet.
2. [Fund raw transaction](https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/fundrawtransaction/). 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](https://bitcoincore.org/en/doc/0.16.0/rpc/rawtransactions/signrawtransaction/). Voila, you're done!


---

