Error sending transaction from P2SH with CSV & conditions #13035

issue chinitadelrey opened this issue on April 20, 2018
  1. chinitadelrey commented at 2:40 AM on April 20, 2018: none

    I am testing a simple escrow transaction where the sender gets to send the UTXO back to himself after 512 seconds (1 block in CSV). nSequence = the token in redeem script = 4194305. using decoderawtransaction & manually parsing the hex data, it looks like there are no errors. Have searched for the error message in the codebase and am not able to figure out where 'unknown error' may be indicating. is this a bug? or am I just missing something? thanks!

    for easy readability, I've attached my parsed version of the transaction hex at the end.

    $ bitcoin-cli -regtest sendrawtransaction 
    02000000013246884b0078951ca69508a9bd6667b16bc8967edd1b01378c010aae6fac36b901000000bf00473044022054b2af907f7be9a1719869db04acf5171c958fcbeda6b8bc8bd5052330fc88b60220
    2592fe1bdbcdcb4b132505a265cf7d55efdf9d2b8de7a83ab786c29c7ab9ab9001004c7363522102e28
    87490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736b210281cd7c6b17e5a62786b2f1f4fa0f71126c39540129e7692dabde56d601c1fc3d52ae6703010040b2752102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736bac6801004000014060e429010000001976a91492d85871fe16cac1cf847ee1b88b9973907670e788ac00000000
    
    error code: -26
    error message:
    64: non-mandatory-script-verify-flag (unknown error)
    

    <!--- What behavior did you expect? -->

    I expected the transaction to be broadcast successfully since the UTXO was clearly more than 512 seconds old by the time I made my numerous attempts.

    I have checked the script works with the btcdeb debugger, which skipped the sequence check. So it shouldn't be an issue with the signature, or the conditional part of the script. It should be an issue with CSV.

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    <!--- How reliably can you reproduce the issue, what are the steps to do so? -->

    <!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->

    $ bitcoin-cli -regtest getinfo 
    {
      "deprecation-warning": "WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16",
      "version": 150100,
      "protocolversion": 70015,
      "walletversion": 139900,
      "balance": 14699.99972510,
      "blocks": 100609,
      "timeoffset": 0,
      "connections": 0,
      "proxy": "",
      "difficulty": 4.656542373906925e-10,
      "testnet": false,
      "keypoololdest": 1522968861,
      "keypoolsize": 1999,
      "paytxfee": 0.00000000,
      "relayfee": 0.00001000,
      "errors": ""
    }
    

    <!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

    MacOS, 2.6 GHz Intel Core i5, SSD

    <!-- Any extra information that might be useful in the debugging process. -->

    <!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->

    
    bitcoin-cli -regtest decoderawtransaction 02000000013246884b0078951ca69508a9bd6667b16bc8967edd1b01378c010aae6fac36b901000000bf00473044022054b2af907f7be9a1719869db04acf5171c958fcbeda6b8bc8bd5052330fc88b602202592fe1bdbcdcb4b132505a265cf7d55efdf9d2b8de7a83ab786c29c7ab9ab9001004c7363522102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736b210281cd7c6b17e5a62786b2f1f4fa0f71126c39540129e7692dabde56d601c1fc3d52ae6703010040b2752102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736bac6801004000014060e429010000001976a91492d85871fe16cac1cf847ee1b88b9973907670e788ac00000000  
    {
      "txid": "7f196d44abc0fe0c363b087c8d4dfd690f73a0c25c39e15c194f1addc371b1cf",
      "hash": "7f196d44abc0fe0c363b087c8d4dfd690f73a0c25c39e15c194f1addc371b1cf",
      "version": 2,
      "size": 276,
      "vsize": 276,
      "locktime": 0,
      "vin": [
        {
          "txid": "b936ac6fae0a018c37011bdd7e96c86bb16766bda90895a61c9578004b884632",
          "vout": 1,
          "scriptSig": {
            "asm": "0 3044022054b2af907f7be9a1719869db04acf5171c958fcbeda6b8bc8bd5052330fc88b602202592fe1bdbcdcb4b132505a265cf7d55efdf9d2b8de7a83ab786c29c7ab9ab90[ALL] 0 63522102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736b210281cd7c6b17e5a62786b2f1f4fa0f71126c39540129e7692dabde56d601c1fc3d52ae6703010040b2752102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736bac68",
            "hex": "00473044022054b2af907f7be9a1719869db04acf5171c958fcbeda6b8bc8bd5052330fc88b602202592fe1bdbcdcb4b132505a265cf7d55efdf9d2b8de7a83ab786c29c7ab9ab9001004c7363522102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736b210281cd7c6b17e5a62786b2f1f4fa0f71126c39540129e7692dabde56d601c1fc3d52ae6703010040b2752102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736bac68"
          },
          "sequence": 4194305
        }
      ],
      "vout": [
        {
          "value": 49.97800000,
          "n": 0,
          "scriptPubKey": {
            "asm": "OP_DUP OP_HASH160 92d85871fe16cac1cf847ee1b88b9973907670e7 OP_EQUALVERIFY OP_CHECKSIG",
            "hex": "76a91492d85871fe16cac1cf847ee1b88b9973907670e788ac",
            "reqSigs": 1,
            "type": "pubkeyhash",
            "addresses": [
              "mtuQ81VrJ4eXmv8igrdkQXd9WF7x8pFnns"
            ]
          }
        }
      ]
    }
    

    finaltransaction2.txt

  2. chinitadelrey commented at 2:44 AM on April 20, 2018: none

    For reference: Redeem script:

    OP_IF 2 02e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736b 0281cd7c6b17e5a62786b2f1f4fa0f71126c39540129e7692dabde56d601c1fc3d 2 OP_CHECKMULTISIG OP_ELSE 4194305 OP_CHECKSEQUENCEVERIFY OP_DROP 02e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736b OP_CHECKSIG OP_ENDIF
    
    

    UTXO:

    {
      "txid": "b936ac6fae0a018c37011bdd7e96c86bb16766bda90895a61c9578004b884632",
      "hash": "b936ac6fae0a018c37011bdd7e96c86bb16766bda90895a61c9578004b884632",
      "version": 2,
      "size": 643,
      "vsize": 643,
      "locktime": 100607,
      "vin": [ .....truncated for readability....
      ],
      "vout": [
        {
          "value": 0.00006160,
          "n": 0,
          "scriptPubKey": {
            "asm": "OP_DUP OP_HASH160 027ba724d86c440d1dae010ac34052685c4a2be6 OP_EQUALVERIFY OP_CHECKSIG",
            "hex": "76a914027ba724d86c440d1dae010ac34052685c4a2be688ac",
            "reqSigs": 1,
            "type": "pubkeyhash",
            "addresses": [
              "mfk5mzW3SSjmq3KNK13ofT6HK5CpfKsE11"
            ]
          }
        }, 
        {
          "value": 50.00000000,
          "n": 1,
          "scriptPubKey": {
            "asm": "OP_HASH160 261387da290c821468d53808d769553436c7598b OP_EQUAL",
            "hex": "a914261387da290c821468d53808d769553436c7598b87",
            "reqSigs": 1,
            "type": "scripthash",
            "addresses": [
              "2MviZ4b5jhR12KrZnEmhKuAadTwAiGbGRhG"
            ]
          }
        }
      ],
      "hex": "02000000050328eba4b196e2348a6b3fedcaa41cac92c909e9af2deef173d7cd277d9b971d000000004847304402203b3fde03309d23343d597946e388353da3da1614fcc3333a3fdcdfb7d80f36090220748abab1ffe86dbfddf2dd0ecf66b0a4684b810e22ca1fd9b9c0e198be8c920701feffffff0d8bb61e36787bb223b49fc5d96b2f6fb9cdeaf9a483685a65d81ca5f32f41640000000049483045022100d773313f700ea9dcf5003ad0105de651d074fa57d8ab815eac4f3dcbdf1bc8ce0220182d5130c889caeb756997371eccc7c5582464c28db3f7919e9fce753be749fc01feffffff6af684700c7990f073e78d2d879b59af8a1f7b034abf6bb722f3cf74b3e0dc530000000049483045022100d2e029ed38a63c4e135b3cadd132336caeb85feb453131f5bd86f8d4b42856bf02202d5a6502f21e0bd66d526a9c0393b4debb7fd026eb3fc8f9c3c3ffd1c8052de801feffffffab71fa60831976cdd720119827313e0f8d90cd0162b2d2e01dcbdd86cc570df4000000004847304402206c1e471a1fae373b8cec2f0acd896f88774f180dfdd472d5de6a1870fbf46ceb022071332450c580562c39a1f3b194a5f0468f52e03b9c25bd2e04e0636129cb60cc01feffffffebb5726c700ef8919cc5580f33787366a810420103725c52f4387a5cca4975c8000000004847304402205f55bbe1638d6c67ec4d9ca83d921ef7e252d9a870988ae35d6f4c7270714a3b02204b219e2d2e1fe8664effc09e52c1d19f0c2fb668cab09dfebfd3b0979b7b0ae501feffffff0210180000000000001976a914027ba724d86c440d1dae010ac34052685c4a2be688ac00f2052a0100000017a914261387da290c821468d53808d769553436c7598b87ff880100",
      "blockhash": "4c44fc4bc8228462fc57b250de219a62afc0791bf3145c6173cb8d69894fbcd5",
      "confirmations": 2,
      "time": 1524166868,
      "blocktime": 1524166868
    }
    
  3. fivepiece commented at 2:50 PM on April 20, 2018: contributor

    You have an extraneous 0x00 in your scriptsig, right before the signature :

                                                                                        VV
    02000000013246884b0078951ca69508a9bd6667b16bc8967edd1b01378c010aae6fac36b901000000bf00473044022054b2af907f7be9a1719869db04acf5171c958fcbeda6b8bc8bd5052330fc88b602202592fe1bdbcdcb4b132505a265cf7d55efdf9d2b8de7a83ab786c29c7ab9ab9001004c7363522102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736b210281cd7c6b17e5a62786b2f1f4fa0f71126c39540129e7692dabde56d601c1fc3d52ae6703010040b2752102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736bac6801004000014060e429010000001976a91492d85871fe16cac1cf847ee1b88b9973907670e788ac00000000
    

    Probably left there after you tried the 2-of-2 case. Removing it and adjusting the scriptsig size should solve your spend of the ELSE branch with the CHECKSIG :

    02000000013246884b0078951ca69508a9bd6667b16bc8967edd1b01378c010aae6fac36b901000000be473044022054b2af907f7be9a1719869db04acf5171c958fcbeda6b8bc8bd5052330fc88b602202592fe1bdbcdcb4b132505a265cf7d55efdf9d2b8de7a83ab786c29c7ab9ab9001004c7363522102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736b210281cd7c6b17e5a62786b2f1f4fa0f71126c39540129e7692dabde56d601c1fc3d52ae6703010040b2752102e2887490bd940ef9122575269db1e4d91eeacc2fd85f61b06e443ddd6414736bac6801004000014060e429010000001976a91492d85871fe16cac1cf847ee1b88b9973907670e788ac00000000
    
  4. chinitadelrey commented at 3:26 PM on April 20, 2018: none

    You are a star! Got it now. Thank you!

  5. chinitadelrey closed this on Apr 20, 2018

  6. DrahtBot locked this on Sep 8, 2021

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-21 21:15 UTC

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