Coverage Report

Created: 2026-09-14 20:36

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.77M
    COutPoint(): n(NULL_INDEX) { }
38
36.8M
    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.47M
    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
138k
    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.09M
    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
339k
    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
517
    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.4M
    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.21k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<VectorWriter&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
40
76.0k
    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.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.14k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
41
42
45.2k
    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
43
22.0M
    bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }
44
45
    friend bool operator<(const COutPoint& a, const COutPoint& b)
46
387M
    {
47
387M
        return std::tie(a.hash, a.n) < std::tie(b.hash, b.n);
48
387M
    }
49
50
    friend bool operator==(const COutPoint& a, const COutPoint& b)
51
92.9M
    {
52
92.9M
        return (a.hash == b.hash && a.n == b.n);
53
92.9M
    }
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.56M
    {
119
8.56M
        nSequence = SEQUENCE_FINAL;
120
8.56M
    }
121
122
    explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
123
    CTxIn(Txid hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
124
125
7.44M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<SizeComputer&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<SizeComputer&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
125
4.47M
    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
138k
    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.09M
    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
339k
    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
517
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<ParamsStream<VectorWriter&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
125
76.0k
    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.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.14k
    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
69.4M
    {
148
69.4M
        SetNull();
149
69.4M
    }
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.19M
    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
289k
    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.77k
    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.79M
    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
521k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<SizeComputer, CTxOut const, ActionSerialize>(CTxOut const&, SizeComputer&, ActionSerialize)
Line
Count
Source
153
413k
    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.45k
    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
830
    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
182k
    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
381k
    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.23k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
154
155
    void SetNull()
156
80.7M
    {
157
80.7M
        nValue = -1;
158
80.7M
        scriptPubKey.clear();
159
80.7M
    }
160
161
    bool IsNull() const
162
108M
    {
163
108M
        return (nValue == -1);
164
108M
    }
165
166
    friend bool operator==(const CTxOut& a, const CTxOut& b)
167
5.93M
    {
168
5.93M
        return (a.nValue       == b.nValue &&
169
5.93M
                a.scriptPubKey == b.scriptPubKey);
170
5.93M
    }
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
362k
{
204
362k
    const bool fAllowWitness = params.allow_witness;
205
206
362k
    s >> tx.version;
207
362k
    unsigned char flags = 0;
208
362k
    tx.vin.clear();
209
362k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
362k
    s >> tx.vin;
212
362k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
292k
        s >> flags;
215
292k
        if (flags != 0) {
216
292k
            s >> tx.vin;
217
292k
            s >> tx.vout;
218
292k
        }
219
292k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
69.7k
        s >> tx.vout;
222
69.7k
    }
223
362k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
292k
        flags ^= 1;
226
687k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
395k
            s >> tx.vin[i].scriptWitness.stack;
228
395k
        }
229
292k
        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
292k
    }
234
362k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
2
        throw std::ios_base::failure("Unknown transaction optional data");
237
2
    }
238
362k
    s >> tx.nLockTime;
239
362k
}
void UnserializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
116k
{
204
116k
    const bool fAllowWitness = params.allow_witness;
205
206
116k
    s >> tx.version;
207
116k
    unsigned char flags = 0;
208
116k
    tx.vin.clear();
209
116k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
116k
    s >> tx.vin;
212
116k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
80.3k
        s >> flags;
215
80.3k
        if (flags != 0) {
216
80.3k
            s >> tx.vin;
217
80.3k
            s >> tx.vout;
218
80.3k
        }
219
80.3k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
35.8k
        s >> tx.vout;
222
35.8k
    }
223
116k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
80.3k
        flags ^= 1;
226
174k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
94.5k
            s >> tx.vin[i].scriptWitness.stack;
228
94.5k
        }
229
80.3k
        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.3k
    }
234
116k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
1
        throw std::ios_base::failure("Unknown transaction optional data");
237
1
    }
238
116k
    s >> tx.nLockTime;
239
116k
}
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
243k
{
204
243k
    const bool fAllowWitness = params.allow_witness;
205
206
243k
    s >> tx.version;
207
243k
    unsigned char flags = 0;
208
243k
    tx.vin.clear();
209
243k
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
243k
    s >> tx.vin;
212
243k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
209k
        s >> flags;
215
209k
        if (flags != 0) {
216
209k
            s >> tx.vin;
217
209k
            s >> tx.vout;
218
209k
        }
219
209k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
33.6k
        s >> tx.vout;
222
33.6k
    }
223
243k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
209k
        flags ^= 1;
226
503k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
293k
            s >> tx.vin[i].scriptWitness.stack;
228
293k
        }
229
209k
        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
209k
    }
234
243k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
1
        throw std::ios_base::failure("Unknown transaction optional data");
237
1
    }
238
243k
    s >> tx.nLockTime;
239
243k
}
void UnserializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
498
{
204
498
    const bool fAllowWitness = params.allow_witness;
205
206
498
    s >> tx.version;
207
498
    unsigned char flags = 0;
208
498
    tx.vin.clear();
209
498
    tx.vout.clear();
210
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
211
498
    s >> tx.vin;
212
498
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
469
        s >> flags;
215
469
        if (flags != 0) {
216
469
            s >> tx.vin;
217
469
            s >> tx.vout;
218
469
        }
219
469
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
29
        s >> tx.vout;
222
29
    }
223
498
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
469
        flags ^= 1;
226
956
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
487
            s >> tx.vin[i].scriptWitness.stack;
228
487
        }
229
469
        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
469
    }
234
498
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
498
    s >> tx.nLockTime;
239
498
}
void UnserializeTransaction<ParamsStream<BufferedFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<BufferedFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
203
2.14k
{
204
2.14k
    const bool fAllowWitness = params.allow_witness;
205
206
2.14k
    s >> tx.version;
207
2.14k
    unsigned char flags = 0;
208
2.14k
    tx.vin.clear();
209
2.14k
    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.14k
    s >> tx.vin;
212
2.14k
    if (tx.vin.size() == 0 && fAllowWitness) {
213
        /* We read a dummy or an empty vin. */
214
2.10k
        s >> flags;
215
2.10k
        if (flags != 0) {
216
2.10k
            s >> tx.vin;
217
2.10k
            s >> tx.vout;
218
2.10k
        }
219
2.10k
    } else {
220
        /* We read a non-empty vin. Assume a normal vout follows. */
221
35
        s >> tx.vout;
222
35
    }
223
2.14k
    if ((flags & 1) && fAllowWitness) {
224
        /* The witness flag is present, and we support witnesses. */
225
2.10k
        flags ^= 1;
226
4.22k
        for (size_t i = 0; i < tx.vin.size(); i++) {
227
2.11k
            s >> tx.vin[i].scriptWitness.stack;
228
2.11k
        }
229
2.10k
        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.10k
    }
234
2.14k
    if (flags) {
235
        /* Unknown flag in the serialization */
236
0
        throw std::ios_base::failure("Unknown transaction optional data");
237
0
    }
238
2.14k
    s >> tx.nLockTime;
239
2.14k
}
240
241
template<typename Stream, typename TxType>
242
void SerializeTransaction(const TxType& tx, Stream& s, const TransactionSerParams& params)
243
6.47M
{
244
6.47M
    const bool fAllowWitness = params.allow_witness;
245
246
6.47M
    s << tx.version;
247
6.47M
    unsigned char flags = 0;
248
    // Consistency check
249
6.47M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
2.33M
        if (tx.HasWitness()) {
252
1.37M
            flags |= 1;
253
1.37M
        }
254
2.33M
    }
255
6.47M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
1.37M
        std::vector<CTxIn> vinDummy;
258
1.37M
        s << vinDummy;
259
1.37M
        s << flags;
260
1.37M
    }
261
6.47M
    s << tx.vin;
262
6.47M
    s << tx.vout;
263
6.47M
    if (flags & 1) {
264
3.18M
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
1.81M
            s << tx.vin[i].scriptWitness.stack;
266
1.81M
        }
267
1.37M
    }
268
6.47M
    s << tx.nLockTime;
269
6.47M
}
void SerializeTransaction<ParamsStream<SizeComputer&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<SizeComputer&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
3.71M
{
244
3.71M
    const bool fAllowWitness = params.allow_witness;
245
246
3.71M
    s << tx.version;
247
3.71M
    unsigned char flags = 0;
248
    // Consistency check
249
3.71M
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1.63M
        if (tx.HasWitness()) {
252
722k
            flags |= 1;
253
722k
        }
254
1.63M
    }
255
3.71M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
722k
        std::vector<CTxIn> vinDummy;
258
722k
        s << vinDummy;
259
722k
        s << flags;
260
722k
    }
261
3.71M
    s << tx.vin;
262
3.71M
    s << tx.vout;
263
3.71M
    if (flags & 1) {
264
1.67M
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
953k
            s << tx.vin[i].scriptWitness.stack;
266
953k
        }
267
722k
    }
268
3.71M
    s << tx.nLockTime;
269
3.71M
}
void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
99.1k
{
244
99.1k
    const bool fAllowWitness = params.allow_witness;
245
246
99.1k
    s << tx.version;
247
99.1k
    unsigned char flags = 0;
248
    // Consistency check
249
99.1k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
98.6k
        if (tx.HasWitness()) {
252
93.5k
            flags |= 1;
253
93.5k
        }
254
98.6k
    }
