Post
Topic
Board Development & Technical Discussion
Re: Using Pycoin to spend non-standard scripts
by
d4n13
on 21/07/2015, 04:07:50 UTC
Maybe we can work on this Tx: http://test.webbtc.com/tx/2e7f518ce5ab61c1c959d25e396bc9d3d684d22ea86dc477b1a90329c6ca354f

I've set up the script like this:

Code:
OP_IF
0330ed33784ee1891122bc608b89da2da45194efaca68564051e5a7be9bee7f63f
OP_CHECKSIGVERIFY
OP_ELSE
80bf07
OP_NOP2
OP_DROP
OP_ENDIF
042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9
OP_CHECKSIG

So its a master key, which is sha256("master"*42)

How would I use pybitcointools to spend this script?

Nb script:
Code:
myscript = "63210330ed33784ee1891122bc608b89da2da45194efaca68564051e5a7be9bee7f63fad670380bf07b1756841042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9ac"

I was working on a cleaner implementation... but got pulled away tonight...

Basically you have to override
Code:
sign(tx,i,priv,hashcode)
You want to change line 341 of transaction.py so that it accepts an input script.  You need to feed it the scriptPubKey of the UTXO you are spending.
Code:
   signing_tx = signature_form(tx, i, '', hashcode)

Then you need to sign the transaction with pubkey 042d...d17c, and copy the sig into "sig1", then sign the transaction with pubkey 0330...f63f, and copy the sig into "sig2".  

Finally your non-standard scriptSig is:
Code:

I've done it on the "Hello World" example I did above, but the code is kinda ugly.

Let me clean it up and I'll write a pybitcointools implementation to spend the coin.