MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / updateState

Method updateState

src/wallet/transaction.cpp:38–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void CWalletTx::updateState(interfaces::Chain& chain)
39{
40 bool active;
41 auto lookup_block = [&](const uint256& hash, int& height, TxState& state) {
42 // If tx block (or conflicting block) was reorged out of chain
43 // while the wallet was shutdown, change tx status to UNCONFIRMED
44 // and reset block height, hash, and index. ABANDONED tx don't have
45 // associated blocks and don't need to be updated. The case where a
46 // transaction was reorged out while online and then reconfirmed
47 // while offline is covered by the rescan logic.
48 if (!chain.findBlock(hash, FoundBlock().inActiveChain(active).height(height)) || !active) {
49 state = TxStateInactive{};
50 }
51 };
52 if (auto* conf = state<TxStateConfirmed>()) {
53 lookup_block(conf->confirmed_block_hash, conf->confirmed_block_height, m_state);
54 } else if (auto* conf = state<TxStateBlockConflicted>()) {
55 lookup_block(conf->conflicting_block_hash, conf->conflicting_block_height, m_state);
56 }
57}
58
59void CWalletTx::CopyFrom(const CWalletTx& _tx)
60{

Callers 1

LoadToWalletMethod · 0.80

Calls 3

FoundBlockClass · 0.85
findBlockMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected