From 6d8b873923a0f9ba0a8d0716b99136c7e242a00c Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 23 May 2014 10:37:03 -0500 Subject: [PATCH] Raise maxStandardSigScriptSize to 1650. This commit raises the maximum allowed size for a standard signature script to cover a 15-of-15 multi-signature pay-to-script-hash with compressed pubkeys. This mirrors a recent change to remain compatible with Bitcoin Core. ok @owinga who also helped verify and correct the script math. Closes #128. --- mempool.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mempool.go b/mempool.go index 84f6dc0564..d41f94624b 100644 --- a/mempool.go +++ b/mempool.go @@ -53,12 +53,22 @@ const ( // maxStandardSigScriptSize is the maximum size allowed for a // transaction input signature script to be considered standard. This - // value allows for a CHECKMULTISIG pay-to-sript-hash with 3 signatures - // since each signature is about 80-bytes, the 3 corresponding public - // keys are 65-bytes each if uncompressed, and the script opcodes take - // a few extra bytes. This value also adds a few extra bytes for - // prosperity. 3*80 + 3*65 + 65 = 500 - maxStandardSigScriptSize = 500 + // value allows for a 15-of-15 CHECKMULTISIG pay-to-script-hash with + // compressed keys. + // + // The form of the overall script is: OP_0 <15 signatures> OP_PUSHDATA2 + // <2 bytes len> [OP_15 <15 pubkeys> OP_15 OP_CHECKMULTISIG] + // + // For the p2sh script portion, each of the 15 compressed pubkeys are + // 33 bytes (plus one for the OP_DATA_33 opcode), and the thus it totals + // to (15*34)+3 = 513 bytes. Next, each of the 15 signatures is a max + // of 73 bytes (plus one for the OP_DATA_73 opcode). Also, there is one + // extra byte for the initial extra OP_0 push and 3 bytes for the + // OP_PUSHDATA2 needed to specify the 513 bytes for the script push. + // That brings the total to 1+(15*74)+3+513 = 1627. This value also + // adds a few extra bytes to provide a little buffer. + // (1 + 15*74 + 3) + (15*34 + 3) + 23 = 1650 + maxStandardSigScriptSize = 1650 // maxStandardMultiSigKeys is the maximum number of public keys allowed // in a multi-signature transaction output script for it to be