Bitcoin Core Fuzz Coverage Report for wallet_tx_can_be_bumped

Coverage Report

Created: 2025-11-19 11:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/Users/brunogarcia/projects/bitcoin-core-dev/src/primitives/transaction.h
Line
Count
Source
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-2022 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
#include <uint256.h>
15
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
27.5k
    COutPoint(): n(NULL_INDEX) { }
37
18.7k
    COutPoint(const Txid& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }
38
39
387k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
31.7k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
25.2k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
24.9k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
305k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
void COutPoint::SerializationOps<ParamsStream<SizeComputer&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<SizeComputer&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
39
31.7k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
31.7k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
void COutPoint::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, COutPoint, ActionUnserialize>(COutPoint&, ParamsStream<DataStream&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
39
25.2k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
25.2k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: void COutPoint::SerializationOps<DataStream, COutPoint, ActionUnserialize>(COutPoint&, DataStream&, ActionUnserialize)
void COutPoint::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<DataStream&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
39
24.9k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
24.9k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: void COutPoint::SerializationOps<DataStream, COutPoint const, ActionSerialize>(COutPoint const&, DataStream&, ActionSerialize)
Unexecuted instantiation: void COutPoint::SerializationOps<ParamsStream<VectorWriter&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void COutPoint::SerializationOps<ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void COutPoint::SerializationOps<ParamsStream<SpanReader&, TransactionSerParams>, COutPoint, ActionUnserialize>(COutPoint&, ParamsStream<SpanReader&, TransactionSerParams>&, ActionUnserialize)
Unexecuted instantiation: void COutPoint::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, COutPoint, ActionUnserialize>(COutPoint&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionUnserialize)
Unexecuted instantiation: void COutPoint::SerializationOps<HashWriter, COutPoint const, ActionSerialize>(COutPoint const&, HashWriter&, ActionSerialize)
Unexecuted instantiation: void COutPoint::SerializationOps<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void COutPoint::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void COutPoint::SerializationOps<ParamsStream<BufferedFile&, TransactionSerParams>, COutPoint, ActionUnserialize>(COutPoint&, ParamsStream<BufferedFile&, TransactionSerParams>&, ActionUnserialize)
void COutPoint::SerializationOps<ParamsStream<HashWriter&, TransactionSerParams>, COutPoint const, ActionSerialize>(COutPoint const&, ParamsStream<HashWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
39
305k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
145
305k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
40
41
0
    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
42
22.1k
    bool IsNull() const { return (hash.IsNull() && 
n == NULL_INDEX413
); }
43
44
    friend bool operator<(const COutPoint& a, const COutPoint& b)
45
20.0k
    {
46
20.0k
        return std::tie(a.hash, a.n) < std::tie(b.hash, b.n);
47
20.0k
    }
48
49
    friend bool operator==(const COutPoint& a, const COutPoint& b)
50
105k
    {
51
105k
        return (a.hash == b.hash && 
a.n == b.n88.8k
);
52
105k
    }
53
54
    friend bool operator!=(const COutPoint& a, const COutPoint& b)
55
0
    {
56
0
        return !(a == b);
57
0
    }
58
59
    std::string ToString() const;
60
};
61
62
/** An input of a transaction.  It contains the location of the previous
63
 * transaction's output that it claims and a signature that matches the
64
 * output's public key.
65
 */
66
class CTxIn
67
{
68
public:
69
    COutPoint prevout;
70
    CScript scriptSig;
71
    uint32_t nSequence;
72
    CScriptWitness scriptWitness; //!< Only serialized through CTransaction
73
74
    /**
75
     * Setting nSequence to this value for every input in a transaction
76
     * disables nLockTime/IsFinalTx().
77
     * It fails OP_CHECKLOCKTIMEVERIFY/CheckLockTime() for any input that has
78
     * it set (BIP 65).
79
     * It has SEQUENCE_LOCKTIME_DISABLE_FLAG set (BIP 68/112).
80
     */
81
    static const uint32_t SEQUENCE_FINAL = 0xffffffff;
82
    /**
83
     * This is the maximum sequence number that enables both nLockTime and
84
     * OP_CHECKLOCKTIMEVERIFY (BIP 65).
85
     * It has SEQUENCE_LOCKTIME_DISABLE_FLAG set (BIP 68/112).
86
     */
87
    static const uint32_t MAX_SEQUENCE_NONFINAL{SEQUENCE_FINAL - 1};
88
89
    // Below flags apply in the context of BIP 68. BIP 68 requires the tx
90
    // version to be set to 2, or higher.
91
    /**
92
     * If this flag is set, CTxIn::nSequence is NOT interpreted as a
93
     * relative lock-time.
94
     * It skips SequenceLocks() for any input that has it set (BIP 68).
95
     * It fails OP_CHECKSEQUENCEVERIFY/CheckSequence() for any input that has
96
     * it set (BIP 112).
97
     */
98
    static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG = (1U << 31);
99
100
    /**
101
     * If CTxIn::nSequence encodes a relative lock-time and this flag
102
     * is set, the relative lock-time has units of 512 seconds,
103
     * otherwise it specifies blocks with a granularity of 1. */
104
    static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22);
105
106
    /**
107
     * If CTxIn::nSequence encodes a relative lock-time, this mask is
108
     * applied to extract that lock-time from the sequence field. */
109
    static const uint32_t SEQUENCE_LOCKTIME_MASK = 0x0000ffff;
110
111
    /**
112
     * In order to use the same number of bits to encode roughly the
113
     * same wall-clock duration, and because blocks are naturally
114
     * limited to occur every 600s on average, the minimum granularity
115
     * for time-based relative lock-time is fixed at 512 seconds.
116
     * Converting from CTxIn::nSequence to seconds is performed by
117
     * multiplying by 512 = 2^9, or equivalently shifting up by
118
     * 9 bits. */
119
    static const int SEQUENCE_LOCKTIME_GRANULARITY = 9;
120
121
    CTxIn()
122
27.5k
    {
123
27.5k
        nSequence = SEQUENCE_FINAL;
124
27.5k
    }
125
126
    explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
127
    CTxIn(Txid hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
128
129
387k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
31.7k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
25.2k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
24.9k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
305k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
void CTxIn::SerializationOps<ParamsStream<SizeComputer&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<SizeComputer&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
129
31.7k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
31.7k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
void CTxIn::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, CTxIn, ActionUnserialize>(CTxIn&, ParamsStream<DataStream&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
129
25.2k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
25.2k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
void CTxIn::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<DataStream&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
129
24.9k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
24.9k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: void CTxIn::SerializationOps<DataStream, CTxIn, ActionUnserialize>(CTxIn&, DataStream&, ActionUnserialize)
Unexecuted instantiation: void CTxIn::SerializationOps<DataStream, CTxIn const, ActionSerialize>(CTxIn const&, DataStream&, ActionSerialize)
Unexecuted instantiation: void CTxIn::SerializationOps<ParamsStream<VectorWriter&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void CTxIn::SerializationOps<ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void CTxIn::SerializationOps<ParamsStream<SpanReader&, TransactionSerParams>, CTxIn, ActionUnserialize>(CTxIn&, ParamsStream<SpanReader&, TransactionSerParams>&, ActionUnserialize)
Unexecuted instantiation: void CTxIn::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, CTxIn, ActionUnserialize>(CTxIn&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionUnserialize)
Unexecuted instantiation: void CTxIn::SerializationOps<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void CTxIn::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void CTxIn::SerializationOps<ParamsStream<BufferedFile&, TransactionSerParams>, CTxIn, ActionUnserialize>(CTxIn&, ParamsStream<BufferedFile&, TransactionSerParams>&, ActionUnserialize)
void CTxIn::SerializationOps<ParamsStream<HashWriter&, TransactionSerParams>, CTxIn const, ActionSerialize>(CTxIn const&, ParamsStream<HashWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
129
305k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
145
305k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
130
131
    friend bool operator==(const CTxIn& a, const CTxIn& b)
132
0
    {
133
0
        return (a.prevout   == b.prevout &&
134
0
                a.scriptSig == b.scriptSig &&
135
0
                a.nSequence == b.nSequence);
136
0
    }
137
138
    friend bool operator!=(const CTxIn& a, const CTxIn& b)
139
0
    {
140
0
        return !(a == b);
141
0
    }
142
143
    std::string ToString() const;
144
};
145
146
/** An output of a transaction.  It contains the public key that the next input
147
 * must be able to sign with to claim it.
148
 */
149
class CTxOut
150
{
151
public:
152
    CAmount nValue;
153
    CScript scriptPubKey;
154
155
    CTxOut()
156
29.9k
    {
157
29.9k
        SetNull();
158
29.9k
    }
159
160
    CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn);
161
162
168k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
38.7k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
19.9k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
23.9k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
85.7k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
void CTxOut::SerializationOps<ParamsStream<SizeComputer&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<SizeComputer&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
162
38.7k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
38.7k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
void CTxOut::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, CTxOut, ActionUnserialize>(CTxOut&, ParamsStream<DataStream&, TransactionSerParams>&, ActionUnserialize)
Line
Count
Source
162
19.9k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
19.9k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
void CTxOut::SerializationOps<ParamsStream<DataStream&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<DataStream&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
162
23.9k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
23.9k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: void CTxOut::SerializationOps<DataStream, CTxOut, ActionUnserialize>(CTxOut&, DataStream&, ActionUnserialize)
Unexecuted instantiation: void CTxOut::SerializationOps<SizeComputer, CTxOut const, ActionSerialize>(CTxOut const&, SizeComputer&, ActionSerialize)
Unexecuted instantiation: void CTxOut::SerializationOps<DataStream, CTxOut const, ActionSerialize>(CTxOut const&, DataStream&, ActionSerialize)
Unexecuted instantiation: void CTxOut::SerializationOps<ParamsStream<VectorWriter&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<VectorWriter&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void CTxOut::SerializationOps<ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void CTxOut::SerializationOps<ParamsStream<SpanReader&, TransactionSerParams>, CTxOut, ActionUnserialize>(CTxOut&, ParamsStream<SpanReader&, TransactionSerParams>&, ActionUnserialize)
Unexecuted instantiation: void CTxOut::SerializationOps<SpanReader, CTxOut, ActionUnserialize>(CTxOut&, SpanReader&, ActionUnserialize)
Unexecuted instantiation: void CTxOut::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, CTxOut, ActionUnserialize>(CTxOut&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionUnserialize)
Unexecuted instantiation: void CTxOut::SerializationOps<HashWriter, CTxOut const, ActionSerialize>(CTxOut const&, HashWriter&, ActionSerialize)
Unexecuted instantiation: void CTxOut::SerializationOps<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void CTxOut::SerializationOps<ParamsStream<AutoFile&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<AutoFile&, TransactionSerParams>&, ActionSerialize)
Unexecuted instantiation: void CTxOut::SerializationOps<ParamsStream<BufferedFile&, TransactionSerParams>, CTxOut, ActionUnserialize>(CTxOut&, ParamsStream<BufferedFile&, TransactionSerParams>&, ActionUnserialize)
void CTxOut::SerializationOps<ParamsStream<HashWriter&, TransactionSerParams>, CTxOut const, ActionSerialize>(CTxOut const&, ParamsStream<HashWriter&, TransactionSerParams>&, ActionSerialize)
Line
Count
Source
162
85.7k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
145
85.7k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
163
164
    void SetNull()
165
29.9k
    {
166
29.9k
        nValue = -1;
167
29.9k
        scriptPubKey.clear();
168
29.9k
    }
169
170
    bool IsNull() const
171
0
    {
172
0
        return (nValue == -1);
173
0
    }
174
175
    friend bool operator==(const CTxOut& a, const CTxOut& b)
176
9.98k
    {
177
9.98k
        return (a.nValue       == b.nValue &&
178
9.98k
                a.scriptPubKey == b.scriptPubKey);
179
9.98k
    }
180
181
    friend bool operator!=(const CTxOut& a, const CTxOut& b)
182
0
    {
183
0
        return !(a == b);
184
0
    }
185
186
    std::string ToString() const;
187
};
188
189
struct CMutableTransaction;
190
191
struct TransactionSerParams {
192
    const bool allow_witness;
193
    SER_PARAMS_OPFUNC
194
};
195
static constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true};
196
static constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false};
197
198
/**
199
 * Basic transaction serialization format:
200
 * - uint32_t version
201
 * - std::vector<CTxIn> vin
202
 * - std::vector<CTxOut> vout
203
 * - uint32_t nLockTime
204
 *
205
 * Extended transaction serialization format:
206
 * - uint32_t version
207
 * - unsigned char dummy = 0x00
208
 * - unsigned char flags (!= 0)
209
 * - std::vector<CTxIn> vin
210
 * - std::vector<CTxOut> vout
211
 * - if (flags & 1):
212
 *   - CScriptWitness scriptWitness; (deserialized into CTxIn)
213
 * - uint32_t nLockTime
214
 */
215
template<typename Stream, typename TxType>
216
void UnserializeTransaction(TxType& tx, Stream& s, const TransactionSerParams& params)
217
17.6k
{
218
17.6k
    const bool fAllowWitness = params.allow_witness;
219
220
17.6k
    s >> tx.version;
221
17.6k
    unsigned char flags = 0;
222
17.6k
    tx.vin.clear();
223
17.6k
    tx.vout.clear();
224
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
225
17.6k
    s >> tx.vin;
226
17.6k
    if (tx.vin.size() == 0 && 
fAllowWitness7.57k
) {
227
        /* We read a dummy or an empty vin. */
228
7.57k
        s >> flags;
229
7.57k
        if (flags != 0) {
230
885
            s >> tx.vin;
231
885
            s >> tx.vout;
232
885
        }
233
10.1k
    } else {
234
        /* We read a non-empty vin. Assume a normal vout follows. */
235
10.1k
        s >> tx.vout;
236
10.1k
    }
237
17.6k
    if ((flags & 1) && 
fAllowWitness590
) {
238
        /* The witness flag is present, and we support witnesses. */
239
590
        flags ^= 1;
240
1.73k
        for (size_t i = 0; i < tx.vin.size(); 
i++1.14k
) {
241
1.14k
            s >> tx.vin[i].scriptWitness.stack;
242
1.14k
        }
243
590
        if (!tx.HasWitness()) {
244
            /* It's illegal to encode witnesses when all witness stacks are empty. */
245
36
            throw std::ios_base::failure("Superfluous witness record");
246
36
        }
247
590
    }
248
17.6k
    if (flags) {
249
        /* Unknown flag in the serialization */
250
30
        throw std::ios_base::failure("Unknown transaction optional data");
251
30
    }
252
17.6k
    s >> tx.nLockTime;
253
17.6k
}
void UnserializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
217
17.6k
{
218
17.6k
    const bool fAllowWitness = params.allow_witness;
219
220
17.6k
    s >> tx.version;
221
17.6k
    unsigned char flags = 0;
222
17.6k
    tx.vin.clear();
223
17.6k
    tx.vout.clear();
224
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
225
17.6k
    s >> tx.vin;
226
17.6k
    if (tx.vin.size() == 0 && 
fAllowWitness7.57k
) {
227
        /* We read a dummy or an empty vin. */
228
7.57k
        s >> flags;
229
7.57k
        if (flags != 0) {
230
885
            s >> tx.vin;
231
885
            s >> tx.vout;
232
885
        }
233
10.1k
    } else {
234
        /* We read a non-empty vin. Assume a normal vout follows. */
235
10.1k
        s >> tx.vout;
236
10.1k
    }
237
17.6k
    if ((flags & 1) && 
fAllowWitness590
) {
238
        /* The witness flag is present, and we support witnesses. */
239
590
        flags ^= 1;
240
1.73k
        for (size_t i = 0; i < tx.vin.size(); 
i++1.14k
) {
241
1.14k
            s >> tx.vin[i].scriptWitness.stack;
242
1.14k
        }
243
590
        if (!tx.HasWitness()) {
244
            /* It's illegal to encode witnesses when all witness stacks are empty. */
245
36
            throw std::ios_base::failure("Superfluous witness record");
246
36
        }
247
590
    }
248
17.6k
    if (flags) {
249
        /* Unknown flag in the serialization */
250
30
        throw std::ios_base::failure("Unknown transaction optional data");
251
30
    }
252
17.6k
    s >> tx.nLockTime;
253
17.6k
}
Unexecuted instantiation: void UnserializeTransaction<ParamsStream<SpanReader&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<SpanReader&, TransactionSerParams>&, TransactionSerParams const&)
Unexecuted instantiation: void UnserializeTransaction<DataStream, CMutableTransaction>(CMutableTransaction&, DataStream&, TransactionSerParams const&)
Unexecuted instantiation: void UnserializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
Unexecuted instantiation: void UnserializeTransaction<ParamsStream<BufferedFile&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction&, ParamsStream<BufferedFile&, TransactionSerParams>&, TransactionSerParams const&)
254
255
template<typename Stream, typename TxType>
256
void SerializeTransaction(const TxType& tx, Stream& s, const TransactionSerParams& params)
257
95.2k
{
258
95.2k
    const bool fAllowWitness = params.allow_witness;
259
260
95.2k
    s << tx.version;
261
95.2k
    unsigned char flags = 0;
262
    // Consistency check
263
95.2k
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
23.2k
        if (tx.HasWitness()) {
266
1.30k
            flags |= 1;
267
1.30k
        }
268
23.2k
    }
269
95.2k
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
1.30k
        std::vector<CTxIn> vinDummy;
272
1.30k
        s << vinDummy;
273
1.30k
        s << flags;
274
1.30k
    }
275
95.2k
    s << tx.vin;
276
95.2k
    s << tx.vout;
277
95.2k
    if (flags & 1) {
278
4.02k
        for (size_t i = 0; i < tx.vin.size(); 
i++2.72k
) {
279
2.72k
            s << tx.vin[i].scriptWitness.stack;
280
2.72k
        }
281
1.30k
    }
282
95.2k
    s << tx.nLockTime;
283
95.2k
}
void SerializeTransaction<ParamsStream<SizeComputer&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<SizeComputer&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
257
19.2k
{
258
19.2k
    const bool fAllowWitness = params.allow_witness;
259
260
19.2k
    s << tx.version;
261
19.2k
    unsigned char flags = 0;
262
    // Consistency check
263
19.2k
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
7.53k
        if (tx.HasWitness()) {
266
222
            flags |= 1;
267
222
        }
268
7.53k
    }
269
19.2k
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
222
        std::vector<CTxIn> vinDummy;
272
222
        s << vinDummy;
273
222
        s << flags;
274
222
    }
275
19.2k
    s << tx.vin;
276
19.2k
    s << tx.vout;
277
19.2k
    if (flags & 1) {
278
772
        for (size_t i = 0; i < tx.vin.size(); 
i++550
) {
279
550
            s << tx.vin[i].scriptWitness.stack;
280
550
        }
281
222
    }
282
19.2k
    s << tx.nLockTime;
283
19.2k
}
void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
257
14.9k
{
258
14.9k
    const bool fAllowWitness = params.allow_witness;
259
260
14.9k
    s << tx.version;
261
14.9k
    unsigned char flags = 0;
262
    // Consistency check
263
14.9k
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
14.9k
        if (tx.HasWitness()) {
266
384
            flags |= 1;
267
384
        }
268
14.9k
    }
269
14.9k
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
384
        std::vector<CTxIn> vinDummy;
272
384
        s << vinDummy;
273
384
        s << flags;
274
384
    }
275
14.9k
    s << tx.vin;
276
14.9k
    s << tx.vout;
277
14.9k
    if (flags & 1) {
278
1.11k
        for (size_t i = 0; i < tx.vin.size(); 
i++735
) {
279
735
            s << tx.vin[i].scriptWitness.stack;
280
735
        }
281
384
    }
282
14.9k
    s << tx.nLockTime;
283
14.9k
}
Unexecuted instantiation: void SerializeTransaction<ParamsStream<SizeComputer&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<SizeComputer&, TransactionSerParams>&, TransactionSerParams const&)
Unexecuted instantiation: void SerializeTransaction<ParamsStream<DataStream&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<DataStream&, TransactionSerParams>&, TransactionSerParams const&)
Unexecuted instantiation: void SerializeTransaction<ParamsStream<VectorWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams const&)
Unexecuted instantiation: void SerializeTransaction<ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>&, TransactionSerParams const&)
Unexecuted instantiation: void SerializeTransaction<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&, TransactionSerParams const&)
Unexecuted instantiation: void SerializeTransaction<ParamsStream<AutoFile&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<AutoFile&, TransactionSerParams>&, TransactionSerParams const&)
void SerializeTransaction<ParamsStream<HashWriter&, TransactionSerParams>, CMutableTransaction>(CMutableTransaction const&, ParamsStream<HashWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
257
7.88k
{
258
7.88k
    const bool fAllowWitness = params.allow_witness;
259
260
7.88k
    s << tx.version;
261
7.88k
    unsigned char flags = 0;
262
    // Consistency check
263
7.88k
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
0
        if (tx.HasWitness()) {
266
0
            flags |= 1;
267
0
        }
268
0
    }
269
7.88k
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
0
        std::vector<CTxIn> vinDummy;
272
0
        s << vinDummy;
273
0
        s << flags;
274
0
    }
275
7.88k
    s << tx.vin;
276
7.88k
    s << tx.vout;
277
7.88k
    if (flags & 1) {
278
0
        for (size_t i = 0; i < tx.vin.size(); i++) {
279
0
            s << tx.vin[i].scriptWitness.stack;
280
0
        }
281
0
    }
282
7.88k
    s << tx.nLockTime;
283
7.88k
}
void SerializeTransaction<ParamsStream<HashWriter&, TransactionSerParams>, CTransaction>(CTransaction const&, ParamsStream<HashWriter&, TransactionSerParams>&, TransactionSerParams const&)
Line
Count
Source
257
53.1k
{
258
53.1k
    const bool fAllowWitness = params.allow_witness;
259
260
53.1k
    s << tx.version;
261
53.1k
    unsigned char flags = 0;
262
    // Consistency check
263
53.1k
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
694
        if (tx.HasWitness()) {
266
694
            flags |= 1;
267
694
        }
268
694
    }
269
53.1k
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
694
        std::vector<CTxIn> vinDummy;
272
694
        s << vinDummy;
273
694
        s << flags;
274
694
    }
275
53.1k
    s << tx.vin;
276
53.1k
    s << tx.vout;
277
53.1k
    if (flags & 1) {
278
2.13k
        for (size_t i = 0; i < tx.vin.size(); 
i++1.44k
) {
279
1.44k
            s << tx.vin[i].scriptWitness.stack;
280
1.44k
        }
281
694
    }
282
53.1k
    s << tx.nLockTime;
283
53.1k
}
284
285
template<typename TxType>
286
inline CAmount CalculateOutputValue(const TxType& tx)
287
0
{
288
0
    return std::accumulate(tx.vout.cbegin(), tx.vout.cend(), CAmount{0}, [](CAmount sum, const auto& txout) { return sum + txout.nValue; });
289
0
}
290
291
292
/** The basic transaction that is broadcasted on the network and contained in
293
 * blocks.  A transaction can contain multiple inputs and outputs.
294
 */
295
class CTransaction
296
{
297
public:
298
    // Default transaction version.
299
    static const uint32_t CURRENT_VERSION{2};
300
301
    // The local variables are made const to prevent unintended modification
302
    // without updating the cached hash value. However, CTransaction is not
303
    // actually immutable; deserialization and assignment are implemented,
304
    // and bypass the constness. This is safe, as they update the entire
305
    // structure, including the hash.
306
    const std::vector<CTxIn> vin;
307
    const std::vector<CTxOut> vout;
308
    const uint32_t version;
309
    const uint32_t nLockTime;
310
311
private:
312
    /** Memory only. */
313
    const bool m_has_witness;
314
    const Txid hash;
315
    const Wtxid m_witness_hash;
316
317
    Txid ComputeHash() const;
318
    Wtxid ComputeWitnessHash() const;
319
320
    bool ComputeHasWitness() const;
321
322
public:
323
    /** Convert a CMutableTransaction into a CTransaction. */
324
    explicit CTransaction(const CMutableTransaction& tx);
325
    explicit CTransaction(CMutableTransaction&& tx);
326
327
    template <typename Stream>
328
87.3k
    inline void Serialize(Stream& s) const {
329
87.3k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
87.3k
    }
void CTransaction::Serialize<ParamsStream<SizeComputer&, TransactionSerParams>>(ParamsStream<SizeComputer&, TransactionSerParams>&) const
Line
Count
Source
328
19.2k
    inline void Serialize(Stream& s) const {
329
19.2k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
19.2k
    }
void CTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
Line
Count
Source
328
14.9k
    inline void Serialize(Stream& s) const {
329
14.9k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
14.9k
    }
Unexecuted instantiation: void CTransaction::Serialize<ParamsStream<VectorWriter&, TransactionSerParams>>(ParamsStream<VectorWriter&, TransactionSerParams>&) const
Unexecuted instantiation: void CTransaction::Serialize<ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>>(ParamsStream<ParamsStream<VectorWriter&, TransactionSerParams>&, TransactionSerParams>&) const
Unexecuted instantiation: void CTransaction::Serialize<ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>>(ParamsStream<BufferedWriter<AutoFile>&, TransactionSerParams>&) const
Unexecuted instantiation: void CTransaction::Serialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&) const
void CTransaction::Serialize<ParamsStream<HashWriter&, TransactionSerParams>>(ParamsStream<HashWriter&, TransactionSerParams>&) const
Line
Count
Source
328
53.1k
    inline void Serialize(Stream& s) const {
329
53.1k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
53.1k
    }
331
332
    /** This deserializing constructor is provided instead of an Unserialize method.
333
     *  Unserialize is not possible, since it would require overwriting const fields. */
334
    template <typename Stream>
335
0
    CTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) : CTransaction(CMutableTransaction(deserialize, params, s)) {}
336
    template <typename Stream>
337
0
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
Unexecuted instantiation: CTransaction::CTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Unexecuted instantiation: CTransaction::CTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Unexecuted instantiation: CTransaction::CTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Unexecuted instantiation: CTransaction::CTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
338
339
0
    bool IsNull() const {
340
0
        return vin.empty() && vout.empty();
341
0
    }
342
343
109k
    const Txid& GetHash() const LIFETIMEBOUND { return hash; }
344
44.1k
    const Wtxid& GetWitnessHash() const LIFETIMEBOUND { return m_witness_hash; };
345
346
    // Return sum of txouts.
347
    CAmount GetValueOut() const;
348
349
    /**
350
     * Get the total transaction size in bytes, including witness data.
351
     * "Total Size" defined in BIP141 and BIP144.
352
     * @return Total transaction size in bytes
353
     */
354
    unsigned int GetTotalSize() const;
355
356
    bool IsCoinBase() const
357
34.0k
    {
358
34.0k
        return (vin.size() == 1 && 
vin[0].prevout.IsNull()15.7k
);
359
34.0k
    }
360
361
    friend bool operator==(const CTransaction& a, const CTransaction& b)
362
11.8k
    {
363
11.8k
        return a.GetWitnessHash() == b.GetWitnessHash();
364
11.8k
    }
365
366
    friend bool operator!=(const CTransaction& a, const CTransaction& b)
367
0
    {
368
0
        return !operator==(a, b);
369
0
    }
370
371
    std::string ToString() const;
372
373
77.1k
    bool HasWitness() const { return m_has_witness; }
374
};
375
376
/** A mutable version of CTransaction. */
377
struct CMutableTransaction
378
{
379
    std::vector<CTxIn> vin;
380
    std::vector<CTxOut> vout;
381
    uint32_t version;
382
    uint32_t nLockTime;
383
384
    explicit CMutableTransaction();
385
    explicit CMutableTransaction(const CTransaction& tx);
386
387
    template <typename Stream>
388
7.88k
    inline void Serialize(Stream& s) const {
389
7.88k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
390
7.88k
    }
Unexecuted instantiation: void CMutableTransaction::Serialize<ParamsStream<SizeComputer&, TransactionSerParams>>(ParamsStream<SizeComputer&, TransactionSerParams>&) const
Unexecuted instantiation: void CMutableTransaction::Serialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&) const
void CMutableTransaction::Serialize<ParamsStream<HashWriter&, TransactionSerParams>>(ParamsStream<HashWriter&, TransactionSerParams>&) const
Line
Count
Source
388
7.88k
    inline void Serialize(Stream& s) const {
389
7.88k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
390
7.88k
    }
391
392
    template <typename Stream>
