Coverage Report

Created: 2026-07-29 23:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/tmp/bitcoin/src/primitives/transaction.h
Line
Count
Source
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#ifndef BITCOIN_PRIMITIVES_TRANSACTION_H
7
#define BITCOIN_PRIMITIVES_TRANSACTION_H
8
9
#include <attributes.h>
10
#include <consensus/amount.h>
11
#include <primitives/transaction_identifier.h> // IWYU pragma: export
12
#include <script/script.h>
13
#include <serialize.h>
14
15
#include <compare>
16
#include <cstddef>
17
#include <cstdint>
18
#include <ios>
19
#include <limits>
20
#include <memory>
21
#include <numeric>
22
#include <string>
23
#include <tuple>
24
#include <utility>
25
#include <vector>
26
27
/** An outpoint - a combination of a transaction hash and an index n into its vout */
28
class COutPoint
29
{
30
public:
31
    Txid hash;
32
    uint32_t n;
33
34
    static constexpr uint32_t NULL_INDEX = std::numeric_limits<uint32_t>::max();
35
36
9.68M
    COutPoint(): n(NULL_INDEX) { }
37
35.3M
    COutPoint(const Txid& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }
38
39
27.0M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<ParamsStream<SizeComputer&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<SizeComputer&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
39
2.86M
    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
39
127k
    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
39
98.9k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<DataStream, COutPoint, ActionUnserialize>(COutPoint&, DataStream&, ActionUnserialize)
Line
Count
Source
39
4.79k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<SpanReader, COutPoint, ActionUnserialize>(COutPoint&, SpanReader&, ActionUnserialize)
Line
Count
Source
39
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
39
1.92M
    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
39
326k
    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
39
473
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
void COutPoint::SerializationOps<HashWriter, COutPoint const, ActionSerialize>(COutPoint const&, HashWriter&, ActionSerialize)
Line
Count
Source
39
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
39
6.28k
    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
39
70.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
39
189k
    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
39
2.48k
    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
39
2.17k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
40
41
49.5k
    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
42
21.5M
    bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }
43
44
    friend bool operator<(const COutPoint& a, const COutPoint& b)
45
369M
    {
46
369M
        return std::tie(a.hash, a.n) < std::tie(b.hash, b.n);
47
369M
    }
48
49
    friend bool operator==(const COutPoint& a, const COutPoint& b)
50
86.2M
    {
51
86.2M
        return (a.hash == b.hash && a.n == b.n);
52
86.2M
    }
53
54
    std::string ToString() const;
55
};
56
57
/** An input of a transaction.  It contains the location of the previous
58
 * transaction's output that it claims and a signature that matches the
59
 * output's public key.
60
 */
61
class CTxIn
62
{
63
public:
64
    COutPoint prevout;
65
    CScript scriptSig;
66
    uint32_t nSequence;
67
    CScriptWitness scriptWitness; //!< Only serialized through CTransaction
68
69
    /**
70
     * Setting nSequence to this value for every input in a transaction
71
     * disables nLockTime/IsFinalTx().
72
     * It fails OP_CHECKLOCKTIMEVERIFY/CheckLockTime() for any input that has
73
     * it set (BIP 65).
74
     * It has SEQUENCE_LOCKTIME_DISABLE_FLAG set (BIP 68/112).
75
     */
76
    static constexpr uint32_t SEQUENCE_FINAL{0xffffffff};
77
    /**
78
     * This is the maximum sequence number that enables both nLockTime and
79
     * OP_CHECKLOCKTIMEVERIFY (BIP 65).
80
     * It has SEQUENCE_LOCKTIME_DISABLE_FLAG set (BIP 68/112).
81
     */
82
    static constexpr uint32_t MAX_SEQUENCE_NONFINAL{SEQUENCE_FINAL - 1};
83
84
    // Below flags apply in the context of BIP 68. BIP 68 requires the tx
85
    // version to be set to 2, or higher.
86
    /**
87
     * If this flag is set, CTxIn::nSequence is NOT interpreted as a
88
     * relative lock-time.
89
     * It skips SequenceLocks() for any input that has it set (BIP 68).
90
     * It fails OP_CHECKSEQUENCEVERIFY/CheckSequence() for any input that has
91
     * it set (BIP 112).
92
     */
93
    static constexpr uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG{1U << 31};
94
95
    /**
96
     * If CTxIn::nSequence encodes a relative lock-time and this flag
97
     * is set, the relative lock-time has units of 512 seconds,
98
     * otherwise it specifies blocks with a granularity of 1. */
99
    static constexpr uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG{1 << 22};
100
101
    /**
102
     * If CTxIn::nSequence encodes a relative lock-time, this mask is
103
     * applied to extract that lock-time from the sequence field. */
104
    static constexpr uint32_t SEQUENCE_LOCKTIME_MASK{0x0000ffff};
105
106
    /**
107
     * In order to use the same number of bits to encode roughly the
108
     * same wall-clock duration, and because blocks are naturally
109
     * limited to occur every 600s on average, the minimum granularity
110
     * for time-based relative lock-time is fixed at 512 seconds.
111
     * Converting from CTxIn::nSequence to seconds is performed by
112
     * multiplying by 512 = 2^9, or equivalently shifting up by
113
     * 9 bits. */
114
    static constexpr int SEQUENCE_LOCKTIME_GRANULARITY{9};
115
116
    CTxIn()
117
8.51M
    {
118
8.51M
        nSequence = SEQUENCE_FINAL;
119
8.51M
    }
120
121
    explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
122
    CTxIn(Txid hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
123
124
5.61M
    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
124
2.86M
    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
124
127k
    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
124
98.9k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
void CTxIn::SerializationOps<DataStream, CTxIn, ActionUnserialize>(CTxIn&, DataStream&, ActionUnserialize)
Line
Count
Source
124
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
124
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
124
1.92M
    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
124
326k
    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
124
473
    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
124
70.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
124
189k
    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
124
2.48k
    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
124
2.17k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
125
126
    friend bool operator==(const CTxIn& a, const CTxIn& b)
127
48
    {
128
48
        return (a.prevout   == b.prevout &&
129
48
                a.scriptSig == b.scriptSig &&
130
48
                a.nSequence == b.nSequence);
131
48
    }
132
133
    std::string ToString() const;
134
};
135
136
/** An output of a transaction.  It contains the public key that the next input
137
 * must be able to sign with to claim it.
138
 */
139
class CTxOut
140
{
141
public:
142
    CAmount nValue;
143
    CScript scriptPubKey;
144
145
    CTxOut()
146
62.7M
    {
147
62.7M
        SetNull();
148
62.7M
    }
149
150
    CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn);
151
152
25.2M
    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
152
5.28M
    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
152
256k
    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
152
192k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<DataStream, CTxOut, ActionUnserialize>(CTxOut&, DataStream&, ActionUnserialize)
Line
Count
Source
152
4.78k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<SpanReader, CTxOut, ActionUnserialize>(CTxOut&, SpanReader&, ActionUnserialize)
Line
Count
Source
152
4.68k
    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
152
3.65M
    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
152
516k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<SizeComputer, CTxOut const, ActionSerialize>(CTxOut const&, SizeComputer&, ActionSerialize)
Line
Count
Source
152
385k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<DataStream, CTxOut const, ActionSerialize>(CTxOut const&, DataStream&, ActionSerialize)
Line
Count
Source
152
7.46k
    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
152
771
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
void CTxOut::SerializationOps<HashWriter, CTxOut const, ActionSerialize>(CTxOut const&, HashWriter&, ActionSerialize)
Line
Count
Source
152
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
152
171k
    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
152
392k
    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
152
2.08k
    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
152
4.29k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
153
154
    void SetNull()
155
73.4M
    {
156
73.4M
        nValue = -1;
157
73.4M
        scriptPubKey.clear();
158
73.4M
    }
159
160
    bool IsNull() const
161
104M
    {
162
104M
        return (nValue == -1);
163
104M
    }
164
165
    friend bool operator==(const CTxOut& a, const CTxOut& b)
166
5.18M
    {
167
5.18M
        return (a.nValue       == b.nValue &&
168
5.18M
                a.scriptPubKey == b.scriptPubKey);
169
5.18M
    }
170
171
    std::string ToString() const;
172
};
173
174
struct CMutableTransaction;
175
176
struct TransactionSerParams {
177
    const bool allow_witness;
178
    SER_PARAMS_OPFUNC
179
};
180
static constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true};
181
static constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false};
182
183
/**
184
 * Basic transaction serialization format:
185
 * - uint32_t version
186
 * - std::vector<CTxIn> vin
187
 * - std::vector<CTxOut> vout
188
 * - uint32_t nLockTime
189
 *
190
 * Extended transaction serialization format:
191
 * - uint32_t version
192
 * - unsigned char dummy = 0x00
193
 * - unsigned char flags (!= 0)
194
 * - std::vector<CTxIn> vin
195
 * - std::vector<CTxOut> vout
196
 * - if (flags & 1):
197
 *   - CScriptWitness scriptWitness; (deserialized into CTxIn)
198
 * - uint32_t nLockTime
199
 */
