Coverage Report

Created: 2026-11-13 17:38

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.51M
    COutPoint(): n(NULL_INDEX) { }
38
30.5M
    COutPoint(const Txid& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }
39
40
28.9M
    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
137k
    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
124k
    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
67.2k
    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.11M
    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
332k
    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<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<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
185k
    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.19k
    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
1.93k
    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
44.1k
    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
43
19.6M
    bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }
44
45
    friend bool operator<(const COutPoint& a, const COutPoint& b)
46
334M
    {
47
334M
        return std::tie(a.hash, a.n) < std::tie(b.hash, b.n);
48
334M
    }
49
50
    friend bool operator==(const COutPoint& a, const COutPoint& b)
51
79.3M
    {
52
79.3M
        return (a.hash == b.hash && a.n == b.n);
53
79.3M
    }
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.29M
    {
119
8.29M
        nSequence = SEQUENCE_FINAL;
120
8.29M
    }
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.39M
    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
137k
    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
124k
    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
67.2k
    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.11M
    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
332k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<DataStream, CTxIn const, ActionSerialize>(CTxIn const&, DataStream&, ActionSerialize)
Line
Count
Source
125
1
    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
185k
    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.19k
    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
1.93k
    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
64.2M
    {
148
64.2M
        SetNull();
149
64.2M
    }
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.09M
    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
291k
    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
266k
    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.79k
    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
166k
    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.83M
    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
525k
    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.43k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<SizeComputer, CTxOut const, ActionSerialize>(CTxOut const&, SizeComputer&, ActionSerialize)
Line
Count
Source
153
398k
    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
832
    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
380k
    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
1.92k
    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
3.80k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
154
155
    void SetNull()
156
73.1M
    {
157
73.1M
        nValue = -1;
158
73.1M
        scriptPubKey.clear();
159
73.1M
    }
160
161
    bool IsNull() const
162
90.7M
    {
163
90.7M
        return (nValue == -1);
164
90.7M
    }
165
166
    friend bool operator==(const CTxOut& a, const CTxOut& b)
167
5.95M
    {
168
5.95M
        return (a.nValue       == b.nValue &&
169
5.95M
                a.scriptPubKey == b.scriptPubKey);
170
5.95M
    }
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
359k
{
204
359k
    const bool fAllowWitness = params.allow_witness;
205
206
359k
    s >> tx.version;
207
359k
    unsigned char flags = 0;
208
359k
    tx.vin.clear();
209
359k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
359k
    s >> tx.vin;
212
359k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
294k
        s >> flags;
215
294k
        if (flags != 0) {
216
293k
            s >> tx.vin;
217
293k
            s >> tx.vout;
218
293k
        }
219
294k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
65.3k
        s >> tx.vout;
222
65.3k
    }
223
359k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
293k
        flags ^= 1;
226
690k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
396k
            s >> tx.vin[i].scriptWitness.stack;
228
396k
        }
229
293k
        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
293k
    }
234
359k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
3
        throw std::ios_base::failure("Unknown transaction optional data");
237
3
    }
238
359k
    s >> tx.nLockTime;
239
359k
}
void UnserializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
115k
{
204
115k
    const bool fAllowWitness = params.allow_witness;
205
206
115k
    s >> tx.version;
207
115k
    unsigned char flags = 0;
208
115k
    tx.vin.clear();
209
115k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
115k
    s >> tx.vin;
212
115k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
80.6k
        s >> flags;
215
80.6k
        if (flags != 0) {
216
80.6k
            s >> tx.vin;
217
80.6k
            s >> tx.vout;
218
80.6k
        }
219
80.6k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
35.2k
        s >> tx.vout;
222
35.2k
    }
223
115k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
80.5k
        flags ^= 1;
226
175k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
94.8k
            s >> tx.vin[i].scriptWitness.stack;
228
94.8k
        }
229
80.5k
        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
80.5k
    }
234
115k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
2
        throw std::ios_base::failure("Unknown transaction optional data");
237
2
    }
238
115k
    s >> tx.nLockTime;
239
115k
}
void UnserializeTransaction<DataStream, CMutableTransaction>(CMutableTransaction&, DataStream&, TransactionSerParams const&)
Line
Count
Source
203
224
{
204
224
    const bool fAllowWitness = params.allow_witness;
205
206
224
    s >> tx.version;
207
224
    unsigned char flags = 0;
208
224
    tx.vin.clear();
209
224
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
224
    s >> tx.vin;
212
224
    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
180
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
180
        s >> tx.vout;
222
180
    }
223
224
    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
224
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
224
    s >> tx.nLockTime;
