59 nSize += (32 + 4 + 1 + 107 + 4);
81 std::vector<std::vector<unsigned char> >
vSolutions;
127 reason =
"scriptsig-size";
130 if (!
txin.scriptSig.IsPushOnly()) {
131 reason =
"scriptsig-not-pushonly";
140 reason =
"scriptpubkey";
145 unsigned int size = txout.scriptPubKey.size();
147 reason =
"datacarrier";
152 reason =
"bare-multisig";
174 for (
const auto&
txin: tx.
vin) {
223 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
226 std::vector<std::vector<unsigned char> >
vSolutions;
235 std::vector<std::vector<unsigned char> > stack;
256 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
260 if (tx.
vin[i].scriptWitness.IsNull())
275 std::vector <std::vector<unsigned char> > stack;
312 std::span stack{tx.
vin[i].scriptWitness.stack};
313 if (stack.size() >= 2 && !stack.back().empty() && stack.back()[0] ==
ANNEX_TAG) {
317 if (stack.size() >= 2) {
324 for (
const auto&
item : stack) {
328 }
else if (stack.size() == 1) {
348 for (
const auto&
txin: tx.
vin) {
361 std::vector <std::vector<uint8_t>> stack;
366 const CScript redeem_script{stack.
back().begin(), stack.back().end()};
367 if (redeem_script.IsWitnessProgram(version,
program)) {
int64_t CAmount
Amount in satoshis (Can be negative)
#define Assert(val)
Identity function.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
Serialized script, used inside transaction inputs and outputs.
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops.
bool IsWitnessProgram(int &version, std::vector< unsigned char > &program) const
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const std::vector< CTxIn > vin
An input of a transaction.
An output of a transaction.
CTxOut out
unspent transaction output
static int64_t GetTransactionInputWeight(const CTxIn &txin)
static int32_t GetTransactionWeight(const CTransaction &tx)
static const int WITNESS_SCALE_FACTOR
bool EvalScript(std::vector< std::vector< unsigned char > > &stack, const CScript &script, script_verify_flags flags, const BaseSignatureChecker &checker, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror)
@ BASE
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
static constexpr uint8_t TAPROOT_LEAF_MASK
static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT
static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE
Signature hash sizes.
static constexpr size_t WITNESS_V1_TAPROOT_SIZE
static constexpr script_verify_flags SCRIPT_VERIFY_NONE
Script verification flags.
bool SpendsNonAnchorWitnessProg(const CTransaction &tx, const CCoinsViewCache &prevouts)
Check whether this transaction spends any witness program but P2A, including not-yet-defined ones.
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check transaction inputs.
CAmount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
int64_t GetVirtualTransactionInputSize(const CTxIn &txin, int64_t nSigOpCost, unsigned int bytes_per_sigop)
static bool CheckSigopsBIP54(const CTransaction &tx, const CCoinsViewCache &inputs)
Check the total number of non-witness sigops across the whole transaction, as per BIP54.
bool IsWitnessStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check if the transaction is over standard P2WSH resources limit: 3600bytes witnessScript size,...
bool IsStandard(const CScript &scriptPubKey, TxoutType &whichType)
bool IsStandardTx(const CTransaction &tx, const std::optional< unsigned > &max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate &dust_relay_fee, std::string &reason)
Check for standard transaction types.
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
std::vector< uint32_t > GetDust(const CTransaction &tx, CFeeRate dust_relay_rate)
Get the vout index numbers of all dust outputs.
int64_t GetSigOpsAdjustedWeight(int64_t weight, int64_t sigop_cost, unsigned int bytes_per_sigop)
static constexpr decltype(CTransaction::version) TX_MIN_STANDARD_VERSION
static constexpr unsigned int MAX_TX_LEGACY_SIGOPS
The maximum number of potentially executed legacy signature operations in a single standard tx.
static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION
static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS
The maximum number of witness stack items in a standard P2WSH script.
static constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE
The maximum size in bytes of each witness stack item in a standard BIP 342 script (Taproot,...
static constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX
Maximum number of ephemeral dust outputs allowed.
static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE
The maximum size in bytes of each witness stack item in a standard P2WSH script.
static constexpr int32_t MAX_STANDARD_TX_WEIGHT
The maximum weight for transactions we're willing to relay/mine.
static constexpr unsigned int MAX_P2SH_SIGOPS
Maximum number of signature check operations in an IsStandard() P2SH script.
static constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE
The maximum size in bytes of a standard witnessScript.
static constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE
The maximum size of a standard ScriptSig.
static constexpr unsigned int ANNEX_TAG
uint64_t GetSerializeSize(const T &t)
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
@ WITNESS_UNKNOWN
Only for Witness versions not already defined above.
@ NULL_DATA
unspendable OP_RETURN script that carries data
T & SpanPopBack(std::span< T > &span)
A span is an object that can refer to a contiguous sequence of objects.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.