200
template<typename Stream, typename TxType>
201
void UnserializeTransaction(TxType& tx, Stream& s, const TransactionSerParams& params)
202
345k
{
203
345k
    const bool fAllowWitness = params.allow_witness;
204
205
345k
    s >> tx.version;
206
345k
    unsigned char flags = 0;
207
345k
    tx.vin.clear();
208
345k
    tx.vout.clear();
209
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
210
345k
    s >> tx.vin;
211
345k
    if (tx.vin.size() == 0 && fAllowWitness) {
212
        /* We read a dummy or an empty vin. */
213
284k
        s >> flags;
214
284k
        if (flags != 0) {
215
284k
            s >> tx.vin;
216
284k
            s >> tx.vout;
217
284k
        }
218
284k
    } else {
219
        /* We read a non-empty vin. Assume a normal vout follows. */
220
60.7k
        s >> tx.vout;
221
60.7k
    }
222
345k
    if ((flags & 1) && fAllowWitness) {
223
        /* The witness flag is present, and we support witnesses. */
224
284k
        flags ^= 1;
225
669k
        for (size_t i = 0; i < tx.vin.size(); i++) {
226
384k
            s >> tx.vin[i].scriptWitness.stack;
227
384k
        }
228
284k
        if (!tx.HasWitness()) {
229
            /* It's illegal to encode witnesses when all witness stacks are empty. */
230
10
            throw std::ios_base::failure("Superfluous witness record");
231
10
        }
232
284k
    }
233
345k
    if (flags) {
234
        /* Unknown flag in the serialization */
235
2
        throw std::ios_base::failure("Unknown transaction optional data");
236
2
    }
237
345k
    s >> tx.nLockTime;
238
345k
}
void UnserializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
202
106k
{
203
106k
    const bool fAllowWitness = params.allow_witness;
204
205
106k
    s >> tx.version;
206
106k
    unsigned char flags = 0;
207
106k
    tx.vin.clear();
208
106k
    tx.vout.clear();
209
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
210
106k
    s >> tx.vin;
211
106k
    if (tx.vin.size() == 0 && fAllowWitness) {
212
        /* We read a dummy or an empty vin. */
213
73.8k
        s >> flags;
214
73.8k
        if (flags != 0) {
215
73.8k
            s >> tx.vin;
216
73.8k
            s >> tx.vout;
217
73.8k
        }
218
73.8k
    } else {
219
        /* We read a non-empty vin. Assume a normal vout follows. */
220
33.1k
        s >> tx.vout;
221
33.1k
    }
222
106k
    if ((flags & 1) && fAllowWitness) {
223
        /* The witness flag is present, and we support witnesses. */
224
73.8k
        flags ^= 1;
225
161k
        for (size_t i = 0; i < tx.vin.size(); i++) {
226
87.2k
            s >> tx.vin[i].scriptWitness.stack;
227
87.2k
        }
228
73.8k
        if (!tx.HasWitness()) {
229
            /* It's illegal to encode witnesses when all witness stacks are empty. */
230
1
            throw std::ios_base::failure("Superfluous witness record");
231
1
        }
232
73.8k
    }
233
106k
    if (flags) {
234
        /* Unknown flag in the serialization */
235
1
        throw std::ios_base::failure("Unknown transaction optional data");
236
1
    }
237
106k
    s >> tx.nLockTime;
238
106k
}
void UnserializeTransaction<DataStream, CMutableTransaction>(CMutableTransaction&, DataStream&, TransactionSerParams const&)
Line
Count
Source
202
219
{
203
219
    const bool fAllowWitness = params.allow_witness;
204
205
219
    s >> tx.version;
206
219
    unsigned char flags = 0;
207
219
    tx.vin.clear();
208
219
    tx.vout.clear();
209
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
210
219
    s >> tx.vin;
211
219
    if (tx.vin.size() == 0 && fAllowWitness) {
212
        /* We read a dummy or an empty vin. */
213
44
        s >> flags;
214
44
        if (flags != 0) {
215
44
            s >> tx.vin;
216
44
            s >> tx.vout;
217
44
        }
218
175
    } else {
219
        /* We read a non-empty vin. Assume a normal vout follows. */
220
175
        s >> tx.vout;
221
175
    }
222
219
    if ((flags & 1) && fAllowWitness) {
223
        /* The witness flag is present, and we support witnesses. */
224
44
        flags ^= 1;
225
4.64k
        for (size_t i = 0; i < tx.vin.size(); i++) {
226
4.59k
            s >> tx.vin[i].scriptWitness.stack;
227
4.59k
        }
228
44
        if (!tx.HasWitness()) {
229
            /* It's illegal to encode witnesses when all witness stacks are empty. */
230
0
            throw std::ios_base::failure("Superfluous witness record");
231
0
        }
232
44
    }
233
219
    if (flags) {
234
        /* Unknown flag in the serialization */
235
0
        throw std::ios_base::failure("Unknown transaction optional data");
236
0
    }
237
219
    s >> tx.nLockTime;
238
219
}
void UnserializeTransaction<SpanReader, CMutableTransaction>(CMutableTransaction&, SpanReader&, TransactionSerParams const&)
Line
Count
Source
202
1
{
203
1
    const bool fAllowWitness = params.allow_witness;
204
205
1
    s >> tx.version;
206
1
    unsigned char flags = 0;
207
1
    tx.vin.clear();
208
1
    tx.vout.clear();
209
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
210
1
    s >> tx.vin;
211
1
    if (tx.vin.size() == 0 && fAllowWitness) {
212
        /* We read a dummy or an empty vin. */
213
0
        s >> flags;
214
0
        if (flags != 0) {
215
0
            s >> tx.vin;
216
0
            s >> tx.vout;
217
0
        }
218
1
    } else {
219
        /* We read a non-empty vin. Assume a normal vout follows. */
220
1
        s >> tx.vout;
221
1
    }
222
1
    if ((flags & 1) && fAllowWitness) {
223
        /* The witness flag is present, and we support witnesses. */
224
0
        flags ^= 1;
225
0
        for (size_t i = 0; i < tx.vin.size(); i++) {
226
0
            s >> tx.vin[i].scriptWitness.stack;
227
0
        }
228
0
        if (!tx.HasWitness()) {
229
            /* It's illegal to encode witnesses when all witness stacks are empty. */
230
0
            throw std::ios_base::failure("Superfluous witness record");
231
0
        }
232
0
    }
233
1
    if (flags) {
234
        /* Unknown flag in the serialization */
235
0
        throw std::ios_base::failure("Unknown transaction optional data");
236
0
    }
237
1
    s >> tx.nLockTime;
238
1
}
void UnserializeTransaction<ParamsStream<SpanReader&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<SpanReader&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
202
235k
{
203
235k
    const bool fAllowWitness = params.allow_witness;
204
205
235k
    s >> tx.version;
206
235k
    unsigned char flags = 0;
207
235k
    tx.vin.clear();
208
235k
    tx.vout.clear();
209
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
210
235k
    s >> tx.vin;
211
235k
    if (tx.vin.size() == 0 && fAllowWitness) {
212
        /* We read a dummy or an empty vin. */
213
208k
        s >> flags;
214
208k
        if (flags != 0) {
215
208k
            s >> tx.vin;
216
208k
            s >> tx.vout;
217
208k
        }
218
208k
    } else {
219
        /* We read a non-empty vin. Assume a normal vout follows. */
220
27.4k
        s >> tx.vout;
221
27.4k
    }
222
235k
    if ((flags & 1) && fAllowWitness) {
223
        /* The witness flag is present, and we support witnesses. */
224
208k
        flags ^= 1;
225
498k
        for (size_t i = 0; i < tx.vin.size(); i++) {
226
290k
            s >> tx.vin[i].scriptWitness.stack;
227
290k
        }
228
208k
        if (!tx.HasWitness()) {
229
            /* It's illegal to encode witnesses when all witness stacks are empty. */
230
9
            throw std::ios_base::failure("Superfluous witness record");
231
9
        }
232
208k
    }
233
235k
    if (flags) {
234
        /* Unknown flag in the serialization */
235
1
        throw std::ios_base::failure("Unknown transaction optional data");
236
1
    }
237
235k
    s >> tx.nLockTime;
238
235k
}
void UnserializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
202
462
{
203
462
    const bool fAllowWitness = params.allow_witness;
204
205
462
    s >> tx.version;
206
462
    unsigned char flags = 0;
207
462
    tx.vin.clear();
208
462
    tx.vout.clear();
209
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
210
462
    s >> tx.vin;
211
462
    if (tx.vin.size() == 0 && fAllowWitness) {
212
        /* We read a dummy or an empty vin. */
213
436
        s >> flags;
214
436
        if (flags != 0) {
215
436
            s >> tx.vin;
216
436
            s >> tx.vout;
217
436
        }
218
436
    } else {
219
        /* We read a non-empty vin. Assume a normal vout follows. */
220
26
        s >> tx.vout;
221
26
    }
222
462
    if ((flags & 1) && fAllowWitness) {
223
        /* The witness flag is present, and we support witnesses. */
224
436
        flags ^= 1;
225
882
        for (size_t i = 0; i < tx.vin.size(); i++) {
226
446
            s >> tx.vin[i].scriptWitness.stack;
227
446
        }
228
436
        if (!tx.HasWitness()) {
229
            /* It's illegal to encode witnesses when all witness stacks are empty. */
230
0
            throw std::ios_base::failure("Superfluous witness record");
231
0
        }
232
436
    }
233
462
    if (flags) {
234
        /* Unknown flag in the serialization */
235
0
        throw std::ios_base::failure("Unknown transaction optional data");
236
0
    }
237
462
    s >> tx.nLockTime;
238
462
}
void UnserializeTransaction<ParamsStream<BufferedFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<BufferedFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
202
2.17k
{
203
2.17k
    const bool fAllowWitness = params.allow_witness;
204
205
2.17k
    s >> tx.version;
206
2.17k
    unsigned char flags = 0;
207
2.17k
    tx.vin.clear();
208
2.17k
    tx.vout.clear();
209
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
210
2.17k
    s >> tx.vin;
211
2.17k
    if (tx.vin.size() == 0 && fAllowWitness) {
212
        /* We read a dummy or an empty vin. */
213
2.14k
        s >> flags;
214
2.14k
        if (flags != 0) {
215
2.14k
            s >> tx.vin;
216
2.14k
            s >> tx.vout;
217
2.14k
        }
218
2.14k
    } else {
219
        /* We read a non-empty vin. Assume a normal vout follows. */
220
35
        s >> tx.vout;
221
35
    }
222
2.17k
    if ((flags & 1) && fAllowWitness) {
223
        /* The witness flag is present, and we support witnesses. */
224
2.14k
        flags ^= 1;
225
4.28k
        for (size_t i = 0; i < tx.vin.size(); i++) {
226
2.14k
            s >> tx.vin[i].scriptWitness.stack;
227
2.14k
        }
228
2.14k
        if (!tx.HasWitness()) {
229
            /* It's illegal to encode witnesses when all witness stacks are empty. */
230
0
            throw std::ios_base::failure("Superfluous witness record");
231
0
        }
232
2.14k
    }
233
2.17k
    if (flags) {
234
        /* Unknown flag in the serialization */
235
0
        throw std::ios_base::failure("Unknown transaction optional data");
236
0
    }
237
2.17k
    s >> tx.nLockTime;
238
2.17k
}
239
240
template<typename Stream, typename TxType>
241
void SerializeTransaction(const TxType& tx, Stream& s, const TransactionSerParams& params)
242
4.79M
{
243
4.79M
    const bool fAllowWitness = params.allow_witness;
244
245
4.79M
    s << tx.version;
246
4.79M
    unsigned char flags = 0;
247
    // Consistency check
248
4.79M
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
1.54M
        if (tx.HasWitness()) {
251
1.30M
            flags |= 1;
252
1.30M
        }
253
1.54M
    }
254
4.79M
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
1.30M
        std::vector<CTxIn> vinDummy;
257
1.30M
        s << vinDummy;
258
1.30M
        s << flags;
259
1.30M
    }
260
4.79M
    s << tx.vin;
261
4.79M
    s << tx.vout;
262
4.79M
    if (flags & 1) {
263
3.00M
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
1.70M
            s << tx.vin[i].scriptWitness.stack;
265
1.70M
        }
266
1.30M
    }
267
4.79M
    s << tx.nLockTime;
268
4.79M
}
void SerializeTransaction<ParamsStream<SizeComputer&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<SizeComputer&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
2.19M
{
243
2.19M
    const bool fAllowWitness = params.allow_witness;
244
245
2.19M
    s << tx.version;
246
2.19M
    unsigned char flags = 0;
247
    // Consistency check
248
2.19M
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
871k
        if (tx.HasWitness()) {
251
676k
            flags |= 1;
252
676k
        }
253
871k
    }
254
2.19M
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
676k
        std::vector<CTxIn> vinDummy;
257
676k
        s << vinDummy;
258
676k
        s << flags;
259
676k
    }
260
2.19M
    s << tx.vin;
261
2.19M
    s << tx.vout;
262
2.19M
    if (flags & 1) {
263
1.54M
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
871k
            s << tx.vin[i].scriptWitness.stack;
265
871k
        }
