Skip to content

Commit

Permalink
Merge #15931: Remove GetDepthInMainChain dependency on locked chain i…
Browse files Browse the repository at this point in the history
…nterface

36b68de Remove getBlockDepth method from Chain::interface (Antoine Riard)
b66c429 Remove locked_chain from GetDepthInMainChain and its callers (Antoine Riard)
0ff0387 Use CWallet::m_last_block_processed_height in GetDepthInMainChain (Antoine Riard)
f77b1de Only return early from BlockUntilSyncedToCurrentChain if current tip is exact match (Antoine Riard)
769ff05 Refactor some importprunedfunds checks with guard clause (Antoine Riard)
5971d38 Add block_height field in struct Confirmation (Antoine Riard)
9700fcb Replace CWalletTx::SetConf by Confirmation initialization list (Antoine Riard)
5aacc3e Add m_last_block_processed_height field in CWallet (Antoine Riard)
10b4729 Pass block height in Chain::BlockConnected/Chain::BlockDisconnected (Antoine Riard)

Pull request description:

  Work starter to remove Chain::Lock interface by adding m_last_block_processed_height in CWallet and m_block_height in CMerkleTx to avoid GetDepthInMainChain having to keep a lock . Once this one done, it should ease work to wipe out more cs_main locks from wallet code.

  I think it's ready for a first round of review before to get further.

  - `BlockUntilSyncedToCurrent` : restrain isPotentialTip to isTip because we want to be sure that wallet see BlockDisconnected callbacks if its height differs from the Chain one. It means during a reorg, an RPC could return before the BlockDisconnected callback had been triggered. This could cause a tx that had been included in the disconnected block to be displayed as confirmed, for example.

  ~~- `AbandonTransaction` : in case of conflicted tx (nIndex = -1), we set its m_block_height to the one of conflicting blocks, but if this height is superior to CWallet::m_last_block_processed_height, that means tx isn't conflicted anymore so we return 0 as tx is again unconfirmed~~ After #16624, we instead rely on Confirmation.

  ~~- `AddToWalletIfInvolvingMe`: in case of block disconnected, transactions are added to mempool again, so we need to replace old txn in `mapWallet` with a height set to zero so we remove check on block_hash.IsNull~~ Already done in #16624

ACKs for top commit:
  jnewbery:
    @jkczyz you've ACKed an intermediate commit (github annoyingly orders commits in date order, not commit order). Did you mean to ACK the final commit in this branch (36b68de).
  jkczyz:
    > @jkczyz you've ACKed an intermediate commit (github annoyingly orders commits in date order, not commit order). Did you mean to ACK the final commit in this branch ([36b68de](36b68de)).
  meshcollider:
    utACK 36b68de
  ryanofsky:
    Code review ACK 36b68de. Changes since last review: new jkczyz refactor importprunedfunds commit, changed BlockUntilSyncedToCurrentChainChanges commit title and description, changed Confirmation struct field order and line-wrapped comment
  jnewbery:
    utACK 36b68de
  promag:
    Code review ACK 36b68de.

Tree-SHA512: 08b89a0bcc39f67c82a6cb6aee195e6a11697770c788ba737b90986b4893f44e90d1ab9ef87239ea3766508b7e24ea882b7199df41173ab27a3d000328c14644
  • Loading branch information
