Coverage Report

Created: 2026-10-07 20:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/primitives/transaction.h
Line
Count
Source
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#ifndef BITCOIN_PRIMITIVES_TRANSACTION_H
7
#define BITCOIN_PRIMITIVES_TRANSACTION_H
8
9
#include <attributes.h>
10
#include <consensus/amount.h>
11
#include <primitives/transaction_identifier.h> // IWYU pragma: export
12
#include <script/script.h>
13
#include <serialize.h>
14
15
#include <algorithm>
16
#include <compare>
17
#include <cstddef>
18
#include <cstdint>
19
#include <ios>
20
#include <limits>
21
#include <memory>
22
#include <numeric>
23
#include <string>
24
#include <tuple>
25
#include <utility>
26
#include <vector>
27
28
/** An outpoint - a combination of a transaction hash and an index n into its vout */
29
class COutPoint
30
{
31
public:
32
    Txid hash;
33
    uint32_t n;
34
35
    static constexpr uint32_t NULL_INDEX = std::numeric_limits<uint32_t>::max();
36
37
16.0k
    COutPoint(): n(NULL_INDEX) { }
38
1.39k
    COutPoint(const Txid& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }
39
40
51.8k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR12SizeComputer20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
40
38.0k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR10SpanReader20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
40
351
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI10SpanReaderS_17ActionUnserializeEEvRT0_RT_T1_
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR12VectorWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
40
229
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
_ZN9COutPoint16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
40
142
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIRS1_IR12VectorWriter20TransactionSerParamsES4_EKS_15ActionSerializeEEvRT0_RT_T1_
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
40
6.40k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI10HashWriterKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR12BufferedFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR10HashWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
40
6.68k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
41
42
0
    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
43
13.7k
    bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }
  Branch (43:35): [True: 184, False: 13.5k]
  Branch (43:52): [True: 59, False: 125]
44
45
    friend bool operator<(const COutPoint& a, const COutPoint& b)
46
3.97k
    {
47
3.97k
        return std::tie(a.hash, a.n) < std::tie(b.hash, b.n);
48
3.97k
    }
49
50
    friend bool operator==(const COutPoint& a, const COutPoint& b)
51
19.2k
    {
52
19.2k
        return (a.hash == b.hash && a.n == b.n);
  Branch (52:17): [True: 10.8k, False: 8.42k]
  Branch (52:37): [True: 10.7k, False: 145]
53
19.2k
    }
54
55
    std::string ToString() const;
56
};
57
58
/** An input of a transaction.  It contains the location of the previous
59
 * transaction's output that it claims and a signature that matches the
60
 * output's public key.
61
 */
