34 int witnessversion = 0;
35 std::vector<unsigned char> witnessprogram;
42 nSize += (32 + 4 + 1 + 107 + 4);
45 return dustRelayFeeIn.
GetFee(nSize);
55 std::vector<std::vector<unsigned char> > vSolutions;
56 whichType =
Solver(scriptPubKey, vSolutions);
61 unsigned char m = vSolutions.front()[0];
62 unsigned char n = vSolutions.back()[0];
103 reason =
"scriptsig-size";
107 reason =
"scriptsig-not-pushonly";
112 unsigned int nDataOut = 0;
116 reason =
"scriptpubkey";
123 reason =
"bare-multisig";
125 }
else if (
IsDust(txout, dust_relay_fee)) {
133 reason =
"multi-op-return";
163 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
167 std::vector<std::vector<unsigned char> > vSolutions;
176 std::vector<std::vector<unsigned char> > stack;
182 CScript subscript(stack.back().begin(), stack.back().end());
188 if (!taproot_active)
return false;
200 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
204 if (tx.
vin[i].scriptWitness.IsNull())
214 std::vector <std::vector<unsigned char> > stack;
222 prevScript =
CScript(stack.back().begin(), stack.back().end());
226 int witnessversion = 0;
227 std::vector<unsigned char> witnessprogram;
237 size_t sizeWitnessStack = tx.
vin[i].scriptWitness.stack.size() - 1;
240 for (
unsigned int j = 0; j < sizeWitnessStack; j++) {
251 auto stack =
MakeSpan(tx.
vin[i].scriptWitness.stack);
252 if (stack.size() >= 2 && !stack.back().empty() && stack.back()[0] ==
ANNEX_TAG) {
256 if (stack.size() >= 2) {
260 if (control_block.empty())
return false;
263 for (
const auto& item : stack) {
267 }
else if (stack.size() == 1) {
static int64_t GetTransactionWeight(const CTransaction &tx)
static const int32_t MAX_STANDARD_VERSION
static const int WITNESS_SCALE_FACTOR
bool IsPushOnly(const_iterator pc) const
Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical).
static constexpr size_t WITNESS_V1_TAPROOT_SIZE
bool IsPayToScriptHash() const
CTxOut out
unspent transaction output
bool fAcceptDatacarrier
A data carrying output is an unspendable output containing data.
static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE
The maximum size of a standard witnessScript.
static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
static const unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE
The maximum size of each witness stack item in a standard BIP 342 script (Taproot, leaf version 0xc0)
unspendable OP_RETURN script that carries data
const std::vector< CTxIn > vin
bool IsWitnessStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check if the transaction is over standard P2WSH resources limit: 3600bytes witnessScript size...
size_t GetSerializeSize(const T &t, int nVersion=0)
int64_t CAmount
Amount in satoshis (Can be negative)
int64_t GetVirtualTransactionInputSize(const CTxIn &txin, int64_t nSigOpCost, unsigned int bytes_per_sigop)
static const unsigned int MAX_P2SH_SIGOPS
Maximum number of signature check operations in an IsStandard() P2SH script.
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs, bool taproot_active)
Check transaction inputs to mitigate two potential denial-of-service attacks:
An input of a transaction.
static int64_t GetTransactionInputWeight(const CTxIn &txin)
static constexpr uint8_t TAPROOT_LEAF_MASK
bool IsWitnessProgram(int &version, std::vector< unsigned char > &program) const
const std::vector< CTxOut > vout
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack...
An output of a transaction.
static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE
Signature hash sizes.
static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS
The maximum number of witness stack items in a standard P2WSH script.
CAmount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
CAmount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE
The maximum size of each witness stack item in a standard P2WSH script.
Serialized script, used inside transaction inputs and outputs.
static constexpr unsigned int ANNEX_TAG
static const unsigned int MAX_STANDARD_TX_WEIGHT
The maximum weight for transactions we're willing to relay/mine.
T & SpanPopBack(Span< T > &span)
Pop the last element off a span, and return a reference to that element.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
Only for Witness versions not already defined above.
Fee rate in satoshis per kilobyte: CAmount / kB.
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
The basic transaction that is broadcasted on the network and contained in blocks. ...
CCoinsView that adds a memory cache for transactions to another CCoinsView.
bool IsStandardTx(const CTransaction &tx, bool permit_bare_multisig, const CFeeRate &dust_relay_fee, std::string &reason)
Check for standard transaction types.
bool EvalScript(std::vector< std::vector< unsigned char > > &stack, const CScript &script, unsigned int flags, const BaseSignatureChecker &checker, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror)
bool IsStandard(const CScript &scriptPubKey, TxoutType &whichType)
unsigned nMaxDatacarrierBytes
Maximum size of TxoutType::NULL_DATA scripts that this node considers standard.
Span< A > constexpr MakeSpan(A(&a)[N])
MakeSpan for arrays: