fuzz coverage

Coverage Report

Created: 2025-06-01 19:34

/Users/eugenesiegel/btc/bitcoin/src/primitives/transaction.h
Line
Count
Source (jump to first uncovered line)
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 <script/script.h>
12
#include <serialize.h>
13
#include <uint256.h>
14
#include <util/transaction_identifier.h> // IWYU pragma: export
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
42.6M
    COutPoint(): n(NULL_INDEX) { }
37
90.7M
    COutPoint(const Txid& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }
38
39
186M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
130M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
1.17M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
1.33M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
50.8k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
10.0M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
43.9M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR12SizeComputer20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
39
130M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
130M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
39
1.17M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
1.17M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR12VectorWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
39
1.33M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
1.33M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIRS1_IR12VectorWriter20TransactionSerParamsES4_EKS_15ActionSerializeEEvRT0_RT_T1_
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR10SpanReader20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
39
50.8k
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
50.8k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI10HashWriterKS_15ActionSerializeEEvRT0_RT_T1_
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
39
10.0M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
10.0M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN9COutPoint16SerializationOpsI12ParamsStreamIR12BufferedFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
_ZN9COutPoint16SerializationOpsI12ParamsStreamIR10HashWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
39
43.9M
    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
Line
Count
Source
156
43.9M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
40
41
10.0M
    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
42
169M
    bool IsNull() const { return (hash.IsNull() && 
n == NULL_INDEX159M
); }
43
44
    friend bool operator<(const COutPoint& a, const COutPoint& b)
45
0
    {
46
0
        return std::tie(a.hash, a.n) < std::tie(b.hash, b.n);
47
0
    }
48
49
    friend bool operator==(const COutPoint& a, const COutPoint& b)
50
220
    {
51
220
        return (a.hash == b.hash && a.n == b.n);
52
220
    }
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
12.4M
    {
123
12.4M
        nSequence = SEQUENCE_FINAL;
124
12.4M
    }
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
186M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
130M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
1.17M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
1.33M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
50.8k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
10.0M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
43.9M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR12SizeComputer20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
129
130M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
130M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
129
1.17M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
1.17M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR12VectorWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
129
1.33M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
1.33M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIRS1_IR12VectorWriter20TransactionSerParamsES4_EKS_15ActionSerializeEEvRT0_RT_T1_
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR10SpanReader20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
129
50.8k
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
50.8k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
129
10.0M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
10.0M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN5CTxIn16SerializationOpsI12ParamsStreamIR12BufferedFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
_ZN5CTxIn16SerializationOpsI12ParamsStreamIR10HashWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
129
43.9M
    SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
Line
Count
Source
156
43.9M
#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
201M
    {
157
201M
        SetNull();
158
201M
    }
159
160
    CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn);
161
162
357M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
260M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
1.06M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
1.79M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
50.8k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
20.0M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
0
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
73.9M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR12SizeComputer20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
162
260M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
260M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
162
1.06M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
1.06M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR12VectorWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
162
1.79M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
1.79M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR10DataStream20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12SizeComputerKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIRS1_IR12VectorWriter20TransactionSerParamsES4_EKS_15ActionSerializeEEvRT0_RT_T1_
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR10SpanReader20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
162
50.8k
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
50.8k
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI10SpanReaderS_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI10HashWriterKS_15ActionSerializeEEvRT0_RT_T1_
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
162
20.0M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
20.0M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR8AutoFile20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Unexecuted instantiation: _ZN6CTxOut16SerializationOpsI12ParamsStreamIR12BufferedFile20TransactionSerParamsES_17ActionUnserializeEEvRT0_RT_T1_
_ZN6CTxOut16SerializationOpsI12ParamsStreamIR10HashWriter20TransactionSerParamsEKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
162
73.9M
    SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
Line
Count
Source
156
73.9M
#define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__))
163
164
    void SetNull()
165
201M
    {
166
201M
        nValue = -1;
167
201M
        scriptPubKey.clear();
168
201M
    }
169
170
    bool IsNull() const
171
40.2M
    {
172
40.2M
        return (nValue == -1);
173
40.2M
    }
174
175
    friend bool operator==(const CTxOut& a, const CTxOut& b)
176
55
    {
177
55
        return (a.nValue       == b.nValue &&
178
55
                a.scriptPubKey == b.scriptPubKey);
179
55
    }
180
181
    friend bool operator!=(const CTxOut& a, const CTxOut& b)
182
55
    {
183
55
        return !(a == b);
184
55
    }
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
466k
{
218
466k
    const bool fAllowWitness = params.allow_witness;
219
220
466k
    s >> tx.version;
221
466k
    unsigned char flags = 0;
222
466k
    tx.vin.clear();
223
466k
    tx.vout.clear();
224
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
225
466k
    s >> tx.vin;
226
466k
    if (tx.vin.size() == 0 && 
fAllowWitness356k
) {
227
        /* We read a dummy or an empty vin. */
228
356k
        s >> flags;
229
356k
        if (flags != 0) {
230
218k
            s >> tx.vin;
231
218k
            s >> tx.vout;
232
218k
        }
233
356k
    } else {
234
        /* We read a non-empty vin. Assume a normal vout follows. */
235
109k
        s >> tx.vout;
236
109k
    }
237
466k
    if ((flags & 1) && 
fAllowWitness181k
) {
238
        /* The witness flag is present, and we support witnesses. */
239
181k
        flags ^= 1;
240
1.09M
        for (size_t i = 0; i < tx.vin.size(); 
i++917k
) {
241
917k
            s >> tx.vin[i].scriptWitness.stack;
242
917k
        }
243
181k
        if (!tx.HasWitness()) {
244
            /* It's illegal to encode witnesses when all witness stacks are empty. */
245
2.61k
            throw std::ios_base::failure("Superfluous witness record");
246
2.61k
        }
247
181k
    }
248
463k
    if (flags) {
249
        /* Unknown flag in the serialization */
250
2.66k
        throw std::ios_base::failure("Unknown transaction optional data");
251
2.66k
    }
252
460k
    s >> tx.nLockTime;
253
460k
}
_Z22UnserializeTransactionI12ParamsStreamIR10DataStream20TransactionSerParamsE19CMutableTransactionEvRT0_RT_RKS3_
Line
Count
Source
217
415k
{
218
415k
    const bool fAllowWitness = params.allow_witness;
219
220
415k
    s >> tx.version;
221
415k
    unsigned char flags = 0;
222
415k
    tx.vin.clear();
223
415k
    tx.vout.clear();
224
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
225
415k
    s >> tx.vin;
226
415k
    if (tx.vin.size() == 0 && 
fAllowWitness356k
) {
227
        /* We read a dummy or an empty vin. */
228
356k
        s >> flags;
229
356k
        if (flags != 0) {
230
218k
            s >> tx.vin;
231
218k
            s >> tx.vout;
232
218k
        }
233
356k
    } else {
234
        /* We read a non-empty vin. Assume a normal vout follows. */
235
58.9k
        s >> tx.vout;
236
58.9k
    }
237
415k
    if ((flags & 1) && 
fAllowWitness181k
) {
238
        /* The witness flag is present, and we support witnesses. */
239
181k
        flags ^= 1;
240
1.09M
        for (size_t i = 0; i < tx.vin.size(); 
i++917k
) {
241
917k
            s >> tx.vin[i].scriptWitness.stack;
242
917k
        }
243
181k
        if (!tx.HasWitness()) {
244
            /* It's illegal to encode witnesses when all witness stacks are empty. */
245
2.61k
            throw std::ios_base::failure("Superfluous witness record");
246
2.61k
        }
247
181k
    }
248
412k
    if (flags) {
249
        /* Unknown flag in the serialization */
250
2.66k
        throw std::ios_base::failure("Unknown transaction optional data");
251
2.66k
    }
252
409k
    s >> tx.nLockTime;
253
409k
}
_Z22UnserializeTransactionI12ParamsStreamIR10SpanReader20TransactionSerParamsE19CMutableTransactionEvRT0_RT_RKS3_
Line
Count
Source
217
50.8k
{
218
50.8k
    const bool fAllowWitness = params.allow_witness;
219
220
50.8k
    s >> tx.version;
221
50.8k
    unsigned char flags = 0;
222
50.8k
    tx.vin.clear();
223
50.8k
    tx.vout.clear();
224
    /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
225
50.8k
    s >> tx.vin;
226
50.8k
    if (tx.vin.size() == 0 && 
fAllowWitness0
) {
227
        /* We read a dummy or an empty vin. */
228
0
        s >> flags;
229
0
        if (flags != 0) {
230
0
            s >> tx.vin;
231
0
            s >> tx.vout;
232
0
        }
233
50.8k
    } else {
234
        /* We read a non-empty vin. Assume a normal vout follows. */
235
50.8k
        s >> tx.vout;
236
50.8k
    }
237
50.8k
    if ((flags & 1) && 
fAllowWitness0
) {
238
        /* The witness flag is present, and we support witnesses. */
239
0
        flags ^= 1;
240
0
        for (size_t i = 0; i < tx.vin.size(); i++) {
241
0
            s >> tx.vin[i].scriptWitness.stack;
242
0
        }
243
0
        if (!tx.HasWitness()) {
244
            /* It's illegal to encode witnesses when all witness stacks are empty. */
245
0
            throw std::ios_base::failure("Superfluous witness record");
246
0
        }
247
0
    }
248
50.8k
    if (flags) {
249
        /* Unknown flag in the serialization */
250
0
        throw std::ios_base::failure("Unknown transaction optional data");
251
0
    }
252
50.8k
    s >> tx.nLockTime;
253
50.8k
}
Unexecuted instantiation: _Z22UnserializeTransactionI10DataStream19CMutableTransactionEvRT0_RT_RK20TransactionSerParams
Unexecuted instantiation: _Z22UnserializeTransactionI12ParamsStreamIR8AutoFile20TransactionSerParamsE19CMutableTransactionEvRT0_RT_RKS3_
Unexecuted instantiation: _Z22UnserializeTransactionI12ParamsStreamIR12BufferedFile20TransactionSerParamsE19CMutableTransactionEvRT0_RT_RKS3_
254
255
template<typename Stream, typename TxType>
256
void SerializeTransaction(const TxType& tx, Stream& s, const TransactionSerParams& params)
257
182M
{
258
182M
    const bool fAllowWitness = params.allow_witness;
259
260
182M
    s << tx.version;
261
182M
    unsigned char flags = 0;
262
    // Consistency check
263
182M
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
61.1M
        if (tx.HasWitness()) {
266
60.5M
            flags |= 1;
267
60.5M
        }
268
61.1M
    }
269
182M
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
60.5M
        std::vector<CTxIn> vinDummy;
272
60.5M
        s << vinDummy;
273
60.5M
        s << flags;
274
60.5M
    }
275
182M
    s << tx.vin;
276
182M
    s << tx.vout;
277
182M
    if (flags & 1) {
278
123M
        for (size_t i = 0; i < tx.vin.size(); 
i++62.8M
) {
279
62.8M
            s << tx.vin[i].scriptWitness.stack;
280
62.8M
        }
281
60.5M
    }
282
182M
    s << tx.nLockTime;
283
182M
}
_Z20SerializeTransactionI12ParamsStreamIR12SizeComputer20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Line
Count
Source
257
130M
{
258
130M
    const bool fAllowWitness = params.allow_witness;
259
260
130M
    s << tx.version;
261
130M
    unsigned char flags = 0;
262
    // Consistency check
263
130M
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
40.0M
        if (tx.HasWitness()) {
266
39.9M
            flags |= 1;
267
39.9M
        }
268
40.0M
    }
269
130M
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
39.9M
        std::vector<CTxIn> vinDummy;
272
39.9M
        s << vinDummy;
273
39.9M
        s << flags;
274
39.9M
    }
275
130M
    s << tx.vin;
276
130M
    s << tx.vout;
277
130M
    if (flags & 1) {
278
79.9M
        for (size_t i = 0; i < tx.vin.size(); 
i++39.9M
) {
279
39.9M
            s << tx.vin[i].scriptWitness.stack;
280
39.9M
        }
281
39.9M
    }
282
130M
    s << tx.nLockTime;
283
130M
}
_Z20SerializeTransactionI12ParamsStreamIR12VectorWriter20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Line
Count
Source
257
811k
{
258
811k
    const bool fAllowWitness = params.allow_witness;
259
260
811k
    s << tx.version;
261
811k
    unsigned char flags = 0;
262
    // Consistency check
263
811k
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
811k
        if (tx.HasWitness()) {
266
276k
            flags |= 1;
267
276k
        }
268
811k
    }
269
811k
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
276k
        std::vector<CTxIn> vinDummy;
272
276k
        s << vinDummy;
273
276k
        s << flags;
274
276k
    }
275
811k
    s << tx.vin;
276
811k
    s << tx.vout;
277
811k
    if (flags & 1) {
278
1.43M
        for (size_t i = 0; i < tx.vin.size(); 
i++1.16M
) {
279
1.16M
            s << tx.vin[i].scriptWitness.stack;
280
1.16M
        }
281
276k
    }
282
811k
    s << tx.nLockTime;
283
811k
}
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR10DataStream20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR12SizeComputer20TransactionSerParamsE19CMutableTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR10DataStream20TransactionSerParamsE19CMutableTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIRS0_IR12VectorWriter20TransactionSerParamsES3_E12CTransactionEvRKT0_RT_RKS3_
_Z20SerializeTransactionI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS5_
Line
Count
Source
257
10.0M
{
258
10.0M
    const bool fAllowWitness = params.allow_witness;
259
260
10.0M
    s << tx.version;
261
10.0M
    unsigned char flags = 0;
262
    // Consistency check
263
10.0M
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
10.0M
        if (tx.HasWitness()) {
266
9.99M
            flags |= 1;
267
9.99M
        }
268
10.0M
    }
269
10.0M
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
9.99M
        std::vector<CTxIn> vinDummy;
272
9.99M
        s << vinDummy;
273
9.99M
        s << flags;
274
9.99M
    }
275
10.0M
    s << tx.vin;
276
10.0M
    s << tx.vout;
277
10.0M
    if (flags & 1) {
278
19.9M
        for (size_t i = 0; i < tx.vin.size(); 
i++9.99M
) {
279
9.99M
            s << tx.vin[i].scriptWitness.stack;
280
9.99M
        }
281
9.99M
    }
282
10.0M
    s << tx.nLockTime;
283
10.0M
}
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR8AutoFile20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Unexecuted instantiation: _Z20SerializeTransactionI12ParamsStreamIR10HashWriter20TransactionSerParamsE19CMutableTransactionEvRKT0_RT_RKS3_
_Z20SerializeTransactionI12ParamsStreamIR10HashWriter20TransactionSerParamsE12CTransactionEvRKT0_RT_RKS3_
Line
Count
Source
257
41.3M
{
258
41.3M
    const bool fAllowWitness = params.allow_witness;
259
260
41.3M
    s << tx.version;
261
41.3M
    unsigned char flags = 0;
262
    // Consistency check
263
41.3M
    if (fAllowWitness) {
264
        /* Check whether witnesses need to be serialized. */
265
10.2M
        if (tx.HasWitness()) {
266
10.2M
            flags |= 1;
267
10.2M
        }
268
10.2M
    }
269
41.3M
    if (flags) {
270
        /* Use extended format in case witnesses are to be serialized. */
271
10.2M
        std::vector<CTxIn> vinDummy;
272
10.2M
        s << vinDummy;
273
10.2M
        s << flags;
274
10.2M
    }
275
41.3M
    s << tx.vin;
276
41.3M
    s << tx.vout;
277
41.3M
    if (flags & 1) {
278
21.9M
        for (size_t i = 0; i < tx.vin.size(); 
i++11.6M
) {
279
11.6M
            s << tx.vin[i].scriptWitness.stack;
280
11.6M
        }
281
10.2M
    }
282
41.3M
    s << tx.nLockTime;
283
41.3M
}
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
182M
    inline void Serialize(Stream& s) const {
329
182M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
182M
    }
_ZNK12CTransaction9SerializeI12ParamsStreamIR12SizeComputer20TransactionSerParamsEEEvRT_
Line
Count
Source
328
130M
    inline void Serialize(Stream& s) const {
329
130M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
130M
    }
