Rebases #9167 by @morcos on master.
Why do this: this is mostly a refactor which fixes some bugs, e.g. fee in gettransaction
for mixed owner inputs.
So, the new IsAllFromMe
code does not check if GetDebit(ISMINE_ALL) > 0
, which IsMine
does. The result is that the existing code will say ’not eligible’ and the new code will say ’eligible’, for many of the coin selector test cases. I think adding a check for GetDebit
to IsAllFromMe
is the right approach, but I believe @morcos removed this part for a reason in #9167.
Ping @morcos. Still investigating the issue, so this may become irrelevant.
Edit: It seems this:
0CTransaction(hash=777c42d727, ver=2, vin.size=0, vout.size=1, nLockTime=0)
1 CTxOut(nValue=0.01000000, scriptPubKey=)
is considered all mine. Which technically speaking is correct, but CWalletTx::GetDebit
explicitly returns 0 (i.e. not mine) for vin.empty()
, so I might adapt that logic in IsAllFromMe
as well.
I believe fdb1d59 (count 0-vin transactions as not mine in IsAllFromMe
) and 5073476 (consider coinbase transaction as all mine in CWallet
) address the problems, but I’m not sure the latter is entirely correct in all cases. If a random person checks a coinbase transaction, I think it will claim it is theirs now. I think adding a ‘can spend’ check should suffice here.
Edit: CWallet::IsAllFromMe
is only used in the feebumper, and since coinbase transactions can’t be fee-bumped anyway, 5073476 should be fine. To clarify: the IsFromMe
code already behaves this way (i.e. consider coinbase transactions as from me, if in miner wallet); it may be worth it to fall back to IsFromMe
style check of GetDebit(..) > 0
though.
Here’s my interpretation of the commits:
OutputEligibleForSpending
to only consider outputs trusted / mine if all their inputs are mine, rather than just one of them.gettransaction
rpc to only include fee information if all inputs pass the relevant filter, rather than just one.CWallet::IsAllFromMe
to consider coinbase transactions mine.
There is no change in behavior.
Change coin selection in SelectCoinsMinConf to only consider coins mine for spending at the fewer required confirmations if all inputs being spent are mine instead of requiring at least one.
No change in behavior. IsTrusted was already a stricter check.
Fee is now only displayed if all inputs meet the required filter, so if displayed the fee will always be correct. Unusual fees may still be displayed in details.
No change in behavior.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.