239
224
}
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
240k
{
204
240k
    const bool fAllowWitness = params.allow_witness;
205
206
240k
    s >> tx.version;
207
240k
    unsigned char flags = 0;
208
240k
    tx.vin.clear();
209
240k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
240k
    s >> tx.vin;
212
240k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
210k
        s >> flags;
215
210k
        if (flags != 0) {
216
210k
            s >> tx.vin;
217
210k
            s >> tx.vout;
218
210k
        }
219
210k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
29.8k
        s >> tx.vout;
222
29.8k
    }
223
240k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
210k
        flags ^= 1;
226
505k
        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
240k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
1
        throw std::ios_base::failure("Unknown transaction optional data");
237
1
    }
238
240k
    s >> tx.nLockTime;
239
240k
}
void UnserializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
500
{
204
500
    const bool fAllowWitness = params.allow_witness;
205
206
500
    s >> tx.version;
207
500
    unsigned char flags = 0;
208
500
    tx.vin.clear();
209
500
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
500
    s >> tx.vin;
212
500
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
470
        s >> flags;
215
470
        if (flags != 0) {
216
470
            s >> tx.vin;
217
470
            s >> tx.vout;
218
470
        }
219
470
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
30
        s >> tx.vout;
222
30
    }
223
500
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
470
        flags ^= 1;
226
957
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
487
            s >> tx.vin[i].scriptWitness.stack;
228
487
        }
229
470
        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
470
    }
234
500
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
500
    s >> tx.nLockTime;
239
500
}
void UnserializeTransaction<ParamsStream<BufferedFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<BufferedFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
1.92k
{
204
1.92k
    const bool fAllowWitness = params.allow_witness;
205
206
1.92k
    s >> tx.version;
207
1.92k
    unsigned char flags = 0;
208
1.92k
    tx.vin.clear();
209
1.92k
    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.92k
    s >> tx.vin;
212
1.92k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
1.89k
        s >> flags;
215
1.89k
        if (flags != 0) {
216
1.89k
            s >> tx.vin;
217
1.89k
            s >> tx.vout;
218
1.89k
        }
219
1.89k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
35
        s >> tx.vout;
222
35
    }
223
1.92k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
1.89k
        flags ^= 1;
226
3.79k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
1.89k
            s >> tx.vin[i].scriptWitness.stack;
228
1.89k
        }
229
1.89k
        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
1.89k
    }
234
1.92k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
1.92k
    s >> tx.nLockTime;
239
1.92k
}
240
241
template<typename Stream, typename TxType>
242
void SerializeTransaction(const TxType& tx, Stream& s, const TransactionSerParams& params)
243
6.42M
{
244
6.42M
    const bool fAllowWitness = params.allow_witness;
245
246
6.42M
    s << tx.version;
247
6.42M
    unsigned char flags = 0;
248
    // Consistency check
249
6.42M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
2.32M
        if (tx.HasWitness()) {
252
1.36M
            flags |= 1;
253
1.36M
        }
254
2.32M
    }
255
6.42M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
1.36M
        std::vector<CTxIn> vinDummy;
258
1.36M
        s << vinDummy;
259
1.36M
        s << flags;
260
1.36M
    }
261
6.42M
    s << tx.vin;
262
6.42M
    s << tx.vout;
263
6.42M
    if (flags & 1) {
264
3.14M
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
1.78M
            s << tx.vin[i].scriptWitness.stack;
266
1.78M
        }
267
1.36M
    }
268
6.42M
    s << tx.nLockTime;
269
6.42M
}
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.62M
        if (tx.HasWitness()) {
252
710k
            flags |= 1;
253
710k
        }
254
1.62M
    }
255
3.67M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
710k
        std::vector<CTxIn> vinDummy;
258
710k
        s << vinDummy;
259
710k
        s << flags;
260
710k
    }
261
3.67M
    s << tx.vin;
262
3.67M
    s << tx.vout;
263
3.67M
    if (flags & 1) {
264
1.63M
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
924k
            s << tx.vin[i].scriptWitness.stack;
266
924k
        }
267
710k
    }
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
100k
{
244
100k
    const bool fAllowWitness = params.allow_witness;
245
246
100k
    s << tx.version;
247
100k
    unsigned char flags = 0;
248
    // Consistency check
249
100k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
99.4k
        if (tx.HasWitness()) {
252
94.3k
            flags |= 1;
253
94.3k
        }
254
99.4k
    }
255
100k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
94.3k
        std::vector<CTxIn> vinDummy;
258
94.3k
        s << vinDummy;
259
94.3k
        s << flags;
260
94.3k
    }
261
100k
    s << tx.vin;
