Misleading error/reject message: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation) #11891

issue Ayms opened this issue on December 13, 2017
  1. Ayms commented at 10:10 PM on December 13, 2017: none

    This is very equivalent to https://bitcoin.stackexchange.com/questions/61030/got-64-non-mandatory-script-verify-flag-signature-must-be-zero-for-failed-chec/61040

    While implementing multisig for https://github.com/Ayms/bitcoin-transactions and just sending funds to a multisig test address (https://btgexp.com/tx/e2fe7ed1c528986fd30d97dd4bb62cc9c17db94c0753333250dc0c32ab5a8bd8) I got this error

    Simply because prevamount: (0.00460457*100000000)=460456.99999999994 was wrongly rounded to 460456, then the signature was incorrect

    "Signature must be zero for failed CHECK(MULTI)SIG operation" is unclear, this probably can be replaced by something more clear like "Wrong signature" and why not "check prevamounts"

  2. Ayms closed this on Dec 19, 2017

  3. maflcko reopened this on Dec 19, 2017

  4. TheBlueMatt commented at 4:02 PM on December 19, 2017: contributor

    Minor usability issue that may still be worth fixing, if its easy to fix. One simple way to address some similar cases is to take the "first error" we get starting from base flags and adding more flags on top until the script fails, at least for ATMP calls from eg sendrawtransaction.

  5. Ayms commented at 4:27 PM on December 19, 2017: none

    I closed it because I noticed that other error messages are unclear too, I don't remember exactly the wording but for example I got "unnecessary data too large" or something like this, because an unnecessary OP_PUSHDATA was used, and I got a "dust" reject message too who did not say what was the limit "output amount should not be below xxx satoshis", etc

    Flags telling what failed would be great but probably they won't be precise enough, then it's probably easier to include in the error messages what are the common mistakes/limits

  6. Ayms commented at 5:54 PM on December 21, 2017: none

    This is coming back, please see https://github.com/Ayms/bitcoin-transactions/issues/5

    I am sure that the serialization for signing is correct (btw cli could display this info "message to be signed (before hash): xxxx")

    I suspect that [r,s] does not follow one of the rules of bitcoin core, that's not the canonical format, because I don't get this error and already checked, is there a link somewhere for the signatures format check?

  7. tdiesler commented at 1:30 PM on May 16, 2018: none

    Here is a step-by-step walk through on a fresh regtest network, which attempts to do the following

    Client version: v0.16.0

    • get an address for account Bob
    • send 10.0 BTC to Bob
    • get an address for Marry
    • create a raw transaction that sends Marry 9.99 BTC
    • sign the raw transaction with Bob's private key

    Sending the raw transaction fails with

    64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code -26)

    > generate 101
    
    > getaccountaddress Bob
    
    2N6hRqr3EEFxT8wzQvrKok9m7c8UebetSD3
    
    > sendtoaddress 2N6hRqr3EEFxT8wzQvrKok9m7c8UebetSD3 10.0
    
    3b6297de06455879df0f34ec4e6dc811500f73a6294ccf5a9d012bef5f6adf6b
    
    > generate 1
    
    > listaccounts
    
    {
      "": 89.99996240,
      "Bob": 10.00000000
    }
    
    > listunspent 1
    
    [
      {
        "txid": "3b6297de06455879df0f34ec4e6dc811500f73a6294ccf5a9d012bef5f6adf6b",
        "vout": 0,
        "address": "2N5gfUJjeas3rPaB3qGE7AwFPdDHkwsygKo",
        "redeemScript": "0014817dd0e02d4bf98c5c3003a710250f65fae490c7",
        "scriptPubKey": "a91488712e431e27588c9af8833ce4c55771e66cf7cb87",
        "amount": 39.99996240,
        "confirmations": 1,
        "spendable": true,
        "solvable": true,
        "safe": true
      },
      {
        "txid": "3b6297de06455879df0f34ec4e6dc811500f73a6294ccf5a9d012bef5f6adf6b",
        "vout": 1,
        "address": "2N6hRqr3EEFxT8wzQvrKok9m7c8UebetSD3",
        "account": "Bob",
        "redeemScript": "0014e8f6002e2336e40c22dcdb5b80c7eeef2b5d405f",
        "scriptPubKey": "a914938e5889d8de2c6d7fd78e13fd63cb96e7dc265e87",
        "amount": 10.00000000,
        "confirmations": 1,
        "spendable": true,
        "solvable": true,
        "safe": true
      },
      {
        "txid": "c4b779821931f31fcc9f3d795b2b6f23540013b9bdbb90325f80de818f1258e0",
        "vout": 0,
        "address": "mw9SJs5QTjusS2GXSVqanYnvydWT8stXVJ",
        "scriptPubKey": "2103ea92592e87e23efe22aab49282fcc00906204d2c799b4dce82ef7ce390f47c7fac",
        "amount": 50.00000000,
        "confirmations": 101,
        "spendable": true,
        "solvable": true,
        "safe": true
      }
    ]
    
    > getaccountaddress Marry
    
    2MudXihor4iwz6newMoG6yU3R4eQrZ32mu1
    
    > createrawtransaction '[{"txid":"3b6297de06455879df0f34ec4e6dc811500f73a6294ccf5a9d012bef5f6adf6b","vout":1}]' '{"2MudXihor4iwz6newMoG6yU3R4eQrZ32mu1":9.99}'
    
    02000000016bdf6a5fef2b019d5acf4c29a6730f5011c86d4eec340fdf79584506de97623b0100000000ffffffff01c0878b3b0000000017a9141a283442bd9961bfa3e572bea276505f14b8f7158700000000
    
    > dumpprivkey 2N6hRqr3EEFxT8wzQvrKok9m7c8UebetSD3
    
    cNXTN1Z7GeCSsAZVRYYuzTumkGmT5y95knzFAidaYu6bghBzsZzg
    
    > signrawtransaction '02000000016bdf6a5fef2b019d5acf4c29a6730f5011c86d4eec340fdf79584506de97623b0100000000ffffffff01c0878b3b0000000017a9141a283442bd9961bfa3e572bea276505f14b8f7158700000000' '[{"txid":"3b6297de06455879df0f34ec4e6dc811500f73a6294ccf5a9d012bef5f6adf6b","vout":1, "scriptPubKey":"a914938e5889d8de2c6d7fd78e13fd63cb96e7dc265e87", "redeemScript":"0014e8f6002e2336e40c22dcdb5b80c7eeef2b5d405f"}]' '["cNXTN1Z7GeCSsAZVRYYuzTumkGmT5y95knzFAidaYu6bghBzsZzg"]'
    
    {
      "hex": "020000000001016bdf6a5fef2b019d5acf4c29a6730f5011c86d4eec340fdf79584506de97623b0100000017160014e8f6002e2336e40c22dcdb5b80c7eeef2b5d405fffffffff01c0878b3b0000000017a9141a283442bd9961bfa3e572bea276505f14b8f7158702473044022069c41acf0c377763ca48bcac20bcb0956a9320b9e5a404a5847816ba1a13dd69022023a75d6b5da3cb82efa050d2f64ea4b46ba83b7dde66cf6aebf1845a7f8173d20121029336bea825e6b65a732bc1e2588ab4b7364b74a42ce2318ebea3bba44aa200d100000000",
      "complete": true
    }
    
    > sendrawtransaction 020000000001016bdf6a5fef2b019d5acf4c29a6730f5011c86d4eec340fdf79584506de97623b0100000017160014e8f6002e2336e40c22dcdb5b80c7eeef2b5d405fffffffff01c0878b3b0000000017a9141a283442bd9961bfa3e572bea276505f14b8f7158702473044022069c41acf0c377763ca48bcac20bcb0956a9320b9e5a404a5847816ba1a13dd69022023a75d6b5da3cb82efa050d2f64ea4b46ba83b7dde66cf6aebf1845a7f8173d20121029336bea825e6b65a732bc1e2588ab4b7364b74a42ce2318ebea3bba44aa200d100000000
    
    64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation)
    
  8. land-pack commented at 9:04 AM on July 20, 2018: none

    @tdiesler Do you fixed it ?

  9. tdiesler commented at 6:41 AM on July 23, 2018: none

    @land-pack Unfortunately, I don't speak C.

  10. Gillian217 commented at 6:58 AM on August 30, 2018: none

    Hi sir, just want to ask if you have already a fix with this issue, I encounter the same error using bitcoin core console. createrawtransaction: screenshot from 2018-08-30 12-59-20 signrawtransaction: screenshot from 2018-08-30 13-01-29 sendrawtransaction: screenshot from 2018-08-30 13-02-02 hope you could help me.

  11. gitchand commented at 9:53 AM on August 5, 2019: none

    While pushing a bch tx : An error occured: 16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation). Code:-26

  12. maflcko added the label Feature on Apr 28, 2020
  13. maflcko added the label Validation on Apr 28, 2020
  14. ccconnor commented at 11:52 AM on December 2, 2021: none

    I run into the same issue in bcha(xec) regtest.

    curl --location --request POST 'http://localhost:6650' \
    --header 'Authorization: Basic xxxxxxxxxx' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "jsonrpc": "1.0",
        "id": "curltest",
        "method": "sendtoaddress",
        "params": [
            "n4LbNgMA1LNr1CqvPHa71ndypUSQucPwpi",
            1000000
        ]
    }'
    
  15. willcl-ark commented at 2:49 PM on April 10, 2024: member

    The feature request didn't seem to attract much attention in the past. Also, the issue seems not important enough right now to keep it sitting around idle in the list of open issues.

    Pull requests with improvements are always welcome.

  16. willcl-ark closed this on Apr 10, 2024

  17. bitcoin locked this on Apr 10, 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-13 15:15 UTC

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