266
676k
    }
267
2.19M
    s << tx.nLockTime;
268
2.19M
}
void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
79.6k
{
243
79.6k
    const bool fAllowWitness = params.allow_witness;
244
245
79.6k
    s << tx.version;
246
79.6k
    unsigned char flags = 0;
247
    // Consistency check
248
79.6k
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
79.0k
        if (tx.HasWitness()) {
251
76.3k
            flags |= 1;
252
76.3k
        }
253
79.0k
    }
254
79.6k
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
76.3k
        std::vector<CTxIn> vinDummy;
257
76.3k
        s << vinDummy;
258
76.3k
        s << flags;
259
76.3k
    }
260
79.6k
    s << tx.vin;
261
79.6k
    s << tx.vout;
262
79.6k
    if (flags & 1) {
263
164k
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
88.2k
            s << tx.vin[i].scriptWitness.stack;
265
88.2k
        }
266
76.3k
    }
267
79.6k
    s << tx.nLockTime;
268
79.6k
}
void SerializeTransaction<ParamsStream<HashWriter&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<HashWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
736k
{
243
736k
    const bool fAllowWitness = params.allow_witness;
244
245
736k
    s << tx.version;
246
736k
    unsigned char flags = 0;
247
    // Consistency check
248
736k
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
1
        if (tx.HasWitness()) {
251
0
            flags |= 1;
252
0
        }
253
1
    }
254
736k
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
0
        std::vector<CTxIn> vinDummy;
257
0
        s << vinDummy;
258
0
        s << flags;
259
0
    }
260
736k
    s << tx.vin;
261
736k
    s << tx.vout;
262
736k
    if (flags & 1) {
263
0
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
0
            s << tx.vin[i].scriptWitness.stack;
265
0
        }
266
0
    }
267
736k
    s << tx.nLockTime;
268
736k
}
void SerializeTransaction<ParamsStream<SizeComputer&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<SizeComputer&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
39
{
243
39
    const bool fAllowWitness = params.allow_witness;
244
245
39
    s << tx.version;
246
39
    unsigned char flags = 0;
247
    // Consistency check
248
39
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
1
        if (tx.HasWitness()) {
251
0
            flags |= 1;
252
0
        }
253
1
    }
254
39
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
0
        std::vector<CTxIn> vinDummy;
257
0
        s << vinDummy;
258
0
        s << flags;
