<p>FWIW, Output is redeemed in <code>61ba3a8b40706931b72929628cf1a07d604f158c8350055725c664d544d00030:0</code></p>

<p>Midstate for sighash :</p>

<pre><code>02000000
01
  D4B9E8EC436BDF27164DF27C7C3609024500D049037940513C94DAC8D3A999ED
  01000000
  58
    76 A9 14 23DFC9AD6D857C92AD2B99004354067492CF464C 88 AD
    63
      76 A9 14 FD00F9FD452FEE2214E8B0F9ACF4C53496BD5636 88 AC
    67
      AA 20 0757152190E14E5889B1270309D7C8E40219D45E04096FCB97D1B4C5A99064E1 87
    68
  FDFFFFFF
01
  006EBE0000000000
  19
  76 A9 14 4F2465FEC27AD88917C9FCB72B09ADE39B8911ED 88 AC
6C3C1300
01000000
</code></pre>

<p>Redeemed by scriptsig :</p>

<pre><code>04 12345678
00
47
  30
  44
    02
    20 71B0D6894AE2252BD67F8D9882C814A2A59E1C7AE8B8F1117DB17A484538833A
    02
    20 680F44F3150B652C49B6523EFF5E750D460F3306ED669835DB7C3095596211BF
  01
41
  049343773D05D5A07F103914D5294CA742DB124BABD2C2CAC5F84E6114F192F07C1E44C956C737A60369FBF4F5E6324DC005BA38D156F61232F9251FEC8EE3E262
</code></pre>

CC BY-SA 3.0
2018-01-26T12:49:34.377Z
2018-01-26T12:49:34.377Z
arubi
<p>I <a href="https://bitcoin.stackexchange.com/questions/36496/how-to-redeem-non-standard-script-tx-testnet-instance">recently posted</a> this <a href="http://test.webbtc.com/script/2d0daa01da8294a54178f8111eb2a02010c425fd15957d8baee8717edcfbe105:0" rel="nofollow noreferrer">Testnet TX</a> (TxID 2d0daa01da8294a54178f8111eb2a02010c425fd15957d8baee8717edcfbe105) which successfully spends <a href="http://test.webbtc.com/tx/8d897ca91774a7fafa086a3275e679248d6bffee015d3b2efefd5dab00df152d.json" rel="nofollow noreferrer">an output</a> (TxID 8d897ca91774a7fafa086a3275e679248d6bffee015d3b2efefd5dab00df152d) of form:</p>

<pre><code>OP_DUP OP_HASH160 ##HASH160_KEY1## OP_EQUALVERIFY OP_CHECKSIGVERIFY OP_IF OP_DUP OP_HASH160 ##HASH160_KEY1## OP_EQUALVERIFY OP_CHECKSIG OP_ELSE OP_HASH256 ##HASH256_OF_SECRET## OP_EQUAL OP_ENDIF
</code></pre>

<p>Where <code>##HASH256_OF_SECRET##</code> is <code>sha256(sha256(3ceb50edd0282cd99dc59351f513dcdf))</code> and <code>##HASH160_KEYx##</code> is the <code>ripemd160(sha256(public key n))</code>.</p>

<p>I have been trying for days using Python (pybitcointools library, Pycoin library, raw tx construction) and Bitcoincore, however I consistently cannot duplicate the Tx myself.</p>

<hr>

<p><strong><em>EDIT</em></strong>: added keys, code</p>

<p>Here's a duplicated Tx on Testnet: <a href="https://blockexplorer.com/testnet/rawtx/ed99a9d3c8da943c5140790349d000450209367c7cf24d1627df6b43ece8b9d4" rel="nofollow noreferrer">ed99a9d3c8da943c5140790349d000450209367c7cf24d1627df6b43ece8b9d4:1</a></p>

<p>Keys (from pycoin):</p>

<pre><code>input                        : 98a6776b00481d69147af4f19982816d24b21f1e45bd6b9b6612969a805dff5d
network                      : Bitcoin testnet3
netcode                      : XTN
secret exponent              : 69045673789968930636498185430340997034503775217197653543201755869784347377501
 hex                         : 98a6776b00481d69147af4f19982816d24b21f1e45bd6b9b6612969a805dff5d
wif                          : cShS7YocDNMfpxHPd1iWbXX6eTFPQoNTJSw6W4sQY5BVimvvw6FY
 uncompressed                : 92k9QgqAnrFCWtwvA4neyJnngkZG3g43ne9BJuzBmeeirPHXtu3
public pair x                : 66609190448066768097937392847179714582119540337817974512409209527265330917500
public pair y                : 13690920648454078566739109880631240403596673427366917192400893160542072726114
 x as hex                    : 9343773d05d5a07f103914d5294ca742db124babd2c2cac5f84e6114f192f07c
 y as hex                    : 1e44c956c737a60369fbf4f5e6324dc005ba38d156f61232f9251fec8ee3e262
