Coverage Report

Created: 2026-07-14 18:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/bitcoin/src/policy/policy.cpp
Line
Count
Source
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
// NOTE: This file is intended to be customised by the end user, and includes only local node policy logic
7
8
#include <policy/policy.h>
9
10
#include <coins.h>
11
#include <consensus/amount.h>
12
#include <consensus/consensus.h>
13
#include <consensus/validation.h>
14
#include <policy/feerate.h>
15
#include <primitives/transaction.h>
16
#include <script/interpreter.h>
17
#include <script/script.h>
18
#include <script/solver.h>
19
#include <serialize.h>
20
#include <span.h>
21
#include <tinyformat.h>
22
23
#include <algorithm>
24
#include <cstddef>
25
#include <vector>
26
27
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
28
3.08M
{
29
    // "Dust" is defined in terms of dustRelayFee,
30
    // which has units satoshis-per-kilobyte.
31
    // If you'd pay more in fees than the value of the output
32
    // to spend something, then we consider it dust.
33
    // A typical spendable non-segwit txout is 34 bytes big, and will
34
    // need a CTxIn of at least 148 bytes to spend:
35
    // so dust is a spendable txout less than
36
    // 182*dustRelayFee/1000 (in satoshis).
37
    // 546 satoshis at the default rate of 3000 sat/kvB.
38
    // A typical spendable segwit P2WPKH txout is 31 bytes big, and will
39
    // need a CTxIn of at least 67 bytes to spend:
40
    // so dust is a spendable txout less than
41
    // 98*dustRelayFee/1000 (in satoshis).
42
    // 294 satoshis at the default rate of 3000 sat/kvB.
43
3.08M
    if (txout.scriptPubKey.IsUnspendable())
  Branch (43:9): [True: 196k, False: 2.89M]
44
196k
        return 0;
45
46
2.89M
    uint64_t nSize{GetSerializeSize(txout)};
47
2.89M
    int witnessversion = 0;
48
2.89M
    std::vector<unsigned char> witnessprogram;
49
50
    // Note this computation is for spending a Segwit v0 P2WPKH output (a 33 bytes
51
    // public key + an ECDSA signature). For Segwit v1 Taproot outputs the minimum
52
    // satisfaction is lower (a single BIP340 signature) but this computation was
53
    // kept to not further reduce the dust level.
54
    // See discussion in https://github.com/bitcoin/bitcoin/pull/22779 for details.
55
2.89M
    if (txout.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
  Branch (55:9): [True: 2.80M, False: 92.6k]
56
        // sum the sizes of the parts of a transaction input
57
        // with 75% segwit discount applied to the script size.
58
2.80M
        nSize += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);
59
2.80M
    } else {
60
92.6k
        nSize += (32 + 4 + 1 + 107 + 4); // the 148 mentioned above
61
92.6k
    }
62
63
2.89M
    return dustRelayFeeIn.GetFee(nSize);
64
3.08M
}
65
66
bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
67
3.08M
{
68
3.08M
    return (txout.nValue < GetDustThreshold(txout, dustRelayFeeIn));
69
3.08M
}
70
71
std::vector<uint32_t> GetDust(const CTransaction& tx, CFeeRate dust_relay_rate)
72
2.44M
{
73
2.44M
    std::vector<uint32_t> dust_outputs;
74
5.16M
    for (uint32_t i{0}; i < tx.vout.size(); ++i) {
  Branch (74:25): [True: 2.72M, False: 2.44M]
75
2.72M
        if (IsDust(tx.vout[i], dust_relay_rate)) dust_outputs.push_back(i);
  Branch (75:13): [True: 280k, False: 2.43M]
76
2.72M
    }
77
2.44M
    return dust_outputs;
78
2.44M
}
79
80
bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType)
81
2.21M
{
82
2.21M
    std::vector<std::vector<unsigned char> > vSolutions;
83
2.21M
    whichType = Solver(scriptPubKey, vSolutions);
84
85
2.21M
    if (whichType == TxoutType::NONSTANDARD) {
  Branch (85:9): [True: 0, False: 2.21M]
86
0
        return false;
87
2.21M
    } else if (whichType == TxoutType::MULTISIG) {
  Branch (87:16): [True: 0, False: 2.21M]
88
0
        unsigned char m = vSolutions.front()[0];
89
0
        unsigned char n = vSolutions.back()[0];
90
        // Support up to x-of-3 multisig txns as standard
91
0
        if (n < 1 || n > 3)
  Branch (91:13): [True: 0, False: 0]
  Branch (91:22): [True: 0, False: 0]
92
0
            return false;
93
0
        if (m < 1 || m > n)
  Branch (93:13): [True: 0, False: 0]
  Branch (93:22): [True: 0, False: 0]
94
0
            return false;
95
0
    }
96
97
2.21M
    return true;
98
2.21M
}
99
100
bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason)
101
2.04M
{
102
2.04M
    if (tx.version > TX_MAX_STANDARD_VERSION || tx.version < TX_MIN_STANDARD_VERSION) {
  Branch (102:9): [True: 31.5k, False: 2.01M]
  Branch (102:49): [True: 11.0k, False: 2.00M]
103
42.5k
        reason = "version";
104
42.5k
        return false;
105
42.5k
    }
106
107
    // Extremely large transactions with lots of inputs can cost the network
108
    // almost as much to process as they cost the sender in fees, because
109
    // computing signature hashes is O(ninputs*txsize). Limiting transactions
110
    // to MAX_STANDARD_TX_WEIGHT mitigates CPU exhaustion attacks.
111
2.00M
    unsigned int sz = GetTransactionWeight(tx);
112
2.00M
    if (sz > MAX_STANDARD_TX_WEIGHT) {
  Branch (112:9): [True: 3.22k, False: 1.99M]
113
3.22k
        reason = "tx-size";
114
3.22k
        return false;
115
3.22k
    }
116
117
1.99M
    for (const CTxIn& txin : tx.vin)
  Branch (117:28): [True: 2.25M, False: 1.99M]
118
2.25M
    {
119
        // Biggest 'standard' txin involving only keys is a 15-of-15 P2SH
120
        // multisig with compressed keys (remember the MAX_SCRIPT_ELEMENT_SIZE byte limit on
121
        // redeemScript size). That works out to a (15*(33+1))+3=513 byte
122
        // redeemScript, 513+1+15*(73+1)+3=1627 bytes of scriptSig, which
123
        // we round off to 1650(MAX_STANDARD_SCRIPTSIG_SIZE) bytes for
124
        // some minor future-proofing. That's also enough to spend a
125
        // 20-of-20 CHECKMULTISIG scriptPubKey, though such a scriptPubKey
126
        // is not considered standard.
127
2.25M
        if (txin.scriptSig.size() > MAX_STANDARD_SCRIPTSIG_SIZE) {
  Branch (127:13): [True: 0, False: 2.25M]
128
0
            reason = "scriptsig-size";
129
0
            return false;
130
0
        }
131
2.25M
        if (!txin.scriptSig.IsPushOnly()) {
  Branch (131:13): [True: 0, False: 2.25M]
132
0
            reason = "scriptsig-not-pushonly";
133
0
            return false;
134
0
        }
135
2.25M
    }
136
137
1.99M
    unsigned int datacarrier_bytes_left = max_datacarrier_bytes.value_or(0);
138
1.99M
    TxoutType whichType;
139
2.21M
    for (const CTxOut& txout : tx.vout) {
  Branch (139:30): [True: 2.21M, False: 1.99M]
140
2.21M
        if (!::IsStandard(txout.scriptPubKey, whichType)) {
  Branch (140:13): [True: 0, False: 2.21M]
141
0
            reason = "scriptpubkey";
142
0
            return false;
143
0
        }
144
145
2.21M
        if (whichType == TxoutType::NULL_DATA) {
  Branch (145:13): [True: 158k, False: 2.06M]
146
158k
            unsigned int size = txout.scriptPubKey.size();
147
158k
            if (size > datacarrier_bytes_left) {
  Branch (147:17): [True: 0, False: 158k]
148
0
                reason = "datacarrier";
149
0
                return false;
150
0
            }
151
158k
            datacarrier_bytes_left -= size;
152
2.06M
        } else if ((whichType == TxoutType::MULTISIG) && (!permit_bare_multisig)) {
  Branch (152:20): [True: 0, False: 2.06M]
  Branch (152:58): [True: 0, False: 0]
153
0
            reason = "bare-multisig";
154
0
            return false;
155
0
        }
156
2.21M
    }
157
158
    // Only MAX_DUST_OUTPUTS_PER_TX dust is permitted(on otherwise valid ephemeral dust)
159
1.99M
    if (GetDust(tx, dust_relay_fee).size() > MAX_DUST_OUTPUTS_PER_TX) {
  Branch (159:9): [True: 9.04k, False: 1.98M]
160
9.04k
        reason = "dust";
161
9.04k
        return false;
162
9.04k
    }
163
164
1.98M
    return true;
165
1.99M
}
166
167
/**
168
 * Check the total number of non-witness sigops across the whole transaction, as per BIP54.
169
 */
170
static bool CheckSigopsBIP54(const CTransaction& tx, const CCoinsViewCache& inputs)
171
521k
{
172
521k
    Assert(!tx.IsCoinBase());
173
174
521k
    unsigned int sigops{0};
175
561k
    for (const auto& txin: tx.vin) {
  Branch (175:26): [True: 561k, False: 521k]
176
561k
        const auto& prev_txo{inputs.AccessCoin(txin.prevout).out};
177
178
        // Unlike the existing block wide sigop limit which counts sigops present in the block
179
        // itself (including the scriptPubKey which is not executed until spending later), BIP54
180
        // counts sigops in the block where they are potentially executed (only).
181
        // This means sigops in the spent scriptPubKey count toward the limit.
182
        // `fAccurate` means correctly accounting sigops for CHECKMULTISIGs(VERIFY) with 16 pubkeys
183
        // or fewer. This method of accounting was introduced by BIP16, and BIP54 reuses it.
184
        // The GetSigOpCount call on the previous scriptPubKey counts both bare and P2SH sigops.
185
561k
        sigops += txin.scriptSig.GetSigOpCount(/*fAccurate=*/true);
186
561k
        sigops += prev_txo.scriptPubKey.GetSigOpCount(txin.scriptSig);
187
188
561k
        if (sigops > MAX_TX_LEGACY_SIGOPS) {
  Branch (188:13): [True: 0, False: 561k]
189
0
            return false;
190
0
        }
191
561k
    }
192
193
521k
    return true;
194
521k
}
195
196
/**
197
 * Check transaction inputs.
198
 *
199
 * This does three things:
200
 *  * Prevents mempool acceptance of spends of future
201
 *    segwit versions we don't know how to validate
202
 *  * Mitigates a potential denial-of-service attack with
203
 *    P2SH scripts with a crazy number of expensive
204
 *    CHECKSIG/CHECKMULTISIG operations.
205
 *  * Prevents spends of unknown/irregular scriptPubKeys,
206
 *    which mitigates potential denial-of-service attacks
207
 *    involving expensive scripts and helps reserve them
208
 *    as potential new upgrade hooks.
209
 *
210
 * Note that only the non-witness portion of the transaction is checked here.
211
 *
212
 * We also check the total number of non-witness sigops across the whole transaction, as per BIP54.
213
 */
