Coverage Report

Created: 2026-10-03 10:33

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.67M
    COutPoint(): n(NULL_INDEX) { }
38
40.3M
    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.41M
    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
143k
    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<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
334k
    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
520
    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<VectorWriter&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
69.6k
    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.51k
    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.4k
    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
43
25.0M
    bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }
44
45
    friend bool operator<(const COutPoint& a, const COutPoint& b)
46
415M
    {
47
415M
        return std::tie(a.hash, a.n) < std::tie(b.hash, b.n);
48
415M
    }
49
50
    friend bool operator==(const COutPoint& a, const COutPoint& b)
51
94.8M
    {
52
94.8M
        return (a.hash == b.hash && a.n == b.n);
53
94.8M
    }
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.45M
    {
119
8.45M
        nSequence = SEQUENCE_FINAL;
120
8.45M
    }
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.40M
    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.41M
    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
143k
    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<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
334k
    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
520
    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
69.6k
    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.51k
    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
64.5M
    {
148
64.5M
        SetNull();
149
64.5M
    }
150
151
    CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn);
152
153
27.5M
    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
297k
    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.78k
    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.87M
    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<SizeComputer, CTxOut const, ActionSerialize>(CTxOut const&, SizeComputer&, ActionSerialize)
Line
Count
Source
153
406k
    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<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<VectorWriter&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
153
169k
    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.27k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
154
155
    void SetNull()
156
76.5M
    {
157
76.5M
        nValue = -1;
158
76.5M
        scriptPubKey.clear();
159
76.5M
    }
160
161
    bool IsNull() const
162
112M
    {
163
112M
        return (nValue == -1);
164
112M
    }
165
166
    friend bool operator==(const CTxOut& a, const CTxOut& b)
167
5.87M
    {
168
5.87M
        return (a.nValue       == b.nValue &&
169
5.87M
                a.scriptPubKey == b.scriptPubKey);
170
5.87M
    }
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
366k
{
204
366k
    const bool fAllowWitness = params.allow_witness;
205
206
366k
    s >> tx.version;
207
366k
    unsigned char flags = 0;
208
366k
    tx.vin.clear();
209
366k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
366k
    s >> tx.vin;
212
366k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
299k
        s >> flags;
215
299k
        if (flags != 0) {
216
299k
            s >> tx.vin;
217
299k
            s >> tx.vout;
218
299k
        }
219
299k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
67.2k
        s >> tx.vout;
222
67.2k
    }
223
366k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
298k
        flags ^= 1;
226
701k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
403k
            s >> tx.vin[i].scriptWitness.stack;
228
403k
        }
229
298k
        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
298k
    }
234
366k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
2
        throw std::ios_base::failure("Unknown transaction optional data");
237
2
    }
238
366k
    s >> tx.nLockTime;
239
366k
}
void UnserializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
121k
{
204
121k
    const bool fAllowWitness = params.allow_witness;
205
206
121k
    s >> tx.version;
207
121k
    unsigned char flags = 0;
208
121k
    tx.vin.clear();
209
121k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
121k
    s >> tx.vin;
212
121k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
84.5k
        s >> flags;
215
84.5k
        if (flags != 0) {
216
84.5k
            s >> tx.vin;
217
84.5k
            s >> tx.vout;
218
84.5k
        }
219
84.5k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
36.5k
        s >> tx.vout;
222
36.5k
    }
223
121k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
84.5k
        flags ^= 1;
226
183k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
99.2k
            s >> tx.vin[i].scriptWitness.stack;
228
99.2k
        }
229
84.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
84.5k
    }
234
121k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
1
        throw std::ios_base::failure("Unknown transaction optional data");
237
1
    }
238
121k
    s >> tx.nLockTime;
239
121k
}
void UnserializeTransaction<DataStream, CMutableTransaction>(CMutableTransaction&, DataStream&, TransactionSerParams const&)
Line
Count
Source
203
219
{
204
219
    const bool fAllowWitness = params.allow_witness;
205
206
219
    s >> tx.version;
207
219
    unsigned char flags = 0;
208
219
    tx.vin.clear();
209
219
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
219
    s >> tx.vin;
212
219
    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
175
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
175
        s >> tx.vout;
222
175
    }
223
219
    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
219
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
219
    s >> tx.nLockTime;
239
219
}
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
242k
{
204
242k
    const bool fAllowWitness = params.allow_witness;
205
206
242k
    s >> tx.version;
207
242k
    unsigned char flags = 0;
208
242k
    tx.vin.clear();
209
242k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
242k
    s >> tx.vin;
212
242k
    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
30.4k
        s >> tx.vout;
222
30.4k
    }
223
242k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
211k
        flags ^= 1;
226
508k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
296k
            s >> tx.vin[i].scriptWitness.stack;
228
296k
        }
229
211k
        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
211k
    }
234
242k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
1
        throw std::ios_base::failure("Unknown transaction optional data");
237
1
    }
238
242k
    s >> tx.nLockTime;
239
242k
}
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
962
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
490
            s >> tx.vin[i].scriptWitness.stack;
228
490
        }
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.16k
{
204
2.16k
    const bool fAllowWitness = params.allow_witness;
205
206
2.16k
    s >> tx.version;
207
2.16k
    unsigned char flags = 0;
208
2.16k
    tx.vin.clear();
209
2.16k
    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.16k
    s >> tx.vin;
212
2.16k
    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.16k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
2.13k
        flags ^= 1;
226
4.26k
        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.16k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
2.16k
    s >> tx.nLockTime;
239
2.16k
}
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.31M
        if (tx.HasWitness()) {
252
1.35M
            flags |= 1;
253
1.35M
        }
254
2.31M
    }
255
6.42M
    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.42M
    s << tx.vin;
262
6.42M
    s << tx.vout;
263
6.42M
    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.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.66M
{
244
3.66M
    const bool fAllowWitness = params.allow_witness;
245
246
3.66M
    s << tx.version;
247
3.66M
    unsigned char flags = 0;
248
    // Consistency check
249
3.66M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1.61M
        if (tx.HasWitness()) {
252
695k
            flags |= 1;
253
695k
        }
254
1.61M
    }
255
3.66M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
695k
        std::vector<CTxIn> vinDummy;
258
695k
        s << vinDummy;
259
695k
        s << flags;
260
695k
    }
261
3.66M
    s << tx.vin;
262
3.66M
    s << tx.vout;
263
3.66M
    if (flags & 1) {
264
1.60M
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
911k
            s << tx.vin[i].scriptWitness.stack;
266
911k
        }
267
695k
    }
268
3.66M
    s << tx.nLockTime;
269
3.66M
}
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
205k
        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<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
58
{
244
58
    const bool fAllowWitness = params.allow_witness;
245
246
58
    s << tx.version;
247
58
    unsigned char flags = 0;
248
    // Consistency check
249
58
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1
        if (tx.HasWitness()) {
252
0
            flags |= 1;
253
0
        }
254
1
    }
255
58
    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
58
    s << tx.vin;
262
58
    s << tx.vout;
263
58
    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
58
    s << tx.nLockTime;
269
58
}
void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
358
{
244
358
    const bool fAllowWitness = params.allow_witness;
245
246
358
    s << tx.version;
247
358
    unsigned char flags = 0;
248
    // Consistency check
249
358
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
302
        if (tx.HasWitness()) {
252
254
            flags |= 1;
253
254
        }
254
302
    }
255
358
    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
358
    s << tx.vin;
262
358
    s << tx.vout;
263
358
    if (flags & 1) {
264
5.12k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
4.86k
            s << tx.vin[i].scriptWitness.stack;
266
4.86k
        }
267
254
    }
268
358
    s << tx.nLockTime;
269
358
}
void SerializeTransaction<ParamsStream<VectorWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
59.2k
{
244
59.2k
    const bool fAllowWitness = params.allow_witness;
245
246
59.2k
    s << tx.version;
247
59.2k
    unsigned char flags = 0;
248
    // Consistency check
249
59.2k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
34.4k
        if (tx.HasWitness()) {
252
32.3k
            flags |= 1;
253
32.3k
        }
254
34.4k
    }
255
59.2k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
32.3k
        std::vector<CTxIn> vinDummy;
258
32.3k
        s << vinDummy;
259
32.3k
        s << flags;
260
32.3k
    }
261
59.2k
    s << tx.vin;
262
59.2k
    s << tx.vout;
263
59.2k
    if (flags & 1) {
264
74.0k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
41.6k
            s << tx.vin[i].scriptWitness.stack;
266
41.6k
        }
267
32.3k
    }
268
59.2k
    s << tx.nLockTime;
