aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-09-26 16:24:21 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-09-26 16:24:28 +0200
commitdc597bb895ef4b74d8564253813c2d140e76c2d6 (patch)
tree61e11723274b0de026dfff59c350a2243d69aab4 /src
parent0f8e09599db6fd34fa5d83160620cb2ddb05f09f (diff)
parentd01a9682b126a5f83c7311e652e6e62f2c2e1d20 (diff)
downloadbitcoin-dc597bb895ef4b74d8564253813c2d140e76c2d6.tar.xz
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
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index fd2c1dfbe7..d83203f409 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -915,6 +915,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,
+ // 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()) {
+ wtx.SetTx(wtxIn.tx);
+ fUpdated = true;
+ }
}
//// debug print