y parity                     : even
key pair as sec              : 029343773d05d5a07f103914d5294ca742db124babd2c2cac5f84e6114f192f07c
 uncompressed                : 049343773d05d5a07f103914d5294ca742db124babd2c2cac5f84e6114f192f07c\
                                 1e44c956c737a60369fbf4f5e6324dc005ba38d156f61232f9251fec8ee3e262
hash160                      : fd00f9fd452fee2214e8b0f9acf4c53496bd5636
 uncompressed                : 23dfc9ad6d857c92ad2b99004354067492cf464c
Bitcoin address              : n4aiRSJEm2gT9QrZTFJ7DJy3KPGnDHxybf
Bitcoin address uncompressed : mine2pMKAyoA6CBimPd1ZdFVi5kvhTM7TT

script = 76a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ad6376a914e900510876cb689f1db6fa982376c301362b740c88ac67aa20644d79d87e0907833e888e272e5d7b925deb261a8499a65cbc0bf26797a15e8e8768

[118, 169, '23dfc9ad6d857c92ad2b99004354067492cf464c', 136, 173, 99, 118, 169, 'fd00f9fd452fee2214e8b0f9acf4c53496bd5636', 136, 172, 103, 170, '0757152190e14e5889b1270309d7c8e40219d45e04096fcb97d1b4c5a99064e1', 135, 104]

*mysecret* = '12345678'.decode('hex')
sha256(sha256(*mysecret*)) == 0757152190e14e5889b1270309d7c8e40219d45e04096fcb97d1b4c5a99064e1
</code></pre>

<hr>

<p><strong>I'm looking for a working guide on constructing a Testnet <em></strong>&amp;<strong></em> P2SH Tx which utilises Boolean scripting. Specifically:</strong></p>