62
class CTxIn
63
{
64
public:
65
    COutPoint prevout;
66
    CScript scriptSig;
67
    uint32_t nSequence;
68
    CScriptWitness scriptWitness; //!< Only serialized through CTransaction
69
70
    /**
71
     * Setting nSequence to this value for every input in a transaction
72
     * disables nLockTime/IsFinalTx().
73
     * It fails OP_CHECKLOCKTIMEVERIFY/CheckLockTime() for any input that has
74
     * it set (BIP 65).
75
     * It has SEQUENCE_LOCKTIME_DISABLE_FLAG set (BIP 68/112).
76
     */
77
    static constexpr uint32_t SEQUENCE_FINAL{0xffffffff};
78
    /**
79
     * This is the maximum sequence number that enables both nLockTime and
80
     * OP_CHECKLOCKTIMEVERIFY (BIP 65).
81
     * It has SEQUENCE_LOCKTIME_DISABLE_FLAG set (BIP 68/112).
82
     */
83
    static constexpr uint32_t MAX_SEQUENCE_NONFINAL{SEQUENCE_FINAL - 1};
84
85
    // Below flags apply in the context of BIP 68. BIP 68 requires the tx
86
    // version to be set to 2, or higher.
87
    /**
88
     * If this flag is set, CTxIn::nSequence is NOT interpreted as a
89
     * relative lock-time.
90
     * It skips SequenceLocks() for any input that has it set (BIP 68).
91
     * It fails OP_CHECKSEQUENCEVERIFY/CheckSequence() for any input that has
92
     * it set (BIP 112).
93
     */
94
    static constexpr uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG{1U << 31};
95
96
    /**
97
     * If CTxIn::nSequence encodes a relative lock-time and this flag
98
     * is set, the relative lock-time has units of 512 seconds,
99
     * otherwise it specifies blocks with a granularity of 1. */
100
    static constexpr uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG{1 << 22};
101
102
    /**
103
     * If CTxIn::nSequence encodes a relative lock-time, this mask is
104
     * applied to extract that lock-time from the sequence field. */
105
    static constexpr uint32_t SEQUENCE_LOCKTIME_MASK{0x0000ffff};
106
107
    /**
108
     * In order to use the same number of bits to encode roughly the
109
     * same wall-clock duration, and because blocks are naturally
110
     * limited to occur every 600s on average, the minimum granularity
111
     * for time-based relative lock-time is fixed at 512 seconds.
112
     * Converting from CTxIn::nSequence to seconds is performed by
113
     * multiplying by 512 = 2^9, or equivalently shifting up by
114
     * 9 bits. */
115
    static constexpr int SEQUENCE_LOCKTIME_GRANULARITY{9};
116
117
    CTxIn()
118
6.75k
    {
119
6.75k
        nSequence = SEQUENCE_FINAL;
120
6.75k
    }
121
122
    explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
123
    CTxIn(Txid hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
124
125
51.7k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR12SizeComputer20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
125
38.0k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR10SpanReader20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
125
351
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR12VectorWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
125
229
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI10SpanReaderS_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIRS1_IR12VectorWriter20TransactionSerParamsES4_EKS_15ActionSerializeEEvRT0_RT_T1_
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
125
6.40k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR12BufferedFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR10HashWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
125
6.68k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
126
127
    friend bool operator==(const CTxIn& a, const CTxIn& b)
128
0
    {
129
0
        return (a.prevout   == b.prevout &&
  Branch (129:17): [True: 0, False: 0]
130
0
                a.scriptSig == b.scriptSig &&
  Branch (130:17): [True: 0, False: 0]
131
0
                a.nSequence == b.nSequence);
  Branch (131:17): [True: 0, False: 0]
132
0
    }
133
134
    std::string ToString() const;
135
};
136
137
/** An output of a transaction.  It contains the public key that the next input
138
 * must be able to sign with to claim it.
139
 */
140
class CTxOut
141
{
142
public:
143
    CAmount nValue;
144
    CScript scriptPubKey;
145
146
    CTxOut()
147
19.4k
    {
148
19.4k
        SetNull();
149
19.4k
    }
150
151
    CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn);
152
153
43.1k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR12SizeComputer20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
153
31.1k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR10SpanReader20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
153
659
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR12VectorWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
153
431
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI10SpanReaderS_17ActionUnserializeEEvRT0_RT_T1_
_ZN6CTxOut16SerializationOpsI12SizeComputerKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
153
150
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIRS1_IR12VectorWriter20TransactionSerParamsES4_EKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12VectorWriterKS_15ActionSerializeEEvRT0_RT_T1_
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
153
4.78k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI10HashWriterKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR12BufferedFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR10HashWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
153
5.97k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
154
155
    void SetNull()
156
19.4k
    {
157
19.4k
        nValue = -1;
158
19.4k
        scriptPubKey.clear();
159
19.4k
    }
160
161
    bool IsNull() const
162
7.86k
    {
163
7.86k
        return (nValue == -1);
164
7.86k
    }
165
166
    friend bool operator==(const CTxOut& a, const CTxOut& b)
167
0
    {
168
0
        return (a.nValue       == b.nValue &&
  Branch (168:17): [True: 0, False: 0]
169
0
                a.scriptPubKey == b.scriptPubKey);
  Branch (169:17): [True: 0, False: 0]
170
0
    }
171
172
    std::string ToString() const;
173
};
174
175
struct CMutableTransaction;
176
177
struct TransactionSerParams {
178
    const bool allow_witness;
179
    SER_PARAMS_OPFUNC
180
};
181
inline constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true};
182
inline constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false};
183
184
/**
185
 * Basic transaction serialization format:
186
 * - uint32_t version
187
 * - std::vector<CTxIn> vin
188
 * - std::vector<CTxOut> vout
189
 * - uint32_t nLockTime
190
 *
191
 * Extended transaction serialization format:
192
 * - uint32_t version
193
 * - unsigned char dummy = 0x00
194
 * - unsigned char flags (!= 0)
195
 * - std::vector<CTxIn> vin
196
 * - std::vector<CTxOut> vout
197
 * - if (flags & 1):
198
 *   - CScriptWitness scriptWitness; (deserialized into CTxIn)
199
 * - uint32_t nLockTime
200
 */
