From f0dcfceb81b8a373eea5900a6fd352209441f119 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Oct 2018 15:40:50 -0700 Subject: [PATCH] Closes #3560. Update Sapling note data correctly when importing a key. --- qa/rpc-tests/wallet_sapling.py | 8 ++++++++ src/wallet/wallet.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/wallet_sapling.py b/qa/rpc-tests/wallet_sapling.py index bba426868..c3b17af50 100755 --- a/qa/rpc-tests/wallet_sapling.py +++ b/qa/rpc-tests/wallet_sapling.py @@ -136,5 +136,13 @@ class WalletSaplingTest(BitcoinTestFramework): assert('outCiphertext' in shieldedOutput) assert('proof' in shieldedOutput) + # Verify importing a spending key will update the nullifiers and witnesses correctly + sk0 = self.nodes[0].z_exportkey(saplingAddr0) + self.nodes[2].z_importkey(sk0, "yes") + assert_equal(self.nodes[2].z_getbalance(saplingAddr0), Decimal('10')) + sk1 = self.nodes[1].z_exportkey(saplingAddr1) + self.nodes[2].z_importkey(sk1, "yes") + assert_equal(self.nodes[2].z_getbalance(saplingAddr1), Decimal('5')) + if __name__ == '__main__': WalletSaplingTest().main() diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d838f485e..2125f0d1c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2367,7 +2367,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) } } // Increment note witness caches - IncrementNoteWitnesses(pindex, &block, sproutTree, saplingTree); + ChainTip(pindex, &block, sproutTree, saplingTree, true); pindex = chainActive.Next(pindex); if (GetTime() >= nNow + 60) {