269
59.2k
}
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.67k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
2.39k
            s << tx.vin[i].scriptWitness.stack;
266
2.39k
        }
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.72M
{
244
1.72M
    const bool fAllowWitness = params.allow_witness;
245
246
1.72M
    s << tx.version;
247
1.72M
    unsigned char flags = 0;
248
    // Consistency check
249
1.72M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
411k
        if (tx.HasWitness()) {
252
411k
            flags |= 1;
253
411k
        }
254
411k
    }
255
1.72M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
411k
        std::vector<CTxIn> vinDummy;
258
411k
        s << vinDummy;
259
411k
        s << flags;
260
411k
    }
261
1.72M
    s << tx.vin;
262
1.72M
    s << tx.vout;
263
1.72M
    if (flags & 1) {
264
975k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
564k
            s << tx.vin[i].scriptWitness.stack;
266
564k
        }
267
411k
    }
268
1.72M
    s << tx.nLockTime;
269
1.72M
}
270
271
template<typename TxType>
272
inline CAmount CalculateOutputValue(const TxType& tx)
273
5.65k
{
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.65k
}
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.71M
    inline void Serialize(Stream& s) const {
320
5.71M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
5.71M
    }
void CTransaction::Serialize<ParamsStream<SizeComputer&, TransactionSerParams>>(ParamsStream<SizeComputer&, TransactionSerParams>&) const
Line
Count
Source
319
3.66M
    inline void Serialize(Stream& s) const {
320
3.66M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
3.66M
    }
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
59.2k
    inline void Serialize(Stream& s) const {
320
59.2k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
59.2k
    }
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.72M
    inline void Serialize(Stream& s) const {
320
1.72M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
1.72M
    }
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
220
    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
219
    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
319k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
328
121k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
328
195k
    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.16k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
329
330
17.3k
    bool IsNull() const {
331
17.3k
        return vin.empty() && vout.empty();
332
17.3k
    }
333
334
199M
    const Txid& GetHash() const LIFETIMEBOUND { return hash; }
335
2.29M
    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
32.4M
    {
349
32.4M
        return (vin.size() == 1 && vin[0].prevout.IsNull());
350
32.4M
    }
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
3.99M
    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
58
    inline void Serialize(Stream& s) const {
383
58
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
58
    }
void CMutableTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
Line
Count
Source
382
358
    inline void Serialize(Stream& s) const {
383
358
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
358
    }
385
386
    template <typename Stream>
387
366k
    inline void Unserialize(Stream& s) {
388
366k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
366k
    }
void CMutableTransaction::Unserialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
387
121k
    inline void Unserialize(Stream& s) {
388
121k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
121k
    }
void CMutableTransaction::Unserialize<ParamsStream<SpanReader&, TransactionSerParams>>(ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
387
242k
    inline void Unserialize(Stream& s) {
388
242k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
242k
    }
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.16k
    inline void Unserialize(Stream& s) {
388
2.16k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
2.16k
    }
390
391
    template <typename Stream>
392
220
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
393
220
        UnserializeTransaction(*this, s, params);
394
220
    }
CMutableTransaction::CMutableTransaction<DataStream>(deserialize_type, TransactionSerParams const&, DataStream&)
Line
Count
Source
392
219
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
393
219
        UnserializeTransaction(*this, s, params);
394
219
    }
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
319k
    CMutableTransaction(deserialize_type, Stream& s) {
398
319k
        Unserialize(s);
399
319k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
397
121k
    CMutableTransaction(deserialize_type, Stream& s) {
398
121k
        Unserialize(s);
399
121k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
397
195k
    CMutableTransaction(deserialize_type, Stream& s) {
398
195k
        Unserialize(s);
399
195k
    }
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.16k
    CMutableTransaction(deserialize_type, Stream& s) {
398
2.16k
        Unserialize(s);
399
2.16k
    }
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
299k
    {
408
300k
        for (size_t i = 0; i < vin.size(); i++) {
409
300k
            if (!vin[i].scriptWitness.IsNull()) {
410
299k
                return true;
411
299k
            }
412
300k
        }
413
60
        return false;
414
299k
    }
415
};
416
417
typedef std::shared_ptr<const CTransaction> CTransactionRef;
418
746k
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)); }
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
116k
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
909
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
87
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.70k
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
43.9k
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.8k
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.1k
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
12.9k
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