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

PSBT Taproot Input Validation Issue #1934

Closed
timechainz opened this issue Jun 7, 2023 · 3 comments · Fixed by #1935
Closed

PSBT Taproot Input Validation Issue #1934

timechainz opened this issue Jun 7, 2023 · 3 comments · Fixed by #1935

Comments

@timechainz
Copy link

Hello again,

I have updated to 6.1.2 and am now seeing some new input validation errors on known valid inputs. I have included an example which was signed in bitcoin-cli

bitcoin-cli walletprocesspsbt "{unsigned}" true "SINGLE|ANYONECANPAY" false false

which results in the following signed psbt:

{
  "tx": {
    "txid": "4810ff15141bd2d7fca4dc4e8fc2f361c716d721f2e221889a2639459d180fc4",
    "hash": "4810ff15141bd2d7fca4dc4e8fc2f361c716d721f2e221889a2639459d180fc4",
    "version": 2,
    "size": 94,
    "vsize": 94,
    "weight": 376,
    "locktime": 0,
    "vin": [
      {
        "txid": "59edb28a4c0c6a9fb319ae6f4e8d5f979b44e786fa127ad012d1eeda83cd944e",
        "vout": 0,
        "scriptSig": {
          "asm": "",
          "hex": ""
        },
        "sequence": 4294967295
      }
    ],
    "vout": [
      {
        "value": 9.90000000,
        "n": 0,
        "scriptPubKey": {
          "asm": "1 2252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6",
          "desc": "rawtr(2252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6)#tfj37s9y",
          "hex": "51202252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6",
          "address": "bc1pyffrxlgln72gtxz0y7cqlkl76n0nsghxm8lm4g82s8jkp0806knqclmd55",
          "type": "witness_v1_taproot"
        }
      }
    ]
  },
  "global_xpubs": [
  ],
  "psbt_version": 0,
  "proprietary": [
  ],
  "unknown": {
  },
  "inputs": [
    {
      "witness_utxo": {
        "amount": 0.00010000,
        "scriptPubKey": {
          "asm": "1 2252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6",
          "desc": "rawtr(2252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6)#tfj37s9y",
          "hex": "51202252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6",
          "address": "bc1pyffrxlgln72gtxz0y7cqlkl76n0nsghxm8lm4g82s8jkp0806knqclmd55",
          "type": "witness_v1_taproot"
        }
      },
      "non_witness_utxo": {
        "txid": "59edb28a4c0c6a9fb319ae6f4e8d5f979b44e786fa127ad012d1eeda83cd944e",
        "hash": "59edb28a4c0c6a9fb319ae6f4e8d5f979b44e786fa127ad012d1eeda83cd944e",
        "version": 1,
        "size": 94,
        "vsize": 94,
        "weight": 376,
        "locktime": 0,
        "vin": [
          {
            "txid": "5d54d7f8e1c17bcf29e5765ab0f40af873a55313c50245ec7eba41427c9afff1",
            "vout": 0,
            "scriptSig": {
              "asm": "",
              "hex": ""
            },
            "sequence": 4294967293
          }
        ],
        "vout": [
          {
            "value": 0.00010000,
            "n": 0,
            "scriptPubKey": {
              "asm": "1 2252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6",
              "desc": "rawtr(2252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6)#tfj37s9y",
              "hex": "51202252337d1f9f9485984f27b00fdbfed4df3822e6d9ffbaa0ea81e560bcefd5a6",
              "address": "bc1pyffrxlgln72gtxz0y7cqlkl76n0nsghxm8lm4g82s8jkp0806knqclmd55",
              "type": "witness_v1_taproot"
            }
          }
        ]
      },
      "sighash": "SINGLE|ANYONECANPAY",
      "taproot_key_path_sig": "643034e6a8dd130e0563ee010f48a61ed0ce4e3b32fae84c76c9478f4cc4a26643a85f8596b9c1556b74a61e6b9056fe5a2a6bb6a5da961864c946bdd4b4eb0383",
      "taproot_internal_key": "8ee617c48a7238c553604be5df980389d0a6fef508099cae34d64a68fcfd7710"
    }
  ],
  "outputs": [
    {
      "taproot_internal_key": "8ee617c48a7238c553604be5df980389d0a6fef508099cae34d64a68fcfd7710"
    }
  ],
  "fee": -9.89990000
}

Sparrow Wallet also confirms this is a valid signature. However, bitcoinjs-lib appears to fail in the validator. I have created a test case which demonstrates this.

https://github.com/timechainz/bitcoinjs-lib-psbt-validation/blob/db3d3bd20f57a89f58f59fa78d641001c6f50fcc/validate-taproot-input.js#LL33C1-L33C1

Any ideas would be appreciated. Thanks!

@junderw
Copy link
Member

junderw commented Jun 7, 2023

Thank you for the new example of a valid signature in the PSBT.

The fix was larger than anticipated, so validating signatures is going to be broken until I can straighten things out.

See the PR for details.

@timechainz
Copy link
Author

Thanks for the update @junderw! I really appreciate all you do for the project!

@junderw
Copy link
Member

junderw commented Jun 9, 2023

Published as 6.1.3

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

Successfully merging a pull request may close this issue.

2 participants