cmdruid / tapscript

A humble library for working with Tapscript and Bitcoin Transactions.

Home Page:https://www.npmjs.com/package/@cmdcode/tapscript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

non-mandatory-script-verify-flag (Witness program hash mismatch)

LightRider5 opened this issue · comments

I have this transaction created with tapscript according to the inscription example , decoded from hex:

{
    "addresses": [
        "tb1peetwkzdue9eey9at87d72ea98zw4yz62mq5j49w8utcf28z4w4dq49yt5z",
        "tb1pezwxd60p00laqcu6fvze0canaczel8rdh44u4yu5995xlczgk4asm3hksg"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": 1000,
    "hash": "1899989d5f95661d60b8b5de873252085043cb528fe75b32040169335790421d",
    "inputs": [
        {
            "addresses": [
                "tb1peetwkzdue9eey9at87d72ea98zw4yz62mq5j49w8utcf28z4w4dq49yt5z"
            ],
            "age": 2536373,
            "output_index": 1,
            "output_value": 20000,
            "prev_hash": "fa2418bba0a89052bb9f045ed3d9b509e58ffb8d76b3b05aa04b1e76dbc1204e",
            "script_type": "pay-to-taproot",
            "sequence": 4294967293,
            "witness": [
                "05cfdbc9641646e51b61dac7ace4436748429004b6e44affbbcbb303126f0ef8a274b4d9d6fcabd3f0eb1b44f9b1e9f6e00b34a218caae4d73d7b50bbcde014e",
                "21021344f6fb0eb5b4ad25dc7db247573e92a1bd2f342317db3e931972434fb9b542ac0063036f7264010118746578742f706c61696e3b636861727365743d7574662d38000068",
                "c11344f6fb0eb5b4ad25dc7db247573e92a1bd2f342317db3e931972434fb9b542"
            ]
        }
    ],
    "opt_in_rbf": true,
    "outputs": [
        {
            "addresses": [
                "tb1pezwxd60p00laqcu6fvze0canaczel8rdh44u4yu5995xlczgk4asm3hksg"
            ],
            "script": "5120c89c66e9e17bffd0639a4b0597e3b3ee059f9c6dbd6bca939429686fe048b57b",
            "script_type": "pay-to-taproot",
            "value": 19000
        }
    ],
    "preference": "low",
    "received": "2023-11-02T15:54:02.249240475Z",
    "relayed_by": "44.202.163.146",
    "size": 268,
    "total": 19000,
    "ver": 2,
    "vin_sz": 1,
    "vout_sz": 1,
    "vsize": 138
}

When I try to broadcast the transaction I get this error: 'sendrawtransaction RPC error: {"code":-26,"message":"non-mandatory-script-verify-flag (Witness program hash mismatch)"}'

commented

Witness program hash mismatch means that the script + cblock does not equal the taproot key for the output. Have you tried using verify_cblock and taproot.verify_tx to check if all the witness terms are valid?

commented

Please feel free to reopen this if you are still having a problem.