259
0
    }
260
39
    s << tx.vin;
261
39
    s << tx.vout;
262
39
    if (flags & 1) {
263
0
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
0
            s << tx.vin[i].scriptWitness.stack;
265
0
        }
266
0
    }
267
39
    s << tx.nLockTime;
268
39
}
void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
331
{
243
331
    const bool fAllowWitness = params.allow_witness;
244
245
331
    s << tx.version;
246
331
    unsigned char flags = 0;
247
    // Consistency check
248
331
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
294
        if (tx.HasWitness()) {
251
247
            flags |= 1;
252
247
        }
253
294
    }
254
331
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
247
        std::vector<CTxIn> vinDummy;
257
247
        s << vinDummy;
258
247
        s << flags;
259
247
    }
260
331
    s << tx.vin;
261
331
    s << tx.vout;
262
331
    if (flags & 1) {
263
5.10k
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
4.85k
            s << tx.vin[i].scriptWitness.stack;
265
4.85k
        }
266
247
    }
267
331
    s << tx.nLockTime;
268
331
}
void SerializeTransaction<ParamsStream<VectorWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
59.7k
{
243
59.7k
    const bool fAllowWitness = params.allow_witness;
244
245
59.7k
    s << tx.version;
246
59.7k
    unsigned char flags = 0;
247
    // Consistency check
248
59.7k
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
35.3k
        if (tx.HasWitness()) {
251
33.4k
            flags |= 1;
252
33.4k
        }
253
35.3k
    }
254
59.7k
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
33.4k
        std::vector<CTxIn> vinDummy;
257
33.4k
        s << vinDummy;
258
33.4k
        s << flags;
259
33.4k
    }
260
59.7k
    s << tx.vin;
261
59.7k
    s << tx.vout;
262
59.7k
    if (flags & 1) {
263
76.1k
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
42.7k
            s << tx.vin[i].scriptWitness.stack;
265
42.7k
        }
266
33.4k
    }
267
59.7k
    s << tx.nLockTime;
268
59.7k
}
void SerializeTransaction<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
157k
{
243
157k
    const bool fAllowWitness = params.allow_witness;
244
245
157k
    s << tx.version;
246
157k
    unsigned char flags = 0;
247
    // Consistency check
248
157k
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
157k
        if (tx.HasWitness()) {
251
122k
            flags |= 1;
252
122k
        }
253
157k
    }
254
157k
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
122k
        std::vector<CTxIn> vinDummy;
257
122k
        s << vinDummy;
258
122k
        s << flags;
259
122k
    }
260
157k
    s << tx.vin;
261
157k
    s << tx.vout;
262
157k
    if (flags & 1) {
263
269k
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
146k
            s << tx.vin[i].scriptWitness.stack;
265
146k
        }
266
122k
    }
267
157k
    s << tx.nLockTime;
268
157k
}
void SerializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
1.30k
{
243
1.30k
    const bool fAllowWitness = params.allow_witness;
244
245
1.30k
    s << tx.version;
246
1.30k
    unsigned char flags = 0;
247
    // Consistency check
248
1.30k
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
1.30k
        if (tx.HasWitness()) {
251
1.23k
            flags |= 1;
252
1.23k
        }
253
1.30k
    }
254
1.30k
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
1.23k
        std::vector<CTxIn> vinDummy;
257
1.23k
        s << vinDummy;
258
1.23k
        s << flags;
259
1.23k
    }
260
1.30k
    s << tx.vin;
261
1.30k
    s << tx.vout;
262
1.30k
    if (flags & 1) {
263
3.60k
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
2.36k
            s << tx.vin[i].scriptWitness.stack;
265
2.36k
        }
266
1.23k
    }
267
1.30k
    s << tx.nLockTime;
268
1.30k
}
void SerializeTransaction<ParamsStream<HashWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<HashWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
242
1.56M
{
243
1.56M
    const bool fAllowWitness = params.allow_witness;
244
245
1.56M
    s << tx.version;
246
1.56M
    unsigned char flags = 0;
247
    // Consistency check
248
1.56M
    if (fAllowWitness) {
249
        /* Check whether witnesses need to be serialized. */
250
395k
        if (tx.HasWitness()) {
251
395k
            flags |= 1;
252
395k
        }
253
395k
    }
254
1.56M
    if (flags) {
255
        /* Use extended format in case witnesses are to be serialized. */
256
395k
        std::vector<CTxIn> vinDummy;
257
395k
        s << vinDummy;
258
395k
        s << flags;
259
395k
    }
260
1.56M
    s << tx.vin;
261
1.56M
    s << tx.vout;
262
1.56M
    if (flags & 1) {
263
939k
        for (size_t i = 0; i < tx.vin.size(); i++) {
264
544k
            s << tx.vin[i].scriptWitness.stack;
265
544k
        }
266
395k
    }
267
1.56M
    s << tx.nLockTime;
268
1.56M
}
269
270
template<typename TxType>
271
inline CAmount CalculateOutputValue(const TxType& tx)
272
5.95k
{
273
76.6k
    return std::accumulate(tx.vout.cbegin(), tx.vout.cend(), CAmount{0}, [](CAmount sum, const auto& txout) { return sum + txout.nValue; });
274
5.95k
}
275
276
277
/** The basic transaction that is broadcasted on the network and contained in
278
 * blocks.  A transaction can contain multiple inputs and outputs.
279
 */
