Calling `walletprocesspsbt` to sign multisig containing `OP_GREATERTHANOREQUAL` op_code #29949

issue KonradStaniec opened this issue on April 24, 2024
  1. KonradStaniec commented at 7:43 AM on April 24, 2024: none

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    I want to create signature by calling walletprocesspsbt endpoint to spend from multisig output. It is worth stating that this is taproot output with one leaf.

    Wallet contains one of the key from multisig. Key was created by first calling getnewaddress and then calling getaddressinfo and retrieving public key.

    Now the issue is that if multisig script is in format: <key1> OP_CHECKSIG <key2> OP_CHECKSIGADD <key3> OP_CHECKSIGADD 2 OP_NUMEQUAL

    where one of the keys is in wallet everything works as expected.

    Psbt to sign:

    {
      "tx": {
        "txid": "626f61fa0b711187cd29a82c7ec0ae56447a8c8b4955bf99c9c8a6459522cf40",
        "hash": "626f61fa0b711187cd29a82c7ec0ae56447a8c8b4955bf99c9c8a6459522cf40",
        "version": 2,
        "size": 82,
        "vsize": 82,
        "weight": 328,
        "locktime": 0,
        "vin": [
          {
            "txid": "32f9c12fe803fa2c26c168850b424e260bca7191b39e775ddf946d51cb0c929b",
            "vout": 0,
            "scriptSig": {
              "asm": "",
              "hex": ""
            },
            "sequence": 0
          }
        ],
        "vout": [
          {
            "value": 0.00098000,
            "n": 0,
            "scriptPubKey": {
              "asm": "0 a2ec9907bfd06d26e41e8af835c8b2b39400bb56",
              "desc": "addr(bcrt1q5tkfjpal6pkjdeq73turtj9jkw2qpw6kfnjp63)#3rygmz90",
              "hex": "0014a2ec9907bfd06d26e41e8af835c8b2b39400bb56",
              "address": "bcrt1q5tkfjpal6pkjdeq73turtj9jkw2qpw6kfnjp63",
              "type": "witness_v0_keyhash"
            }
          }
        ]
      },
      "global_xpubs": [
      ],
      "psbt_version": 0,
      "proprietary": [
      ],
      "unknown": {
      },
      "inputs": [
        {
          "witness_utxo": {
            "amount": 0.00100000,
            "scriptPubKey": {
              "asm": "1 c3e8e2c9fc6033f3ebcd9d5b39212f52873e8b6e356a64bd364d76e59011f33a",
              "desc": "rawtr(c3e8e2c9fc6033f3ebcd9d5b39212f52873e8b6e356a64bd364d76e59011f33a)#kgt72cne",
              "hex": "5120c3e8e2c9fc6033f3ebcd9d5b39212f52873e8b6e356a64bd364d76e59011f33a",
              "address": "bcrt1pc05w9j0uvqel867dn4dnjgf022rnazmwx44xf0fkf4mwtyq37vaqrecrxw",
              "type": "witness_v1_taproot"
            }
          },
          "witness_script": {
            "asm": "51af6bd7bdaa1e3d2dc777c27bdf76b7ad1161ee48197cd8cf0ea4523b3dfa53 OP_CHECKSIG 65a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403 OP_CHECKSIGADD 71a79e74ad98f51b2c299de2c10f298130e2c3be2c3a266767a2c55d420749a9 OP_CHECKSIGADD 2 OP_NUMEQUAL",
            "hex": "2051af6bd7bdaa1e3d2dc777c27bdf76b7ad1161ee48197cd8cf0ea4523b3dfa53ac2065a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403ba2071a79e74ad98f51b2c299de2c10f298130e2c3be2c3a266767a2c55d420749a9ba529c",
            "type": "nonstandard"
          },
          "taproot_scripts": [
            {
              "script": "2051af6bd7bdaa1e3d2dc777c27bdf76b7ad1161ee48197cd8cf0ea4523b3dfa53ac2065a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403ba2071a79e74ad98f51b2c299de2c10f298130e2c3be2c3a266767a2c55d420749a9ba529c",
              "leaf_ver": 192,
              "control_blocks": [
                "c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"
              ]
            }
          ],
          "taproot_bip32_derivs": [
            {
              "pubkey": "65a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403",
              "master_fingerprint": "00000000",
              "path": "m",
              "leaf_hashes": [
              ]
            }
          ],
          "taproot_internal_key": "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0",
          "taproot_merkle_root": "a0739e00a984d9cdfb5f08740d3c6b405af4d98baa7dfcc823cab15c8c465661"
        }
      ],
      "outputs": [
        {
        }
      ],
      "fee": 0.00002000
    }
    

    Psbt signed:

    {
      "tx": {
        "txid": "626f61fa0b711187cd29a82c7ec0ae56447a8c8b4955bf99c9c8a6459522cf40",
        "hash": "626f61fa0b711187cd29a82c7ec0ae56447a8c8b4955bf99c9c8a6459522cf40",
        "version": 2,
        "size": 82,
        "vsize": 82,
        "weight": 328,
        "locktime": 0,
        "vin": [
          {
            "txid": "32f9c12fe803fa2c26c168850b424e260bca7191b39e775ddf946d51cb0c929b",
            "vout": 0,
            "scriptSig": {
              "asm": "",
              "hex": ""
            },
            "sequence": 0
          }
        ],
        "vout": [
          {
            "value": 0.00098000,
            "n": 0,
            "scriptPubKey": {
              "asm": "0 a2ec9907bfd06d26e41e8af835c8b2b39400bb56",
              "desc": "addr(bcrt1q5tkfjpal6pkjdeq73turtj9jkw2qpw6kfnjp63)#3rygmz90",
              "hex": "0014a2ec9907bfd06d26e41e8af835c8b2b39400bb56",
              "address": "bcrt1q5tkfjpal6pkjdeq73turtj9jkw2qpw6kfnjp63",
              "type": "witness_v0_keyhash"
            }
          }
        ]
      },
      "global_xpubs": [
      ],
      "psbt_version": 0,
      "proprietary": [
      ],
      "unknown": {
      },
      "inputs": [
        {
          "witness_utxo": {
            "amount": 0.00100000,
            "scriptPubKey": {
              "asm": "1 c3e8e2c9fc6033f3ebcd9d5b39212f52873e8b6e356a64bd364d76e59011f33a",
              "desc": "rawtr(c3e8e2c9fc6033f3ebcd9d5b39212f52873e8b6e356a64bd364d76e59011f33a)#kgt72cne",
              "hex": "5120c3e8e2c9fc6033f3ebcd9d5b39212f52873e8b6e356a64bd364d76e59011f33a",
              "address": "bcrt1pc05w9j0uvqel867dn4dnjgf022rnazmwx44xf0fkf4mwtyq37vaqrecrxw",
              "type": "witness_v1_taproot"
            }
          },
          "witness_script": {
            "asm": "51af6bd7bdaa1e3d2dc777c27bdf76b7ad1161ee48197cd8cf0ea4523b3dfa53 OP_CHECKSIG 65a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403 OP_CHECKSIGADD 71a79e74ad98f51b2c299de2c10f298130e2c3be2c3a266767a2c55d420749a9 OP_CHECKSIGADD 2 OP_NUMEQUAL",
            "hex": "2051af6bd7bdaa1e3d2dc777c27bdf76b7ad1161ee48197cd8cf0ea4523b3dfa53ac2065a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403ba2071a79e74ad98f51b2c299de2c10f298130e2c3be2c3a266767a2c55d420749a9ba529c",
            "type": "nonstandard"
          },
          "taproot_script_path_sigs": [
            {
              "pubkey": "65a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403",
              "leaf_hash": "a0739e00a984d9cdfb5f08740d3c6b405af4d98baa7dfcc823cab15c8c465661",
              "sig": "34ac8762e23d1521611f67ce608bf36a46ed5036b2cbc4fa3d6b8bde8d85449eea31e52422589199e63c0d0fd62fd6e03d840e00bf03d52c6e5e7987e1901a1a"
            }
          ],
          "taproot_scripts": [
            {
              "script": "2051af6bd7bdaa1e3d2dc777c27bdf76b7ad1161ee48197cd8cf0ea4523b3dfa53ac2065a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403ba2071a79e74ad98f51b2c299de2c10f298130e2c3be2c3a266767a2c55d420749a9ba529c",
              "leaf_ver": 192,
              "control_blocks": [
                "c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"
              ]
            }
          ],
          "taproot_bip32_derivs": [
            {
              "pubkey": "65a70371debcdafa542f1570282395054c082efada30e03d93c1b98cc1963403",
              "master_fingerprint": "00000000",
              "path": "m",
              "leaf_hashes": [
              ]
            }
          ],
          "taproot_internal_key": "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0",
          "taproot_merkle_root": "a0739e00a984d9cdfb5f08740d3c6b405af4d98baa7dfcc823cab15c8c465661"
        }
      ],
      "outputs": [
        {
        }
      ],
      "fee": 0.00002000
    }
    

    Issue arises when script is changed to similar, but different form: <key1> OP_CHECKSIG <key2> OP_CHECKSIGADD <key3> OP_CHECKSIGADD 2 OP_GREATERTHANOREQUAL

    With such script psbt becomes:

    {
      "tx": {
        "txid": "c0ee6554b98748d4bddb2f1fefae3e3470f70ba4901fceb56caf1df502cca29c",
        "hash": "c0ee6554b98748d4bddb2f1fefae3e3470f70ba4901fceb56caf1df502cca29c",
        "version": 2,
        "size": 82,
        "vsize": 82,
        "weight": 328,
        "locktime": 0,
        "vin": [
          {
            "txid": "c660a8f365c54bf78f5a7f7d59d7b02d81d76434117433e0719f50b19d793c3f",
            "vout": 0,
            "scriptSig": {
              "asm": "",
              "hex": ""
            },
            "sequence": 0
          }
        ],
        "vout": [
          {
            "value": 0.00098000,
            "n": 0,
            "scriptPubKey": {
              "asm": "0 885d64578216908d6e0a745295149a648deb89cb",
              "desc": "addr(bcrt1q3pwkg4uzz6gg6ms2w3ff29y6vjx7hzwt6dg29t)#2kplfgfu",
              "hex": "0014885d64578216908d6e0a745295149a648deb89cb",
              "address": "bcrt1q3pwkg4uzz6gg6ms2w3ff29y6vjx7hzwt6dg29t",
              "type": "witness_v0_keyhash"
            }
          }
        ]
      },
      "global_xpubs": [
      ],
      "psbt_version": 0,
      "proprietary": [
      ],
      "unknown": {
      },
      "inputs": [
        {
          "witness_utxo": {
            "amount": 0.00100000,
            "scriptPubKey": {
              "asm": "1 acd1d2a6e6b8a5366046fc8c4b0beb0f1f731416ddfc2b6ce5e8a6ec05494d22",
              "desc": "rawtr(acd1d2a6e6b8a5366046fc8c4b0beb0f1f731416ddfc2b6ce5e8a6ec05494d22)#l0v0wqh8",
              "hex": "5120acd1d2a6e6b8a5366046fc8c4b0beb0f1f731416ddfc2b6ce5e8a6ec05494d22",
              "address": "bcrt1p4nga9fhxhzjnvczxljxykzltpu0hx9qkmh7zkm89aznwcp2ff53qlumd30",
              "type": "witness_v1_taproot"
            }
          },
          "witness_script": {
            "asm": "1ab6538f0041c05f205f04b8f98f671ab30059ebabba92abfc0b717b663ff6e8 OP_CHECKSIG 6b198710ea0801dd2bd0fa492745ade0287a56ad3de5db3b16cb2da00d67dd0d OP_CHECKSIGADD dcd39254d982fc1e65e71b765e278115a53d25351ccebf64c213d70f69804957 OP_CHECKSIGADD 2 OP_GREATERTHANOREQUAL",
            "hex": "201ab6538f0041c05f205f04b8f98f671ab30059ebabba92abfc0b717b663ff6e8ac206b198710ea0801dd2bd0fa492745ade0287a56ad3de5db3b16cb2da00d67dd0dba20dcd39254d982fc1e65e71b765e278115a53d25351ccebf64c213d70f69804957ba52a2",
            "type": "nonstandard"
          },
          "taproot_scripts": [
            {
              "script": "201ab6538f0041c05f205f04b8f98f671ab30059ebabba92abfc0b717b663ff6e8ac206b198710ea0801dd2bd0fa492745ade0287a56ad3de5db3b16cb2da00d67dd0dba20dcd39254d982fc1e65e71b765e278115a53d25351ccebf64c213d70f69804957ba52a2",
              "leaf_ver": 192,
              "control_blocks": [
                "c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"
              ]
            }
          ],
          "taproot_bip32_derivs": [
            {
              "pubkey": "dcd39254d982fc1e65e71b765e278115a53d25351ccebf64c213d70f69804957",
              "master_fingerprint": "00000000",
              "path": "m",
              "leaf_hashes": [
              ]
            }
          ],
          "taproot_internal_key": "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0",
          "taproot_merkle_root": "8dcf9fd2a9bff82480b8113d97bdd1f1b0324c58cb7f767421bf4764e6e40536"
        }
      ],
      "outputs": [
        {
        }
      ],
      "fee": 0.00002000
    }
    

    In this case bitcoind, returns the same psbt, without taproot_script_path_sigs field or any error.

    I actually created question on bitcoin stack exchange - https://bitcoin.stackexchange.com/questions/122759/how-can-i-sign-custom-tapscript-leaf-using-bitcoind-walletprocesspsbt-rpc-endp, but looked into this a bit deeper and isolated OP_GREATERTHANOREQUAL as op code which made all difference.

    Expected behaviour

    In this case I would expect:

    • either return signatures also for script containing OP_GREATERTHANOREQUAL
    • or return error saying that this op_code is not supported for walletprocesspsbt call

    Steps to reproduce

    1. Create wallet with the key which should later become part of the multisig.
    2. Create taproot output with one script spending path. The script should be the taproot multi sig (OP_CHECKSIGADD) with OP_GREATERTHANOREQUAL opcode and contain key created in step 1
    3. Create psbt and call walletprocesspsbt endpoint on wallet created in step 1
    4. Response should be an error or psbt with signature made by key

    Relevant log output

    No response

    How did you obtain Bitcoin Core

    Pre-built binaries

    What version of Bitcoin Core are you using?

    v26.0

    Operating system and version

    "MacOs Sonoma 14.3"

    Machine specifications

    No response

  2. achow101 commented at 2:42 PM on April 24, 2024: member

    Bitcoin Core cannot sign non-standard scripts or scripts that are not Miniscript. This is expected behavior. walletprocesspsbt does not return an error because signing is not the only thing that it does, so returning an error for a failing to sign is not appropriate.

  3. sipa commented at 2:50 PM on April 24, 2024: member

    For some more background, Bitcoin Core has logic to try various things when signing, which includes Miniscript. The script variant you tried with OP_NUMEQUAL at the end is valid Miniscript (multi_a(2,<key1>,<key2>,<key3>) specifically), but the variant with OP_GREATERTHANOREQUAL is not.

    When signing fails, Bitcoin Core doesn't know why it failed; it simply didn't find any patterns it knew how to sign for, and as @achow101 points out, it doesn't even know your intent was to sign.

  4. KonradStaniec commented at 3:16 AM on April 25, 2024: none

    Thanks for the quick responses! I think this issue can be closed then.

    Two follow up questions, I would have:

    1. Is there some other way to sign transaction, through bitcoind, which tries to spend from script which is not compatible with miniscript ?
    2. Is there some problem with OP_GREATERTHANOREQUAL which makes it non compatible with Miniscript ?
  5. achow101 commented at 2:02 PM on April 25, 2024: member

    Is there some other way to sign transaction, through bitcoind, which tries to spend from script which is not compatible with miniscript ?

    No

    Is there some problem with OP_GREATERTHANOREQUAL which makes it non compatible with Miniscript ?

    Yes, it is third party malleable, which makes it much harder to do analysis. For any additional signatures provided after the threshold has been reached, a third party can trivially remove those signatures and the transaction is still valid. Miniscript tries to not be third party malleable, and this script construction is trivially malleable, so it is not compatible.

  6. achow101 closed this on Apr 25, 2024

  7. bitcoin locked this on Apr 25, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-18 09:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me