3

I'm attempting to construct a funding transaction for a DLC. So far I have created the following transaction which encodes entry of a bet for local/remote collateral of 1000/1000 sats and binary win/lose all or nothing outcome.

As far as I can tell, the transactions are accurate in terms of inputs/outputs addresses etc, and the signatures were provided (see below), but I'm getting this error:

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

when attempting to broadcast the transaction. hex:

<txhash>

I also attempted broadcasting with another service, which had a more descriptive error so I'll also post this here:

Error validating transaction: Error running script for input 0 referencing <hash> at 1: incorrect number of witness items for version 0 witness program of length 20.

I'm not really sure how to interpret this error and also unsure of how to go about debugging, so any pointers would be really appreciated. Searching for these errors on StackExchange doesn't seem to provide any relevant hits except maybe this answer. Is it possible that incorrect private keys used to sign the transactions could lead to the witness program hash mismatch? (as suggested by Andrew Chow).

{
    "addresses": [
        "<addrs>",
        "<addrs>",
        "<addrs>",
        "<addrs>",
        "<addrs>"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": <amt>,
    "hash": "d6c6069357ed571c91294d736f44db57a22b1e422ebd6947cc912ef8f498f8ca",
    "inputs": [
        {
            "addresses": [
                "<addrs>"
            ],
            "age": 00,
            "output_index": 1,
            "output_value":<amt>,
            "prev_hash": "<hash>",
            "script_type": "pay-to-witness-pubkey-hash",
            "sequence": 4294967295
        },
        {
            "addresses": [
                "<addrs>"
            ],
            "age": 00,
            "output_index": 1,
            "output_value": <amt>,
            "prev_hash": "f174bf45da30a7a43360c37fde80955ad3e0b45e6913b0aab1314fdfabe2e0c7",
            "script_type": "pay-to-witness-pubkey-hash",
            "sequence": 4294967295,
            "witness": [
                "304402207bb9cffa80ee109758b6c0c74ac2d5745cb42bb06c76b0cf7a86e64cc4159bba0220351f1ae477c5703c2990336a2888a4ff1c52e3d01897931ba3b48fce694797c101",
                "022b89efbabb2ab7f712912c399ef161216b07d101fa95a3ffbb4ce675548b64e1"
            ]
        }
    ],
    "outputs": [
        {
            "addresses": [
                "<addrs>"
            ],
            "script": "002002349639c02aee43f4474e269bc03860d0290f7f3fc15f0bcea54b2025dffae8",
            "script_type": "pay-to-witness-script-hash",
            "value": <amt>
        },
        {
            "addresses": [
                "<addrs>"
            ],
            "script": "00147bd21f276fa2e6a81a69a1d89c4217876810bf98",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": <amt>
        },
        {
            "addresses": [
                "<addrs>"
            ],
            "script": "00148e0892c30b293a2ae1fa90988cc6004f03eadc1c",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": <amt>
        }
    ],
    "preference": "low",
    "received": "<datetime>",
    "relayed_by": "<ip>",
    "size": <size>,
    "total": <amt>,
    "ver": 2,
    "vin_sz": 2,
    "vout_sz": 3,
    "vsize": <vsize>
}

1 Answer 1

2

If you look at input 0, it doesn't contain a witness element, this means it isn't signed. You need to sign both inputs to be able to broadcast.

1
  • Thanks Ben, had missed that. Appreciate it
    – satirn
    Oct 14, 2021 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.