Skip to content

Commit e2ff5e7

Browse files
author
MarcoFalke
committed
Merge #20497: [Refactor] Add MAX_STANDARD_SCRIPTSIG_SIZE to policy
e416cfc Add MAX_STANDARD_SCRIPTSIG_SIZE to policy (sanket1729) Pull request description: 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 reach 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 ACKs for top commit: sipa: utACK e416cfc practicalswift: cr ACK e416cfc theStack: Code Review ACK e416cfc Tree-SHA512: 1a91ee23dfb6085807e04dd0687d7a443e0f3e0f52d0a995a6599dff28533b0b599afba2724735d93948a64a3e25d0bc016ce3e771c0bd453eef78b22dc2369d
2 parents 5009159 + e416cfc commit e2ff5e7

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/policy/policy.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,15 @@ bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeR
9292

9393
for (const CTxIn& txin : tx.vin)
9494
{
95-
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
96-
// keys (remember the 520 byte limit on redeemScript size). That works
97-
// out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627
98-
// bytes of scriptSig, which we round off to 1650 bytes for some minor
99-
// future-proofing. That's also enough to spend a 20-of-20
100-
// CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not
101-
// considered standard.
102-
if (txin.scriptSig.size() > 1650) {
95+
// Biggest 'standard' txin involving only keys is a 15-of-15 P2SH
96+
// multisig with compressed keys (remember the 520 byte limit on
97+
// redeemScript size). That works out to a (15*(33+1))+3=513 byte
98+
// redeemScript, 513+1+15*(73+1)+3=1627 bytes of scriptSig, which
99+
// we round off to 1650(MAX_STANDARD_SCRIPTSIG_SIZE) bytes for
100+
// some minor future-proofing. That's also enough to spend a
101+
// 20-of-20 CHECKMULTISIG scriptPubKey, though such a scriptPubKey
102+
// is not considered standard.
103+
if (txin.scriptSig.size() > MAX_STANDARD_SCRIPTSIG_SIZE) {
103104
reason = "scriptsig-size";
104105
return false;
105106
}

src/policy/policy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE = 80;
4444
static const unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE = 80;
4545
/** The maximum size of a standard witnessScript */
4646
static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600;
47+
/** The maximum size of a standard ScriptSig */
48+
static const unsigned int MAX_STANDARD_SCRIPTSIG_SIZE = 1650;
4749
/** Min feerate for defining dust. Historically this has been based on the
4850
* minRelayTxFee, however changing the dust limit changes which transactions are
4951
* standard and should be done with care and ideally rarely. It makes sense to

0 commit comments

Comments
 (0)