Skip to content

Commit dc597bb

Browse files
committed
Merge #11225: wallet: update stored witness in AddToWallet
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
2 parents 0f8e095 + d01a968 commit dc597bb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,15 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
915915
wtx.fFromMe = wtxIn.fFromMe;
916916
fUpdated = true;
917917
}
918+
// If we have a witness-stripped version of this transaction, and we
919+
// see a new version with a witness, then we must be upgrading a pre-segwit
920+
// wallet. Store the new version of the transaction with the witness,
921+
// as the stripped-version must be invalid.
922+
// TODO: Store all versions of the transaction, instead of just one.
923+
if (wtxIn.tx->HasWitness() && !wtx.tx->HasWitness()) {
924+
wtx.SetTx(wtxIn.tx);
925+
fUpdated = true;
926+
}
918927
}
919928

920929
//// debug print

0 commit comments

Comments
 (0)