meshcollider committed Nov 8, 2019
2 parents 2fb6140 + 36b68de commit 99ab3a7
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 201 deletions.
16 changes: 4 additions & 12 deletions src/interfaces/chain.cpp
Expand Up @@ -58,12 +58,6 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
}
return nullopt;
}
int getBlockDepth(const uint256& hash) override
{
const Optional<int> tip_height = getHeight();
const Optional<int> height = getBlockHeight(hash);
return tip_height && height ? *tip_height - *height + 1 : 0;
}
uint256 getBlockHash(int height) override
{
LockAssertion lock(::cs_main);
Expand Down Expand Up @@ -182,11 +176,11 @@ class NotificationsHandlerImpl : public Handler, CValidationInterface
const CBlockIndex* index,
const std::vector<CTransactionRef>& tx_conflicted) override
{
m_notifications->BlockConnected(*block, tx_conflicted);
m_notifications->BlockConnected(*block, tx_conflicted, index->nHeight);
}
void BlockDisconnected(const std::shared_ptr<const CBlock>& block) override
void BlockDisconnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
{
m_notifications->BlockDisconnected(*block);
m_notifications->BlockDisconnected(*block, index->nHeight);
}
void UpdatedBlockTip(const CBlockIndex* index, const CBlockIndex* fork_index, bool is_ibd) override
{
Expand Down Expand Up @@ -353,13 +347,11 @@ class ChainImpl : public Chain
{
return MakeUnique<NotificationsHandlerImpl>(*this, notifications);
}
void waitForNotificationsIfNewBlocksConnected(const uint256& old_tip) override
void waitForNotificationsIfTipChanged(const uint256& old_tip) override
{
if (!old_tip.IsNull()) {
LOCK(::cs_main);
if (old_tip == ::ChainActive().Tip()->GetBlockHash()) return;
CBlockIndex* block = LookupBlockIndex(old_tip);
if (block && block->GetAncestor(::ChainActive().Height()) == ::ChainActive().Tip()) return;
}
SyncWithValidationInterfaceQueue();
}
Expand Down
13 changes: 4 additions & 9 deletions src/interfaces/chain.h
Expand Up @@ -76,10 +76,6 @@ class Chain
//! included in the current chain.
virtual Optional<int> getBlockHeight(const uint256& hash) = 0;

//! Get block depth. Returns 1 for chain tip, 2 for preceding block, and
//! so on. Returns 0 for a block not included in the current chain.
virtual int getBlockDepth(const uint256& hash) = 0;

//! Get block hash. Height must be valid or this function will abort.
virtual uint256 getBlockHash(int height) = 0;

Expand Down Expand Up @@ -226,8 +222,8 @@ class Chain
virtual ~Notifications() {}
virtual void TransactionAddedToMempool(const CTransactionRef& tx) {}
virtual void TransactionRemovedFromMempool(const CTransactionRef& ptx) {}
virtual void BlockConnected(const CBlock& block, const std::vector<CTransactionRef>& tx_conflicted) {}
virtual void BlockDisconnected(const CBlock& block) {}
virtual void BlockConnected(const CBlock& block, const std::vector<CTransactionRef>& tx_conflicted, int height) {}
virtual void BlockDisconnected(const CBlock& block, int height) {}
virtual void UpdatedBlockTip() {}
virtual void ChainStateFlushed(const CBlockLocator& locator) {}
};
Expand All @@ -236,9 +232,8 @@ class Chain
virtual std::unique_ptr<Handler> handleNotifications(Notifications& notifications) = 0;

//! Wait for pending notifications to be processed unless block hash points to the current
//! chain tip, or to a possible descendant of the current chain tip that isn't currently
//! connected.
virtual void waitForNotificationsIfNewBlocksConnected(const uint256& old_tip) = 0;
//! chain tip.
virtual void waitForNotificationsIfTipChanged(const uint256& old_tip) = 0;

