diff options
author | Andrew Chow <achow101-github@achow101.com> | 2022-02-01 14:42:02 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2022-02-01 14:46:11 -0500 |
commit | 02e1d8d06f2d7bd03687b2b2d5fd0dfc9a6c9cfc (patch) | |
tree | 687de7c479fdce3a864611a9881e3c63c23e1ae8 /src/wallet | |
parent | 133f73e86bd7c3114263500be2fb5090dd76b4bc (diff) | |
parent | 3ee6d0788ec1b90f7c39c9644dba4011f7cf5db4 (diff) |
Merge bitcoin/bitcoin#24083: Revert "Add to spends only transcations from me"
3ee6d0788ec1b90f7c39c9644dba4011f7cf5db4 test: add more wallet conflicts assertions (S3RK)
3b98bf9c43ece060d57d7ae31624d4a8220de266 Revert "Add to spends only transcations from me" (S3RK)
Pull request description:
This reverts commit d04566415e16ae685af066384f346dff522c068f from #22929.
This commit was based on invalid assumption that `mapTxSpends` should contain only outgoing txs and broke wallet conflicts feature.
ACKs for top commit:
achow101:
ACK 3ee6d0788ec1b90f7c39c9644dba4011f7cf5db4
Tree-SHA512: bf5a77ced6bac57d5eb85771d9189c53e1edc295d179ed5a1bdce18e365794a9101b4cecf35387b27f67260db3b47f7214e7876e490494529b748cceeb95632d
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/test/wallet_tests.cpp | 25 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 4 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 9a74545fb5..8ef0d46c4f 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -825,35 +825,30 @@ BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup) context.args = &gArgs; context.chain = m_node.chain.get(); auto wallet = TestLoadWallet(context); - AddKey(*wallet, coinbaseKey); + CKey key; + key.MakeNewKey(true); + AddKey(*wallet, key); - // rescan to ensure coinbase transactions from test fixture are picked up by the wallet - { - WalletRescanReserver reserver(*wallet); - reserver.reserve(); - wallet->ScanForWalletTransactions(m_node.chain->getBlockHash(0), 0, /* max height= */ {}, reserver, /* update= */ true); - } - // create one more block to get the first block coinbase to maturity + std::string error; m_coinbase_txns.push_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]); - // spend first coinbase tx - auto spend_tx = TestSimpleSpend(*m_coinbase_txns[0], 0, coinbaseKey, GetScriptForRawPubKey(coinbaseKey.GetPubKey())); - CreateAndProcessBlock({spend_tx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())); + auto block_tx = TestSimpleSpend(*m_coinbase_txns[0], 0, coinbaseKey, GetScriptForRawPubKey(key.GetPubKey())); + CreateAndProcessBlock({block_tx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())); SyncWithValidationInterfaceQueue(); { - auto spend_tx_hash = spend_tx.GetHash(); + auto block_hash = block_tx.GetHash(); auto prev_hash = m_coinbase_txns[0]->GetHash(); LOCK(wallet->cs_wallet); BOOST_CHECK(wallet->HasWalletSpend(prev_hash)); - BOOST_CHECK_EQUAL(wallet->mapWallet.count(spend_tx_hash), 1u); + BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 1u); - std::vector<uint256> vHashIn{spend_tx_hash}, vHashOut; + std::vector<uint256> vHashIn{ block_hash }, vHashOut; BOOST_CHECK_EQUAL(wallet->ZapSelectTx(vHashIn, vHashOut), DBErrors::LOAD_OK); BOOST_CHECK(!wallet->HasWalletSpend(prev_hash)); - BOOST_CHECK_EQUAL(wallet->mapWallet.count(spend_tx_hash), 0u); + BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 0u); } TestUnloadWallet(std::move(wallet)); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 337a5139e1..84962af906 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -952,9 +952,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const wtx.nOrderPos = IncOrderPosNext(&batch); wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx)); wtx.nTimeSmart = ComputeTimeSmart(wtx, rescanning_old_block); - if (IsFromMe(*tx.get())) { - AddToSpends(hash); - } + AddToSpends(hash, &batch); } if (!fInsertedNew) |