chainside / btcpy

A Python3 SegWit-compliant library which provides tools to handle Bitcoin data structures in a simple fashion.
https://www.chainside.net
GNU Lesser General Public License v3.0
271 stars 74 forks source link

Type of multisig is error! #33

Closed zzir closed 6 years ago

zzir commented 6 years ago

chainside-btcpy (0.3.3)

height: 232023 txid: 701b8cc6652deadd9cfcbfb0ec8da6f957f8dd36c7184af8e2235bd2958a877f


code:

from pprint import pprint
from btcpy.structs.transaction import Transaction

tx = Transaction.unhexlify("01000000017adceb45e0b9d2107145908de1c3f2ca8a764464466823b7967ff8c348971582000000004a0048304502201282a86d2512b5e8ccbe869e8d030178ab57a176c428eefe6e74ec86255c7f80022100d63c9e0a80859afbb432d508642d504802e8a86cab285e454d6d009f7cd4afcc01ffffffff0145df6e0500000000475121037953dbf08030f67352134992643d033417eaa6fcfb770c038f364ff40d7615882100e8f87dd9d24c3a2f102a5a8276c4a8f58176c961dada423b61063a312b7c270e52ae568a0300")
for out in tx.outs:
    pprint(out.to_json())

output:

Type is "nonstandard".

{'n': 0,
 'scriptPubKey': {'asm': 'OP_1 '
                         '037953dbf08030f67352134992643d033417eaa6fcfb770c038f364ff40d761588 '
                         '00e8f87dd9d24c3a2f102a5a8276c4a8f58176c961dada423b61063a312b7c270e '
                         'OP_2 OP_CHECKMULTISIG',
                  'hex': '5121037953dbf08030f67352134992643d033417eaa6fcfb770c038f364ff40d7615882100e8f87dd9d24c3a2f102a5a8276c4a8f58176c961dada423b61063a312b7c270e52ae',
                  'type': 'nonstandard'},
 'value': '0.91152197'}

Then the output of Bitcoin-cli

Type is "multisig"!

"vout": [
    {
      "value": 0.91152197,
      "n": 0,
      "scriptPubKey": {
        "asm": "1 037953dbf08030f67352134992643d033417eaa6fcfb770c038f364ff40d761588 00e8f87dd9d24c3a2f102a5a8276c4a8f58176c961dada423b61063a312b7c270e 2 OP_CHECKMULTISIG",
        "hex": "5121037953dbf08030f67352134992643d033417eaa6fcfb770c038f364ff40d7615882100e8f87dd9d24c3a2f102a5a8276c4a8f58176c961dada423b61063a312b7c270e52ae",
        "reqSigs": 1,
        "type": "multisig",
        "addresses": [
          "13MH4zmU4UT4Ct6BhoRFGjigC8gN9a9FNn"
        ]
      }
    }
  ]
SimoneBronzini commented 6 years ago

Thanks a lot for pointing this out. Looking into it right now!

SimoneBronzini commented 6 years ago

The problem there is that one of the two pubkeys in the multisig script starts with 0x00, which is an invalid prefix for Bitcoin pubkeys. We need to decide whether a multisig script (by the way, also P2PK scripts can suffer from this) should still be considered a multisig even if the keys it includes are invalid.