_ZNK12CTransaction9SerializeI12ParamsStreamIR12VectorWriter20TransactionSerParamsEEEvRT_
Line
Count
Source
328
811k
    inline void Serialize(Stream& s) const {
329
811k
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
811k
    }
Unexecuted instantiation: _ZNK12CTransaction9SerializeI12ParamsStreamIR10DataStream20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZNK12CTransaction9SerializeI12ParamsStreamIRS1_IR12VectorWriter20TransactionSerParamsES4_EEEvRT_
_ZNK12CTransaction9SerializeI12ParamsStreamIR14BufferedWriterI8AutoFileE20TransactionSerParamsEEEvRT_
Line
Count
Source
328
10.0M
    inline void Serialize(Stream& s) const {
329
10.0M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
10.0M
    }
Unexecuted instantiation: _ZNK12CTransaction9SerializeI12ParamsStreamIR8AutoFile20TransactionSerParamsEEEvRT_
_ZNK12CTransaction9SerializeI12ParamsStreamIR10HashWriter20TransactionSerParamsEEEvRT_
Line
Count
Source
328
41.3M
    inline void Serialize(Stream& s) const {
329
41.3M
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
330
41.3M
    }
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
466k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
_ZN12CTransactionC1I12ParamsStreamIR10DataStream20TransactionSerParamsEEE16deserialize_typeRT_
Line
Count
Source
337
415k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
Unexecuted instantiation: _ZN12CTransactionC1I12ParamsStreamIR8AutoFile20TransactionSerParamsEEE16deserialize_typeRT_
_ZN12CTransactionC1I12ParamsStreamIR10SpanReader20TransactionSerParamsEEE16deserialize_typeRT_
Line
Count
Source
337
50.8k
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
Unexecuted instantiation: _ZN12CTransactionC1I12ParamsStreamIR12BufferedFile20TransactionSerParamsEEE16deserialize_typeRT_
338
339
47.8k
    bool IsNull() const {
340
47.8k
        return vin.empty() && 
vout.empty()234
;
341
47.8k
    }
342
343
110M
    const Txid& GetHash() const LIFETIMEBOUND { return hash; }
344
306k
    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
160M
    {
358
160M
        return (vin.size() == 1 && 
vin[0].prevout.IsNull()159M
);
359
160M
    }
360
361
    friend bool operator==(const CTransaction& a, const CTransaction& b)
362
0
    {
363
0
        return a.hash == b.hash;
364
0
    }
365
366
    friend bool operator!=(const CTransaction& a, const CTransaction& b)
367
0
    {
368
0
        return a.hash != b.hash;
369
0
    }
370
371
    std::string ToString() const;
372
373
102M
    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
0
    inline void Serialize(Stream& s) const {
389
0
        SerializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
390
0
    }
Unexecuted instantiation: _ZNK19CMutableTransaction9SerializeI12ParamsStreamIR12SizeComputer20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZNK19CMutableTransaction9SerializeI12ParamsStreamIR10DataStream20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZNK19CMutableTransaction9SerializeI12ParamsStreamIR10HashWriter20TransactionSerParamsEEEvRT_
391
392
    template <typename Stream>
393
466k
    inline void Unserialize(Stream& s) {
394
466k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
395
466k
    }
_ZN19CMutableTransaction11UnserializeI12ParamsStreamIR10DataStream20TransactionSerParamsEEEvRT_
Line
Count
Source
393
415k
    inline void Unserialize(Stream& s) {
394
415k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
395
415k
    }
_ZN19CMutableTransaction11UnserializeI12ParamsStreamIR10SpanReader20TransactionSerParamsEEEvRT_
Line
Count
Source
393
50.8k
    inline void Unserialize(Stream& s) {
394
50.8k
        UnserializeTransaction(*this, s, s.template GetParams<TransactionSerParams>());
395
50.8k
    }
Unexecuted instantiation: _ZN19CMutableTransaction11UnserializeI12ParamsStreamIR8AutoFile20TransactionSerParamsEEEvRT_
Unexecuted instantiation: _ZN19CMutableTransaction11UnserializeI12ParamsStreamIR12BufferedFile20TransactionSerParamsEEEvRT_
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
466k
    CMutableTransaction(deserialize_type, Stream& s) {
404
466k
        Unserialize(s);
405
466k
    }
