0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-15 11:36:00 -05:00

Add MAX_STANDARD_SCRIPTSIG_SIZE to policy

Bitcoin core has a standardness rule for max satisfaction script sig size.
This PR adds to the policy header file so that it is documented along with
along policy rules. The initial reasoning that 1650 is an implicit
limit(would not reached assuming all other policy rules are being
followed) is outdated.

As we now know, bitcoin transactions can have spend conditions are more than
just signatures and there may exist p2sh transactions involving 100 byte
preimages that maybe non-standard because of this rule. Because this
rule is no longer implicit, we should explicitly document it in policy
header file
This commit is contained in:
sanket1729 2020-11-25 13:49:50 -06:00
parent 50091592dd
commit e416cfc92b
2 changed files with 11 additions and 8 deletions

View file

@ -92,14 +92,15 @@ bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeR
for (const CTxIn& txin : tx.vin) for (const CTxIn& txin : tx.vin)
{ {
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed // Biggest 'standard' txin involving only keys is a 15-of-15 P2SH
// keys (remember the 520 byte limit on redeemScript size). That works // multisig with compressed keys (remember the 520 byte limit on
// out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 // redeemScript size). That works out to a (15*(33+1))+3=513 byte
// bytes of scriptSig, which we round off to 1650 bytes for some minor // redeemScript, 513+1+15*(73+1)+3=1627 bytes of scriptSig, which
// future-proofing. That's also enough to spend a 20-of-20 // we round off to 1650(MAX_STANDARD_SCRIPTSIG_SIZE) bytes for
// CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not // some minor future-proofing. That's also enough to spend a
// considered standard. // 20-of-20 CHECKMULTISIG scriptPubKey, though such a scriptPubKey
if (txin.scriptSig.size() > 1650) { // is not considered standard.
if (txin.scriptSig.size() > MAX_STANDARD_SCRIPTSIG_SIZE) {
reason = "scriptsig-size"; reason = "scriptsig-size";
return false; return false;
} }

View file

@ -44,6 +44,8 @@ static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE = 80;
static const unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE = 80; static const unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE = 80;
/** The maximum size of a standard witnessScript */ /** The maximum size of a standard witnessScript */
static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600; static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600;
/** The maximum size of a standard ScriptSig */
static const unsigned int MAX_STANDARD_SCRIPTSIG_SIZE = 1650;
/** Min feerate for defining dust. Historically this has been based on the /** Min feerate for defining dust. Historically this has been based on the
* minRelayTxFee, however changing the dust limit changes which transactions are * minRelayTxFee, however changing the dust limit changes which transactions are
* standard and should be done with care and ideally rarely. It makes sense to * standard and should be done with care and ideally rarely. It makes sense to