Coverage Report

Created: 2026-09-14 20:36

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