_ZN19CMutableTransactionC2I12ParamsStreamIR10DataStream20TransactionSerParamsEEE16deserialize_typeRT_
Line
Count
Source
403
415k
    CMutableTransaction(deserialize_type, Stream& s) {
404
415k
        Unserialize(s);
405
415k
    }
Unexecuted instantiation: _ZN19CMutableTransactionC2I12ParamsStreamIR8AutoFile20TransactionSerParamsEEE16deserialize_typeRT_
_ZN19CMutableTransactionC2I12ParamsStreamIR10SpanReader20TransactionSerParamsEEE16deserialize_typeRT_
Line
Count
Source
403
50.8k
    CMutableTransaction(deserialize_type, Stream& s) {
404
50.8k
        Unserialize(s);
405
50.8k
    }
Unexecuted instantiation: _ZN19CMutableTransactionC2I12ParamsStreamIR12BufferedFile20TransactionSerParamsEEE16deserialize_typeRT_
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
179k
    {
414
208k
        for (size_t i = 0; i < vin.size(); 
i++29.0k
) {
415
205k
            if (!vin[i].scriptWitness.IsNull()) {
416
176k
                return true;
417
176k
            }
418
205k
        }
419
2.61k
        return false;
420
179k
    }
421
};
422
423
typedef std::shared_ptr<const CTransaction> CTransactionRef;
424
30.6M
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
cmpctblock.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Line
Count
Source
424
341k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
Unexecuted instantiation: mini_miner.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: p2p_headers_presync.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: package_eval.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: txdownloadman.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: tx_pool.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: tx_pool.cpp:_ZL18MakeTransactionRefIRK19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: txorphan.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: utxo_total_supply.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: notifications.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: spend.cpp:_ZL18MakeTransactionRefI19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: mempool.cpp:_ZL18MakeTransactionRefIRK12CTransactionENSt3__110shared_ptrIS1_EEOT_
chainparams.cpp:_ZL18MakeTransactionRefI19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Line
Count
Source
424
299k
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
Unexecuted instantiation: feebumper.cpp:_ZL18MakeTransactionRefI19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: backup.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: wallet.cpp:_ZL18MakeTransactionRefIRK12CTransactionENSt3__110shared_ptrIS1_EEOT_
Unexecuted instantiation: mining.cpp:_ZL18MakeTransactionRefI19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: setup_common.cpp:_ZL18MakeTransactionRefIRK19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: setup_common.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: txmempool.cpp:_ZL18MakeTransactionRefIRK19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Unexecuted instantiation: miner.cpp:_ZL18MakeTransactionRefIR19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
miner.cpp:_ZL18MakeTransactionRefI19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Line
Count
Source
424
9.99M
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
Unexecuted instantiation: mempool.cpp:_ZL18MakeTransactionRefI19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
validation.cpp:_ZL18MakeTransactionRefI19CMutableTransactionENSt3__110shared_ptrIK12CTransactionEEOT_
Line
Count
Source
424
19.9M
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
425
426
/** A generic txid reference (txid or wtxid). */
427
class GenTxid
428
{
429
    bool m_is_wtxid;
430
    uint256 m_hash;
431
0
    GenTxid(bool is_wtxid, const uint256& hash) : m_is_wtxid(is_wtxid), m_hash(hash) {}
432
433
public:
434
0
    static GenTxid Txid(const uint256& hash) { return GenTxid{false, hash}; }
435
0
    static GenTxid Wtxid(const uint256& hash) { return GenTxid{true, hash}; }
436
0
    bool IsWtxid() const { return m_is_wtxid; }
437
0
    const uint256& GetHash() const LIFETIMEBOUND { return m_hash; }
438
0
    friend bool operator==(const GenTxid& a, const GenTxid& b) { return a.m_is_wtxid == b.m_is_wtxid && a.m_hash == b.m_hash; }
439
0
    friend bool operator<(const GenTxid& a, const GenTxid& b) { return std::tie(a.m_is_wtxid, a.m_hash) < std::tie(b.m_is_wtxid, b.m_hash); }
440
};
441
442
#endif // BITCOIN_PRIMITIVES_TRANSACTION_H