201
template<typename Stream, typename TxType>
202
void UnserializeTransaction(TxType& tx, Stream& s, const TransactionSerParams& params)
203
8.00k
{
204
8.00k
    const bool fAllowWitness = params.allow_witness;
205
206
8.00k
    s >> tx.version;
207
8.00k
    unsigned char flags = 0;
208
8.00k
    tx.vin.clear();
209
8.00k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
8.00k
    s >> tx.vin;
212
8.00k
    if (tx.vin.size() == 0 && fAllowWitness) {
  Branch (212:9): [True: 308, False: 43]
  Branch (212:31): [True: 308, False: 0]
  Branch (212:9): [True: 0, False: 0]
  Branch (212:31): [True: 0, False: 0]
  Branch (212:9): [True: 3.31k, False: 4.33k]
  Branch (212:31): [True: 3.31k, False: 0]
  Branch (212:9): [True: 0, False: 0]
  Branch (212:31): [True: 0, False: 0]
  Branch (212:9): [True: 0, False: 0]
  Branch (212:31): [True: 0, False: 0]
213
        /* We read a dummy or an empty vin. */
214
3.62k
        s >> flags;
215
3.62k
        if (flags != 0) {
  Branch (215:13): [True: 308, False: 0]
  Branch (215:13): [True: 0, False: 0]
  Branch (215:13): [True: 648, False: 2.67k]
  Branch (215:13): [True: 0, False: 0]
  Branch (215:13): [True: 0, False: 0]
216
956
            s >> tx.vin;
217
956
            s >> tx.vout;
218
956
        }
219
4.38k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
4.38k
        s >> tx.vout;
222
4.38k
    }
223
8.00k
    if ((flags & 1) && fAllowWitness) {
  Branch (223:9): [True: 308, False: 43]
  Branch (223:24): [True: 308, False: 0]
  Branch (223:9): [True: 0, False: 0]
  Branch (223:24): [True: 0, False: 0]
  Branch (223:9): [True: 457, False: 7.20k]
  Branch (223:24): [True: 457, False: 0]
  Branch (223:9): [True: 0, False: 0]
  Branch (223:24): [True: 0, False: 0]
  Branch (223:9): [True: 0, False: 0]
  Branch (223:24): [True: 0, False: 0]
224
        /* The witness flag is present, and we support witnesses. */
225
765
        flags ^= 1;
226
1.92k
        for (size_t i = 0; i < tx.vin.size(); i++) {
  Branch (226:28): [True: 308, False: 308]
  Branch (226:28): [True: 0, False: 0]
  Branch (226:28): [True: 856, False: 457]
  Branch (226:28): [True: 0, False: 0]
  Branch (226:28): [True: 0, False: 0]
227
1.16k
            s >> tx.vin[i].scriptWitness.stack;
228
1.16k
        }
229
765
        if (!tx.HasWitness()) {
  Branch (229:13): [True: 0, False: 308]
  Branch (229:13): [True: 0, False: 0]
  Branch (229:13): [True: 42, False: 415]
  Branch (229:13): [True: 0, False: 0]
  Branch (229:13): [True: 0, False: 0]
230
            /* It's illegal to encode witnesses when all witness stacks are empty. */
231
42
            throw std::ios_base::failure("Superfluous witness record");
232
42
        }
233
765
    }
234
7.96k
    if (flags) {
  Branch (234:9): [True: 0, False: 351]
  Branch (234:9): [True: 0, False: 0]
  Branch (234:9): [True: 51, False: 7.56k]
  Branch (234:9): [True: 0, False: 0]
  Branch (234:9): [True: 0, False: 0]
235
        /* Unknown flag in the serialization */
236
51
        throw std::ios_base::failure("Unknown transaction optional data");
237
51
    }
238
7.91k
    s >> tx.nLockTime;
239
7.91k
}
_Z22UnserializeTransactionI12ParamsStreamIR10SpanReader20TransactionSerParamsE19CMutableTransactionEvRT0_RT_RKS3_
Line
Count
Source
203
351
{
204
351
    const bool fAllowWitness = params.allow_witness;
205
206
351
    s >> tx.version;
207
351
    unsigned char flags = 0;
208
351
    tx.vin.clear();
209
351
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
351
    s >> tx.vin;
212
351
    if (tx.vin.size() == 0 && fAllowWitness) {
  Branch (212:9): [True: 308, False: 43]
  Branch (212:31): [True: 308, False: 0]
213
        /* We read a dummy or an empty vin. */
214
308
        s >> flags;
215
308
        if (flags != 0) {
  Branch (215:13): [True: 308, False: 0]
216
308
            s >> tx.vin;
217
308
            s >> tx.vout;
218
308
        }
219
308
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
43
        s >> tx.vout;
222
43
    }
223
351
    if ((flags & 1) && fAllowWitness) {
  Branch (223:9): [True: 308, False: 43]
  Branch (223:24): [True: 308, False: 0]
224
        /* The witness flag is present, and we support witnesses. */
225
308
        flags ^= 1;
226
616
        for (size_t i = 0; i < tx.vin.size(); i++) {
  Branch (226:28): [True: 308, False: 308]
227
308
            s >> tx.vin[i].scriptWitness.stack;
228
308
        }
229
308
        if (!tx.HasWitness()) {
  Branch (229:13): [True: 0, False: 308]
230
            /* It's illegal to encode witnesses when all witness stacks are empty. */
231
0
            throw std::ios_base::failure("Superfluous witness record");
232
0
        }
233
308
    }
234
351
    if (flags) {
  Branch (234:9): [True: 0, False: 351]
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
351
    s >> tx.nLockTime;
239
351
}
Unexecuted instantiation: _Z22UnserializeTransactionI10SpanReader19CMutableTransactionEvRT0_RT_RK20TransactionSerParams
_Z22UnserializeTransactionI12ParamsStreamIR10DataStream20TransactionSerParamsE19CMutableTransactionEvRT0_RT_RKS3_
Line
Count
Source
203
7.65k
{
204
7.65k
    const bool fAllowWitness = params.allow_witness;
205
206
7.65k
    s >> tx.version;
207
7.65k
    unsigned char flags = 0;
208
7.65k
    tx.vin.clear();
209
7.65k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
7.65k
    s >> tx.vin;
212
7.65k
    if (tx.vin.size() == 0 && fAllowWitness) {
  Branch (212:9): [True: 3.31k, False: 4.33k]
  Branch (212:31): [True: 3.31k, False: 0]
213
        /* We read a dummy or an empty vin. */
214
3.31k
        s >> flags;
215
3.31k
        if (flags != 0) {
  Branch (215:13): [True: 648, False: 2.67k]
216
648
            s >> tx.vin;
217
648
            s >> tx.vout;
218
648
        }
219
4.33k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
4.33k
        s >> tx.vout;
222
4.33k
    }
223
7.65k
    if ((flags & 1) && fAllowWitness) {
  Branch (223:9): [True: 457, False: 7.20k]
  Branch (223:24): [True: 457, False: 0]
224
        /* The witness flag is present, and we support witnesses. */
225
457
        flags ^= 1;
226
1.31k
        for (size_t i = 0; i < tx.vin.size(); i++) {
  Branch (226:28): [True: 856, False: 457]
227
856
            s >> tx.vin[i].scriptWitness.stack;
228
856
        }
229
457
        if (!tx.HasWitness()) {
  Branch (229:13): [True: 42, False: 415]
230
            /* It's illegal to encode witnesses when all witness stacks are empty. */
231
42
            throw std::ios_base::failure("Superfluous witness record");
232
42
        }
233
457
    }
234
7.61k
    if (flags) {
  Branch (234:9): [True: 51, False: 7.56k]
235
        /* Unknown flag in the serialization */
236
51
        throw std::ios_base::failure("Unknown transaction optional data");
237
51
    }
238
7.56k
    s >> tx.nLockTime;
239
7.56k
}
Unexecuted instantiation: _Z22UnserializeTransactionI12ParamsStreamIR8AutoFile20TransactionSerParamsE19CMutableTransactionEvRT0_RT_RKS3_
Unexecuted instantiation: _Z22UnserializeTransactionI12ParamsStreamIR12BufferedFile20TransactionSerParamsE19CMutableTransactionEvRT0_RT_RKS3_
240
241
template<typename Stream, typename TxType>
242
void SerializeTransaction(const TxType& tx, Stream& s, const TransactionSerParams& params)
243
37.8k
{
244
37.8k
    const bool fAllowWitness = params.allow_witness;
245
246
37.8k
    s << tx.version;
247
37.8k
    unsigned char flags = 0;
248
    // Consistency check
249
37.8k
    if (fAllowWitness) {
  Branch (249:9): [True: 12.2k, False: 17.9k]
  Branch (249:9): [True: 71, False: 158]
  Branch (249:9): [True: 0, False: 0]
  Branch (249:9): [True: 0, False: 0]
  Branch (249:9): [True: 0, False: 0]
  Branch (249:9): [True: 0, False: 0]
  Branch (249:9): [True: 0, False: 0]
  Branch (249:9): [True: 0, False: 0]
  Branch (249:9): [True: 0, False: 0]
  Branch (249:9): [True: 0, False: 0]
  Branch (249:9): [True: 658, False: 6.73k]
250
        /* Check whether witnesses need to be serialized. */
251
13.0k
        if (tx.HasWitness()) {
  Branch (251:13): [True: 500, False: 11.7k]
  Branch (251:13): [True: 61, False: 10]
  Branch (251:13): [True: 0, False: 0]
  Branch (251:13): [True: 0, False: 0]
  Branch (251:13): [True: 0, False: 0]
  Branch (251:13): [True: 0, False: 0]
  Branch (251:13): [True: 0, False: 0]
  Branch (251:13): [True: 0, False: 0]
  Branch (251:13): [True: 0, False: 0]
  Branch (251:13): [True: 0, False: 0]
  Branch (251:13): [True: 658, False: 0]
252
1.21k
            flags |= 1;
253
1.21k
        }
254
13.0k
    }
255
37.8k
    if (flags) {
  Branch (255:9): [True: 500, False: 29.7k]
  Branch (255:9): [True: 61, False: 168]
  Branch (255:9): [True: 0, False: 0]
  Branch (255:9): [True: 0, False: 0]
  Branch (255:9): [True: 0, False: 0]
  Branch (255:9): [True: 0, False: 0]
  Branch (255:9): [True: 0, False: 0]
  Branch (255:9): [True: 0, False: 0]
  Branch (255:9): [True: 0, False: 0]
  Branch (255:9): [True: 0, False: 0]
  Branch (255:9): [True: 658, False: 6.73k]
256
        /* Use extended format in case witnesses are to be serialized. */
257
1.21k
        std::vector<CTxIn> vinDummy;
258
1.21k
        s << vinDummy;
259
1.21k
        s << flags;
260
1.21k
    }
261
37.8k
    s << tx.vin;
262
37.8k
    s << tx.vout;
263
37.8k
    if (flags & 1) {
  Branch (263:9): [True: 500, False: 29.7k]
  Branch (263:9): [True: 61, False: 168]
  Branch (263:9): [True: 0, False: 0]
  Branch (263:9): [True: 0, False: 0]
  Branch (263:9): [True: 0, False: 0]
  Branch (263:9): [True: 0, False: 0]
  Branch (263:9): [True: 0, False: 0]
  Branch (263:9): [True: 0, False: 0]
  Branch (263:9): [True: 0, False: 0]
  Branch (263:9): [True: 0, False: 0]
  Branch (263:9): [True: 658, False: 6.73k]
264
3.16k
        for (size_t i = 0; i < tx.vin.size(); i++) {
  Branch (264:28): [True: 868, False: 500]
  Branch (264:28): [True: 61, False: 61]
  Branch (264:28): [True: 0, False: 0]
  Branch (264:28): [True: 0, False: 0]
  Branch (264:28): [True: 0, False: 0]
  Branch (264:28): [True: 0, False: 0]
  Branch (264:28): [True: 0, False: 0]
  Branch (264:28): [True: 0, False: 0]
  Branch (264:28): [True: 0, False: 0]
  Branch (264:28): [True: 0, False: 0]
  Branch (264:28): [True: 1.02k, False: 658]
265
1.94k
            s << tx.vin[i].scriptWitness.stack;
266
1.94k
        }
267
1.21k
    }
268
37.8k
    s << tx.nLockTime;
269
37.8k
}
_Z20SerializeTransactionI12ParamsStreamIR12SizeComputer20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Line
Count
Source
243
30.2k
{
244
30.2k
    const bool fAllowWitness = params.allow_witness;
245
246
30.2k
    s << tx.version;
247
30.2k
    unsigned char flags = 0;
248
    // Consistency check
249
30.2k
    if (fAllowWitness) {
  Branch (249:9): [True: 12.2k, False: 17.9k]
250
        /* Check whether witnesses need to be serialized. */
251
12.2k
        if (tx.HasWitness()) {
  Branch (251:13): [True: 500, False: 11.7k]
252
500
            flags |= 1;
253
500
        }
254
12.2k
    }
255
30.2k
    if (flags) {
  Branch (255:9): [True: 500, False: 29.7k]
256
        /* Use extended format in case witnesses are to be serialized. */
257
500
        std::vector<CTxIn> vinDummy;
258
500
        s << vinDummy;
259
500
        s << flags;
260
500
    }
261
30.2k
    s << tx.vin;
262
30.2k
    s << tx.vout;
263
30.2k
    if (flags & 1) {
  Branch (263:9): [True: 500, False: 29.7k]
264
1.36k
        for (size_t i = 0; i < tx.vin.size(); i++) {
  Branch (264:28): [True: 868, False: 500]
265
868
            s << tx.vin[i].scriptWitness.stack;
266
868
        }
267
500
    }
268
30.2k
    s << tx.nLockTime;
269
30.2k
}
_Z20SerializeTransactionI12ParamsStreamIR12VectorWriter20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Line
Count
Source
243
229
{
244
229
    const bool fAllowWitness = params.allow_witness;
245
246
229
    s << tx.version;
247
229
    unsigned char flags = 0;
248
    // Consistency check
249
229
    if (fAllowWitness) {
  Branch (249:9): [True: 71, False: 158]
250
        /* Check whether witnesses need to be serialized. */
251
71
        if (tx.HasWitness()) {
  Branch (251:13): [True: 61, False: 10]
252
61
            flags |= 1;
253
61
        }
254
71
    }
255
229
    if (flags) {
  Branch (255:9): [True: 61, False: 168]
256
        /* Use extended format in case witnesses are to be serialized. */
257
61
        std::vector<CTxIn> vinDummy;
258
61
        s << vinDummy;
259
61
        s << flags;
260
61
    }
261
229
    s << tx.vin;
262
229
    s << tx.vout;
263
229
    if (flags & 1) {
  Branch (263:9): [True: 61, False: 168]
264
122
        for (size_t i = 0; i < tx.vin.size(); i++) {
  Branch (264:28): [True: 61, False: 61]
265
61
            s << tx.vin[i].scriptWitness.stack;
266
61
        }
267
61
    }
268
229
    s << tx.nLockTime;
269
229
}
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR10DataStream20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR12SizeComputer20TransactionSerParamsE19CMutableTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR10DataStream20TransactionSerParamsE19CMutableTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIRS0_IR12VectorWriter20TransactionSerParamsES3_E12CTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR12VectorWriter20TransactionSerParamsE19CMutableTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS5_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR8AutoFile20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR10HashWriter20TransactionSerParamsE19CMutableTransactionEvRKT0_RT_RKS3_
_Z20SerializeTransactionI12ParamsStreamIR10HashWriter20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Line
Count
Source
243
7.38k
{
244
7.38k
    const bool fAllowWitness = params.allow_witness;
245
246
7.38k
    s << tx.version;
247
7.38k
    unsigned char flags = 0;
248
    // Consistency check
249
7.38k
    if (fAllowWitness) {
  Branch (249:9): [True: 658, False: 6.73k]
250
        /* Check whether witnesses need to be serialized. */
251
658
        if (tx.HasWitness()) {
  Branch (251:13): [True: 658, False: 0]
252
658
            flags |= 1;
253
658
        }
254
658
    }
255
7.38k
    if (flags) {
  Branch (255:9): [True: 658, False: 6.73k]
256
        /* Use extended format in case witnesses are to be serialized. */
257
658
        std::vector<CTxIn> vinDummy;
258
658
        s << vinDummy;
259
658
        s << flags;
260
658
    }
261
7.38k
    s << tx.vin;
262
7.38k
    s << tx.vout;
263
7.38k
    if (flags & 1) {
  Branch (263:9): [True: 658, False: 6.73k]
264
1.67k
        for (size_t i = 0; i < tx.vin.size(); i++) {
  Branch (264:28): [True: 1.02k, False: 658]
265
1.02k
            s << tx.vin[i].scriptWitness.stack;
266
1.02k
        }
267
658
    }
268
7.38k
    s << tx.nLockTime;
269
7.38k
}
270
271
template<typename TxType>
272
inline CAmount CalculateOutputValue(const TxType& tx)
273
0
{
274
0
    return std::accumulate(tx.vout.cbegin(), tx.vout.cend(), CAmount{0}, [](CAmount sum, const auto& txout) { return sum + txout.nValue; });
275
0
}
276
277
struct EqualsOptions {
278
    bool include_script_sig{true};
279
    bool include_witness_data{true};
280
};
281
282
283
/** The basic transaction that is broadcasted on the network and contained in
284
 * blocks.  A transaction can contain multiple inputs and outputs.
285
 */
286
class CTransaction
287
{
288
public:
289
    // Default transaction version.
290
    static constexpr uint32_t CURRENT_VERSION{2};
291
292
    // The local variables are made const to prevent unintended modification
293
    // without updating the cached hash value. However, CTransaction is not
294
    // actually immutable; deserialization and assignment are implemented,
295
    // and bypass the constness. This is safe, as they update the entire
296
    // structure, including the hash.
297
    const std::vector<CTxIn> vin;
298
    const std::vector<CTxOut> vout;
299
    const uint32_t version;
300
    const uint32_t nLockTime;
301
302
private:
303
    /** Memory only. */
304
    const bool m_has_witness;
305
    const Txid hash;
306
    const Wtxid m_witness_hash;
307
308
    Txid ComputeHash() const;
309
    Wtxid ComputeWitnessHash() const;
310
311
    bool ComputeHasWitness() const;
312
313
public:
314
    /** Convert a CMutableTransaction into a CTransaction. */
315
    explicit CTransaction(const CMutableTransaction& tx);
316
    explicit CTransaction(CMutableTransaction&& tx);
317
318
    template <typename Stream>
319
37.8k
    inline void Serialize(Stream& s) const {
320
37.8k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
37.8k
    }
_ZNK12CTransaction9SerializeI12ParamsStreamIR12SizeComputer20TransactionSerParamsEEEvRT_
Line
Count
Source
319
30.2k
    inline void Serialize(Stream& s) const {
320
30.2k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
30.2k
    }
_ZNK12CTransaction9SerializeI12ParamsStreamIR12VectorWriter20TransactionSerParamsEEEvRT_
Line
Count
Source
319
229
    inline void Serialize(Stream& s) const {
320
229
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
229
    }
Unexecuted instantiation: _ZNK12CTransaction9SerializeI12ParamsStreamIR10DataStream20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZNK12CTransaction9SerializeI12ParamsStreamIRS1_IR12VectorWriter20TransactionSerParamsES4_EEEvRT_
Unexecuted instantiation: _ZNK12CTransaction9SerializeI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZNK12CTransaction9SerializeI12ParamsStreamIR8AutoFile20TransactionSerParamsEEEvRT_
_ZNK12CTransaction9SerializeI12ParamsStreamIR10HashWriter20TransactionSerParamsEEEvRT_
Line
Count
Source
319
7.38k
    inline void Serialize(Stream& s) const {
320
7.38k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
7.38k
    }
322
323
    /** This deserializing constructor is provided instead of an Unserialize method.
324
     *  Unserialize is not possible, since it would require overwriting const fields. */
325
    template <typename Stream>
326
0
    CTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) : CTransaction(CMutableTransaction(deserialize, params, s)) {}
327
    template <typename Stream>
328
8.00k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
_ZN12CTransactionC2I12ParamsStreamIR10SpanReader20TransactionSerParamsEEE16deserialize_typeRT_
Line
Count
Source
328
351
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
_ZN12CTransactionC2I12ParamsStreamIR10DataStream20TransactionSerParamsEEE16deserialize_typeRT_
Line
Count
Source
328
7.65k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
Unexecuted instantiation: _ZN12CTransactionC2I12ParamsStreamIR8AutoFile20TransactionSerParamsEEE16deserialize_typeRT_
Unexecuted instantiation: _ZN12CTransactionC2I12ParamsStreamIR12BufferedFile20TransactionSerParamsEEE16deserialize_typeRT_
329
330
0
    bool IsNull() const {
331
0
        return vin.empty() && vout.empty();
  Branch (331:16): [True: 0, False: 0]
  Branch (331:31): [True: 0, False: 0]
332
0
    }
333
334
24.3k
    const Txid& GetHash() const LIFETIMEBOUND { return hash; }
335
65.4k
    const Wtxid& GetWitnessHash() const LIFETIMEBOUND { return m_witness_hash; };
336
337
    // Return sum of txouts.
338
    CAmount GetValueOut() const;
339
340
    /**
341
     * Calculate the total transaction size in bytes, including witness data.
342
     * "Total Size" defined in BIP141 and BIP144.
343
     * @return Total transaction size in bytes
344
     */
345
    unsigned int ComputeTotalSize() const;
346
347
    bool IsCoinBase() const
348
10.7k
    {
349
10.7k
        return (vin.size() == 1 && vin[0].prevout.IsNull());
  Branch (349:17): [True: 9.39k, False: 1.32k]
  Branch (349:36): [True: 56, False: 9.33k]
350
10.7k
    }
351
352
    bool Equals(const CTransaction& other, const EqualsOptions opts = {}) const
353
0
    {
354
0
        return nLockTime == other.nLockTime &&
  Branch (354:16): [True: 0, False: 0]
355
0
            version == other.version &&
  Branch (355:13): [True: 0, False: 0]
356
0
            vout == other.vout &&
  Branch (356:13): [True: 0, False: 0]
357
0
            std::ranges::equal(vin, other.vin, [&opts](const CTxIn& self, const CTxIn& other) {
  Branch (357:13): [True: 0, False: 0]
358
0
                return self.prevout == other.prevout &&
  Branch (358:24): [True: 0, False: 0]
359
0
                    self.nSequence == other.nSequence &&
  Branch (359:21): [True: 0, False: 0]
360
0
                    (opts.include_script_sig ? self.scriptSig == other.scriptSig : true) &&
  Branch (360:21): [True: 0, False: 0]
  Branch (360:22): [True: 0, False: 0]
361
0
                    (opts.include_witness_data ? self.scriptWitness.stack == other.scriptWitness.stack : true);
  Branch (361:21): [True: 0, False: 0]
  Branch (361:22): [True: 0, False: 0]
362
0
            });
363
0
    }
364
365
    std::string ToString() const;
366
367
27.1k
    bool HasWitness() const { return m_has_witness; }
368
};
369
370
/** A mutable version of CTransaction. */
371
struct CMutableTransaction
372
{
373
    std::vector<CTxIn> vin;
374
    std::vector<CTxOut> vout;
375
    uint32_t version;
376
    uint32_t nLockTime;
377
378
    explicit CMutableTransaction();
379
    explicit CMutableTransaction(const CTransaction& tx);
380
381
    template <typename Stream>
382
0
    inline void Serialize(Stream& s) const {
383
0
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
0
    }
Unexecuted instantiation: _ZNK19CMutableTransaction9SerializeI12ParamsStreamIR12SizeComputer20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZNK19CMutableTransaction9SerializeI12ParamsStreamIR10DataStream20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZNK19CMutableTransaction9SerializeI12ParamsStreamIR12VectorWriter20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZNK19CMutableTransaction9SerializeI12ParamsStreamIR10HashWriter20TransactionSerParamsEEEvRT_
385
386
    template <typename Stream>
387
8.00k
    inline void Unserialize(Stream& s) {
388
8.00k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
8.00k
    }
_ZN19CMutableTransaction11UnserializeI12ParamsStreamIR10SpanReader20TransactionSerParamsEEEvRT_
Line
Count
Source
387
351
    inline void Unserialize(Stream& s) {
388
351
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
351
    }
_ZN19CMutableTransaction11UnserializeI12ParamsStreamIR10DataStream20TransactionSerParamsEEEvRT_
Line
Count
Source
387
7.65k
    inline void Unserialize(Stream& s) {
388
7.65k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
7.65k
    }
Unexecuted instantiation: _ZN19CMutableTransaction11UnserializeI12ParamsStreamIR8AutoFile20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZN19CMutableTransaction11UnserializeI12ParamsStreamIR12BufferedFile20TransactionSerParamsEEEvRT_
390
391
    template <typename Stream>
392
0
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
393
0
        UnserializeTransaction(*this, s, params);
394
0
    }