262
100k
    s << tx.vout;
263
100k
    if (flags & 1) {
264
204k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
110k
            s << tx.vin[i].scriptWitness.stack;
266
110k
        }
267
94.3k
    }
268
100k
    s << tx.nLockTime;
269
100k
}
void SerializeTransaction<ParamsStream<VectorWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
57.2k
{
244
57.2k
    const bool fAllowWitness = params.allow_witness;
245
246
57.2k
    s << tx.version;
247
57.2k
    unsigned char flags = 0;
248
    // Consistency check
249
57.2k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
32.5k
        if (tx.HasWitness()) {
252
30.7k
            flags |= 1;
253
30.7k
        }
254
32.5k
    }
255
57.2k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
30.7k
        std::vector<CTxIn> vinDummy;
258
30.7k
        s << vinDummy;
259
30.7k
        s << flags;
260
30.7k
    }
261
57.2k
    s << tx.vin;
262
57.2k
    s << tx.vout;
263
57.2k
    if (flags & 1) {
264
70.3k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
39.6k
            s << tx.vin[i].scriptWitness.stack;
266
39.6k
        }
267
30.7k
    }
268
57.2k
    s << tx.nLockTime;
269
57.2k
}
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
60
{
244
60
    const bool fAllowWitness = params.allow_witness;
245
246
60
    s << tx.version;
247
60
    unsigned char flags = 0;
248
    // Consistency check
249
60
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1
        if (tx.HasWitness()) {
252
0
            flags |= 1;
253
0
        }
254
1
    }
255
60
    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
60
    s << tx.vin;
262
60
    s << tx.vout;
263
60
    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
60
    s << tx.nLockTime;
269
60
}
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
303
        if (tx.HasWitness()) {
252
255
            flags |= 1;
253
255
        }
254
303
    }
255
361
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
255
        std::vector<CTxIn> vinDummy;
258
255
        s << vinDummy;
259
255
        s << flags;
260
255
    }
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
255
    }
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
153k
{
244
153k
    const bool fAllowWitness = params.allow_witness;
245
246
153k
    s << tx.version;
247
153k
    unsigned char flags = 0;
248
    // Consistency check
249
153k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
153k
        if (tx.HasWitness()) {
252
116k
            flags |= 1;
253
116k
        }
254
153k
    }
255
153k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
116k
        std::vector<CTxIn> vinDummy;
258
116k
        s << vinDummy;
259
116k
        s << flags;
260
116k
    }
261
153k
    s << tx.vin;
262
153k
    s << tx.vout;
263
153k
    if (flags & 1) {
264
257k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
140k
            s << tx.vin[i].scriptWitness.stack;
266
140k
        }
267
116k
    }
268
153k
    s << tx.nLockTime;
269
153k
}
void SerializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
1.23k
{
244
1.23k
    const bool fAllowWitness = params.allow_witness;
245
246
1.23k
    s << tx.version;
247
1.23k
    unsigned char flags = 0;
248
    // Consistency check
249
1.23k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1.23k
        if (tx.HasWitness()) {
252
1.16k
            flags |= 1;
253
1.16k
        }
254
1.23k
    }
255
1.23k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
1.16k
        std::vector<CTxIn> vinDummy;
258
1.16k
        s << vinDummy;
259
1.16k
        s << flags;
260
1.16k
    }
261
1.23k
    s << tx.vin;
262
1.23k
    s << tx.vout;
263
1.23k
    if (flags & 1) {
264
3.24k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
2.07k
            s << tx.vin[i].scriptWitness.stack;
266
2.07k
        }
267
1.16k
    }
268
1.23k
    s << tx.nLockTime;
269
1.23k
}
void SerializeTransaction<ParamsStream<HashWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<HashWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
1.71M
{
244
1.71M
    const bool fAllowWitness = params.allow_witness;
245
246
1.71M
    s << tx.version;
247
1.71M
    unsigned char flags = 0;
248
    // Consistency check
249
1.71M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
406k
        if (tx.HasWitness()) {
252
406k
            flags |= 1;
253
406k
        }
254
406k
    }
255
1.71M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
406k
        std::vector<CTxIn> vinDummy;
258
406k
        s << vinDummy;
259
406k
        s << flags;
260
406k
    }
261
1.71M
    s << tx.vin;
262
1.71M
    s << tx.vout;
263
1.71M
    if (flags & 1) {
264
966k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
559k
            s << tx.vin[i].scriptWitness.stack;
266
559k
        }
267
406k
    }
268
1.71M
    s << tx.nLockTime;
