Comment for 15-of-15 p2sh script calculation is incorrect #4224

issue davecgh opened this issue on May 23, 2014
  1. davecgh commented at 5:41 PM on May 23, 2014: contributor

    As the title indicates, the comment for https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L516-L522 is incorrect. The final value of 1650 is fine because it has the buffer, but the math in the comments forgets to account for the script push which will need an OP_PUSHDATA2 + 2-bytes for the 513 script bytes.

    In particular the form is:

    OP_0 <15 signatures> OP_PUSHDATA2 <2 bytes len> [OP_15 <15 pubkeys> OP_15 OP_CHECKMULTISIG]

    (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627

  2. laanwj added the label Bug on May 25, 2014
  3. sipa commented at 12:44 PM on June 28, 2014: member

    You're right. The formula in comments seems to imply that a single-byte push suffices.

  4. fanquake referenced this in commit 675bcd5892 on Jun 28, 2014
  5. laanwj closed this on Jun 28, 2014

  6. petertodd commented at 11:03 PM on June 30, 2014: contributor

    Ha, good catch! I knew a few extra bytes would turn out to be a good idea.

  7. MathyV referenced this in commit cb47137cb5 on Nov 3, 2014
  8. reddink referenced this in commit d9c830ba32 on May 27, 2020
  9. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-26 09:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me