pycoin
pycoin copied to clipboard
Partial P2SH Transaction proposal Or just the signature
I am trying to figure the best way to partially sign a multi-sig P2SH transaction and just return the signature.
It looked at the test itest_sign_pay_to_script_multisig() to see if there was a way to modify that code to do it, but as far as I can tell it wants to solve for a completely signed transaction.
def testFullSignMultiSigP2SH(self):
"""
Test using pycoin to sign p2sh
"""
console.terse("{0}\n".format(self.testFullSignMultiSigP2SH.__doc__))
from pycoin.key import Key
from pycoin.tx import Tx, TxIn, TxOut, tx_utils
from pycoin.tx.pay_to import ScriptMultisig
from pycoin.tx.pay_to import (address_for_pay_to_script,
build_hash160_lookup, build_p2sh_lookup)
from pycoin.tx.TxOut import standard_tx_out_script
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])
tx2 = tx_utils.create_tx(tx1.tx_outs_as_spendable(), [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)
Any suggestions on how to use pycoin to just return a signature of a given p2sh transaction proposal?
This is now pretty easy to do now in master
... if you're still interested, let me know, and I can write a bit of sample code.
Sample code would be great! Thanks.