Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
[wallet] fee fixes: always create change, adjust value, and p… #10333
Conversation
instagibbs
changed the title from
CreateTransction fee fixes: always create change, adjust value, and p… to [wallet] fee fixes: always create change, adjust value, and p…
May 3, 2017
jonasschnelli
added the
Wallet
label
May 4, 2017
|
Note: This is a "regression" due to A bit confusing since the change is dropped when |
instagibbs
referenced
this pull request
May 8, 2017
Open
[WIP] [Wallet] Target effective value during transaction creation #10360
laanwj
added this to the
0.15.0
milestone
May 11, 2017
|
rebased, and included logic to attempt change larger than |
|
suggested new strategy: instead of "trying one more time" when change is in middle-ground, cache the current transaction, increase the amount you're attempting to send, and try again. If you then run out of available coins, you simply return the cached version of the transaction. |
laanwj
added
to Blockers in High-priority for review
Jun 22, 2017
|
Implemented the previously mentioned idea. Instead of doing "one more try" to get acceptable change, it caches the successful yet small change transaction and slowly grows the amount of coins it grabs until it creates an acceptable transaction, given reasonable chosen inputs this will result in a transaction with change larger than MIN_FINAL_CHANGE. If it fails and runs out of coins it returns the cached transaction. |
| + // change dust or change larger than MIN_FINAL_CHANGE, it will | ||
| + // return this transaction. | ||
| + CMutableTransaction tx_cached; | ||
| + bool have_cached_txn; |
achow101
Jun 23, 2017
Contributor
Shouldn't you assign have_cached_txn to false here as it is not assiged before it is used down below?
| + // Insert change txn at random position: | ||
| + nChangePosInOut = GetRandInt(txNew.vout.size()+1); | ||
| + } | ||
| + else if ((unsigned int)nChangePosInOut > txNew.vout.size()) |
achow101
Jun 23, 2017
Contributor
I don't see how this case matters. Wouldn't nChangePosInOut never be set to an out of range index?
instagibbs
Jun 23, 2017
Member
Caller may request a too-high change position. This is also a simple code move, not going to change this logic.
| + } else if (txNew.vout[nChangePosInOut].nValue < MIN_FINAL_CHANGE) { | ||
| + // Save this transaction, use if we cannot get large-enough change | ||
| + if (!have_cached_txn) { | ||
| + tx_cached = txNew; |
achow101
Jun 23, 2017
Contributor
have_cached_txn should probably be set to true here as it is never actually set anywhere
|
fixed issues, thanks @achow101 |
morcos
referenced
this pull request
Jun 30, 2017
Merged
Add change output if necessary to reduce excess fee #10712
|
I think #10712 is preferable to this PR |
|
closing in favor of #10712 |
instagibbs
closed this
Jul 5, 2017
laanwj
removed
from Blockers in High-priority for review
Jul 6, 2017
laanwj
added a commit
that referenced
this pull request
Jul 11, 2017
|
|
laanwj |
e8b9523
|
instagibbs commentedMay 3, 2017
•
edited
…rune later
This PR is an attempt to solve some of #10247 , first and foremost the case:
This is resolved by always assuming a change output exists, and rebalancing that value by the fee excess, and deleting when necessary. The logic is also simpler to me.