395
396
    template <typename Stream>
397
8.00k
    CMutableTransaction(deserialize_type, Stream& s) {
398
8.00k
        Unserialize(s);
399
8.00k
    }
_ZN19CMutableTransactionC2I12ParamsStreamIR10SpanReader20TransactionSerParamsEEE16deserialize_typeRT_
Line
Count
Source
397
351
    CMutableTransaction(deserialize_type, Stream& s) {
398
351
        Unserialize(s);
399
351
    }
_ZN19CMutableTransactionC2I12ParamsStreamIR10DataStream20TransactionSerParamsEEE16deserialize_typeRT_
Line
Count
Source
397
7.65k
    CMutableTransaction(deserialize_type, Stream& s) {
398
7.65k
        Unserialize(s);
399
7.65k
    }
Unexecuted instantiation: _ZN19CMutableTransactionC2I12ParamsStreamIR8AutoFile20TransactionSerParamsEEE16deserialize_typeRT_
Unexecuted instantiation: _ZN19CMutableTransactionC2I12ParamsStreamIR12BufferedFile20TransactionSerParamsEEE16deserialize_typeRT_
400
401
    /** Compute the hash of this CMutableTransaction. This is computed on the
402
     * fly, as opposed to GetHash() in CTransaction, which uses a cached result.
403
     */
404
    Txid GetHash() const;
405
406
    bool HasWitness() const
407
715
    {
408
878
        for (size_t i = 0; i < vin.size(); i++) {
  Branch (408:28): [True: 836, False: 42]
409
836
            if (!vin[i].scriptWitness.IsNull()) {
  Branch (409:17): [True: 673, False: 163]
410
673
                return true;
411
673
            }
412
836
        }
413
42
        return false;
414
715
    }
415
};
416
417
typedef std::shared_ptr<const CTransaction> CTransactionRef;
418
0
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
Unexecuted instantiation: cmpctblock.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: coins_view.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: coinscache_sim.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: connect_block.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: mini_miner.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: p2p_headers_presync.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: p2p_private_broadcast.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: package_eval.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: private_broadcast.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: txdownloadman.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: tx_pool.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: tx_pool.cpp:_ZL18MakeTransactionRefIRK19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: txorphan.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: txorphan.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: utxo_total_supply.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: ipc.cpp:_ZL18MakeTransactionRefIRK19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: spend.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: mempool.cpp:_ZL18MakeTransactionRefIRK12CTransactionESt10shared_ptrIS1_EOT_
Unexecuted instantiation: chainparams.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: wallet.cpp:_ZL18MakeTransactionRefIRK12CTransactionESt10shared_ptrIS1_EOT_
Unexecuted instantiation: feebumper.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: backup.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: mining.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: setup_common.cpp:_ZL18MakeTransactionRefIRK19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: setup_common.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: txmempool.cpp:_ZL18MakeTransactionRefIRK19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: txmempool.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: miner.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: miner.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: mempool.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
Unexecuted instantiation: validation.cpp:_ZL18MakeTransactionRefI19CMutableTransactionESt10shared_ptrIK12CTransactionEOT_
419
420
namespace std {
421
/** Disable default std::hash for CTransactionRef to prevent accidentally
422
 *  comparing by pointer. Use CTransactionRefHash or provide a custom
423
 *  hasher. */
424
template <>
425
struct hash<CTransactionRef> {
426
    hash() = delete;
427
    // Belt-and-suspenders, already implied by the above.
428
    size_t operator()(const CTransactionRef&) const = delete;
429
};
430
} // namespace std
431
432
#endif // BITCOIN_PRIMITIVES_TRANSACTION_H