269
1.71M
}
270
271
template<typename TxType>
272
inline CAmount CalculateOutputValue(const TxType& tx)
273
5.69k
{
274
79.3k
    return std::accumulate(tx.vout.cbegin(), tx.vout.cend(), CAmount{0}, [](CAmount sum, const auto& txout) { return sum + txout.nValue; });
275
5.69k
}
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.70M
    inline void Serialize(Stream& s) const {
320
5.70M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
5.70M
    }
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
100k
    inline void Serialize(Stream& s) const {
320
100k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
100k
    }
void CTransaction::Serialize<ParamsStream<VectorWriter&, TransactionSerParams>>(ParamsStream<VectorWriter&, TransactionSerParams>&) const
Line
Count
Source
319
57.2k
    inline void Serialize(Stream& s) const {
320
57.2k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
57.2k
    }
void CTransaction::Serialize<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>>(ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&) const
Line
Count
Source
319
153k
    inline void Serialize(Stream& s) const {
320
153k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
153k
    }
void CTransaction::Serialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&) const
Line
Count
Source
319
1.23k
    inline void Serialize(Stream& s) const {
320
1.23k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
1.23k
    }
void CTransaction::Serialize<ParamsStream<HashWriter&, TransactionSerParams>>(ParamsStream<HashWriter&, TransactionSerParams>&) const
Line
Count
Source
319
1.71M
    inline void Serialize(Stream& s) const {
320
1.71M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
1.71M
    }
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
225
    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
224
    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
313k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
328
115k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
328
194k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
328
500
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
328
1.92k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
329
330
13.2k
    bool IsNull() const {
331
13.2k
        return vin.empty() && vout.empty();
332
13.2k
    }
333
334
152M
    const Txid& GetHash() const LIFETIMEBOUND { return hash; }
335
3.31M
    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
25.1M
    {
349
25.1M
        return (vin.size() == 1 && vin[0].prevout.IsNull());
350
25.1M
    }
351
352
    bool Equals(const CTransaction& other, const EqualsOptions opts = {}) const
353
74
    {
354
74
        return nLockTime == other.nLockTime &&
355
74
            version == other.version &&
356
74
            vout == other.vout &&
357
74
            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
74
    }
364
365
    std::string ToString() const;
366
367
3.98M
    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
60
    inline void Serialize(Stream& s) const {
383
60
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
60
    }
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
359k
    inline void Unserialize(Stream& s) {
388
359k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
359k
    }
void CMutableTransaction::Unserialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
387
115k
    inline void Unserialize(Stream& s) {
388
115k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
115k
    }
void CMutableTransaction::Unserialize<ParamsStream<SpanReader&, TransactionSerParams>>(ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
387
240k
    inline void Unserialize(Stream& s) {
388
240k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
240k
    }
void CMutableTransaction::Unserialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
387
500
    inline void Unserialize(Stream& s) {
388
500
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
500
    }
void CMutableTransaction::Unserialize<ParamsStream<BufferedFile&, TransactionSerParams>>(ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
387
1.92k
    inline void Unserialize(Stream& s) {
388
1.92k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
1.92k
    }
390
391
    template <typename Stream>
392
225
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
393
225
        UnserializeTransaction(*this, s, params);
394
225
    }
CMutableTransaction::CMutableTransaction<DataStream>(deserialize_type, TransactionSerParams const&, DataStream&)
Line
Count
Source
392
224
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
393
224
        UnserializeTransaction(*this, s, params);
394
224
    }
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
313k
    CMutableTransaction(deserialize_type, Stream& s) {
398
313k
        Unserialize(s);
399
313k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
397
115k
    CMutableTransaction(deserialize_type, Stream& s) {
398
115k
        Unserialize(s);
399
115k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
397
194k
    CMutableTransaction(deserialize_type, Stream& s) {
398
194k
        Unserialize(s);
399
194k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
397
500
    CMutableTransaction(deserialize_type, Stream& s) {
398
500
        Unserialize(s);
399
500
    }
CMutableTransaction::CMutableTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
397
1.92k
    CMutableTransaction(deserialize_type, Stream& s) {
398
1.92k
        Unserialize(s);
399
1.92k
    }
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
294k
    {
408
294k
        for (size_t i = 0; i < vin.size(); i++) {
409
294k
            if (!vin[i].scriptWitness.IsNull()) {
410
293k
                return true;
411
293k
            }
412
294k
        }
413
60
        return false;
414
294k
    }
415
};
416
417
typedef std::shared_ptr<const CTransaction> CTransactionRef;
418
748k
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
8
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
2
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
118k
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
879
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
85
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.92k
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.1k
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
38.0k
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.6k
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.03k
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
5
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.4k
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