mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
Revert "Add to spends only transcations from me"
This reverts commit d04566415e
.
This commit is contained in:
parent
dbf81a73e3
commit
3b98bf9c43
2 changed files with 11 additions and 18 deletions
|
@ -820,35 +820,30 @@ BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
|
||||||
context.args = &gArgs;
|
context.args = &gArgs;
|
||||||
context.chain = m_node.chain.get();
|
context.chain = m_node.chain.get();
|
||||||
auto wallet = TestLoadWallet(context);
|
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
|
std::string error;
|
||||||
{
|
|
||||||
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
|
|
||||||
m_coinbase_txns.push_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
|
m_coinbase_txns.push_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
|
||||||
// spend first coinbase tx
|
auto block_tx = TestSimpleSpend(*m_coinbase_txns[0], 0, coinbaseKey, GetScriptForRawPubKey(key.GetPubKey()));
|
||||||
auto spend_tx = TestSimpleSpend(*m_coinbase_txns[0], 0, coinbaseKey, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
|
CreateAndProcessBlock({block_tx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
|
||||||
CreateAndProcessBlock({spend_tx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
|
|
||||||
|
|
||||||
SyncWithValidationInterfaceQueue();
|
SyncWithValidationInterfaceQueue();
|
||||||
|
|
||||||
{
|
{
|
||||||
auto spend_tx_hash = spend_tx.GetHash();
|
auto block_hash = block_tx.GetHash();
|
||||||
auto prev_hash = m_coinbase_txns[0]->GetHash();
|
auto prev_hash = m_coinbase_txns[0]->GetHash();
|
||||||
|
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
BOOST_CHECK(wallet->HasWalletSpend(prev_hash));
|
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_EQUAL(wallet->ZapSelectTx(vHashIn, vHashOut), DBErrors::LOAD_OK);
|
||||||
|
|
||||||
BOOST_CHECK(!wallet->HasWalletSpend(prev_hash));
|
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));
|
TestUnloadWallet(std::move(wallet));
|
||||||
|
|
|
@ -952,9 +952,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const
|
||||||
wtx.nOrderPos = IncOrderPosNext(&batch);
|
wtx.nOrderPos = IncOrderPosNext(&batch);
|
||||||
wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx));
|
wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx));
|
||||||
wtx.nTimeSmart = ComputeTimeSmart(wtx, rescanning_old_block);
|
wtx.nTimeSmart = ComputeTimeSmart(wtx, rescanning_old_block);
|
||||||
if (IsFromMe(*tx.get())) {
|
AddToSpends(hash, &batch);
|
||||||
AddToSpends(hash);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fInsertedNew)
|
if (!fInsertedNew)
|
||||||
|
|
Loading…
Add table
Reference in a new issue