Skip to content

Commit 3b98bf9

Browse files
committed
Revert "Add to spends only transcations from me"
This reverts commit d045664.
1 parent dbf81a7 commit 3b98bf9

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

src/wallet/test/wallet_tests.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -820,35 +820,30 @@ BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
820820
context.args = &gArgs;
821821
context.chain = m_node.chain.get();
822822
auto wallet = TestLoadWallet(context);
823-
AddKey(*wallet, coinbaseKey);
823+
CKey key;
824+
key.MakeNewKey(true);
825+
AddKey(*wallet, key);
824826

825-
// rescan to ensure coinbase transactions from test fixture are picked up by the wallet
826-
{
827-
WalletRescanReserver reserver(*wallet);
828-
reserver.reserve();
829-
wallet->ScanForWalletTransactions(m_node.chain->getBlockHash(0), 0, /* max height= */ {}, reserver, /* update= */ true);
830-
}
831-
// create one more block to get the first block coinbase to maturity
827+
std::string error;
832828
m_coinbase_txns.push_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
833-
// spend first coinbase tx
834-
auto spend_tx = TestSimpleSpend(*m_coinbase_txns[0], 0, coinbaseKey, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
835-
CreateAndProcessBlock({spend_tx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
829+
auto block_tx = TestSimpleSpend(*m_coinbase_txns[0], 0, coinbaseKey, GetScriptForRawPubKey(key.GetPubKey()));
830+
CreateAndProcessBlock({block_tx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
836831

837832
SyncWithValidationInterfaceQueue();
838833

839834
{
840-
auto spend_tx_hash = spend_tx.GetHash();
835+
auto block_hash = block_tx.GetHash();
841836
auto prev_hash = m_coinbase_txns[0]->GetHash();
842837

843838
LOCK(wallet->cs_wallet);
844839
BOOST_CHECK(wallet->HasWalletSpend(prev_hash));
845-
BOOST_CHECK_EQUAL(wallet->mapWallet.count(spend_tx_hash), 1u);
840+
BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 1u);
846841

847-
std::vector<uint256> vHashIn{spend_tx_hash}, vHashOut;
842+
std::vector<uint256> vHashIn{ block_hash }, vHashOut;
848843
BOOST_CHECK_EQUAL(wallet->ZapSelectTx(vHashIn, vHashOut), DBErrors::LOAD_OK);
849844

850845
BOOST_CHECK(!wallet->HasWalletSpend(prev_hash));
851-
BOOST_CHECK_EQUAL(wallet->mapWallet.count(spend_tx_hash), 0u);
846+
BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 0u);
852847
}
853848

854849
TestUnloadWallet(std::move(wallet));

src/wallet/wallet.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const
952952
wtx.nOrderPos = IncOrderPosNext(&batch);
953953
wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx));
954954
wtx.nTimeSmart = ComputeTimeSmart(wtx, rescanning_old_block);
955-
if (IsFromMe(*tx.get())) {
956-
AddToSpends(hash);
957-
}
955+
AddToSpends(hash, &batch);
958956
}
959957

960958
if (!fInsertedNew)

0 commit comments

Comments
 (0)