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

btcdeb not work for P2SH puzzle transaction, show unexpected stack info. #14

Closed
passionofvc opened this issue Jun 17, 2018 · 4 comments
Closed

Comments

@passionofvc
Copy link

hi @kallewoof
I create a puzzle P2SH output and make a transaction to redeem it.
the redeemScript is just 93016387, and scriptPubKey is [OP_HASH160 hash160(93016387) OP_EQUAL]=(a9143f58b4f7b14847a9083694b9b3b52a4cea2569ed87)
and spend it also just send back to itself.


#redeemScript
  93     01     63      87
  OP_ADD 1Byte  int:99  OP_EQUAL

#scriptSig
  51  01 62    04   93  01  63  87
  

because this is not normal transaction, and can not create by signrawtransaction bitcoin core cli,
I create by python https://github.com/passionofvc/raw-tx-tool/blob/master/P2SH/redeem_P2SH.py
and broatcast to testnet
https://live.blockcypher.com/btc-testnet/tx/e8a9df4f3b5f5ff454ab96083fca8f8375359df26051ef2831bbc07e93788b27/

./btcdeb --tx=0100000001e2d4fe69fbfa62beac61da2a07ae84d96e3e1c14cdee348cf3c84efd20eda37d00000000085101620493016387ffffffff0160ceab070000000017a9143f58b4f7b14847a9083694b9b3b52a4cea2569ed8700000000 --txin=02000000019729eadf29e14ea589a2ebc7a2341b7d8abcdfe321c253d3234316e76369bc8c000000006a4730440220562f08fb8da9449d69a20ea9009a5f3372c2c01f57072593bceced7dfb10e88902204cf3d2ceff3b4537dad9e06fde49f58d2e02ad10c6786dd867ca65d94fd5f40d01210396a4b78bd85494a32e7189cd597fc4d3f6ad4e8cfc76356eec7339bdd0a9efdbffffffff010055ad070000000017a9143f58b4f7b14847a9083694b9b3b52a4cea2569ed8700000000

btcdeb -- type `./btcdeb -h` for start up options
got transaction:
CTransaction(hash=e8a9df4f3b, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(7da3ed20fd, 0), scriptSig=5101620493016387)
    CScriptWitness()
    CTxOut(nValue=1.28700000, scriptPubKey=a9143f58b4f7b14847a9083694b9b3)

got input tx #0:
CTransaction(hash=7da3ed20fd, ver=2, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(8cbc6963e7, 0), scriptSig=4730440220562f08fb8da944)
    CScriptWitness()
    CTxOut(nValue=1.28800000, scriptPubKey=a9143f58b4f7b14847a9083694b9b3)

input tx index = 0; tx input vout = 0; value = 128800000
warning: ambiguous input 51 is interpreted as a numeric value; use 0x51 to force into hexadecimal interpretation
warning: ambiguous input 62 is interpreted as a numeric value; use 0x62 to force into hexadecimal interpretation
warning: ambiguous input 93016387 is interpreted as a numeric value; use 0x93016387 to force into hexadecimal interpretation
3 op script loaded. type `help` for usage information
script                                   |   stack 
-----------------------------------------+---------
OP_HASH160                               | 43518b05
3f58b4f7b14847a9083694b9b3b52a4cea2569ed |       3e
OP_EQUAL                                 |       33
#0001 OP_HASH160

@kallewoof
Copy link
Member

This should now work correctly as of latest master.

Would you mind double checking and closing the issue if things seem to be correct?

@passionofvc
Copy link
Author

hi @kallewoof
very thanks!, It’s work!


script                                   |   stack 
-----------------------------------------+---------
OP_HASH160                               | 93016387
3f58b4f7b14847a9083694b9b3b52a4cea2569ed |       62
OP_EQUAL                                 |       01
#0001 OP_HASH160
btcdeb> step
		<> POP  stack
		<> PUSH stack 3f58b4f7b14847a9083694b9b3b52a4cea2569ed
script                                   |                                   stack 
-----------------------------------------+-----------------------------------------
3f58b4f7b14847a9083694b9b3b52a4cea2569ed | 3f58b4f7b14847a9083694b9b3b52a4cea2569ed
OP_EQUAL                                 |                                       62
                                         |                                       01
#0002 3f58b4f7b14847a9083694b9b3b52a4cea2569ed
btcdeb> step
		<> PUSH stack 3f58b4f7b14847a9083694b9b3b52a4cea2569ed
script                                   |                                   stack 
-----------------------------------------+-----------------------------------------
OP_EQUAL                                 | 3f58b4f7b14847a9083694b9b3b52a4cea2569ed
                                         | 3f58b4f7b14847a9083694b9b3b52a4cea2569ed
                                         |                                       62
                                         |                                       01
#0003 OP_EQUAL
btcdeb> step
		<> POP  stack
		<> POP  stack
		<> PUSH stack 01
script                                   |                                   stack 
-----------------------------------------+-----------------------------------------
                                         |                                       01
                                         |                                       62
                                         |                                       01
btcdeb> step
Drop-in P2SH redeem script
		<> POP  stack
Restoring stack:
- 01
- 62
Script:
- OP_ADD
- 63
- OP_EQUAL
script                                   |                                   stack 
-----------------------------------------+-----------------------------------------
OP_ADD                                   |                                       62
63                                       |                                       01
OP_EQUAL                                 | 
btcdeb> step
		<> POP  stack
		<> POP  stack
		<> PUSH stack 63
script                                   |                                   stack 
-----------------------------------------+-----------------------------------------
63                                       |                                       63
OP_EQUAL                                 | 
btcdeb> step
		<> PUSH stack 63
script                                   |                                   stack 
-----------------------------------------+-----------------------------------------
OP_EQUAL                                 |                                       63
                                         |                                       63
btcdeb> step
		<> POP  stack
		<> POP  stack
		<> PUSH stack 01
script                                   |                                   stack 
-----------------------------------------+-----------------------------------------
                                         |                                       01
btcdeb> step
script                                   |                                   stack 
-----------------------------------------+-----------------------------------------
                                         |                                       01
btcdeb> step
at end of script
btcdeb> 

@passionofvc
Copy link
Author

passionofvc commented Jun 19, 2018 via email

@kallewoof
Copy link
Member

Glad it works! Btw btcdeb will repeat the last command if you hit enter so you don't have to type out 'step' every time. ;)

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

2 participants