Stack: c:pk_h(030500...)
Bowfish opened this issue · comments
I'm trying to create a raw transaction. There is something wrong with the transaction I created, but I'm not able to figure out what.
I run btcdeb with this options:
btcdeb --tx=010000000116402fe74ebc194f15f19ca11c5d49266608b024363c0b077a17c02bee4d1d82000000008b483045022100d15f16b3d27295a78cd3b51d0076e2267f4c13137ddae2bda21ad125e7f2f07a02207fb126e311e06da096e1ee281dd2cbf34a1d76f5b0b204bd7c26d4f3bbba7bd40141045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992ffffffff02404b4c00000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488acf0e1ad02000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888ac00000000 --txin=0200000001602e636f316b16fc4bc0a966d71b0958b1f6104d93477672b7a836db4a357d95000000006a47304402201ff42f44fcd505e037c01605448641750bc99a3567a1c27ec330517491e25bb0022031faef6084ea2e7c9539e213e5c63caa41926492e3e5271064201b8d3f54ed2a012102b6c09f33d3cf812b01924877415f05135a20f0cdaaf35c75cf2e37e7c17480aafeffffff0280f0fa02000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888ac28f00a2701000000160014596b304f8ae291f6f588bc6759d8218d4cb478e87000000
and this is the initial state when btcdeb starts:
btcdeb 0.2.19 -- type `btcdeb -h` for start up options
got transaction e1dff72b80938b65dd4d97268971d3c33ce98ac3d1604818038795d5e64ff84f:
CTransaction(hash=e1dff72b80, ver=1, vin.size=1, vout.size=2, nLockTime=0)
CTxIn(COutPoint(821d4dee2b, 0), scriptSig=483045022100d15f16b3d272)
CScriptWitness()
CTxOut(nValue=0.05000000, scriptPubKey=76a91459fe1a9f9f0a5af33396c599)
CTxOut(nValue=0.44950000, scriptPubKey=76a914814a2c0bb0d155667341be55)
got input tx #0 821d4dee2bc0177a070b3c3624b0086626495d1ca19cf1154f19bc4ee72f4016:
CTransaction(hash=821d4dee2b, ver=2, vin.size=1, vout.size=2, nLockTime=112)
CTxIn(COutPoint(957d354adb, 0), scriptSig=47304402201ff42f44fcd505, nSequence=4294967294)
CScriptWitness()
CTxOut(nValue=0.50000000, scriptPubKey=76a914814a2c0bb0d155667341be55)
CTxOut(nValue=49.49995560, scriptPubKey=0014596b304f8ae291f6f588bc6759)
input tx index = 0; tx input vout = 0; value = 50000000
unknown key ID 814a2c0bb0d155667341be55633e7351a7d5c578: returning fake key
8 op script loaded. type `help` for usage information
script | stack
-------------------------------------------------------------------+-------------------------------------------------------------------
3045022100d15f16b3d27295a78cd3b51d0076e2267f4c13137ddae2bda21ad... | c:pk_h(03050000000000000000000000000000000000000000000000000000...
045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af... |
<<< scriptPubKey >>> |
OP_DUP |
OP_HASH160 |
814a2c0bb0d155667341be55633e7351a7d5c578 |
OP_EQUALVERIFY |
OP_CHECKSIG |
#0000 3045022100d15f16b3d27295a78cd3b51d0076e2267f4c13137ddae2bda21ad125e7f2f07a02207fb126e311e06da096e1ee281dd2cbf34a1d76f5b0b204bd7c26d4f3bbba7bd401
Why is there c:pk_h(03050000000000000000000000000000000000000000000000000000...
on the stack and what does it it mean?
What is wrong with my transaction?
I get an error when I try your line above; you may have missed copy-pasting all of it as it seems btcdeb expects more data.
The c:pk_h(...) part is simply trying to display your transaction as a Miniscript representation. I'll see if I can clarify that (maybe put the item at the bottom instead of the top...).
Try stepping and it should show you items being put on the stack as usual.
Yeah, verified in bitcoin-cli:
$ bitcoin-cli -datadir=x -regtest decoderawtransaction 0200000001602e636f316b16fc4bc0a966d71b0958b1f6104d93477672b7a836db4a357d95000000006a47304402201ff42f44fcd505e037c01605448641750bc99a3567a1c27ec330517491e25bb0022031faef6084ea2e7c9539e213e5c63caa41926492e3e5271064201b8d3f54ed2a012102b6c09f33d3cf812b01924877415f05135a20f0cdaaf35c75cf2e37e7c17480aafeffffff0280f0fa02000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888ac28f00a2701000000160014596b304f8ae291f6f588bc6759d8218d4cb478e87000000
error code: -22
error message:
TX decode failed
There was a missing '00'. Adding it let me see your tx. It does fail on the checksig part, though.
If you do DEBUG_SIGNING=1 DEBUG_SIGHASH=1 btcdeb [...]
you get this:
#0007 OP_CHECKSIG
btcdeb> step
GenericTransactionSignatureChecker::CheckSig(72 len sig, 65 len pubkey, sigversion=0)
sig = 3045022100d15f16b3d27295a78cd3b51d0076e2267f4c13137ddae2bda21ad125e7f2f07a02207fb126e311e06da096e1ee281dd2cbf34a1d76f5b0b204bd7c26d4f3bbba7bd401
pub key = 045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992
script code = 76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac
hash type = 01 (SIGHASH_ALL)
SignatureHash(nIn=0, nHashType=01, amount=50000000)
- sigversion = SIGVERSION_BASE (non-segwit style)
Serializing transaction
<< txTo.nVersion (00000001)
#004 01000000
<< nInputs = 1 [compact]
#001 01
(serialize input 0)
<< txTo.vin[nInput=0].prevout = COutPoint(821d4dee2b, 0)
#032 16402fe74ebc194f15f19ca11c5d49266608b024363c0b077a17c02bee4d1d82
#004 00000000
(SerializeScriptCode)
<< scriptCode.size()=25 - nCodeSeparators=0
#001 19
<< script:76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac
#025 76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac
<< txTo.vin[nInput].nSequence = 4294967295 [0xffffffff]
#004 ffffffff
<< nOutputs = 2 [compact]
#001 02
(serialize output 0)
#008 404b4c0000000000
#001 19
#025 76a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac
(serialize output 1)
#008 f0e1ad0200000000
#001 19
#025 76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac
<< txTo.nLockTime = 0 [0x0]
#004 00000000
#004 01000000
sighash = 779302f71255f26c5c1734d7305d0ad80f78bee5b038c82b3109c1d02bbf22ec
pubkey.Verify(sig=3045022100d15f16b3d27295a78cd3b51d0076e2267f4c13137ddae2bda21ad125e7f2f07a02207fb126e311e06da096e1ee281dd2cbf34a1d76f5b0b204bd7c26d4f3bbba7bd4, sighash=779302f71255f26c5c1734d7305d0ad80f78bee5b038c82b3109c1d02bbf22ec):
result: FAILURE
- failed: VerifySignature() failed
error: Signature must be zero for failed CHECK(MULTI)SIG operation
btcdeb>
Not sure what's wrong there, but maybe you can spot the problem yourself?