Skip to content

Unable to convert value to a Python type when accessing wrapped_script in P2SH #53

@cpsola

Description

@cpsola

Whenever I try to access the wrapped_script of a P2SH input I obtain this error:

TypeError: Unable to convert function return value to a Python type! The signature was
(arg0: blocksci.blocksci_interface.PayToScriptHashScript) -> Optional[blocksci::AnyScript]

I'm not sure if I am doing something wrong or this is a bug in Blocksci's code.

For instance, this code generates the abovementioned error:

tx0 = blocksci.Tx("e5779b9e78f9650debc2893fd9636d827b26b4ddfa6a8172fe8708c924f5c39d")
for txin in tx0.ins:
    print(txin.address_type)
    print(txin.address.script)
    print(txin.address.script.wrapped_script)

The result of executing the code is:

Pay to script hash
P2SHAddress(address=37paP4uTjmA4Pi85LG6CF9huift3Dw1kFT, wrappedAddress=NonStandardScript())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-115-1d098e8f187e> in <module>()
      5     print(txin.address.script)
----> 6     print(txin.address.script.wrapped_script)

TypeError: Unable to convert function return value to a Python type! The signature was
	(arg0: blocksci.blocksci_interface.PayToScriptHashScript) -> Optional[blocksci::AnyScript]

So it correctly prints the address_type and script, but fails to show the wrapped script. This also happens with multisig scripts encapsulated in P2SH (not only with non standard ones).

The input of transaction e5779... is spending a P2SH output (the second output of this transaction). The redeem script used to spent the output is PUSHDATA(2)[5357], which is what I am trying to recover.

BTW, the tool is great to explore blockchain data, thanks for making it publicly available!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions