-
Notifications
You must be signed in to change notification settings - Fork 37.7k
wallet: update stored witness in AddToWallet #11225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace witness-stripped wallet transactions with full transactions; this can happen when upgrading from a pre-segwit wallet to a segwit- aware wallet.
utACK 617c459. |
utACK d01a968 This should be backported to 0.15(.1), I think. |
@@ -914,6 +914,15 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose) | |||
wtx.fFromMe = wtxIn.fFromMe; | |||
fUpdated = true; | |||
} | |||
// If we have a witness-stripped version of this transaction, and we | |||
// see a new version with a witness, then we must be upgrading a pre-segwit | |||
// wallet. Store the new version of the transaction with the witness, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space.
// wallet. Store the new version of the transaction with the witness, | ||
// as the stripped-version must be invalid. | ||
// TODO: Store all versions of the transaction, instead of just one. | ||
if (wtxIn.tx->HasWitness() && !wtx.tx->HasWitness()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First check stored transaction:
if (!wtx.tx->HasWitness() && wtxIn.tx->HasWitness()) {
BTW, remove TODO comment and create an issue since it requires a significant change/discussion? |
Wait, do we want to also update if the witness was malleated on its way into a block? |
@TheBlueMatt I considered that issue, and decided it was more conservative (at least for now) to not do that, because: b) is pretty edge-case, to be sure, but since the only benefit to storing the actually-confirmed-witness is recordkeeping, which doesn't affect our wallet's behavior, I figure why risk it. IMO we should eventually store both the original version of the transaction and any malleated versions that get confirmed. |
Yea, ok, more complexity than I figured, this is clearly better than nothing as-is and anything more looks like it'll take some real rewriting of our malleability handling. |
d01a968 wallet: update stored witness in AddToWallet (Suhas Daftuar) Pull request description: Replace witness-stripped wallet transactions with full transactions; this can happen when upgrading from a pre-segwit wallet to a segwit- aware wallet. Tree-SHA512: a348b16b38ae738fa75cf7d3ff50ebd0d0071d5d6061c9a10dc3325fc34f6bc96a67aea21fde460ca20f6178768ee0af04d6d8785b35647f436a9083c4270b07
Replace witness-stripped wallet transactions with full transactions; this can happen when upgrading from a pre-segwit wallet to a segwit- aware wallet. Github-Pull: bitcoin#11225 Rebased-From: d01a968
Replace witness-stripped wallet transactions with full transactions;
this can happen when upgrading from a pre-segwit wallet to a segwit-
aware wallet.