393
17.6k
    inline void Unserialize(Stream& s) {
394
17.6k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
395
17.6k
    }
void CMutableTransaction::Unserialize<ParamsStream<DataStream&, TransactionSerParams>>(ParamsStream<DataStream&, TransactionSerParams>&)
Line
Count
Source
393
17.6k
    inline void Unserialize(Stream& s) {
394
17.6k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
395
17.6k
    }
Unexecuted instantiation: void CMutableTransaction::Unserialize<ParamsStream<SpanReader&, TransactionSerParams>>(ParamsStream<SpanReader&, TransactionSerParams>&)
Unexecuted instantiation: void CMutableTransaction::Unserialize<ParamsStream<AutoFile&, TransactionSerParams>>(ParamsStream<AutoFile&, TransactionSerParams>&)
Unexecuted instantiation: void CMutableTransaction::Unserialize<ParamsStream<BufferedFile&, TransactionSerParams>>(ParamsStream<BufferedFile&, TransactionSerParams>&)
396
397
    template <typename Stream>
398
0
    CMutableTransaction(deserialize_type, const TransactionSerParams& params, Stream& s) {
399
0
        UnserializeTransaction(*this, s, params);
400
0
    }
401
402
    template <typename Stream>
403
0
    CMutableTransaction(deserialize_type, Stream& s) {
404
0
        Unserialize(s);
405
0
    }
Unexecuted instantiation: CMutableTransaction::CMutableTransaction<ParamsStream<DataStream&, TransactionSerParams>>(deserialize_type, ParamsStream<DataStream&, TransactionSerParams>&)
Unexecuted instantiation: CMutableTransaction::CMutableTransaction<ParamsStream<AutoFile&, TransactionSerParams>>(deserialize_type, ParamsStream<AutoFile&, TransactionSerParams>&)
Unexecuted instantiation: CMutableTransaction::CMutableTransaction<ParamsStream<SpanReader&, TransactionSerParams>>(deserialize_type, ParamsStream<SpanReader&, TransactionSerParams>&)
Unexecuted instantiation: CMutableTransaction::CMutableTransaction<ParamsStream<BufferedFile&, TransactionSerParams>>(deserialize_type, ParamsStream<BufferedFile&, TransactionSerParams>&)
406
407
    /** Compute the hash of this CMutableTransaction. This is computed on the
408
     * fly, as opposed to GetHash() in CTransaction, which uses a cached result.
409
     */
410
    Txid GetHash() const;
411
412
    bool HasWitness() const
413
505
    {
414
685
        for (size_t i = 0; i < vin.size(); 
i++180
) {
415
649
            if (!vin[i].scriptWitness.IsNull()) {
416
469
                return true;
417
469
            }
418
649
        }
419
36
        return false;
420
505
    }
421
};
422
423
typedef std::shared_ptr<const CTransaction> CTransactionRef;
424
19.5k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
Unexecuted instantiation: mini_miner.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: p2p_headers_presync.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: package_eval.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: txdownloadman.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: tx_pool.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: tx_pool.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction const&>(CMutableTransaction const&)
Unexecuted instantiation: txorphan.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: txorphan.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Unexecuted instantiation: utxo_total_supply.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
feebumper.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Line
Count
Source
424
15.8k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
Unexecuted instantiation: spend.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
mempool.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CTransaction const&>(CTransaction const&)
Line
Count
Source
424
3.76k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
Unexecuted instantiation: chainparams.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Unexecuted instantiation: feebumper.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Unexecuted instantiation: backup.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: wallet.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CTransaction const&>(CTransaction const&)
Unexecuted instantiation: mining.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Unexecuted instantiation: setup_common.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction const&>(CMutableTransaction const&)
Unexecuted instantiation: setup_common.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: txmempool.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction const&>(CMutableTransaction const&)
Unexecuted instantiation: txmempool.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: miner.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction&>(CMutableTransaction&)
Unexecuted instantiation: miner.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Unexecuted instantiation: mempool.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
Unexecuted instantiation: validation.cpp:std::__1::shared_ptr<CTransaction const> MakeTransactionRef<CMutableTransaction>(CMutableTransaction&&)
425
426
#endif // BITCOIN_PRIMITIVES_TRANSACTION_H