214
TxValidationState ValidateInputsStandardness(const CTransaction& tx, const CCoinsViewCache& mapInputs)
215
521k
{
216
521k
    TxValidationState state;
217
521k
    if (tx.IsCoinBase()) {
  Branch (217:9): [True: 0, False: 521k]
218
0
        return state; // Coinbases don't use vin normally
219
0
    }
220
221
521k
    if (!CheckSigopsBIP54(tx, mapInputs)) {
  Branch (221:9): [True: 0, False: 521k]
222
0
        state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs", "non-witness sigops exceed bip54 limit");
223
0
        return state;
224
0
    }
225
226
1.08M
    for (unsigned int i = 0; i < tx.vin.size(); i++) {
  Branch (226:30): [True: 561k, False: 521k]
227
561k
        const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out;
228
229
561k
        std::vector<std::vector<unsigned char> > vSolutions;
230
561k
        TxoutType whichType = Solver(prev.scriptPubKey, vSolutions);
231
561k
        if (whichType == TxoutType::NONSTANDARD) {
  Branch (231:13): [True: 0, False: 561k]
232
0
            state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs", strprintf("input %u script unknown", i));
233
0
            return state;
234
561k
        } else if (whichType == TxoutType::WITNESS_UNKNOWN) {
  Branch (234:20): [True: 0, False: 561k]
235
            // WITNESS_UNKNOWN failures are typically also caught with a policy
236
            // flag in the script interpreter, but it can be helpful to catch
237
            // this type of NONSTANDARD transaction earlier in transaction
238
            // validation.
239
0
            state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs", strprintf("input %u witness program is undefined", i));
240
0
            return state;
241
561k
        } else if (whichType == TxoutType::SCRIPTHASH) {
  Branch (241:20): [True: 5.43k, False: 556k]
242
5.43k
            std::vector<std::vector<unsigned char> > stack;
243
5.43k
            ScriptError serror;
244
            // convert the scriptSig into a stack, so we can inspect the redeemScript
245
5.43k
            if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE, &serror)) {
  Branch (245:17): [True: 44, False: 5.38k]
246
44
                state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs", strprintf("p2sh scriptsig malformed (input %u: %s)", i, ScriptErrorString(serror)));
247
44
                return state;
248
44
            }
249
5.38k
            if (stack.empty()) {
  Branch (249:17): [True: 0, False: 5.38k]
250
0
                state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs", strprintf("input %u P2SH redeemscript missing", i));
251
0
                return state;
252
0
            }
253
5.38k
            CScript subscript(stack.back().begin(), stack.back().end());
254
5.38k
            unsigned int sigop_count = subscript.GetSigOpCount(true);
255
5.38k
            if (sigop_count > MAX_P2SH_SIGOPS) {
  Branch (255:17): [True: 108, False: 5.27k]
256
108
                state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs", strprintf("p2sh redeemscript sigops exceed limit (input %u: %u > %u)", i, sigop_count, MAX_P2SH_SIGOPS));
257
108
                return state;
258
108
            }
259
5.38k
        }
260
561k
    }
261
262
521k
    return state;
263
521k
}
264
265
bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
266
478k
{
267
478k
    if (tx.IsCoinBase())
  Branch (267:9): [True: 0, False: 478k]
268
0
        return true; // Coinbases are skipped
269
270
993k
    for (unsigned int i = 0; i < tx.vin.size(); i++)
  Branch (270:30): [True: 514k, False: 478k]
271
514k
    {
272
        // We don't care if witness for this input is empty, since it must not be bloated.
273
        // If the script is invalid without witness, it would be caught sooner or later during validation.
274
514k
        if (tx.vin[i].scriptWitness.IsNull())
  Branch (274:13): [True: 12.4k, False: 501k]
275
12.4k
            continue;
276
277
501k
        const CTxOut &prev = mapInputs.AccessCoin(tx.vin[i].prevout).out;
278
279
        // get the scriptPubKey corresponding to this input:
280
501k
        CScript prevScript = prev.scriptPubKey;
281
282
        // witness stuffing detected
283
501k
        if (prevScript.IsPayToAnchor()) {
  Branch (283:13): [True: 0, False: 501k]
284
0
            return false;
285
0
        }
286
287
501k
        bool p2sh = false;
288
501k
        if (prevScript.IsPayToScriptHash()) {
  Branch (288:13): [True: 0, False: 501k]
289
0
            std::vector <std::vector<unsigned char> > stack;
290
            // If the scriptPubKey is P2SH, we try to extract the redeemScript casually by converting the scriptSig
291
            // into a stack. We do not check IsPushOnly nor compare the hash as these will be done later anyway.
292
            // If the check fails at this stage, we know that this txid must be a bad one.
293
0
            if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE))
  Branch (293:17): [True: 0, False: 0]
294
0
                return false;
295
0
            if (stack.empty())
  Branch (295:17): [True: 0, False: 0]
296
0
                return false;
297
0
            prevScript = CScript(stack.back().begin(), stack.back().end());
298
0
            p2sh = true;
299
0
        }
300
301
501k
        int witnessversion = 0;
302
501k
        std::vector<unsigned char> witnessprogram;
303
304
        // Non-witness program must not be associated with any witness
305
501k
        if (!prevScript.IsWitnessProgram(witnessversion, witnessprogram))
  Branch (305:13): [True: 0, False: 501k]
306
0
            return false;
307
308
        // Check P2WSH standard limits
309
501k
        if (witnessversion == 0 && witnessprogram.size() == WITNESS_V0_SCRIPTHASH_SIZE) {
  Branch (309:13): [True: 489k, False: 12.9k]
  Branch (309:36): [True: 487k, False: 1.42k]
310
487k
            if (tx.vin[i].scriptWitness.stack.back().size() > MAX_STANDARD_P2WSH_SCRIPT_SIZE)
  Branch (310:17): [True: 0, False: 487k]
311
0
                return false;
312
487k
            size_t sizeWitnessStack = tx.vin[i].scriptWitness.stack.size() - 1;
313
487k
            if (sizeWitnessStack > MAX_STANDARD_P2WSH_STACK_ITEMS)
  Branch (313:17): [True: 0, False: 487k]
314
0
                return false;
315
492k
            for (unsigned int j = 0; j < sizeWitnessStack; j++) {
  Branch (315:38): [True: 5.25k, False: 487k]
316
5.25k
                if (tx.vin[i].scriptWitness.stack[j].size() > MAX_STANDARD_P2WSH_STACK_ITEM_SIZE)
  Branch (316:21): [True: 97, False: 5.15k]
317
97
                    return false;
318
5.25k
            }
319
487k
        }
320
321
        // Check policy limits for Taproot spends:
322
        // - MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE limit for stack item size
323
        // - No annexes
324
501k
        if (witnessversion == 1 && witnessprogram.size() == WITNESS_V1_TAPROOT_SIZE && !p2sh) {
  Branch (324:13): [True: 12.9k, False: 488k]
  Branch (324:36): [True: 12.9k, False: 0]
  Branch (324:88): [True: 12.9k, False: 0]
325
            // Taproot spend (non-P2SH-wrapped, version 1, witness program size 32; see BIP 341)
326
12.9k
            std::span stack{tx.vin[i].scriptWitness.stack};
327
12.9k
            if (stack.size() >= 2 && !stack.back().empty() && stack.back()[0] == ANNEX_TAG) {
  Branch (327:17): [True: 4.27k, False: 8.68k]
  Branch (327:38): [True: 4.27k, False: 0]
  Branch (327:63): [True: 18, False: 4.25k]
328
                // Annexes are nonstandard as long as no semantics are defined for them.
329
18
                return false;
330
18
            }
331
12.9k
            if (stack.size() >= 2) {
  Branch (331:17): [True: 4.25k, False: 8.68k]
332
                // Script path spend (2 or more stack elements after removing optional annex)
333
4.25k
                const auto& control_block = SpanPopBack(stack);
334
4.25k
                SpanPopBack(stack); // Ignore script
335
4.25k
                if (control_block.empty()) return false; // Empty control block is invalid
  Branch (335:21): [True: 0, False: 4.25k]
336
4.25k
                if ((control_block[0] & TAPROOT_LEAF_MASK) == TAPROOT_LEAF_TAPSCRIPT) {
  Branch (336:21): [True: 1.49k, False: 2.76k]
337
                    // Leaf version 0xc0 (aka Tapscript, see BIP 342)
338
1.49k
                    for (const auto& item : stack) {
  Branch (338:43): [True: 1.45k, False: 1.49k]
339
1.45k
                        if (item.size() > MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE) return false;
  Branch (339:29): [True: 0, False: 1.45k]
340
1.45k
                    }
341
1.49k
                }
342
8.68k
            } else if (stack.size() == 1) {
  Branch (342:24): [True: 8.68k, False: 0]
343
                // Key path spend (1 stack element after removing optional annex)
344
                // (no policy rules apply)
345
8.68k
            } else {
346
                // 0 stack elements; this is already invalid by consensus rules
347
0
                return false;
348
0
            }
349
12.9k
        }