255
99.1k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
93.5k
        std::vector<CTxIn> vinDummy;
258
93.5k
        s << vinDummy;
259
93.5k
        s << flags;
260
93.5k
    }
261
99.1k
    s << tx.vin;
262
99.1k
    s << tx.vout;
263
99.1k
    if (flags & 1) {
264
203k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
110k
            s << tx.vin[i].scriptWitness.stack;
266
110k
        }
267
93.5k
    }
268
99.1k
    s << tx.nLockTime;
269
99.1k
}
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
52
{
244
52
    const bool fAllowWitness = params.allow_witness;
245
246
52
    s << tx.version;
247
52
    unsigned char flags = 0;
248
    // Consistency check
249
52
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1
        if (tx.HasWitness()) {
252
0
            flags |= 1;
253
0
        }
254
1
    }
255
52
    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
52
    s << tx.vin;
262
52
    s << tx.vout;
263
52
    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
52
    s << tx.nLockTime;
269
52
}
void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
352
{
244
352
    const bool fAllowWitness = params.allow_witness;
245
246
352
    s << tx.version;
247
352
    unsigned char flags = 0;
248
    // Consistency check
249
352
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
302
        if (tx.HasWitness()) {
252
254
            flags |= 1;
253
254
        }
254
302
    }
255
352
    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
352
    s << tx.vin;
262
352
    s << tx.vout;
263
352
    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
352
    s << tx.nLockTime;
269
352
}
void SerializeTransaction<ParamsStream<VectorWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
243
62.2k
{
244
62.2k
    const bool fAllowWitness = params.allow_witness;
245
246
62.2k
    s << tx.version;
247
62.2k
    unsigned char flags = 0;
248
    // Consistency check
249
62.2k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
34.1k
        if (tx.HasWitness()) {
252
32.0k
            flags |= 1;
253
32.0k
        }
254
34.1k
    }
255
62.2k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
32.0k
        std::vector<CTxIn> vinDummy;
258
32.0k
        s << vinDummy;
259
32.0k
        s << flags;
260
32.0k
    }
261
62.2k
    s << tx.vin;
262
62.2k
    s << tx.vout;
263
62.2k
    if (flags & 1) {
264
73.4k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
41.3k
            s << tx.vin[i].scriptWitness.stack;
266
41.3k
        }
267
32.0k
    }
268
62.2k
    s << tx.nLockTime;
269
62.2k
}
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
117k
            flags |= 1;
253
117k
        }
254
153k
    }
255
153k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
117k
        std::vector<CTxIn> vinDummy;
258
117k
        s << vinDummy;
259
117k
        s << flags;
260
117k
    }
261
153k
    s << tx.vin;
262
153k
    s << tx.vout;
263
153k
    if (flags & 1) {
264
258k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
141k
            s << tx.vin[i].scriptWitness.stack;
266
141k
        }
267
117k
    }
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.34k
{
244
1.34k
    const bool fAllowWitness = params.allow_witness;
245
246
1.34k
    s << tx.version;
247
1.34k
    unsigned char flags = 0;
248
    // Consistency check
249
1.34k
    if (fAllowWitness) {
250
        /* Check whether witnesses need to be serialized. */
251
1.34k
        if (tx.HasWitness()) {
252
1.26k
            flags |= 1;
253
1.26k
        }
254
1.34k
    }
255
1.34k
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
1.26k
        std::vector<CTxIn> vinDummy;
258
1.26k
        s << vinDummy;
259
1.26k
        s << flags;
260
1.26k
    }
261
1.34k
    s << tx.vin;
262
1.34k
    s << tx.vout;
263
1.34k
    if (flags & 1) {
264
3.66k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
2.39k
            s << tx.vin[i].scriptWitness.stack;
266
2.39k
        }
267
1.26k
    }
268
1.34k
    s << tx.nLockTime;
269
1.34k
}
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
404k
        if (tx.HasWitness()) {
252
404k
            flags |= 1;
253
404k
        }
254
404k
    }
255
1.72M
    if (flags) {
256
        /* Use extended format in case witnesses are to be serialized. */
257
404k
        std::vector<CTxIn> vinDummy;
258
404k
        s << vinDummy;
259
404k
        s << flags;
260
404k
    }
261
1.72M
    s << tx.vin;
262
1.72M
    s << tx.vout;
263
1.72M
    if (flags & 1) {
264
960k
        for (size_t i = 0; i < tx.vin.size(); i++) {
265
556k
            s << tx.vin[i].scriptWitness.stack;
266
556k
        }
267
404k
    }
268
1.72M
    s << tx.nLockTime;