<ol>
<li>A working testnet example of the question posed above <a href="https://bitcoin.stackexchange.com/questions/36496/how-to-redeem-non-standard-script-tx-testnet-instance">(detailed further here)</a> (I'll offer a bounty for this)</li>
<li>Constructing a multisig Tx of form: <code>(1 KEY1 KEY2 2 CHECKMULTISIG) OR MASTERKEY</code></li>
</ol>

CC BY-SA 3.0
2015-06-23T22:57:23.157Z
Just a quick question: are you checking the output number in the transaction you are spending? It seems strange you can reproduce the transaction only at times.Your successful transaction in "prev_out": has  "n": 1 but the output number in the previous transaction is likely to be different each time. How do you create the transaction? With bitcoin-cli createrawtransaction?
halftimepad
CC BY-SA 3.0
2015-06-24T01:13:36.537Z
@halftimepad both pybitcointools and Bitcoin core
Wizard Of Ozzie
CC BY-SA 3.0
2015-06-24T07:45:02.747Z
Do you have at hand the hex raw transaction for one case where you could reproduce the transaction and for one where you couldn't? With that I can tell you if it is a problem with the output number.
halftimepad
CC BY-SA 3.0
2015-06-25T01:41:37.430Z
@halftimepad sounds good, I'll check my iPython logs
Wizard Of Ozzie
CC BY-SA 3.0
2017-03-16T12:20:44.257Z
@wizard-of-ozzie its been a while since you asked, do you still need help with the issue?
sr_gi
<development><script><testnet><raw-transaction><multi-signature>
Working example of raw transaction utilising Boolean (OP_IF, OP_ENDIF) scripting REQUIRED
Wizard Of Ozzie
# Working example of raw transaction utilising Boolean (OP_IF, OP_ENDIF) scripting REQUIRED

(Asked by: username_0 on 2015-03-23)

I recently posted this Testnet TX (TxID 2d0daa01da8294a54178f8111eb2a02010c425fd15957d8baee8717edcfbe105) which successfully spends an output (TxID 8d897ca91774a7fafa086a3275e679248d6bffee015d3b2efefd5dab00df152d) of form:
OP_DUP OP_HASH160 ##HASH160_KEY1## OP_EQUALVERIFY OP_CHECKSIGVERIFY OP_IF OP_DUP OP_HASH160 ##HASH160_KEY1## OP_EQUALVERIFY OP_CHECKSIG OP_ELSE OP_HASH256 ##HASH256_OF_SECRET## OP_EQUAL OP_ENDIF

Where ##HASH256_OF_SECRET## is sha256(sha256(3ceb50edd0282cd99dc59351f513dcdf)) and ##HASH160_KEYx## is the ripemd160(sha256(public key n)).
I have been trying for days using Python (pybitcointools library, Pycoin library, raw tx construction) and Bitcoincore, however I consistently cannot duplicate the Tx myself.

EDIT: added keys, code
Here's a duplicated Tx on Testnet: ed99a9d3c8da943c5140790349d000450209367c7cf24d1627df6b43ece8b9d4:1
Keys (from pycoin):
input                        : 98a6776b00481d69147af4f19982816d24b21f1e45bd6b9b6612969a805dff5d
network                      : Bitcoin testnet3
netcode                      : XTN
secret exponent              : 69045673789968930636498185430340997034503775217197653543201755869784347377501
 hex                         : 98a6776b00481d69147af4f19982816d24b21f1e45bd6b9b6612969a805dff5d
wif                          : cShS7YocDNMfpxHPd1iWbXX6eTFPQoNTJSw6W4sQY5BVimvvw6FY
 uncompressed                : 92k9QgqAnrFCWtwvA4neyJnngkZG3g43ne9BJuzBmeeirPHXtu3
public pair x                : 66609190448066768097937392847179714582119540337817974512409209527265330917500
public pair y                : 13690920648454078566739109880631240403596673427366917192400893160542072726114
 x as hex                    : 9343773d05d5a07f103914d5294ca742db124babd2c2cac5f84e6114f192f07c
 y as hex                    : 1e44c956c737a60369fbf4f5e6324dc005ba38d156f61232f9251fec8ee3e262
y parity                     : even
key pair as sec              : 029343773d05d5a07f103914d5294ca742db124babd2c2cac5f84e6114f192f07c
 uncompressed                : 049343773d05d5a07f103914d5294ca742db124babd2c2cac5f84e6114f192f07c\
                                 1e44c956c737a60369fbf4f5e6324dc005ba38d156f61232f9251fec8ee3e262
hash160                      : fd00f9fd452fee2214e8b0f9acf4c53496bd5636
 uncompressed                : 23dfc9ad6d857c92ad2b99004354067492cf464c
Bitcoin address              : n4aiRSJEm2gT9QrZTFJ7DJy3KPGnDHxybf
Bitcoin address uncompressed : mine2pMKAyoA6CBimPd1ZdFVi5kvhTM7TT

script = 76a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ad6376a914e900510876cb689f1db6fa982376c301362b740c88ac67aa20644d79d87e0907833e888e272e5d7b925deb261a8499a65cbc0bf26797a15e8e8768

[118, 169, '23dfc9ad6d857c92ad2b99004354067492cf464c', 136, 173, 99, 118, 169, 'fd00f9fd452fee2214e8b0f9acf4c53496bd5636', 136, 172, 103, 170, '0757152190e14e5889b1270309d7c8e40219d45e04096fcb97d1b4c5a99064e1', 135, 104]

*mysecret* = '12345678'.decode('hex')
sha256(sha256(*mysecret*)) == 0757152190e14e5889b1270309d7c8e40219d45e04096fcb97d1b4c5a99064e1


I'm looking for a working guide on constructing a Testnet & P2SH Tx which utilises Boolean scripting. Specifically:

A working testnet example of the question posed above (detailed further here) (I'll offer a bounty for this)
Constructing a multisig Tx of form: (1 KEY1 KEY2 2 CHECKMULTISIG) OR MASTERKEY

**Tags:** development, script, testnet, raw-transaction, multi-signature

> **Comments:**
> **username_1**: Just a quick question: are you checking the output number in the transaction you are spending? It seems strange you can reproduce the transaction only at times.Your successful transaction in "prev_out": has  "n": 1 but the output number in the previous transaction is likely to be different each time. How do you create the transaction? With bitcoin-cli createrawtransaction?  
> **username_0**: @username_1 both pybitcointools and Bitcoin core  
> **username_1**: Do you have at hand the hex raw transaction for one case where you could reproduce the transaction and for one where you couldn't? With that I can tell you if it is a problem with the output number.  
> **username_0**: @username_1 sounds good, I'll check my iPython logs  
> **username_2**: @wizard-of-ozzie its been a while since you asked, do you still need help with the issue?  

---

## 1 answers

### Answer by username_3 on 2018-01-26. Score: 1

FWIW, Output is redeemed in 61ba3a8b40706931b72929628cf1a07d604f158c8350055725c664d544d00030:0
Midstate for sighash :
02000000
01
  D4B9E8EC436BDF27164DF27C7C3609024500D049037940513C94DAC8D3A999ED
  01000000
  58
    76 A9 14 23DFC9AD6D857C92AD2B99004354067492CF464C 88 AD
    63
      76 A9 14 FD00F9FD452FEE2214E8B0F9ACF4C53496BD5636 88 AC
    67
      AA 20 0757152190E14E5889B1270309D7C8E40219D45E04096FCB97D1B4C5A99064E1 87
    68
  FDFFFFFF
01
  006EBE0000000000
  19
  76 A9 14 4F2465FEC27AD88917C9FCB72B09ADE39B8911ED 88 AC
6C3C1300
01000000

Redeemed by scriptsig :
04 12345678
00
47
  30
  44
    02
    20 71B0D6894AE2252BD67F8D9882C814A2A59E1C7AE8B8F1117DB17A484538833A
    02
    20 680F44F3150B652C49B6523EFF5E750D460F3306ED669835DB7C3095596211BF
  01
41
  049343773D05D5A07F103914D5294CA742DB124BABD2C2CAC5F84E6114F192F07C1E44C956C737A60369FBF4F5E6324DC005BA38D156F61232F9251FEC8EE3E262


---

