Coverage Report

Created: 2026-10-07 13:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/tmp/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
9.53M
    COutPoint(): n(NULL_INDEX) { }
38
42.5M
    COutPoint(const Txid& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }
39
40
29.0M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<SizeComputer&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<SizeComputer&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
4.42M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, COutPoint, ActionUnserialize>(COutPoint&, ParamsStream<DataStream&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
40
141k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<DataStream&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
123k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<DataStream, COutPoint, ActionUnserialize>(COutPoint&, DataStream&, ActionUnserialize)
Line
Count
Source
40
4.79k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<SpanReader, COutPoint, ActionUnserialize>(COutPoint&, SpanReader&, ActionUnserialize)
Line
Count
Source
40
1
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<VectorWriter&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
76.1k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<HashWriter&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<HashWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
2.13M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<SpanReader&, TransactionSerParams>, COutPoint, ActionUnserialize>(COutPoint&, ParamsStream<SpanReader&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
40
340k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, COutPoint, ActionUnserialize>(COutPoint&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
40
519
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<HashWriter, COutPoint const, ActionSerialize>(COutPoint const&, HashWriter&, ActionSerialize)
Line
Count
Source
40
21.5M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<DataStream, COutPoint const, ActionSerialize>(COutPoint const&, DataStream&, ActionSerialize)
Line
Count
Source
40
6.18k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
186k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
2.32k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<BufferedFile&, TransactionSerParams>, COutPoint, ActionUnserialize>(COutPoint&, ParamsStream<BufferedFile&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
40
2.17k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<SpanWriter, COutPoint const, ActionSerialize>(COutPoint const&, SpanWriter&, ActionSerialize)
Line
Count
Source
40
59
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
41
42
45.6k
    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
43
26.1M
    bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }
44
45
    friend bool operator<(const COutPoint& a, const COutPoint& b)
46
453M
    {
47
453M
        return std::tie(a.hash, a.n) < std::tie(b.hash, b.n);
48
453M
    }
49
50
    friend bool operator==(const COutPoint& a, const COutPoint& b)
51
102M
    {
52
102M
        return (a.hash == b.hash && a.n == b.n);
53
102M
    }
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
8.32M
    {
119
8.32M
        nSequence = SEQUENCE_FINAL;
120
8.32M
    }
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
7.44M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<SizeComputer&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<SizeComputer&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
125
4.42M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, CTxIn, ActionUnserialize>(CTxIn&, ParamsStream<DataStream&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
125
141k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<DataStream&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
125
123k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<DataStream, CTxIn, ActionUnserialize>(CTxIn&, DataStream&, ActionUnserialize)
Line
Count
Source
125
4.79k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<SpanReader, CTxIn, ActionUnserialize>(CTxIn&, SpanReader&, ActionUnserialize)
Line
Count
Source
125
1
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<VectorWriter&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
125
76.1k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<HashWriter&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<HashWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
125
2.13M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<SpanReader&, TransactionSerParams>, CTxIn, ActionUnserialize>(CTxIn&, ParamsStream<SpanReader&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
125
340k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, CTxIn, ActionUnserialize>(CTxIn&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
125
519
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
125
186k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
125
2.32k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<BufferedFile&, TransactionSerParams>, CTxIn, ActionUnserialize>(CTxIn&, ParamsStream<BufferedFile&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
125
2.17k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
126
127
    friend bool operator==(const CTxIn& a, const CTxIn& b)
128
48
    {
129
48
        return (a.prevout   == b.prevout &&
130
48
                a.scriptSig == b.scriptSig &&
131
48
                a.nSequence == b.nSequence);
132
48
    }
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
71.0M
    {
148
71.0M
        SetNull();
149
71.0M
    }
150
151
    CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn);
152
153
27.4M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<SizeComputer&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<SizeComputer&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
153
7.08M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, CTxOut, ActionUnserialize>(CTxOut&, ParamsStream<DataStream&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
153
296k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<DataStream&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
153
265k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<DataStream, CTxOut, ActionUnserialize>(CTxOut&, DataStream&, ActionUnserialize)
Line
Count
Source
153
4.78k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<SpanReader, CTxOut, ActionUnserialize>(CTxOut&, SpanReader&, ActionUnserialize)
Line
Count
Source
153
4.81k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<VectorWriter&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
153
176k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<HashWriter&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<HashWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
153
3.84M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<SpanReader&, TransactionSerParams>, CTxOut, ActionUnserialize>(CTxOut&, ParamsStream<SpanReader&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
153
529k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<SizeComputer, CTxOut const, ActionSerialize>(CTxOut const&, SizeComputer&, ActionSerialize)
Line
Count
Source
153
399k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<DataStream, CTxOut const, ActionSerialize>(CTxOut const&, DataStream&, ActionSerialize)
Line
Count
Source
153
7.44k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, CTxOut, ActionUnserialize>(CTxOut&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
153
837
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<HashWriter, CTxOut const, ActionSerialize>(CTxOut const&, HashWriter&, ActionSerialize)
Line
Count
Source
153
14.4M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
153
382k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
153
2.15k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<ParamsStream<BufferedFile&, TransactionSerParams>, CTxOut, ActionUnserialize>(CTxOut&, ParamsStream<BufferedFile&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
153
4.28k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
154
155
    void SetNull()
156
83.8M
    {
157
83.8M
        nValue = -1;
158
83.8M
        scriptPubKey.clear();
159
83.8M
    }
160
161
    bool IsNull() const
162
120M
    {
163
120M
        return (nValue == -1);
164
120M
    }
165
166
    friend bool operator==(const CTxOut& a, const CTxOut& b)
167
5.85M
    {
168
5.85M
        return (a.nValue       == b.nValue &&
169
5.85M
                a.scriptPubKey == b.scriptPubKey);
170
5.85M
    }
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
367k
{
204
367k
    const bool fAllowWitness = params.allow_witness;
205
206
367k
    s >> tx.version;
207
367k
    unsigned char flags = 0;
208
367k
    tx.vin.clear();
209
367k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
367k
    s >> tx.vin;
212
367k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
296k
        s >> flags;
215
296k
        if (flags != 0) {
216
296k
            s >> tx.vin;
217
296k
            s >> tx.vout;
218
296k
        }
219
296k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
70.7k
        s >> tx.vout;
222
70.7k
    }
223
367k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
296k
        flags ^= 1;
226
696k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
399k
            s >> tx.vin[i].scriptWitness.stack;
228
399k
        }
229
296k
        if (!tx.HasWitness()) {
230
            /* It's illegal to encode witnesses when all witness stacks are empty. */
231
10
            throw std::ios_base::failure("Superfluous witness record");
232
10
        }
233
296k
    }
234
367k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
2
        throw std::ios_base::failure("Unknown transaction optional data");
237
2
    }
238
367k
    s >> tx.nLockTime;
239
367k
}
void UnserializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
119k
{
204
119k
    const bool fAllowWitness = params.allow_witness;
205
206
119k
    s >> tx.version;
207
119k
    unsigned char flags = 0;
208
119k
    tx.vin.clear();
209
119k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
119k
    s >> tx.vin;
212
119k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
82.8k
        s >> flags;
215
82.8k
        if (flags != 0) {
216
82.8k
            s >> tx.vin;
217
82.8k
            s >> tx.vout;
218
82.8k
        }
219
82.8k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
36.7k
        s >> tx.vout;
222
36.7k
    }
223
119k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
82.8k
        flags ^= 1;
226
179k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
96.9k
            s >> tx.vin[i].scriptWitness.stack;
228
96.9k
        }
229
82.8k
        if (!tx.HasWitness()) {
230
            /* It's illegal to encode witnesses when all witness stacks are empty. */
231
1
            throw std::ios_base::failure("Superfluous witness record");
232
1
        }
233
82.8k
    }
234
119k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
1
        throw std::ios_base::failure("Unknown transaction optional data");
237
1
    }
238
119k
    s >> tx.nLockTime;
239
119k
}
void UnserializeTransaction<DataStream, CMutableTransaction>(CMutableTransaction&, DataStream&, TransactionSerParams const&)
Line
Count
Source
203
220
{
204
220
    const bool fAllowWitness = params.allow_witness;
205
206
220
    s >> tx.version;
207
220
    unsigned char flags = 0;
208
220
    tx.vin.clear();
209
220
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
220
    s >> tx.vin;
212
220
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
44
        s >> flags;
215
44
        if (flags != 0) {
216
44
            s >> tx.vin;
217
44
            s >> tx.vout;
218
44
        }
219
176
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
176
        s >> tx.vout;
222
176
    }
223
220
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
44
        flags ^= 1;
226
4.64k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
4.59k
            s >> tx.vin[i].scriptWitness.stack;
228
4.59k
        }
229
44
        if (!tx.HasWitness()) {
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
44
    }
234
220
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
220
    s >> tx.nLockTime;
239
220
}
void UnserializeTransaction<SpanReader, CMutableTransaction>(CMutableTransaction&, SpanReader&, TransactionSerParams const&)
Line
Count
Source
203
1
{
204
1
    const bool fAllowWitness = params.allow_witness;
205
206
1
    s >> tx.version;
207
1
    unsigned char flags = 0;
208
1
    tx.vin.clear();
209
1
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
1
    s >> tx.vin;
212
1
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
0
        s >> flags;
215
0
        if (flags != 0) {
216
0
            s >> tx.vin;
217
0
            s >> tx.vout;
218
0
        }
219
1
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
1
        s >> tx.vout;
222
1
    }
223
1
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
0
        flags ^= 1;
226
0
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
0
            s >> tx.vin[i].scriptWitness.stack;
228
0
        }
229
0
        if (!tx.HasWitness()) {
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
0
    }
234
1
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
1
    s >> tx.nLockTime;
239
1
}
void UnserializeTransaction<ParamsStream<SpanReader&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<SpanReader&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
244k
{
204
244k
    const bool fAllowWitness = params.allow_witness;
205
206
244k
    s >> tx.version;
207
244k
    unsigned char flags = 0;
208
244k
    tx.vin.clear();
209
244k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
244k
    s >> tx.vin;
212
244k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
211k
        s >> flags;
215
211k
        if (flags != 0) {
216
211k
            s >> tx.vin;
217
211k
            s >> tx.vout;
218
211k
        }
219
211k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
33.7k
        s >> tx.vout;
222
33.7k
    }
223
244k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
210k
        flags ^= 1;
226
506k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
295k
            s >> tx.vin[i].scriptWitness.stack;
228
295k
        }
229
210k
        if (!tx.HasWitness()) {
230
            /* It's illegal to encode witnesses when all witness stacks are empty. */
231
9
            throw std::ios_base::failure("Superfluous witness record");
232
9
        }
233
210k
    }
234
244k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
1
        throw std::ios_base::failure("Unknown transaction optional data");
237
1
    }
238
244k
    s >> tx.nLockTime;
239
244k
}
void UnserializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
502
{
204
502
    const bool fAllowWitness = params.allow_witness;
205
206
502
    s >> tx.version;
207
502
    unsigned char flags = 0;
208
502
    tx.vin.clear();
209
502
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
502
    s >> tx.vin;
212
502
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
472
        s >> flags;
215
472
        if (flags != 0) {
216
472
            s >> tx.vin;
217
472
            s >> tx.vout;
218
472
        }
219
472
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
30
        s >> tx.vout;
222
30
    }
223
502
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
472
        flags ^= 1;
226
961
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
489
            s >> tx.vin[i].scriptWitness.stack;
228
489
        }
229
472
        if (!tx.HasWitness()) {
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
472
    }
234
502
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
502
    s >> tx.nLockTime;
239
502
}
void UnserializeTransaction<ParamsStream<BufferedFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<BufferedFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
2.17k
{
204
2.17k
    const bool fAllowWitness = params.allow_witness;
205
206
2.17k
    s >> tx.version;
207
2.17k
    unsigned char flags = 0;
208
2.17k
    tx.vin.clear();
209
2.17k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
2.17k
    s >> tx.vin;
212
2.17k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
2.13k
        s >> flags;
215
2.13k
        if (flags != 0) {
216
2.13k
            s >> tx.vin;
217
2.13k
            s >> tx.vout;
218
2.13k
        }
219
2.13k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
35
        s >> tx.vout;
222
35
    }
223
2.17k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
2.13k
        flags ^= 1;
226
4.27k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
2.13k
            s >> tx.vin[i].scriptWitness.stack;
228
2.13k
        }
229
2.13k
        if (!tx.HasWitness()) {
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
2.13k
    }
234
2.17k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
2.17k
    s >> tx.nLockTime;
239
2.17k
}
240
241
template<typename Stream, typename TxType>
242
void SerializeTransaction(const TxType& tx, Stream& s, const TransactionSerParams& params)
243
6.44M
{
244
6.44M
    const bool fAllowWitness = params.allow_witness;
245
246
6.44M
    s << tx.version;
247
6.44M
    unsigned char flags = 0;
248
    // Consistency check
249
6.44M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
2.31M
        if (tx.HasWitness()) {
252
1.35M
            flags |= 1;
253
1.35M
        }
254
2.31M
    }
255
6.44M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
1.35M
        std::vector<CTxIn> vinDummy;
258
1.35M
        s << vinDummy;
259
1.35M
        s << flags;
260
1.35M
    }
261
6.44M
    s << tx.vin;
262
6.44M
    s << tx.vout;
263
6.44M
    if (flags & 1) {
264
3.13M
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
1.77M
            s << tx.vin[i].scriptWitness.stack;
266
1.77M
        }
267
1.35M
    }
268
6.44M
    s << tx.nLockTime;
269
6.44M
}
void SerializeTransaction<ParamsStream<SizeComputer&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<SizeComputer&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
3.67M
{
244
3.67M
    const bool fAllowWitness = params.allow_witness;
245
246
3.67M
    s << tx.version;
247
3.67M
    unsigned char flags = 0;
248
    // Consistency check
249
3.67M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1.61M
        if (tx.HasWitness()) {
252
700k
            flags |= 1;
253
700k
        }
254
1.61M
    }
255
3.67M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
700k
        std::vector<CTxIn> vinDummy;
258
700k
        s << vinDummy;
259
700k
        s << flags;
260
700k
    }
261
3.67M
    s << tx.vin;
262
3.67M
    s << tx.vout;
263
3.67M
    if (flags & 1) {
264
1.61M
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
914k
            s << tx.vin[i].scriptWitness.stack;
266
914k
        }
267
700k
    }
268
3.67M
    s << tx.nLockTime;
269
3.67M
}
void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
99.7k
{
244
99.7k
    const bool fAllowWitness = params.allow_witness;
245
246
99.7k
    s << tx.version;
247
99.7k
    unsigned char flags = 0;
248
    // Consistency check
249
99.7k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
99.1k
        if (tx.HasWitness()) {
252
94.0k
            flags |= 1;
253
94.0k
        }
254
99.1k
    }
255
99.7k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
94.0k
        std::vector<CTxIn> vinDummy;
258
94.0k
        s << vinDummy;
259
94.0k
        s << flags;
260
94.0k
    }
261
99.7k
    s << tx.vin;
262
99.7k
    s << tx.vout;
263
99.7k
    if (flags & 1) {
264
203k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
109k
            s << tx.vin[i].scriptWitness.stack;
266
109k
        }
267
94.0k
    }
268
99.7k
    s << tx.nLockTime;
269
99.7k
}
void SerializeTransaction<ParamsStream<VectorWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
62.7k
{
244
62.7k
    const bool fAllowWitness = params.allow_witness;
245
246
62.7k
    s << tx.version;
247
62.7k
    unsigned char flags = 0;
248
    // Consistency check
249
62.7k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
35.0k
        if (tx.HasWitness()) {
252
33.0k
            flags |= 1;
253
33.0k
        }
254
35.0k
    }
255
62.7k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
33.0k
        std::vector<CTxIn> vinDummy;
258
33.0k
        s << vinDummy;
259
33.0k
        s << flags;
260
33.0k
    }
261
62.7k
    s << tx.vin;
262
62.7k
    s << tx.vout;
263
62.7k
    if (flags & 1) {
264
75.0k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
42.0k
            s << tx.vin[i].scriptWitness.stack;
266
42.0k
        }
267
33.0k
    }
268
62.7k
    s << tx.nLockTime;
269
62.7k
}
void SerializeTransaction<ParamsStream<HashWriter&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<HashWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
711k
{
244
711k
    const bool fAllowWitness = params.allow_witness;
245
246
711k
    s << tx.version;
247
711k
    unsigned char flags = 0;
248
    // Consistency check
249
711k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1
        if (tx.HasWitness()) {
252
0
            flags |= 1;
253
0
        }
254
1
    }
255
711k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
0
        std::vector<CTxIn> vinDummy;
258
0
        s << vinDummy;
259
0
        s << flags;
260
0
    }
261
711k
    s << tx.vin;
262
711k
    s << tx.vout;
263
711k
    if (flags & 1) {
264
0
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
0
            s << tx.vin[i].scriptWitness.stack;
266
0
        }
267
0
    }
268
711k
    s << tx.nLockTime;
269
711k
}
void SerializeTransaction<ParamsStream<SizeComputer&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<SizeComputer&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
61
{
244
61
    const bool fAllowWitness = params.allow_witness;
245
246
61
    s << tx.version;
247
61
    unsigned char flags = 0;
248
    // Consistency check
249
61
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1
        if (tx.HasWitness()) {
252
0
            flags |= 1;
253
0
        }
254
1
    }
255
61
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
0
        std::vector<CTxIn> vinDummy;
258
0
        s << vinDummy;
259
0
        s << flags;
260
0
    }
261
61
    s << tx.vin;
262
61
    s << tx.vout;
263
61
    if (flags & 1) {
264
0
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
0
            s << tx.vin[i].scriptWitness.stack;
266
0
        }
267
0
    }
268
61
    s << tx.nLockTime;
269
61
}
void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
361
{
244
361
    const bool fAllowWitness = params.allow_witness;
245
246
361
    s << tx.version;
247
361
    unsigned char flags = 0;
248
    // Consistency check
249
361
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
302
        if (tx.HasWitness()) {
252
254
            flags |= 1;
253
254
        }
254
302
    }
255
361
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
254
        std::vector<CTxIn> vinDummy;
258
254
        s << vinDummy;
259
254
        s << flags;
260
254
    }
261
361
    s << tx.vin;
262
361
    s << tx.vout;
263
361
    if (flags & 1) {
264
5.12k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
4.87k
            s << tx.vin[i].scriptWitness.stack;
266
4.87k
        }
267
254
    }
268
361
    s << tx.nLockTime;
269
361
}
void SerializeTransaction<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
154k
{
244
154k
    const bool fAllowWitness = params.allow_witness;
245
246
154k
    s << tx.version;
247
154k
    unsigned char flags = 0;
248
    // Consistency check
249
154k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
154k
        if (tx.HasWitness()) {
252
118k
            flags |= 1;
253
118k
        }
254
154k
    }
255
154k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
118k
        std::vector<CTxIn> vinDummy;
258
118k
        s << vinDummy;
259
118k
        s << flags;
260
118k
    }
261
154k
    s << tx.vin;
262
154k
    s << tx.vout;
263
154k
    if (flags & 1) {
264
260k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
142k
            s << tx.vin[i].scriptWitness.stack;
266
142k
        }
267
118k
    }
268
154k
    s << tx.nLockTime;
269
154k
}
void SerializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
1.35k
{
244
1.35k
    const bool fAllowWitness = params.allow_witness;
245
246
1.35k
    s << tx.version;
247
1.35k
    unsigned char flags = 0;
248
    // Consistency check
249
1.35k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1.35k
        if (tx.HasWitness()) {
252
1.27k
            flags |= 1;
253
1.27k
        }
254
1.35k
    }
255
1.35k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
1.27k
        std::vector<CTxIn> vinDummy;
258
1.27k
        s << vinDummy;
259
1.27k
        s << flags;
260
1.27k
    }
261
1.35k
    s << tx.vin;
262
1.35k
    s << tx.vout;
263
1.35k
    if (flags & 1) {
264
3.48k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
2.20k
            s << tx.vin[i].scriptWitness.stack;
266
2.20k
        }
267
1.27k
    }
268
1.35k
    s << tx.nLockTime;
269
1.35k
}
void SerializeTransaction<ParamsStream<HashWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<HashWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
1.73M
{
244
1.73M
    const bool fAllowWitness = params.allow_witness;
245
246
1.73M
    s << tx.version;
247
1.73M
    unsigned char flags = 0;
248
    // Consistency check
249
1.73M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
409k
        if (tx.HasWitness()) {
252
409k
            flags |= 1;
253
409k
        }
254
409k
    }
255
1.73M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
409k
        std::vector<CTxIn> vinDummy;
258
409k
        s << vinDummy;
259
409k
        s << flags;
260
409k
    }
261
1.73M
    s << tx.vin;
262
1.73M
    s << tx.vout;
263
1.73M
    if (flags & 1) {
264
974k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
564k
            s << tx.vin[i].scriptWitness.stack;
266
564k
        }
267
409k
    }
268
1.73M
    s << tx.nLockTime;
269
1.73M
}
270
271
template<typename TxType>
272
inline CAmount CalculateOutputValue(const TxType& tx)
273
5.66k
{
274
79.2k
    return std::accumulate(tx.vout.cbegin(), tx.vout.cend(), CAmount{0}, [](CAmount sum, const auto& txout) { return sum + txout.nValue; });
275
5.66k
}
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
5.72M
    inline void Serialize(Stream& s) const {
320
5.72M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
5.72M
    }
void CTransaction::Serialize<ParamsStream<SizeComputer&, TransactionSerParams>>(ParamsStream<SizeComputer&, TransactionSerParams>&) const
Line
Count
Source
319
3.67M
    inline void Serialize(Stream& s) const {
320
3.67M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
3.67M
    }
void CTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
Line
Count
Source
319
99.7k
    inline void Serialize(Stream& s) const {
320
99.7k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
99.7k
    }
void CTransaction::Serialize<ParamsStream<VectorWriter&, TransactionSerParams>>(ParamsStream<VectorWriter&, TransactionSerParams>&) const
Line
Count
Source
319
62.7k
    inline void Serialize(Stream& s) const {
320
62.7k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
62.7k
    }
void CTransaction::Serialize<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>>(ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&) const
Line
Count
Source
319
154k
    inline void Serialize(Stream& s) const {
320
154k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
154k
    }
void CTransaction::Serialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&) const
Line
Count
Source
319
1.35k
    inline void Serialize(Stream& s) const {
320
1.35k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
1.35k
    }
void CTransaction::Serialize<ParamsStream<HashWriter&, TransactionSerParams>>(ParamsStream<HashWriter&, TransactionSerParams>&) const
Line
Count
Source
319
1.73M
    inline void Serialize(Stream& s) const {
320
1.73M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
1.73M
    }
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
221
    CTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) : CTransaction(CMutableTransaction(deserialize, params, s)) {}
CTransaction::CTransaction<DataStream>(deserialize_type, TransactionSerParams const&, DataStream&)
Line
Count
Source
326
220
    CTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) : CTransaction(CMutableTransaction(deserialize, params, s)) {}
CTransaction::CTransaction<SpanReader>(deserialize_type, TransactionSerParams const&, SpanReader&)
Line
Count
Source
326
1
    CTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) : CTransaction(CMutableTransaction(deserialize, params, s)) {}
327
    template <typename Stream>
328
320k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
328
119k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
328
197k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
328
502
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
328
2.17k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
329
330
18.1k
    bool IsNull() const {
331
18.1k
        return vin.empty() && vout.empty();
332
18.1k
    }
333
334
209M
    const Txid& GetHash() const LIFETIMEBOUND { return hash; }
335
2.28M
    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
34.1M
    {
349
34.1M
        return (vin.size() == 1 && vin[0].prevout.IsNull());
350
34.1M
    }
351
352
    bool Equals(const CTransaction& other, const EqualsOptions opts = {}) const
353
75
    {
354
75
        return nLockTime == other.nLockTime &&
355
75
            version == other.version &&
356
75
            vout == other.vout &&
357
75
            std::ranges::equal(vin, other.vin, [&opts](const CTxIn& self, const CTxIn& other) {
358
42
                return self.prevout == other.prevout &&
359
42
                    self.nSequence == other.nSequence &&
360
42
                    (opts.include_script_sig ? self.scriptSig == other.scriptSig : true) &&
361
42
                    (opts.include_witness_data ? self.scriptWitness.stack == other.scriptWitness.stack : true);
362
42
            });
363
75
    }
364
365
    std::string ToString() const;
366
367
4.00M
    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
712k
    inline void Serialize(Stream& s) const {
383
712k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
712k
    }
void CMutableTransaction::Serialize<ParamsStream<HashWriter&, TransactionSerParams>>(ParamsStream<HashWriter&, TransactionSerParams>&) const
Line
Count
Source
382
711k
    inline void Serialize(Stream& s) const {
383
711k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
711k
    }
void CMutableTransaction::Serialize<ParamsStream<SizeComputer&, TransactionSerParams>>(ParamsStream<SizeComputer&, TransactionSerParams>&) const
Line
Count
Source
382
61
    inline void Serialize(Stream& s) const {
383
61
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
61
    }
void CMutableTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
Line
Count
Source
382
361
    inline void Serialize(Stream& s) const {
383
361
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
361
    }
385
386
    template <typename Stream>
387
367k
    inline void Unserialize(Stream& s) {
388
367k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
367k
    }
void CMutableTransaction::Unserialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
387
119k
    inline void Unserialize(Stream& s) {
388
119k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
119k
    }
void CMutableTransaction::Unserialize<ParamsStream<SpanReader&, TransactionSerParams>>(ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
387
244k
    inline void Unserialize(Stream& s) {
388
244k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
244k
    }
void CMutableTransaction::Unserialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
387
502
    inline void Unserialize(Stream& s) {
388
502
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
502
    }
void CMutableTransaction::Unserialize<ParamsStream<BufferedFile&, TransactionSerParams>>(ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
387
2.17k
    inline void Unserialize(Stream& s) {
388
2.17k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
2.17k
    }
390
391
    template <typename Stream>
392
221
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
393
221
        UnserializeTransaction(*this, s, params);
394
221
    }
CMutableTransaction::CMutableTransaction<DataStream>(deserialize_type, TransactionSerParams const&, DataStream&)
Line
Count
Source
392
220
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
393
220
        UnserializeTransaction(*this, s, params);
394
220
    }
CMutableTransaction::CMutableTransaction<SpanReader>(deserialize_type, TransactionSerParams const&, SpanReader&)
Line
Count
Source
392
1
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
393
1
        UnserializeTransaction(*this, s, params);
394
1
    }
395
396
    template <typename Stream>
397
320k
    CMutableTransaction(deserialize_type, Stream& s) {
398
320k
        Unserialize(s);
399
320k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
397
119k
    CMutableTransaction(deserialize_type, Stream& s) {
398
119k
        Unserialize(s);
399
119k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
397
197k
    CMutableTransaction(deserialize_type, Stream& s) {
398
197k
        Unserialize(s);
399
197k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
397
502
    CMutableTransaction(deserialize_type, Stream& s) {
398
502
        Unserialize(s);
399
502
    }
CMutableTransaction::CMutableTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
397
2.17k
    CMutableTransaction(deserialize_type, Stream& s) {
398
2.17k
        Unserialize(s);
399
2.17k
    }
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
296k
    {
408
297k
        for (size_t i = 0; i < vin.size(); i++) {
409
297k
            if (!vin[i].scriptWitness.IsNull()) {
410
296k
                return true;
411
296k
            }
412
297k
        }
413
60
        return false;
414
296k
    }
415
};
416
417
typedef std::shared_ptr<const CTransaction> CTransactionRef;
418
753k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
blockencodings_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
12
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
blockencodings_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
3
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
blockfilter_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
2
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
blockpolicyestimator_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
49.1k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
coinsviewoverlay_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
801
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
denialofservice_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
7
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
mempool_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
15
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
mempool_fee_estimator_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
186k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
merkle_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
122k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
miner_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
222
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
miner_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
100
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
miniminer_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
588
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
orphanage_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
276
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
pmt_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
6.48k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
private_broadcast_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
10.0k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
rbf_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
1.25k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
script_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
134
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
serialize_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
1
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txdownload_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
65
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txdownload_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
2
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txindex_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
1
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txpackage_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
78
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txpackage_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CTransaction&>(CTransaction&)
Line
Count
Source
418
3
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txpackage_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
35
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txvalidation_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
34
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txvalidationcache_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction const&>(CMutableTransaction const&)
Line
Count
Source
418
3
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
validation_block_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
938
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
validation_block_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
88
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
validation_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
18
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
validation_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
1
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
coinselector_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
116k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
group_outputs_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
124
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
wallet_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
6
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
wallet_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction const&>(CMutableTransaction const&)
Line
Count
Source
418
2
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
wallet_transaction_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
2
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
ipc_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
1
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
mining.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
155
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
setup_common.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction const&>(CMutableTransaction const&)
Line
Count
Source
418
29
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
setup_common.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
2
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txmempool.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction const&>(CMutableTransaction const&)
Line
Count
Source
418
24.7k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
txmempool.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
3
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
miner.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
8.81k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
miner.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
44.0k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
mempool.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
39.2k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
validation.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
98.5k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
spend.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
4.01k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
wallet.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CTransaction const&>(CTransaction const&)
Line
Count
Source
418
25.4k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
feebumper.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
104
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
backup.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
418
4
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
chainparams.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
418
13.0k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
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