280
class CTransaction
281
{
282
public:
283
    // Default transaction version.
284
    static constexpr uint32_t CURRENT_VERSION{2};
285
286
    // The local variables are made const to prevent unintended modification
287
    // without updating the cached hash value. However, CTransaction is not
288
    // actually immutable; deserialization and assignment are implemented,
289
    // and bypass the constness. This is safe, as they update the entire
290
    // structure, including the hash.
291
    const std::vector<CTxIn> vin;
292
    const std::vector<CTxOut> vout;
293
    const uint32_t version;
294
    const uint32_t nLockTime;
295
296
private:
297
    /** Memory only. */
298
    const bool m_has_witness;
299
    const Txid hash;
300
    const Wtxid m_witness_hash;
301
302
    Txid ComputeHash() const;
303
    Wtxid ComputeWitnessHash() const;
304
305
    bool ComputeHasWitness() const;
306
307
public:
308
    /** Convert a CMutableTransaction into a CTransaction. */
309
    explicit CTransaction(const CMutableTransaction& tx);
310
    explicit CTransaction(CMutableTransaction&& tx);
311
312
    template <typename Stream>
313
4.05M
    inline void Serialize(Stream& s) const {
314
4.05M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
315
4.05M
    }
void CTransaction::Serialize<ParamsStream<SizeComputer&, TransactionSerParams>>(ParamsStream<SizeComputer&, TransactionSerParams>&) const
Line
Count
Source
313
2.19M
    inline void Serialize(Stream& s) const {
314
2.19M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
315
2.19M
    }
void CTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
Line
Count
Source
313
79.6k
    inline void Serialize(Stream& s) const {
314
79.6k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
315
79.6k
    }
void CTransaction::Serialize<ParamsStream<VectorWriter&, TransactionSerParams>>(ParamsStream<VectorWriter&, TransactionSerParams>&) const
Line
Count
Source
313
59.7k
    inline void Serialize(Stream& s) const {
314
59.7k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
315
59.7k
    }
void CTransaction::Serialize<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>>(ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&) const
Line
Count
Source
313
157k
    inline void Serialize(Stream& s) const {
314
157k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
315
157k
    }
void CTransaction::Serialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&) const
Line
Count
Source
313
1.30k
    inline void Serialize(Stream& s) const {
314
1.30k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
315
1.30k
    }
void CTransaction::Serialize<ParamsStream<HashWriter&, TransactionSerParams>>(ParamsStream<HashWriter&, TransactionSerParams>&) const
Line
Count
Source
313
1.56M
    inline void Serialize(Stream& s) const {
314
1.56M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
315
1.56M
    }
316
317
    /** This deserializing constructor is provided instead of an Unserialize method.
318
     *  Unserialize is not possible, since it would require overwriting const fields. */
319
    template <typename Stream>
320
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
320
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
320
1
    CTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) : CTransaction(CMutableTransaction(deserialize, params, s)) {}
321
    template <typename Stream>
322
302k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
322
106k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
322
192k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
322
462
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction::CTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
322
2.17k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
323
324
17.7k
    bool IsNull() const {
325
17.7k
        return vin.empty() && vout.empty();
326
17.7k
    }
327
328
171M
    const Txid& GetHash() const LIFETIMEBOUND { return hash; }
329
1.83M
    const Wtxid& GetWitnessHash() const LIFETIMEBOUND { return m_witness_hash; };
330
331
    // Return sum of txouts.
332
    CAmount GetValueOut() const;
333
334
    /**
335
     * Calculate the total transaction size in bytes, including witness data.
336
     * "Total Size" defined in BIP141 and BIP144.
337
     * @return Total transaction size in bytes
338
     */
339
    unsigned int ComputeTotalSize() const;
340
341
    bool IsCoinBase() const
342
28.5M
    {
343
28.5M
        return (vin.size() == 1 && vin[0].prevout.IsNull());
344
28.5M
    }
345
346
    friend bool operator==(const CTransaction& a, const CTransaction& b)
347
4.07k
    {
348
4.07k
        return a.GetWitnessHash() == b.GetWitnessHash();
349
4.07k
    }
350
351
    std::string ToString() const;
352
353
3.09M
    bool HasWitness() const { return m_has_witness; }
354
};
355
356
/** A mutable version of CTransaction. */
357
struct CMutableTransaction
358
{
359
    std::vector<CTxIn> vin;
360
    std::vector<CTxOut> vout;
361
    uint32_t version;
362
    uint32_t nLockTime;
363
364
    explicit CMutableTransaction();
365
    explicit CMutableTransaction(const CTransaction& tx);
366
367
    template <typename Stream>
368
736k
    inline void Serialize(Stream& s) const {
369
736k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
370
736k
    }
void CMutableTransaction::Serialize<ParamsStream<HashWriter&, TransactionSerParams>>(ParamsStream<HashWriter&, TransactionSerParams>&) const
Line
Count
Source
368
736k
    inline void Serialize(Stream& s) const {
369
736k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
370
736k
    }
void CMutableTransaction::Serialize<ParamsStream<SizeComputer&, TransactionSerParams>>(ParamsStream<SizeComputer&, TransactionSerParams>&) const
Line
Count
Source
368
39
    inline void Serialize(Stream& s) const {
369
39
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
370
39
    }
void CMutableTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
Line
Count
Source
368
331
    inline void Serialize(Stream& s) const {
369
331
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
370
331
    }
371
372
    template <typename Stream>
373
345k
    inline void Unserialize(Stream& s) {
374
345k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
375
345k
    }
void CMutableTransaction::Unserialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
373
106k
    inline void Unserialize(Stream& s) {
374
106k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
375
106k
    }
void CMutableTransaction::Unserialize<ParamsStream<SpanReader&, TransactionSerParams>>(ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
373
235k
    inline void Unserialize(Stream& s) {
374
235k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
375
235k
    }
void CMutableTransaction::Unserialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
373
462
    inline void Unserialize(Stream& s) {
374
462
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
375
462
    }
void CMutableTransaction::Unserialize<ParamsStream<BufferedFile&, TransactionSerParams>>(ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
373
2.17k
    inline void Unserialize(Stream& s) {
374
2.17k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
375
2.17k
    }
376
377
    template <typename Stream>
378
220
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
379
220
        UnserializeTransaction(*this, s, params);
380
220
    }
CMutableTransaction::CMutableTransaction<DataStream>(deserialize_type, TransactionSerParams const&, DataStream&)
Line
Count
Source
378
219
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
379
219
        UnserializeTransaction(*this, s, params);
380
219
    }
CMutableTransaction::CMutableTransaction<SpanReader>(deserialize_type, TransactionSerParams const&, SpanReader&)
Line
Count
Source
378
1
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
379
1
        UnserializeTransaction(*this, s, params);
380
1
    }
381
382
    template <typename Stream>
383
302k
    CMutableTransaction(deserialize_type, Stream& s) {
384
302k
        Unserialize(s);
385
302k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
383
106k
    CMutableTransaction(deserialize_type, Stream& s) {
384
106k
        Unserialize(s);
385
106k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Line
Count
Source
383
192k
    CMutableTransaction(deserialize_type, Stream& s) {
384
192k
        Unserialize(s);
385
192k
    }
CMutableTransaction::CMutableTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Line
Count
Source
383
462
    CMutableTransaction(deserialize_type, Stream& s) {
384
462
        Unserialize(s);
385
462
    }
CMutableTransaction::CMutableTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
Line
Count
Source
383
2.17k
    CMutableTransaction(deserialize_type, Stream& s) {
384
2.17k
        Unserialize(s);
385
2.17k
    }
386
387
    /** Compute the hash of this CMutableTransaction. This is computed on the
388
     * fly, as opposed to GetHash() in CTransaction, which uses a cached result.
389
     */
390
    Txid GetHash() const;
391
392
    bool HasWitness() const
393
284k
    {
394
285k
        for (size_t i = 0; i < vin.size(); i++) {
395
285k
            if (!vin[i].scriptWitness.IsNull()) {
396
284k
                return true;
397
284k
            }
398
285k
        }
399
60
        return false;
400
284k
    }
401
};
402
403
typedef std::shared_ptr<const CTransaction> CTransactionRef;
404
608k
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
404
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
404
3
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
Unexecuted instantiation: blockfilter_index_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction const&>(CMutableTransaction const&)
blockfilter_index_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Line
Count
Source
404
23
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
404
2
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
404
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
404
14
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
404
160k
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
404
322
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
404
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
404
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
404
6.48k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
policyestimator_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
404
49.2k
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
404
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
404
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
404
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
404
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
404
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
404
2
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
404
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
404
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
404
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
404
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
404
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
404
856
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
404
88
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
validation_tests.cpp:std::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
404
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
404
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
404
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
404
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
404
8
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
404
1
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
404
27
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
404
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
404
24.8k
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
404
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
404
7.57k
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
404
47.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
404
35.3k
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
404
104
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
404
104k
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
404
3.81k
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
404
24.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
404
98
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
404
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
404
12.1k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
405
406
namespace std {
407
/** Disable default std::hash for CTransactionRef to prevent accidentally
408
 *  comparing by pointer. Use CTransactionRefHash or provide a custom
409
 *  hasher. */
410
template <>
411
struct hash<CTransactionRef> {
412
    hash() = delete;
413
    // Belt-and-suspenders, already implied by the above.
414
    size_t operator()(const CTransactionRef&) const = delete;
415
};
416
} // namespace std
417
418
#endif // BITCOIN_PRIMITIVES_TRANSACTION_H