//! Register handler for RPC. Command is not copied, so reference
//! needs to remain valid until Handler is disconnected.
Expand Down
29 changes: 14 additions & 15 deletions src/interfaces/wallet.cpp
Expand Up @@ -31,7 +31,7 @@ namespace interfaces {
namespace {

//! Construct wallet tx struct.
WalletTx MakeWalletTx(interfaces::Chain::Lock& locked_chain, CWallet& wallet, const CWalletTx& wtx)
WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx)
{
WalletTx result;
result.tx = wtx.tx;
Expand All @@ -49,7 +49,7 @@ WalletTx MakeWalletTx(interfaces::Chain::Lock& locked_chain, CWallet& wallet, co
wallet.IsMine(result.txout_address.back()) :
ISMINE_NO);
}
result.credit = wtx.GetCredit(locked_chain, ISMINE_ALL);
result.credit = wtx.GetCredit(ISMINE_ALL);
result.debit = wtx.GetDebit(ISMINE_ALL);
result.change = wtx.GetChange();
result.time = wtx.GetTxTime();
Expand All @@ -63,21 +63,20 @@ WalletTxStatus MakeWalletTxStatus(interfaces::Chain::Lock& locked_chain, const C
{
WalletTxStatus result;
result.block_height = locked_chain.getBlockHeight(wtx.m_confirm.hashBlock).get_value_or(std::numeric_limits<int>::max());
result.blocks_to_maturity = wtx.GetBlocksToMaturity(locked_chain);
result.depth_in_main_chain = wtx.GetDepthInMainChain(locked_chain);
result.blocks_to_maturity = wtx.GetBlocksToMaturity();
result.depth_in_main_chain = wtx.GetDepthInMainChain();
result.time_received = wtx.nTimeReceived;
result.lock_time = wtx.tx->nLockTime;
result.is_final = locked_chain.checkFinalTx(*wtx.tx);
result.is_trusted = wtx.IsTrusted(locked_chain);
result.is_abandoned = wtx.isAbandoned();
result.is_coinbase = wtx.IsCoinBase();
result.is_in_main_chain = wtx.IsInMainChain(locked_chain);
result.is_in_main_chain = wtx.IsInMainChain();
return result;
}

//! Construct wallet TxOut struct.
WalletTxOut MakeWalletTxOut(interfaces::Chain::Lock& locked_chain,
CWallet& wallet,
WalletTxOut MakeWalletTxOut(CWallet& wallet,
const CWalletTx& wtx,
int n,
int depth) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Expand All @@ -86,7 +85,7 @@ WalletTxOut MakeWalletTxOut(interfaces::Chain::Lock& locked_chain,
result.txout = wtx.tx->vout[n];
result.time = wtx.GetTxTime();
result.depth_in_main_chain = depth;
result.is_spent = wallet.IsSpent(locked_chain, wtx.GetHash(), n);
result.is_spent = wallet.IsSpent(wtx.GetHash(), n);
return result;
}

Expand Down Expand Up @@ -235,7 +234,7 @@ class WalletImpl : public Wallet
{
auto locked_chain = m_wallet->chain().lock();
LOCK(m_wallet->cs_wallet);
return m_wallet->AbandonTransaction(*locked_chain, txid);
return m_wallet->AbandonTransaction(txid);
}
bool transactionCanBeBumped(const uint256& txid) override
{
Expand Down Expand Up @@ -282,7 +281,7 @@ class WalletImpl : public Wallet
LOCK(m_wallet->cs_wallet);
auto mi = m_wallet->mapWallet.find(txid);
if (mi != m_wallet->mapWallet.end()) {
return MakeWalletTx(*locked_chain, *m_wallet, mi->second);
return MakeWalletTx(*m_wallet, mi->second);
}
return {};
}
Expand All @@ -293,7 +292,7 @@ class WalletImpl : public Wallet
std::vector<WalletTx> result;
result.reserve(m_wallet->mapWallet.size());
for (const auto& entry : m_wallet->mapWallet) {
result.emplace_back(MakeWalletTx(*locked_chain, *m_wallet, entry.second));
result.emplace_back(MakeWalletTx(*m_wallet, entry.second));
}
return result;
}
Expand Down Expand Up @@ -338,7 +337,7 @@ class WalletImpl : public Wallet
in_mempool = mi->second.InMempool();
order_form = mi->second.vOrderForm;
tx_status = MakeWalletTxStatus(*locked_chain, mi->second);
return MakeWalletTx(*locked_chain, *m_wallet, mi->second);
return MakeWalletTx(*m_wallet, mi->second);
}
return {};
}
Expand Down Expand Up @@ -407,7 +406,7 @@ class WalletImpl : public Wallet
auto& group = result[entry.first];
for (const auto& coin : entry.second) {
group.emplace_back(COutPoint(coin.tx->GetHash(), coin.i),
MakeWalletTxOut(*locked_chain, *m_wallet, *coin.tx, coin.i, coin.nDepth));
MakeWalletTxOut(*m_wallet, *coin.tx, coin.i, coin.nDepth));
}
}
return result;
Expand All @@ -422,9 +421,9 @@ class WalletImpl : public Wallet
result.emplace_back();
auto it = m_wallet->mapWallet.find(output.hash);
if (it != m_wallet->mapWallet.end()) {
int depth = it->second.GetDepthInMainChain(*locked_chain);
int depth = it->second.GetDepthInMainChain();
if (depth >= 0) {
result.back() = MakeWalletTxOut(*locked_chain, *m_wallet, it->second, output.n, depth);
result.back() = MakeWalletTxOut(*m_wallet, it->second, output.n, depth);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/qt/test/wallettests.cpp
Expand Up @@ -139,10 +139,12 @@ void TestGUI(interfaces::Node& node)
wallet->LoadWallet(firstRun);
{
auto spk_man = wallet->GetLegacyScriptPubKeyMan();
auto locked_chain = wallet->chain().lock();
LOCK(wallet->cs_wallet);
AssertLockHeld(spk_man->cs_wallet);
wallet->SetAddressBook(GetDestinationForKey(test.coinbaseKey.GetPubKey(), wallet->m_default_address_type), "", "receive");
spk_man->AddKeyPubKey(test.coinbaseKey, test.coinbaseKey.GetPubKey());
wallet->SetLastBlockProcessed(105, ::ChainActive().Tip()->GetBlockHash());
}
{
auto locked_chain = wallet->chain().lock();
Expand Down
3 changes: 2 additions & 1 deletion src/test/validation_block_tests.cpp
Expand Up @@ -40,9 +40,10 @@ struct TestSubscriber : public CValidationInterface {
m_expected_tip = block->GetHash();
}

void BlockDisconnected(const std::shared_ptr<const CBlock>& block) override
void BlockDisconnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override
{
BOOST_CHECK_EQUAL(m_expected_tip, block->GetHash());
BOOST_CHECK_EQUAL(m_expected_tip, pindex->GetBlockHash());

m_expected_tip = block->hashPrevBlock;
}
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Expand Up @@ -2458,7 +2458,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, const CChainParams&
UpdateTip(pindexDelete->pprev, chainparams);
// Let wallets know transactions went from 1-confirmed to
// 0-confirmed or conflicted:
GetMainSignals().BlockDisconnected(pblock);
GetMainSignals().BlockDisconnected(pblock, pindexDelete);
return true;
}

Expand Down
11 changes: 6 additions & 5 deletions src/validationinterface.cpp
Expand Up @@ -29,7 +29,7 @@ struct MainSignalsInstance {
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
boost::signals2::signal<void (const CTransactionRef &)> TransactionAddedToMempool;
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::vector<CTransactionRef>&)> BlockConnected;
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &)> BlockDisconnected;
boost::signals2::signal<void (const std::shared_ptr<const CBlock>&, const CBlockIndex* pindex)> BlockDisconnected;
boost::signals2::signal<void (const CTransactionRef &)> TransactionRemovedFromMempool;
boost::signals2::signal<void (const CBlockLocator &)> ChainStateFlushed;
boost::signals2::signal<void (const CBlock&, const BlockValidationState&)> BlockChecked;
Expand Down Expand Up @@ -92,7 +92,7 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
conns.UpdatedBlockTip = g_signals.m_internals->UpdatedBlockTip.connect(std::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
conns.TransactionAddedToMempool = g_signals.m_internals->TransactionAddedToMempool.connect(std::bind(&CValidationInterface::TransactionAddedToMempool, pwalletIn, std::placeholders::_1));
conns.BlockConnected = g_signals.m_internals->BlockConnected.connect(std::bind(&CValidationInterface::BlockConnected, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
conns.BlockDisconnected = g_signals.m_internals->BlockDisconnected.connect(std::bind(&CValidationInterface::BlockDisconnected, pwalletIn, std::placeholders::_1));
conns.BlockDisconnected = g_signals.m_internals->BlockDisconnected.connect(std::bind(&CValidationInterface::BlockDisconnected, pwalletIn, std::placeholders::_1, std::placeholders::_2));
conns.TransactionRemovedFromMempool = g_signals.m_internals->TransactionRemovedFromMempool.connect(std::bind(&CValidationInterface::TransactionRemovedFromMempool, pwalletIn, std::placeholders::_1));
conns.ChainStateFlushed = g_signals.m_internals->ChainStateFlushed.connect(std::bind(&CValidationInterface::ChainStateFlushed, pwalletIn, std::placeholders::_1));
conns.BlockChecked = g_signals.m_internals->BlockChecked.connect(std::bind(&CValidationInterface::BlockChecked, pwalletIn, std::placeholders::_1, std::placeholders::_2));
Expand Down Expand Up @@ -156,9 +156,10 @@ void CMainSignals::BlockConnected(const std::shared_ptr<const CBlock> &pblock, c
});
}

void CMainSignals::BlockDisconnected(const std::shared_ptr<const CBlock> &pblock) {
m_internals->m_schedulerClient.AddToProcessQueue([pblock, this] {
m_internals->BlockDisconnected(pblock);
void CMainSignals::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
{
m_internals->m_schedulerClient.AddToProcessQueue([pblock, pindex, this] {
m_internals->BlockDisconnected(pblock, pindex);
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/validationinterface.h
Expand Up @@ -114,7 +114,7 @@ class CValidationInterface {
*
* Called on a background thread.
*/
virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block) {}
virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) {}
/**
* Notifies listeners of the new active block chain on-disk.
*
Expand Down Expand Up @@ -178,7 +178,7 @@ class CMainSignals {
void UpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
void TransactionAddedToMempool(const CTransactionRef &);
void BlockConnected(const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::shared_ptr<const std::vector<CTransactionRef>> &);
void BlockDisconnected(const std::shared_ptr<const CBlock> &);
void BlockDisconnected(const std::shared_ptr<const CBlock> &, const CBlockIndex* pindex);
void ChainStateFlushed(const CBlockLocator &);
void BlockChecked(const CBlock&, const BlockValidationState&);
void NewPoWValidBlock(const CBlockIndex *, const std::shared_ptr<const CBlock>&);
Expand Down
12 changes: 6 additions & 6 deletions src/wallet/feebumper.cpp
Expand Up @@ -16,7 +16,7 @@

//! Check whether transaction has descendant in wallet or mempool, or has been
//! mined, or conflicts with a mined transaction. Return a feebumper::Result.
static feebumper::Result PreconditionChecks(interfaces::Chain::Lock& locked_chain, const CWallet& wallet, const CWalletTx& wtx, std::vector<std::string>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, std::vector<std::string>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
{
if (wallet.HasWalletSpend(wtx.GetHash())) {
errors.push_back("Transaction has descendants in the wallet");
Expand All @@ -30,7 +30,7 @@ static feebumper::Result PreconditionChecks(interfaces::Chain::Lock& locked_chai
}
}

if (wtx.GetDepthInMainChain(locked_chain) != 0) {
if (wtx.GetDepthInMainChain() != 0) {
errors.push_back("Transaction has been mined, or is conflicted with a mined transaction");
return feebumper::Result::WALLET_ERROR;
}
Expand Down Expand Up @@ -146,7 +146,7 @@ bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid)
if (wtx == nullptr) return false;

std::vector<std::string> errors_dummy;
feebumper::Result res = PreconditionChecks(*locked_chain, wallet, *wtx, errors_dummy);
feebumper::Result res = PreconditionChecks(wallet, *wtx, errors_dummy);
return res == feebumper::Result::OK;
}

Expand All @@ -165,7 +165,7 @@ Result CreateTotalBumpTransaction(const CWallet* wallet, const uint256& txid, co
}
const CWalletTx& wtx = it->second;

Result result = PreconditionChecks(*locked_chain, *wallet, wtx, errors);
Result result = PreconditionChecks(*wallet, wtx, errors);
if (result != Result::OK) {
return result;
}
Expand Down Expand Up @@ -291,7 +291,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
}
const CWalletTx& wtx = it->second;

Result result = PreconditionChecks(*locked_chain, wallet, wtx, errors);
Result result = PreconditionChecks(wallet, wtx, errors);
if (result != Result::OK) {
return result;
}
Expand Down Expand Up @@ -382,7 +382,7 @@ Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransacti
CWalletTx& oldWtx = it->second;

// make sure the transaction still has no descendants and hasn't been mined in the meantime
Result result = PreconditionChecks(*locked_chain, wallet, oldWtx, errors);
Result result = PreconditionChecks(wallet, oldWtx, errors);
if (result != Result::OK) {
return result;
}
Expand Down
38 changes: 18 additions & 20 deletions src/wallet/rpcdump.cpp
Expand Up @@ -316,7 +316,7 @@ UniValue importaddress(const JSONRPCRequest& request)
{
auto locked_chain = pwallet->chain().lock();
LOCK(pwallet->cs_wallet);
pwallet->ReacceptWalletTransactions(*locked_chain);
pwallet->ReacceptWalletTransactions();
}
}

Expand Down Expand Up @@ -354,28 +354,26 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
//Search partial merkle tree in proof for our transaction and index in valid block
std::vector<uint256> vMatch;
std::vector<unsigned int> vIndex;
unsigned int txnIndex = 0;
if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) == merkleBlock.header.hashMerkleRoot) {

auto locked_chain = pwallet->chain().lock();
if (locked_chain->getBlockHeight(merkleBlock.header.GetHash()) == nullopt) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
}

std::vector<uint256>::const_iterator it;
if ((it = std::find(vMatch.begin(), vMatch.end(), hashTx))==vMatch.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction given doesn't exist in proof");
}
if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Something wrong with merkleblock");
}

txnIndex = vIndex[it - vMatch.begin()];
auto locked_chain = pwallet->chain().lock();
Optional<int> height = locked_chain->getBlockHeight(merkleBlock.header.GetHash());
if (height == nullopt) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
}
else {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Something wrong with merkleblock");

std::vector<uint256>::const_iterator it;
if ((it = std::find(vMatch.begin(), vMatch.end(), hashTx)) == vMatch.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction given doesn't exist in proof");
}

wtx.SetConf(CWalletTx::Status::CONFIRMED, merkleBlock.header.GetHash(), txnIndex);
unsigned int txnIndex = vIndex[it - vMatch.begin()];

CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, *height, merkleBlock.header.GetHash(), txnIndex);
wtx.m_confirm = confirm;

auto locked_chain = pwallet->chain().lock();
LOCK(pwallet->cs_wallet);

if (pwallet->IsMine(*wtx.tx)) {
Expand Down Expand Up @@ -507,7 +505,7 @@ UniValue importpubkey(const JSONRPCRequest& request)
{
auto locked_chain = pwallet->chain().lock();
LOCK(pwallet->cs_wallet);
pwallet->ReacceptWalletTransactions(*locked_chain);
pwallet->ReacceptWalletTransactions();
}
}

Expand Down Expand Up @@ -1406,7 +1404,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
{
auto locked_chain = pwallet->chain().lock();
LOCK(pwallet->cs_wallet);
pwallet->ReacceptWalletTransactions(*locked_chain);
pwallet->ReacceptWalletTransactions();
}

if (pwallet->IsAbortingRescan()) {
Expand Down

0 comments on commit 99ab3a7

Please sign in to comment.