269
1.72M
}
270
271
template<typename TxType>
272
inline CAmount CalculateOutputValue(const TxType& tx)
273
5.59k
{
274
79.1k
    return std::accumulate(tx.vout.cbegin(), tx.vout.cend(), CAmount{0}, [](CAmount sum, const auto& txout) { return sum + txout.nValue; });
275
5.59k
}
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.75M
    inline void Serialize(Stream& s) const {
320
5.75M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
5.75M
    }
void CTransaction::Serialize<ParamsStream<SizeComputer&, TransactionSerParams>>(ParamsStream<SizeComputer&, TransactionSerParams>&) const
Line
Count
Source
319
3.71M
    inline void Serialize(Stream& s) const {
320
3.71M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
3.71M
    }
void CTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
Line
Count
Source
319
99.1k
    inline void Serialize(Stream& s) const {
320
99.1k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
99.1k
    }
void CTransaction::Serialize<ParamsStream<VectorWriter&, TransactionSerParams>>(ParamsStream<VectorWriter&, TransactionSerParams>&) const
Line
Count
Source
319
62.2k
    inline void Serialize(Stream& s) const {
320
62.2k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
62.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.34k
    inline void Serialize(Stream& s) const {
320
1.34k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
321
1.34k
    }
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
315k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
328
116k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
328
197k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
328
498
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
328
2.14k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
329
330
18.1k
    bool IsNull() const {
331
18.1k
        return vin.empty() && vout.empty();
332
18.1k
    }
333
334
181M
    const Txid& GetHash() const LIFETIMEBOUND { return hash; }
335
2.26M
    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
29.8M
    {
349
29.8M
        return (vin.size() == 1 && vin[0].prevout.IsNull());
350
29.8M
    }
351
352
    bool Equals(const CTransaction& other, const EqualsOptions opts = {}) const
353
75
    {
354
75
        return nLockTime == other.nLockTime &&
355
75
            version == other.version &&
356
75
            vout == other.vout &&
357
75
            std::ranges::equal(vin, other.vin, [&opts](const CTxIn& self, const CTxIn& other) {
358
42
                return self.prevout == other.prevout &&
359
42
                    self.nSequence == other.nSequence &&
360
42
                    (opts.include_script_sig ? self.scriptSig == other.scriptSig : true) &&
361
42
                    (opts.include_witness_data ? self.scriptWitness.stack == other.scriptWitness.stack : true);
362
42
            });
363
75
    }
364
365
    std::string ToString() const;
366
367
4.01M
    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
52
    inline void Serialize(Stream& s) const {
383
52
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
52
    }
void CMutableTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
Line
Count
Source
382
352
    inline void Serialize(Stream& s) const {
383
352
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
384
352
    }
385
386
    template <typename Stream>
387
362k
    inline void Unserialize(Stream& s) {
388
362k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
362k
    }
void CMutableTransaction::Unserialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
387
116k
    inline void Unserialize(Stream& s) {
388
116k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
116k
    }
void CMutableTransaction::Unserialize<ParamsStream<SpanReader&, TransactionSerParams>>(ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
387
243k
    inline void Unserialize(Stream& s) {
388
243k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
243k
    }
void CMutableTransaction::Unserialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
387
498
    inline void Unserialize(Stream& s) {
388
498
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
498
    }
void CMutableTransaction::Unserialize<ParamsStream<BufferedFile&, TransactionSerParams>>(ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
387
2.14k
    inline void Unserialize(Stream& s) {
388
2.14k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
389
2.14k
    }
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
315k
    CMutableTransaction(deserialize_type, Stream& s) {
398
315k
        Unserialize(s);
399
315k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
397
116k
    CMutableTransaction(deserialize_type, Stream& s) {
398
116k
        Unserialize(s);
399
116k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
397
197k
    CMutableTransaction(deserialize_type, Stream& s) {
398
197k
        Unserialize(s);
399
197k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
397
498
    CMutableTransaction(deserialize_type, Stream& s) {
398
498
        Unserialize(s);
399
498
    }
CMutableTransaction::CMutableTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
397
2.14k
    CMutableTransaction(deserialize_type, Stream& s) {
398
2.14k
        Unserialize(s);
399
2.14k
    }
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
292k
    {
408
293k
        for (size_t i = 0; i < vin.size(); i++) {
409
293k
            if (!vin[i].scriptWitness.IsNull()) {
410
292k
                return true;
411
292k
            }
412
293k
        }
413
62
        return false;
414
292k
    }
415
};
416
417
typedef std::shared_ptr<const CTransaction> CTransactionRef;
418
759k
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
14
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
131k
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
806
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
75
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
8
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
137
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.7k
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.4k
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
97.4k
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
3.94k
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.1k
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
3
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.6k
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