Skip to content

p2tr script path: invalid script (witness stack last element)  #154

@panicfarm

Description

@panicfarm

I created and successfully mined a regtest network transaction that spent two p2tr script-path outputs. The scripts where 1 of 2 multisigs:

DESCRIPTOR_VOUT0="tr($UNSPENDABLE_BIP341,multi_a(1,0327adc7f1cde671f02a01e39b33754d480a42670f95f951d9fb72f84aee5d7878,021856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812))"
DESCRIPTOR_VOUT1="tr($UNSPENDABLE_BIP341,multi_a(1,028d8b9b2d93fd38c31005b05bc1c60e95cf5068a665360516685ce65d66819b86,021856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812))"

The transaction was accepted by the regtest network bitcoin-core 0.25 and successfully mined. Trying to verify it with btcdeb, I got invalid script (witness stack last element) error:

$btcdeb -s 0 --tx=020000000001027eed70a2a6f3fd1ed05972f7cc0aa245033d4e538c5d4928e027e292f262e3ff0000000000fdffffff7eed70a2a6f3fd1ed05972f7cc0aa245033d4e538c5d4928e027e292f262e3ff0100000000fdffffff0100e1f5050000000022512093f6840b7dd8f6abc80d9675b7e28b929519316b5c6be39695f149a085f5b661040040f409bf08c40e63732327150b2581cde3afdfb7e9038f8d47c92a5cfd6c5fd9fc7179695e4db11a4a86dbb113deac1a57e8b113a96e2b3736ff959709cd4bdef7462027adc7f1cde671f02a01e39b33754d480a42670f95f951d9fb72f84aee5d7878ac201856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812ba519c21c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0040040b5769e66e31556e49441fb2a9a39db7c3a20d5782670b43c7d6cf248d7ba87c50ebd9aa65815693f72b83cbc34e80ed4edb3a7ca06e32db6b2384166b0934a7c46208d8b9b2d93fd38c31005b05bc1c60e95cf5068a665360516685ce65d66819b86ac201856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812ba519c21c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000 --txin=02000000000103f8b9481805180ead77b0bb773b3b41e045f7288d937633d291928141faf967eb00000000910047304402203ddd89c6e9a680f2922bfcc197f34fb17e2ef601d74a43f6d30767aa52e5ac3d02203994e8f2e6c46de0a87be87c6636f367dec2bc35e1386d574143d39e351bba3a01475121024fddf183fad49c01d1d281f94e9d79ad286f6498347faf4b33bf5ad6bac1d1582103295d76c56065ee78e5a14174da0759f8bbbea5a4017bb38a2aa6842ac0cb56a252aefdfffffff8b9481805180ead77b0bb773b3b41e045f7288d937633d291928141faf967eb0100000000fdffffff3b85bc34f079df21cb1e4467235d9d07d3a5db23297e88f39ec162c624a8ebe60000000000fdffffff0300e1f505000000002251209e08466dc0201e1a4cf77640210dbfd986d99669b7d5b17e664d9f855e5c702c00e1f5050000000022512058da1e1524d3ccde9024fbc3ff89a47c470e0ea7ac54b8859229f32308f18d0800a3e111000000001976a914dba4f00c333269440e726c2138c098089cecf65488ac00030047304402205eebdfa5ca1a8afc86a3ece97e3cbcc7218dc1ded6067dbbcccd1ff94ecc62d50220673f189a048125bb7f0896659320cbfecc0f6b9487839752eade8d03233a1435016951210327adc7f1cde671f02a01e39b33754d480a42670f95f951d9fb72f84aee5d78782102eeb99fe49aa809e22a1fe636f6b4b03199bd69b227d91fc2bb5d9c2188e3eabc21021856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a81253ae0400473044022053622215fbb232eb89e37f2ed78f08f1ec12a764a513261763d505ab9cf4df1702201a6ce9c780c43b1a82913bd4e2817b264da2c9f9bfeaa16c7a42c00d3f878f6b0147304402201d1a484921b85886bc9f5e412ae6c8ea306747f8e4994c8f39a627e1db688b0d02203d9b188e2a90f6f2982025671702b72ce92ade4cdc62e175e502f62f8e346f720147522102eeb99fe49aa809e22a1fe636f6b4b03199bd69b227d91fc2bb5d9c2188e3eabc210351dc2689f37c6eb017e5815cb49e6de435f69c6df1910e817a370880b224a13d52ae00000000
btcdeb 5.0.24 -- type `btcdeb -h` for start up options
LOG: signing segwit taproot
notice: btcdeb has gotten quieter; use --verbose if necessary (this message is temporary)
input tx index = 0; tx input vout = 0; value = 100000000
got witness stack of size 4
34 bytes (v0=P2WSH, v1=taproot/tapscript)
Taproot commitment:
- control  = c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0
- program  = 9e08466dc0201e1a4cf77640210dbfd986d99669b7d5b17e664d9f855e5c702c
- script   = 2027adc7f1cde671f02a01e39b33754d480a42670f95f951d9fb72f84aee5d7878ac201856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812ba519c
- path len = 0
- p        = 50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0
- q        = 9e08466dc0201e1a4cf77640210dbfd986d99669b7d5b17e664d9f855e5c702c
- k        = 8ce7142d2b807fd784ca36efa908ebb2cce6a5b1a7145d8331242f054665a5ee          (tap leaf hash)
  (TapLeaf(0xc0 || 2027adc7f1cde671f02a01e39b33754d480a42670f95f951d9fb72f84aee5d7878ac201856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812ba519c))
invalid script (witness stack last element)

I tried to decode the tapscript with bitcoin-cli, and noticed that it was labeled "nonstandard" and that the keys that I put in the descriptors lost their parity prefixes and became x-only keys:

$ bitcoin-cli -regtest decodescript 2027adc7f1cde671f02a01e39b33754d480a42670f95f951d9fb72f84aee5d7878ac201856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812ba519c
{
  "asm": "27adc7f1cde671f02a01e39b33754d480a42670f95f951d9fb72f84aee5d7878 OP_CHECKSIG 1856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812 OP_CHECKSIGADD 1 OP_NUMEQUAL",
  "desc": "raw(2027adc7f1cde671f02a01e39b33754d480a42670f95f951d9fb72f84aee5d7878ac201856595019d8211e061b91911357cee2b9e683aa023a2744245fb05b7893a812ba519c)#jhjz42cq",
  "type": "nonstandard"
}

What is the reason for this invalid script (witness stack last element) error, while the transaction was accepted by the core v0.25 and mined successfully?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions