0

https://pastebin.com/kdQPkELN

if anyone can see why i am getting a 16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)failure.... It is a p2sh multisig transaction 2 of 3. 2 public keys are uncompressed and one key is compressed. I can't seem to figure it out. created originally on bitcoin core v0.16 and i am trying to send it out on core v0.17... Not sure why this is causing a problem.

 -> #0000 0
    #0001 3044022052c7ee72b96cba77f5a9e165e73251f01638ebc931fd2750cf3b8f6e4b41778f02207a1321f9b4a39e4e62b5199253822163f24135577f6b8c0d1258ce485b1d865d01
    #0002 3045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b901
    #0003 52410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753ae
    <<< scriptPubKey >>>
    #0005 OP_HASH160
    #0006 0ea69eba81a9bfecfe7aa5b5f2b9a2bca6cdb68a
    #0007 OP_EQUAL
    <<< P2SH script >>>
    #0009 2
    #0010 0428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f
    #0011 04624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a
    #0012 03d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b57
    #0013 3
    #0014 OP_CHECKMULTISIG

btcdeb output:

stack has 8 entries [require 5]
stack has 8 entries [require 8]
scriptCode = 52410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753ae
looping for multisig
loop: sigs = 2, keys = 3
- got sig 3045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b901
- got key 03d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b57
GenericTransactionSignatureChecker::CheckSig(72 len sig, 33 len pubkey, sigversion=0)
  sig         = 3045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b901
  pub key     = 03d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b57
  script code = 52410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753ae
  hash type   = 01 (SIGHASH_ALL)
SignatureHash(nIn=0, nHashType=01, amount=192000)
- sigversion = SIGVERSION_BASE (non-segwit style)
Serializing transaction
 << txTo.nVersion (00000001)
#004 01000000
 << nInputs = 1 [compact]
#001 01
(serialize input 0)
 << txTo.vin[nInput=0].prevout = COutPoint(8291bcc5ac, 0)
#032 a9c174acdc3493ba18e19654c440a8b78a86fba56e728af7af8853acc5bc9182
#004 00000000
(SerializeScriptCode)
 << scriptCode.size()=169 - nCodeSeparators=0
#001 a9
 << script:52410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753ae
#169 52410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753ae
 << txTo.vin[nInput].nSequence = 4294967295 [0xffffffff]
#004 ffffffff
 << nOutputs = 2 [compact]
#001 02
(serialize output 0)
#008 4871000000000000
#001 19
#025 76a914ded6cec3c85c32c29216258099343f55875f99c888ac
(serialize output 1)
#008 90dc010000000000
#001 19
#025 76a914fe2951cabb6d9e43aece6d530ac5967a5f895d4188ac
 << txTo.nLockTime = 0 [0x0]
#004 00000000
#004 01000000
  sighash     = 0c6027c0017de012eaa0c7c6ee1074f06a1fbc5c15e2b84291ea80bfaea68da7
  pubkey.Verify(sig=3045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b9, sighash=0c6027c0017de012eaa0c7c6ee1074f06a1fbc5c15e2b84291ea80bfaea68da7):
  result: FAILURE
- failed: VerifySignature() failed
- sig check failed
loop: sigs = 2, keys = 2
- got sig 3045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b901
- got key 04624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a
GenericTransactionSignatureChecker::CheckSig(72 len sig, 65 len pubkey, sigversion=0)
  sig         = 3045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b901
  pub key     = 04624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a
  script code = 52410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753ae
  hash type   = 01 (SIGHASH_ALL)
SignatureHash(nIn=0, nHashType=01, amount=192000)
- sigversion = SIGVERSION_BASE (non-segwit style)
Serializing transaction
 << txTo.nVersion (00000001)
#004 01000000
 << nInputs = 1 [compact]
#001 01
(serialize input 0)
 << txTo.vin[nInput=0].prevout = COutPoint(8291bcc5ac, 0)
#032 a9c174acdc3493ba18e19654c440a8b78a86fba56e728af7af8853acc5bc9182
#004 00000000
(SerializeScriptCode)
 << scriptCode.size()=169 - nCodeSeparators=0
#001 a9
 << script:52410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753ae
#169 52410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753ae
 << txTo.vin[nInput].nSequence = 4294967295 [0xffffffff]
#004 ffffffff
 << nOutputs = 2 [compact]
#001 02
(serialize output 0)
#008 4871000000000000
#001 19
#025 76a914ded6cec3c85c32c29216258099343f55875f99c888ac
(serialize output 1)
#008 90dc010000000000
#001 19
#025 76a914fe2951cabb6d9e43aece6d530ac5967a5f895d4188ac
 << txTo.nLockTime = 0 [0x0]
#004 00000000
#004 01000000
  sighash     = 0c6027c0017de012eaa0c7c6ee1074f06a1fbc5c15e2b84291ea80bfaea68da7
  pubkey.Verify(sig=3045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b9, sighash=0c6027c0017de012eaa0c7c6ee1074f06a1fbc5c15e2b84291ea80bfaea68da7):
  result: FAILURE
- failed: VerifySignature() failed
- sig check failed
loop ended in failure state
        <> POP  stack
        <> POP  stack
        <> POP  stack
        <> POP  stack
        <> POP  stack
error: Signature must be zero for failed CHECK(MULTI)SIG operation
btcdeb> 

Still a little confused with the output

1

Your signature 3045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b9 for pubkey 04624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a is wrong.

EDIT after btcdeb output: Actually both are wrong.

Wild guess: maybe this signature is for the third key and you forgot to add an empty byte array in-between the signatures ?

You might want to use btcdeb to debug your signature:

DEBUG_SIGNING=1 DEBUG_SIGHASH=1 ./btcdeb --tx=0100000001a9c174acdc3493ba18e19654c440a8b78a86fba56e728af7af8853acc5bc918200000000fd3d0100473044022052c7ee72b96cba77f5a9e165e73251f01638ebc931fd2750cf3b8f6e4b41778f02207a1321f9b4a39e4e62b5199253822163f24135577f6b8c0d1258ce485b1d865d01483045022100a8174334724185341d5c47fa70a5b6228bc357a6fd98427cc2c31a898136dc44022000886624847174494956e919bb83b2d3b195bca4b7f37aba0e7c391b2c5510b9014ca952410428e87e0c4670b46541f17f8ad42c2b731b196fb8f1185b47939fa97d826944303921a8993eebe288d6b8bdf1e804dd16e122d32f720455b4eeedf7a4cc98770f4104624ee12cb0b3e63ceac25ed5bf16fb5d9791a9f17bd09963bbb44fa23e15a9d703b5ef7250dc304d606ecc39f976539b5a833462f7258cfd1dde0ca63b74935a2103d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b5753aeffffffff0248710000000000001976a914ded6cec3c85c32c29216258099343f55875f99c888ac90dc0100000000001976a914fe2951cabb6d9e43aece6d530ac5967a5f895d4188ac00000000 --txin 020000000001037cc2ca29b2f72cdc03823bfae73030af625275e2323c7286dd83811aa7a578c90100000000ffffffffa85a130e60eecb36ee6e83cb622f3ed691946735fc9b07ada9e8c55b8eae215b010000006b483045022100df357edebc8a2eb7ead2ecfd11d4a7f1801fad491c87b693c44e206f6d2eddf30220184bca044c07e2dae06c809aa47dd37cfc7cc0db7da09600d9adbdc1ea1d44ea0121029cdaffb32f9508cfba8ef3c241f31978d76ac48f3bec3009dcbd798f70e3b619ffffffff08b620e68ed09ed674663fdb94e31c7d370bcaf40d880fa131f348c1763725c6000000006b483045022100860460170083a49cda6d68dec001892032df39988db52e2b8f91d8947c1cb71f0220277849a9319d16b0fcc60870e0efba55dc56251bf555d8e447ce6422949be288012102c87f969e60e1d85fb2f53c1314359123780f9c94b71299b03ac32e0a9d011f19ffffffff0200ee02000000000017a9140ea69eba81a9bfecfe7aa5b5f2b9a2bca6cdb68a879c1c0400000000001600149a0c39fc518500521b942ee1227cadc0933ebdc80247304402205226fa48d146904296bb6f26c5598c71234dbc46464d10498379dc8893e6114d0220526a3cb559e53ba5597824272dc1f8c36461ef9cac21c3e39fbbad1d4024e870012103a5f2fff56c0e7c45e8f5760a7580fb54470201345167bd060863c6c7c8bd78c2000000000000
| improve this answer | |
  • it is the signature from the second pubkey. why are you saying 2nd sig is bad.? – user3554230 Mar 27 at 13:20
  • i added the btcdeb output... but im not sure which signature is failing. 03d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b57 is the pub key i am not using for signing if that helps – user3554230 Mar 27 at 13:49
  • Because btcdeb said so (and bitcoind too) ! :D How did you sign it ? If it's by hand then don't forget the empty byte array for the signature for the pubkey you don't use (03d25273b1b2ab9e96b666764d2bc448019440f095aa989f5289145f293be98b57). – darosior Mar 27 at 14:37
  • it is the signature from a nano ledger s and the corresponding public key. – user3554230 Mar 27 at 14:58
  • i didn't add the 03d25 pub key when i did my signing. The signature was returned directly from the ledger. – user3554230 Mar 27 at 15:06

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.