diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-05-07 20:53:48 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-05-19 13:22:27 -0400 |
commit | cc3f14b27c06b7a0da1472f5c7100c3f0b76fd98 (patch) | |
tree | 242d69a5ec147c416a71e1ca56123de54940866c /src/bench | |
parent | d97d25d95006725e705635530b27643363d6b2a4 (diff) |
Move output reductions for fee to after coin selection
Simplifies CreateTransactionInternal without changing behavior. Removes
the pick_new_inputs variable by moving the subtract fee from amount
implementation to later in the loop to where it is possible to calculate
the fee for the transaction. This allows the fee to be subtracted from
the outputs within a single iteration, instead of calculating the fee in
the first iteration, and subtracting the fee in the second.
This also removes another scenario where a second iteration of the loop
finds a smaller input set (and thus smaller fees than the first
iteration) with no change and so a third iteration of the loop is done in order to make
a change output that contains the excess fees.
To handle these cases, we always create a change output which contains
the difference between selected input values and the recipient amounts.
Once the transaction fee is calculated, the change output is reduced (in
the normal case) or the recipient amounts are reduced (in the subtract
fee from amount case). All of this is done in a single iteration of the
loop.
Diffstat (limited to 'src/bench')
0 files changed, 0 insertions, 0 deletions