/tmp/bitcoin/src/wallet/transaction.h
Line | Count | Source |
1 | | // Copyright (c) 2021-present The Bitcoin Core developers |
2 | | // Distributed under the MIT software license, see the accompanying |
3 | | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | | |
5 | | #ifndef BITCOIN_WALLET_TRANSACTION_H |
6 | | #define BITCOIN_WALLET_TRANSACTION_H |
7 | | |
8 | | #include <attributes.h> |
9 | | #include <consensus/amount.h> |
10 | | #include <primitives/transaction.h> |
11 | | #include <tinyformat.h> |
12 | | #include <uint256.h> |
13 | | #include <util/check.h> |
14 | | #include <util/overloaded.h> |
15 | | #include <util/strencodings.h> |
16 | | #include <util/string.h> |
17 | | #include <wallet/types.h> |
18 | | |
19 | | #include <bitset> |
20 | | #include <cstdint> |
21 | | #include <map> |
22 | | #include <utility> |
23 | | #include <variant> |
24 | | #include <vector> |
25 | | |
26 | | namespace interfaces { |
27 | | class Chain; |
28 | | } // namespace interfaces |
29 | | |
30 | | namespace wallet { |
31 | | //! State of transaction confirmed in a block. |
32 | | struct TxStateConfirmed { |
33 | | uint256 confirmed_block_hash; |
34 | | int confirmed_block_height; |
35 | | int position_in_block; |
36 | | |
37 | 179k | explicit TxStateConfirmed(const uint256& block_hash, int height, int index) : confirmed_block_hash(block_hash), confirmed_block_height(height), position_in_block(index) {} |
38 | 19.9k | std::string toString() const { return strprintf("Confirmed (block=%s, height=%i, index=%i)", confirmed_block_hash.ToString(), confirmed_block_height, position_in_block); } |
39 | | }; |
40 | | |
41 | | //! State of transaction added to mempool. |
42 | | struct TxStateInMempool { |
43 | 3.86k | std::string toString() const { return strprintf("InMempool"); } |
44 | | }; |
45 | | |
46 | | //! State of rejected transaction that conflicts with a confirmed block. |
47 | | struct TxStateBlockConflicted { |
48 | | uint256 conflicting_block_hash; |
49 | | int conflicting_block_height; |
50 | | |
51 | 266 | explicit TxStateBlockConflicted(const uint256& block_hash, int height) : conflicting_block_hash(block_hash), conflicting_block_height(height) {} |
52 | 0 | std::string toString() const { return strprintf("BlockConflicted (block=%s, height=%i)", conflicting_block_hash.ToString(), conflicting_block_height); } |
53 | | }; |
54 | | |
55 | | //! State of transaction not confirmed or conflicting with a known block and |
56 | | //! not in the mempool. May conflict with the mempool, or with an unknown block, |
57 | | //! or be abandoned, never broadcast, or rejected from the mempool for another |
58 | | //! reason. |
59 | | struct TxStateInactive { |
60 | | bool abandoned; |
61 | | |
62 | 129k | explicit TxStateInactive(bool abandoned = false) : abandoned(abandoned) {} |
63 | 2.17k | std::string toString() const { return strprintf("Inactive (abandoned=%i)", abandoned); } |
64 | | }; |
65 | | |
66 | | //! State of transaction loaded in an unrecognized state with unexpected hash or |
67 | | //! index values. Treated as inactive (with serialized hash and index values |
68 | | //! preserved) by default, but may enter another state if transaction is added |
69 | | //! to the mempool, or confirmed, or abandoned, or found conflicting. |
70 | | struct TxStateUnrecognized { |
71 | | uint256 block_hash; |
72 | | int index; |
73 | | |
74 | 8.94k | TxStateUnrecognized(const uint256& block_hash, int index) : block_hash(block_hash), index(index) {} |
75 | 0 | std::string toString() const { return strprintf("Unrecognized (block=%s, index=%i)", block_hash.ToString(), index); } |
76 | | }; |
77 | | |
78 | | //! All possible CWalletTx states |
79 | | using TxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateBlockConflicted, TxStateInactive, TxStateUnrecognized>; |
80 | | |
81 | | //! Subset of states transaction sync logic is implemented to handle. |
82 | | using SyncTxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateInactive>; |
83 | | |
84 | | //! Try to interpret deserialized TxStateUnrecognized data as a recognized state. |
85 | | static inline TxState TxStateInterpretSerialized(TxStateUnrecognized data) |
86 | 8.94k | { |
87 | 8.94k | if (data.block_hash == uint256::ZERO) { |
88 | 85 | if (data.index == 0) return TxStateInactive{}; |
89 | 8.85k | } else if (data.block_hash == uint256::ONE) { |
90 | 125 | if (data.index == -1) return TxStateInactive{/*abandoned=*/true}; |
91 | 8.73k | } else if (data.index >= 0) { |
92 | 8.66k | return TxStateConfirmed{data.block_hash, /*height=*/-1, data.index}; |
93 | 8.66k | } else if (data.index == -1) { |
94 | 59 | return TxStateBlockConflicted{data.block_hash, /*height=*/-1}; |
95 | 59 | } |
96 | 11 | return data; |
97 | 8.94k | } Unexecuted instantiation: wallet_test_fixture.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: coinselector_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: coinselection_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: feebumper_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: group_outputs_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: ismine_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: psbt_wallet_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: scriptpubkeyman_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: spend_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: wallet_rpc_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: wallet_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) wallet_transaction_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Line | Count | Source | 86 | 28 | { | 87 | 28 | if (data.block_hash == uint256::ZERO) { | 88 | 7 | if (data.index == 0) return TxStateInactive{}; | 89 | 21 | } else if (data.block_hash == uint256::ONE) { | 90 | 5 | if (data.index == -1) return TxStateInactive{/*abandoned=*/true}; | 91 | 16 | } else if (data.index >= 0) { | 92 | 10 | return TxStateConfirmed{data.block_hash, /*height=*/-1, data.index}; | 93 | 10 | } else if (data.index == -1) { | 94 | 3 | return TxStateBlockConflicted{data.block_hash, /*height=*/-1}; | 95 | 3 | } | 96 | 11 | return data; | 97 | 28 | } |
Unexecuted instantiation: walletdb_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: walletload_tests.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: util.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: init.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: interfaces.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: load.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: receive.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) wallet.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Line | Count | Source | 86 | 8.91k | { | 87 | 8.91k | if (data.block_hash == uint256::ZERO) { | 88 | 78 | if (data.index == 0) return TxStateInactive{}; | 89 | 8.83k | } else if (data.block_hash == uint256::ONE) { | 90 | 120 | if (data.index == -1) return TxStateInactive{/*abandoned=*/true}; | 91 | 8.71k | } else if (data.index >= 0) { | 92 | 8.65k | return TxStateConfirmed{data.block_hash, /*height=*/-1, data.index}; | 93 | 8.65k | } else if (data.index == -1) { | 94 | 56 | return TxStateBlockConflicted{data.block_hash, /*height=*/-1}; | 95 | 56 | } | 96 | 0 | return data; | 97 | 8.91k | } |
Unexecuted instantiation: spend.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: transaction.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: walletdb.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: export.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: feebumper.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: fees.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: addresses.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: backup.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: coins.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: encrypt.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: signmessage.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) Unexecuted instantiation: transactions.cpp:wallet::TxStateInterpretSerialized(wallet::TxStateUnrecognized) |
98 | | |
99 | | //! Get TxState serialized block hash. Inverse of TxStateInterpretSerialized. |
100 | | static inline uint256 TxStateSerializedBlockHash(const TxState& state) |
101 | 31.9k | { |
102 | 31.9k | return std::visit(util::Overloaded{ |
103 | 31.9k | [](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; },wallet_transaction_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const Line | Count | Source | 103 | 9 | [](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; }, |
transaction.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const Line | Count | Source | 103 | 32 | [](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; }, |
wallet.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const Line | Count | Source | 103 | 3.16k | [](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; }, |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const |
104 | 31.9k | [](const TxStateInMempool& in_mempool) { return uint256::ZERO; },wallet_transaction_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const Line | Count | Source | 104 | 2 | [](const TxStateInMempool& in_mempool) { return uint256::ZERO; }, |
transaction.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const Line | Count | Source | 104 | 3.45k | [](const TxStateInMempool& in_mempool) { return uint256::ZERO; }, |
wallet.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const Line | Count | Source | 104 | 2.13k | [](const TxStateInMempool& in_mempool) { return uint256::ZERO; }, |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const |
105 | 31.9k | [](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; },wallet_transaction_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const Line | Count | Source | 105 | 427 | [](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; }, |
transaction.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const Line | Count | Source | 105 | 4.88k | [](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; }, |
wallet.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const Line | Count | Source | 105 | 17.6k | [](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; }, |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const |
106 | 31.9k | [](const TxStateBlockConflicted& conflicted) { return conflicted.conflicting_block_hash; },wallet_transaction_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const Line | Count | Source | 106 | 3 | [](const TxStateBlockConflicted& conflicted) { return conflicted.conflicting_block_hash; }, |
Unexecuted instantiation: transaction.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const wallet.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const Line | Count | Source | 106 | 209 | [](const TxStateBlockConflicted& conflicted) { return conflicted.conflicting_block_hash; }, |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const |
107 | 31.9k | [](const TxStateUnrecognized& unrecognized) { return unrecognized.block_hash; }wallet_transaction_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const Line | Count | Source | 107 | 11 | [](const TxStateUnrecognized& unrecognized) { return unrecognized.block_hash; } |
Unexecuted instantiation: transaction.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const Unexecuted instantiation: wallet.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const |
108 | 31.9k | }, state); |
109 | 31.9k | } Unexecuted instantiation: wallet_test_fixture.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: coinselector_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: coinselection_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: feebumper_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: group_outputs_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: ismine_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: psbt_wallet_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: scriptpubkeyman_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: spend_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: wallet_rpc_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: wallet_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) wallet_transaction_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Line | Count | Source | 101 | 452 | { | 102 | 452 | return std::visit(util::Overloaded{ | 103 | 452 | [](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; }, | 104 | 452 | [](const TxStateInMempool& in_mempool) { return uint256::ZERO; }, | 105 | 452 | [](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; }, | 106 | 452 | [](const TxStateBlockConflicted& conflicted) { return conflicted.conflicting_block_hash; }, | 107 | 452 | [](const TxStateUnrecognized& unrecognized) { return unrecognized.block_hash; } | 108 | 452 | }, state); | 109 | 452 | } |
Unexecuted instantiation: walletdb_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: walletload_tests.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: util.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: init.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: interfaces.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: load.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: receive.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) wallet.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Line | Count | Source | 101 | 23.1k | { | 102 | 23.1k | return std::visit(util::Overloaded{ | 103 | 23.1k | [](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; }, | 104 | 23.1k | [](const TxStateInMempool& in_mempool) { return uint256::ZERO; }, | 105 | 23.1k | [](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; }, | 106 | 23.1k | [](const TxStateBlockConflicted& conflicted) { return conflicted.conflicting_block_hash; }, | 107 | 23.1k | [](const TxStateUnrecognized& unrecognized) { return unrecognized.block_hash; } | 108 | 23.1k | }, state); | 109 | 23.1k | } |
Unexecuted instantiation: spend.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) transaction.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Line | Count | Source | 101 | 8.36k | { | 102 | 8.36k | return std::visit(util::Overloaded{ | 103 | 8.36k | [](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; }, | 104 | 8.36k | [](const TxStateInMempool& in_mempool) { return uint256::ZERO; }, | 105 | 8.36k | [](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; }, | 106 | 8.36k | [](const TxStateBlockConflicted& conflicted) { return conflicted.conflicting_block_hash; }, | 107 | 8.36k | [](const TxStateUnrecognized& unrecognized) { return unrecognized.block_hash; } | 108 | 8.36k | }, state); | 109 | 8.36k | } |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: export.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: feebumper.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: fees.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: addresses.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: backup.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: coins.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: encrypt.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: signmessage.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: transactions.cpp:wallet::TxStateSerializedBlockHash(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) |
110 | | |
111 | | //! Get TxState serialized block index. Inverse of TxStateInterpretSerialized. |
112 | | static inline int TxStateSerializedIndex(const TxState& state) |
113 | 31.9k | { |
114 | 31.9k | return std::visit(util::Overloaded{ |
115 | 31.9k | [](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; },wallet_transaction_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const Line | Count | Source | 115 | 9 | [](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; }, |
transaction.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const Line | Count | Source | 115 | 32 | [](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; }, |
wallet.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const Line | Count | Source | 115 | 3.16k | [](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; }, |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInactive const&)::operator()(wallet::TxStateInactive const&) const |
116 | 31.9k | [](const TxStateInMempool& in_mempool) { return 0; },wallet_transaction_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const Line | Count | Source | 116 | 2 | [](const TxStateInMempool& in_mempool) { return 0; }, |
transaction.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const Line | Count | Source | 116 | 3.45k | [](const TxStateInMempool& in_mempool) { return 0; }, |
wallet.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const Line | Count | Source | 116 | 2.13k | [](const TxStateInMempool& in_mempool) { return 0; }, |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateInMempool const&)::operator()(wallet::TxStateInMempool const&) const |
117 | 31.9k | [](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; },wallet_transaction_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const Line | Count | Source | 117 | 427 | [](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; }, |
transaction.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const Line | Count | Source | 117 | 4.88k | [](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; }, |
wallet.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const Line | Count | Source | 117 | 17.6k | [](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; }, |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateConfirmed const&)::operator()(wallet::TxStateConfirmed const&) const |
118 | 31.9k | [](const TxStateBlockConflicted& conflicted) { return -1; },wallet_transaction_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const Line | Count | Source | 118 | 3 | [](const TxStateBlockConflicted& conflicted) { return -1; }, |
Unexecuted instantiation: transaction.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const wallet.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const Line | Count | Source | 118 | 209 | [](const TxStateBlockConflicted& conflicted) { return -1; }, |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateBlockConflicted const&)::operator()(wallet::TxStateBlockConflicted const&) const |
119 | 31.9k | [](const TxStateUnrecognized& unrecognized) { return unrecognized.index; }wallet_transaction_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const Line | Count | Source | 119 | 11 | [](const TxStateUnrecognized& unrecognized) { return unrecognized.index; } |
Unexecuted instantiation: transaction.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const Unexecuted instantiation: wallet.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const Unexecuted instantiation: export.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(wallet::TxStateUnrecognized const&)::operator()(wallet::TxStateUnrecognized const&) const |
120 | 31.9k | }, state); |
121 | 31.9k | } Unexecuted instantiation: wallet_test_fixture.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: coinselector_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: coinselection_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: feebumper_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: group_outputs_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: ismine_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: psbt_wallet_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: scriptpubkeyman_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: spend_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: wallet_rpc_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: wallet_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) wallet_transaction_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Line | Count | Source | 113 | 452 | { | 114 | 452 | return std::visit(util::Overloaded{ | 115 | 452 | [](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; }, | 116 | 452 | [](const TxStateInMempool& in_mempool) { return 0; }, | 117 | 452 | [](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; }, | 118 | 452 | [](const TxStateBlockConflicted& conflicted) { return -1; }, | 119 | 452 | [](const TxStateUnrecognized& unrecognized) { return unrecognized.index; } | 120 | 452 | }, state); | 121 | 452 | } |
Unexecuted instantiation: walletdb_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: walletload_tests.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: util.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: init.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: interfaces.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: load.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: receive.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) wallet.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Line | Count | Source | 113 | 23.1k | { | 114 | 23.1k | return std::visit(util::Overloaded{ | 115 | 23.1k | [](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; }, | 116 | 23.1k | [](const TxStateInMempool& in_mempool) { return 0; }, | 117 | 23.1k | [](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; }, | 118 | 23.1k | [](const TxStateBlockConflicted& conflicted) { return -1; }, | 119 | 23.1k | [](const TxStateUnrecognized& unrecognized) { return unrecognized.index; } | 120 | 23.1k | }, state); | 121 | 23.1k | } |
Unexecuted instantiation: spend.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) transaction.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Line | Count | Source | 113 | 8.36k | { | 114 | 8.36k | return std::visit(util::Overloaded{ | 115 | 8.36k | [](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; }, | 116 | 8.36k | [](const TxStateInMempool& in_mempool) { return 0; }, | 117 | 8.36k | [](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; }, | 118 | 8.36k | [](const TxStateBlockConflicted& conflicted) { return -1; }, | 119 | 8.36k | [](const TxStateUnrecognized& unrecognized) { return unrecognized.index; } | 120 | 8.36k | }, state); | 121 | 8.36k | } |
Unexecuted instantiation: walletdb.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: export.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: feebumper.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: fees.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: addresses.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: backup.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: coins.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: encrypt.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: signmessage.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) Unexecuted instantiation: transactions.cpp:wallet::TxStateSerializedIndex(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) |
122 | | |
123 | | //! Return TxState or SyncTxState as a string for logging or debugging. |
124 | | template<typename T> |
125 | | std::string TxStateString(const T& state) |
126 | 26.0k | { |
127 | 26.0k | return std::visit([](const auto& s) { return s.toString(); }, state);auto std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> wallet::TxStateString<std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized>>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::operator()<wallet::TxStateConfirmed>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) const Line | Count | Source | 127 | 19.9k | return std::visit([](const auto& s) { return s.toString(); }, state); |
auto std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> wallet::TxStateString<std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized>>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::operator()<wallet::TxStateInMempool>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) const Line | Count | Source | 127 | 3.86k | return std::visit([](const auto& s) { return s.toString(); }, state); |
Unexecuted instantiation: auto std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> wallet::TxStateString<std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized>>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::operator()<wallet::TxStateBlockConflicted>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) const auto std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> wallet::TxStateString<std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized>>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::operator()<wallet::TxStateInactive>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) const Line | Count | Source | 127 | 2.17k | return std::visit([](const auto& s) { return s.toString(); }, state); |
Unexecuted instantiation: auto std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> wallet::TxStateString<std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized>>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::'lambda'(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&)::operator()<wallet::TxStateUnrecognized>(std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateBlockConflicted, wallet::TxStateInactive, wallet::TxStateUnrecognized> const&) const |
128 | 26.0k | } |
129 | | |
130 | | /** |
131 | | * Cachable amount subdivided into avoid reuse and all balances |
132 | | */ |
133 | | struct CachableAmount |
134 | | { |
135 | | std::optional<CAmount> m_avoid_reuse_value; |
136 | | std::optional<CAmount> m_all_value; |
137 | | inline void Reset() |
138 | 130k | { |
139 | 130k | m_avoid_reuse_value.reset(); |
140 | 130k | m_all_value.reset(); |
141 | 130k | } |
142 | | void Set(bool avoid_reuse, CAmount value) |
143 | 2.11k | { |
144 | 2.11k | if (avoid_reuse) { |
145 | 0 | m_avoid_reuse_value = value; |
146 | 2.11k | } else { |
147 | 2.11k | m_all_value = value; |
148 | 2.11k | } |
149 | 2.11k | } |
150 | | CAmount Get(bool avoid_reuse) |
151 | 4.31k | { |
152 | 4.31k | if (avoid_reuse) { |
153 | 0 | Assert(m_avoid_reuse_value.has_value()); |
154 | 0 | return m_avoid_reuse_value.value(); |
155 | 0 | } |
156 | 4.31k | Assert(m_all_value.has_value()); |
157 | 4.31k | return m_all_value.value(); |
158 | 4.31k | } |
159 | | bool IsCached(bool avoid_reuse) |
160 | 4.31k | { |
161 | 4.31k | if (avoid_reuse) return m_avoid_reuse_value.has_value(); |
162 | 4.31k | return m_all_value.has_value(); |
163 | 4.31k | } |
164 | | }; |
165 | | |
166 | | |
167 | | /** Legacy class used for deserializing vtxPrev for backwards compatibility. |
168 | | * vtxPrev was removed in commit 93a18a3650292afbb441a47d1fa1b94aeb0164e3, |
169 | | * but old wallet.dat files may still contain vtxPrev vectors of CMerkleTxs. |
170 | | * These need to get deserialized for field alignment when deserializing |
171 | | * a CWalletTx, but the deserialized values are discarded.**/ |
172 | | class CMerkleTx |
173 | | { |
174 | | public: |
175 | | template<typename Stream> |
176 | | void Unserialize(Stream& s) |
177 | 0 | { |
178 | 0 | CTransactionRef tx; |
179 | 0 | uint256 hashBlock; |
180 | 0 | std::vector<uint256> vMerkleBranch; |
181 | 0 | int nIndex; |
182 | |
|
183 | 0 | s >> TX_WITH_WITNESS(tx) >> hashBlock >> vMerkleBranch >> nIndex; |
184 | 0 | } |
185 | | }; |
186 | | |
187 | | /** |
188 | | * A transaction with a bunch of additional info that only the owner cares about. |
189 | | * It includes any unrecorded transactions needed to link it back to the block chain. |
190 | | */ |
191 | | class CWalletTx |
192 | | { |
193 | | public: |
194 | | // "from" and "message" are obsolete fields that could be set in |
195 | | // the UI prior to 2011 (removed in commit 4d9b223) |
196 | | // These fields are kept to avoid losing metadata. |
197 | | std::optional<std::string> m_from; |
198 | | std::optional<std::string> m_message; |
199 | | // Comment strings provided by the user |
200 | | std::optional<std::string> m_comment; |
201 | | std::optional<std::string> m_comment_to; |
202 | | std::optional<Txid> m_replaces_txid; |
203 | | std::optional<Txid> m_replaced_by_txid; |
204 | | // BIP 21 URI Messages |
205 | | std::vector<std::string> m_messages; |
206 | | // BIP 70 Payment Request (deprecated, field kept to preserve metadata from old wallets) |
207 | | std::vector<std::string> m_payment_requests; |
208 | | unsigned int nTimeReceived; //!< time received by this node |
209 | | /** |
210 | | * Stable timestamp that never changes, and reflects the order a transaction |
211 | | * was added to the wallet. Timestamp is based on the block time for a |
212 | | * transaction added as part of a block, or else the time when the |
213 | | * transaction was received if it wasn't part of a block, with the timestamp |
214 | | * adjusted in both cases so timestamp order matches the order transactions |
215 | | * were added to the wallet. More details can be found in |
216 | | * CWallet::ComputeTimeSmart(). |
217 | | */ |
218 | | unsigned int nTimeSmart; |
219 | | // Cached value for whether the transaction spends any inputs known to the wallet |
220 | | mutable std::optional<bool> m_cached_from_me{std::nullopt}; |
221 | | int64_t nOrderPos; //!< position in ordered transaction list |
222 | | std::multimap<int64_t, CWalletTx*>::const_iterator m_it_wtxOrdered; |
223 | | |
224 | | // memory only |
225 | | enum AmountType { DEBIT, CREDIT, AMOUNTTYPE_ENUM_ELEMENTS }; |
226 | | mutable CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]; |
227 | | /** |
228 | | * This flag is true if all m_amounts caches are empty. This is particularly |
229 | | * useful in places where MarkDirty is conditionally called and the |
230 | | * condition can be expensive and thus can be skipped if the flag is true. |
231 | | * See MarkDestinationsDirty. |
232 | | */ |
233 | | mutable bool m_is_cache_empty{true}; |
234 | | mutable bool fChangeCached; |
235 | | mutable CAmount nChangeCached; |
236 | | |
237 | 142k | CWalletTx(CTransactionRef tx, const TxState& state) : m_state(state) |
238 | 142k | { |
239 | 142k | Assert(tx); |
240 | 142k | m_canonical_wtxid = tx->GetWitnessHash(); |
241 | 142k | m_txs.emplace(tx->GetWitnessHash(), std::move(tx)); |
242 | 142k | SetDefaults(); |
243 | 142k | } |
244 | | |
245 | | template <typename Stream> |
246 | 8.91k | CWalletTx(deserialize_type, Stream& s, const std::map<Wtxid, CTransactionRef>& variants) : m_state(TxStateInactive{}) |
247 | 8.91k | { |
248 | 8.91k | Unserialize(s); |
249 | 8.91k | const Txid& canonical_txid = GetHash(); |
250 | 8.91k | for (const auto& [wtxid, tx] : variants) { |
251 | 8.43k | if (tx->GetHash() != canonical_txid) throw std::runtime_error("variant txid does not match wallet txid"); |
252 | 8.43k | } |
253 | | // Merge witness variants |
254 | 8.91k | m_txs.insert(variants.begin(), variants.end()); |
255 | 8.91k | Assert(m_txs.contains(GetWitnessHash())); |
256 | 8.91k | } |
257 | | |
258 | | TxState m_state; |
259 | | |
260 | | // Set of mempool transactions that conflict |
261 | | // directly with the transaction, or that conflict |
262 | | // with an ancestor transaction. This set will be |
263 | | // empty if state is InMempool or Confirmed, but |
264 | | // can be nonempty if state is Inactive or |
265 | | // BlockConflicted. |
266 | | std::set<Txid> mempool_conflicts; |
267 | | |
268 | | // Track v3 mempool tx that spends from this tx |
269 | | // so that we don't try to create another unconfirmed child |
270 | | std::optional<Txid> truc_child_in_mempool; |
271 | | |
272 | | template<typename Stream> |
273 | | void Serialize(Stream& s) const |
274 | 23.5k | { |
275 | 23.5k | std::map<std::string, std::string> string_values; |
276 | 23.5k | if (m_from) string_values["from"] = *m_from; |
277 | 23.5k | if (m_message) string_values["message"] = *m_message; |
278 | 23.5k | if (m_comment) string_values["comment"] = *m_comment; |
279 | 23.5k | if (m_comment_to) string_values["to"] = *m_comment_to; |
280 | 23.5k | if (m_replaces_txid) string_values["replaces_txid"] = m_replaces_txid->ToString(); |
281 | 23.5k | if (m_replaced_by_txid) string_values["replaced_by_txid"] = m_replaced_by_txid->ToString(); |
282 | 23.5k | string_values["fromaccount"] = ""; |
283 | 23.5k | if (nOrderPos != -1) string_values["n"] = util::ToString(nOrderPos); |
284 | 23.5k | if (nTimeSmart) string_values["timesmart"] = strprintf("%u", nTimeSmart); |
285 | | |
286 | 23.5k | std::vector<std::pair<std::string, std::string>> msgs_reqs; |
287 | 23.5k | msgs_reqs.reserve(m_messages.size() + m_payment_requests.size()); |
288 | 23.5k | for (const std::string& msg : m_messages) { |
289 | 0 | msgs_reqs.emplace_back("Message", msg); |
290 | 0 | } |
291 | 23.5k | for (const std::string& req : m_payment_requests) { |
292 | 0 | msgs_reqs.emplace_back("PaymentRequest", req); |
293 | 0 | } |
294 | | |
295 | 23.5k | std::vector<uint8_t> dummy_vector1; // Used to be vMerkleBranch |
296 | 23.5k | std::vector<uint8_t> dummy_vector2; // Used to be vtxPrev |
297 | 23.5k | bool dummy_bool = false; // Used to be fFromMe, and fSpent |
298 | 23.5k | uint32_t dummy_int = 0; // Used to be fTimeReceivedIsTxTime |
299 | 23.5k | uint256 serializedHash = TxStateSerializedBlockHash(m_state); |
300 | 23.5k | int serializedIndex = TxStateSerializedIndex(m_state); |
301 | 23.5k | s << TX_WITH_WITNESS(GetTx()) << serializedHash << dummy_vector1 << serializedIndex << dummy_vector2 << string_values << msgs_reqs << dummy_int << nTimeReceived << dummy_bool << dummy_bool; |
302 | 23.5k | } |
303 | | |
304 | | template<typename Stream> |
305 | | void Unserialize(Stream& s) |
306 | 8.91k | { |
307 | 8.91k | Init(); |
308 | | |
309 | 8.91k | std::vector<uint256> dummy_vector1; // Used to be vMerkleBranch |
310 | 8.91k | std::vector<CMerkleTx> dummy_vector2; // Used to be vtxPrev |
311 | 8.91k | bool dummy_bool; // Used to be fFromMe, and fSpent |
312 | 8.91k | uint32_t dummy_int; // Used to be fTimeReceivedIsTxTime |
313 | 8.91k | uint256 serialized_block_hash; |
314 | 8.91k | int serializedIndex; |
315 | 8.91k | std::map<std::string, std::string> string_values; |
316 | 8.91k | std::vector<std::pair<std::string, std::string>> msgs_reqs; |
317 | 8.91k | CTransactionRef canonical_tx; |
318 | 8.91k | s >> TX_WITH_WITNESS(canonical_tx) >> serialized_block_hash >> dummy_vector1 >> serializedIndex >> dummy_vector2 >> string_values >> msgs_reqs >> dummy_int >> nTimeReceived >> dummy_bool >> dummy_bool; |
319 | 8.91k | m_canonical_wtxid = canonical_tx->GetWitnessHash(); |
320 | 8.91k | m_txs.emplace(m_canonical_wtxid, std::move(canonical_tx)); |
321 | | |
322 | 8.91k | m_state = TxStateInterpretSerialized({serialized_block_hash, serializedIndex}); |
323 | | |
324 | 8.91k | string_values.erase("fromaccount"); |
325 | 8.91k | string_values.erase("spent"); |
326 | 17.9k | for (const auto& [key, value] : string_values) { |
327 | 17.9k | if (key == "n") nOrderPos = LocaleIndependentAtoi<int64_t>(value); |
328 | 9.02k | else if (key == "timesmart") nTimeSmart = LocaleIndependentAtoi<int64_t>(value); |
329 | 106 | else if (key == "from") m_from = value; |
330 | 106 | else if (key == "message") m_message = value; |
331 | 106 | else if (key == "comment") m_comment = value; |
332 | 98 | else if (key == "to") m_comment_to = value; |
333 | 94 | else if (key == "replaces_txid") m_replaces_txid = Txid::FromHex(value); |
334 | 47 | else if (key == "replaced_by_txid") m_replaced_by_txid = Txid::FromHex(value); |
335 | 0 | else { |
336 | 0 | throw std::runtime_error("Unexpected value in CWalletTx strings value map"); |
337 | 0 | } |
338 | 17.9k | } |
339 | | |
340 | 8.91k | for (const auto& [type, data] : msgs_reqs) { |
341 | 0 | if (type == "Message") m_messages.emplace_back(data); |
342 | 0 | else if (type == "PaymentRequest") m_payment_requests.emplace_back(data); |
343 | 0 | else { |
344 | 0 | throw std::runtime_error("Unknown type in CWalletTx messages and requests vector"); |
345 | 0 | } |
346 | 0 | } |
347 | 8.91k | } |
348 | | |
349 | 2.91M | CTransactionRef GetTx() const { return m_txs.at(m_canonical_wtxid); } |
350 | | |
351 | | // Update the state of this wallet transaction along with a transaction that may have a different wtxid. |
352 | | // If the given transaction has a different wtxid, the transaction is stored if it has not been seen before. |
353 | | // The canonical wtxid is also updated. The tx that is confirmed becomes canonical. For unconfirmed txs, |
354 | | // those with witnesses are preferred, followed by least weight. |
355 | | bool Update(CTransactionRef tx, const TxState& new_state); |
356 | | |
357 | | //! make sure balances are recalculated |
358 | | void MarkDirty() |
359 | 65.3k | { |
360 | 65.3k | m_amounts[DEBIT].Reset(); |
361 | 65.3k | m_amounts[CREDIT].Reset(); |
362 | 65.3k | fChangeCached = false; |
363 | 65.3k | m_is_cache_empty = true; |
364 | 65.3k | m_cached_from_me = std::nullopt; |
365 | 65.3k | } |
366 | | |
367 | | /** True if only scriptSigs are different */ |
368 | | bool IsEquivalentTo(const CWalletTx& tx) const; |
369 | | |
370 | | bool InMempool() const; |
371 | | |
372 | | int64_t GetTxTime() const; |
373 | | |
374 | 2.86M | template<typename T> const T* state() const { return std::get_if<T>(&m_state); }wallet::TxStateInactive const* wallet::CWalletTx::state<wallet::TxStateInactive>() const Line | Count | Source | 374 | 338k | template<typename T> const T* state() const { return std::get_if<T>(&m_state); } |
wallet::TxStateBlockConflicted const* wallet::CWalletTx::state<wallet::TxStateBlockConflicted>() const Line | Count | Source | 374 | 469k | template<typename T> const T* state() const { return std::get_if<T>(&m_state); } |
wallet::TxStateConfirmed const* wallet::CWalletTx::state<wallet::TxStateConfirmed>() const Line | Count | Source | 374 | 1.90M | template<typename T> const T* state() const { return std::get_if<T>(&m_state); } |
wallet::TxStateInMempool const* wallet::CWalletTx::state<wallet::TxStateInMempool>() const Line | Count | Source | 374 | 149k | template<typename T> const T* state() const { return std::get_if<T>(&m_state); } |
|
375 | 26.0k | template<typename T> T* state() { return std::get_if<T>(&m_state); }wallet::TxStateConfirmed* wallet::CWalletTx::state<wallet::TxStateConfirmed>() Line | Count | Source | 375 | 12.8k | template<typename T> T* state() { return std::get_if<T>(&m_state); } |
wallet::TxStateBlockConflicted* wallet::CWalletTx::state<wallet::TxStateBlockConflicted>() Line | Count | Source | 375 | 745 | template<typename T> T* state() { return std::get_if<T>(&m_state); } |
wallet::TxStateInMempool* wallet::CWalletTx::state<wallet::TxStateInMempool>() Line | Count | Source | 375 | 12.4k | template<typename T> T* state() { return std::get_if<T>(&m_state); } |
|
376 | | |
377 | | //! Update transaction state when attaching to a chain, filling in heights |
378 | | //! of conflicted and confirmed blocks |
379 | | void updateState(interfaces::Chain& chain); |
380 | | |
381 | 311k | bool isAbandoned() const { return state<TxStateInactive>() && state<TxStateInactive>()->abandoned; } |
382 | 303k | bool isMempoolConflicted() const { return !mempool_conflicts.empty(); } |
383 | 382k | bool isBlockConflicted() const { return state<TxStateBlockConflicted>(); } |
384 | 24.0k | bool isInactive() const { return state<TxStateInactive>(); } |
385 | 17.5k | bool isUnconfirmed() const { return !isAbandoned() && !isBlockConflicted() && !isMempoolConflicted() && !isConfirmed(); } |
386 | 637k | bool isConfirmed() const { return state<TxStateConfirmed>(); } |
387 | 1.00M | const Txid& GetHash() const LIFETIMEBOUND { return GetTx()->GetHash(); } |
388 | 16.2k | const Wtxid& GetWitnessHash() const LIFETIMEBOUND { return GetTx()->GetWitnessHash(); } |
389 | 791k | bool IsCoinBase() const { return GetTx()->IsCoinBase(); } |
390 | | |
391 | 27.1k | const std::map<Wtxid, CTransactionRef>& GetTxs() const { return m_txs; } |
392 | | |
393 | | // Disable copying of CWalletTx objects to prevent bugs where instances get |
394 | | // copied in and out of the mapWallet map, and fields are updated in the |
395 | | // wrong copy. |
396 | | CWalletTx(const CWalletTx&) = delete; |
397 | | CWalletTx& operator=(const CWalletTx&) = delete; |
398 | | |
399 | | // Enable the default move constructor |
400 | 8.91k | CWalletTx(CWalletTx&&) = default; |
401 | | |
402 | | private: |
403 | | void SetDefaults() |
404 | 151k | { |
405 | 151k | nTimeReceived = 0; |
406 | 151k | nTimeSmart = 0; |
407 | 151k | fChangeCached = false; |
408 | 151k | nChangeCached = 0; |
409 | 151k | nOrderPos = -1; |
410 | 151k | } |
411 | | |
412 | | void Init() |
413 | 8.91k | { |
414 | 8.91k | m_txs.clear(); |
415 | 8.91k | m_canonical_wtxid = Wtxid{}; |
416 | 8.91k | SetDefaults(); |
417 | 8.91k | } |
418 | | |
419 | | Wtxid m_canonical_wtxid; |
420 | | std::map<Wtxid, CTransactionRef> m_txs; |
421 | | |
422 | | //! Set m_canonical_wtxid to the best variant under the unconfirmed rule |
423 | | //! (witnessed preferred, then least weight). Ignores state. |
424 | | void RecomputeCanonical(); |
425 | | }; |
426 | | |
427 | | struct WalletTxOrderComparator { |
428 | | bool operator()(const CWalletTx* a, const CWalletTx* b) const |
429 | 314 | { |
430 | 314 | return a->nOrderPos < b->nOrderPos; |
431 | 314 | } |
432 | | }; |
433 | | |
434 | | class WalletTXO |
435 | | { |
436 | | private: |
437 | | const CWalletTx& m_wtx; |
438 | | const CTxOut& m_output; |
439 | | |
440 | | public: |
441 | | WalletTXO(const CWalletTx& wtx, const CTxOut& output) |
442 | 42.9k | : m_wtx(wtx), |
443 | 42.9k | m_output(output) |
444 | 42.9k | { |
445 | 42.9k | Assume(std::ranges::find(wtx.GetTx()->vout, output) != wtx.GetTx()->vout.end()); |
446 | 42.9k | } |
447 | | |
448 | 781k | const CWalletTx& GetWalletTx() const { return m_wtx; } |
449 | | |
450 | 733k | const CTxOut& GetTxOut() const { return m_output; } |
451 | | }; |
452 | | } // namespace wallet |
453 | | |
454 | | #endif // BITCOIN_WALLET_TRANSACTION_H |