[Pkg-bitcoin-commits] [bitcoin] 51/126: wallet: update stored witness in AddToWallet

Jonas Smedegaard dr at jones.dk
Mon Nov 13 20:01:55 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.15.1_dfsg-1
in repository bitcoin.

commit 6b4d9f273607bcacaa65a7a030eef5cc9d6bb6e8
Author: Suhas Daftuar <sdaftuar at chaincode.com>
Date:   Sun Sep 3 08:43:35 2017 -0400

    wallet: update stored witness in AddToWallet
    
    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: #11225
    Rebased-From: d01a9682b126a5f83c7311e652e6e62f2c2e1d20
---
 src/wallet/wallet.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index bf8981e..5e833eb 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -969,6 +969,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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/bitcoin.git



More information about the Pkg-bitcoin-commits mailing list