350
501k
    }
351
478k
    return true;
352
478k
}
353
354
bool SpendsNonAnchorWitnessProg(const CTransaction& tx, const CCoinsViewCache& prevouts)
355
8.53k
{
356
8.53k
    if (tx.IsCoinBase()) {
  Branch (356:9): [True: 0, False: 8.53k]
357
0
        return false;
358
0
    }
359
360
8.53k
    int version;
361
8.53k
    std::vector<uint8_t> program;
362
9.27k
    for (const auto& txin: tx.vin) {
  Branch (362:26): [True: 9.27k, False: 2.35k]
363
9.27k
        const auto& prev_spk{prevouts.AccessCoin(txin.prevout).out.scriptPubKey};
364
365
        // Note this includes not-yet-defined witness programs.
366
9.27k
        if (prev_spk.IsWitnessProgram(version, program) && !prev_spk.IsPayToAnchor(version, program)) {
  Branch (366:13): [True: 6.28k, False: 2.99k]
  Branch (366:60): [True: 6.12k, False: 161]
367
6.12k
            return true;
368
6.12k
        }
369
370
        // For P2SH extract the redeem script and check if it spends a non-Taproot witness program. Note
371
        // this is fine to call EvalScript (as done in ValidateInputsStandardness/IsWitnessStandard) because this
372
        // function is only ever called after IsStandardTx, which checks the scriptsig is pushonly.
373
3.15k
        if (prev_spk.IsPayToScriptHash()) {
  Branch (373:13): [True: 1.53k, False: 1.61k]
374
            // If EvalScript fails or results in an empty stack, the transaction is invalid by consensus.
375
1.53k
            std::vector <std::vector<uint8_t>> stack;
376
1.53k
            if (!EvalScript(stack, txin.scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker{}, SigVersion::BASE)
  Branch (376:17): [True: 0, False: 1.53k]
  Branch (376:17): [True: 0, False: 1.53k]
377
1.53k
                || stack.empty()) {
  Branch (377:20): [True: 0, False: 1.53k]
378
0
                continue;
379
0
            }
380
1.53k
            const CScript redeem_script{stack.back().begin(), stack.back().end()};
381
1.53k
            if (redeem_script.IsWitnessProgram(version, program)) {
  Branch (381:17): [True: 56, False: 1.48k]
382
56
                return true;
383
56
            }
384
1.53k
        }
385
3.15k
    }
386
387
2.35k
    return false;
388
8.53k
}
389
390
int64_t GetSigOpsAdjustedWeight(int64_t weight, int64_t sigop_cost, unsigned int bytes_per_sigop)
391
31.3M
{
392
31.3M
    return std::max(weight, sigop_cost * bytes_per_sigop);
393
31.3M
}
394
395
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
396
16.5M
{
397
16.5M
    return (GetSigOpsAdjustedWeight(nWeight, nSigOpCost, bytes_per_sigop) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;
398
16.5M
}
399
400
int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost, unsigned int bytes_per_sigop)
401
0
{
402
0
    return GetVirtualTransactionSize(GetTransactionWeight(tx), nSigOpCost, bytes_per_sigop);
403
0
}
404
405
int64_t GetVirtualTransactionInputSize(const CTxIn& txin, int64_t nSigOpCost, unsigned int bytes_per_sigop)
406
0
{
407
0
    return GetVirtualTransactionSize(GetTransactionInputWeight(txin), nSigOpCost, bytes_per_sigop);
408
0
}