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];
104 reason =
"scriptsig-size";
108 reason =
"scriptsig-not-pushonly";
113 unsigned int nDataOut = 0;
117 reason =
"scriptpubkey";
124 reason =
"bare-multisig";
126 }
else if (
IsDust(txout, dust_relay_fee)) {
134 reason =
"multi-op-return";
164 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
168 std::vector<std::vector<unsigned char> > vSolutions;
177 std::vector<std::vector<unsigned char> > stack;
183 CScript subscript(stack.back().begin(), stack.back().end());
189 if (!taproot_active)
return false;
201 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
205 if (tx.
vin[i].scriptWitness.IsNull())
215 std::vector <std::vector<unsigned char> > stack;
223 prevScript =
CScript(stack.back().begin(), stack.back().end());
227 int witnessversion = 0;
228 std::vector<unsigned char> witnessprogram;
238 size_t sizeWitnessStack = tx.
vin[i].scriptWitness.stack.size() - 1;
241 for (
unsigned int j = 0; j < sizeWitnessStack; j++) {
252 auto stack =
MakeSpan(tx.
vin[i].scriptWitness.stack);
253 if (stack.size() >= 2 && !stack.back().empty() && stack.back()[0] ==
ANNEX_TAG) {
257 if (stack.size() >= 2) {
261 if (control_block.empty())
return false;
264 for (
const auto& item : stack) {
268 }
else if (stack.size() == 1) {
static int64_t GetTransactionWeight(const CTransaction &tx)
static const int WITNESS_SCALE_FACTOR
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
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 in bytes of a standard witnessScript.
static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
bool IsWitnessProgram(int &version, std::vector< unsigned char > &program) const
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 in bytes of each witness stack item in a standard BIP 342 script (Taproot...
static decltype(CTransaction::nVersion) constexpr TX_MAX_STANDARD_VERSION
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)
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack...
static const unsigned int MAX_STANDARD_SCRIPTSIG_SIZE
The maximum size of a standard ScriptSig.
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)
bool IsPushOnly(const_iterator pc) const
Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical).
static constexpr uint8_t TAPROOT_LEAF_MASK
const std::vector< CTxOut > vout
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)
static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE
The maximum size in bytes 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.
CAmount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
Span< A > constexpr MakeSpan(A(&a)[N])
MakeSpan for arrays: