Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign p2sh multisig not working #81

Closed
rubensayshi opened this issue Feb 17, 2015 · 3 comments
Closed

Sign p2sh multisig not working #81

rubensayshi opened this issue Feb 17, 2015 · 3 comments

Comments

@rubensayshi
Copy link
Contributor

I can't get signing of a multisig TX to work properly, it seems to me that the redeemscript is dumped when signing and the resulting txin.script is just the signatures without the redeem script ...

I might just be doing something wrong ...

I took the existing test case and trying to work that one out (I also sent a tiny amount of BTC to that address so we can test live ...)

Adding the following line at the end of test_sign_pay_to_script_multisig also throws an Exception.

print ScriptMultisig.from_script(tx2.txs_in[0].script)

spending real BTC:

    def test_sign_pay_to_script_multisig_live(self):
        N, M = 3, 3
        keys = [Key(secret_exponent=i) for i in range(1, M+2)]
        tx_in = TxIn.coinbase_tx_in(script=b'')
        underlying_script = ScriptMultisig(n=N, sec_keys=[key.sec() for key in keys[:M]]).script()
        address = address_for_pay_to_script(underlying_script)
        self.assertEqual(address, "39qEwuwyb2cAX38MFtrNzvq3KV9hSNov3q")
        script = standard_tx_out_script(address)
        tx_out = TxOut(1000000, script)
        tx1 = Tx(version=1, txs_in=[tx_in], txs_out=[tx_out])

        s = Spendable.from_dict(dict(
            coin_value=500000,
            script_hex=b2h(underlying_script),
            tx_hash_hex=b2h_rev(h2b("efdee0cb54de0aef77660b8766f39b7eab69c7d23ec0409709507750f460e587")),
            tx_out_index=0
        ))

        tx2 = tx_utils.create_tx([s], [address])
        hash160_lookup = build_hash160_lookup(key.secret_exponent() for key in keys[:M])
        p2sh_lookup = build_p2sh_lookup([underlying_script])
        tx2.sign(hash160_lookup=hash160_lookup, p2sh_lookup=p2sh_lookup)
        self.assertEqual(tx2.bad_signature_count(), 0)

        # this throws 'n value invalid'
        # print ScriptMultisig.from_script(tx2.txs_in[0].script)

        print tx2.as_hex()
@shayanb
Copy link
Contributor

shayanb commented Feb 17, 2015

What do you get in the output? I seem to have the same problem, check if this is relevant to your issue #76

@richardkiss
Copy link
Owner

Now that v0.62 has been released, is this issue resolved?

@richardkiss
Copy link
Owner

I'm going to close this issue, as p2sh signing is pretty solid these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants