2

I issued this transaction on testnet (for a homework later solved with another script). python-bitcoinlib validates the transaction but when i submit it to blockcypher it gets rejected with error:

{"error": "Error validating transaction: Error running script for input 0 referencing e96a1ae8aaff2920601fdfd8cb12289d77bad2a4d595e2093d9d828107023705 at 0: Script was NOT verified successfully.."}

My first transaction scriptPubKey: (transaction hash: e96a1ae8aaff2920601fdfd8cb12289d77bad2a4d595e2093d9d828107023705)

    [2, j1_public_key, j2_public_key, j3_public_key, 3, OP_CHECKMULTISIGVERIFY,
      1, my_public_key, p2_public_key, 2, OP_CHECKMULTISIG]

And the failed transaction scriptSig is:

[0, my_sig, 0, sig_j1, sig_j2]

and failed transaction hex is:

01000000010537020781829d3d09e295d5a4d2ba779d2812cbd8df1f602029ffaae81a6ae900000000dc0047304402206558714362318ff5aa05bd1849b82726f4d3ab2545bc15379b73de1fca4ef6c002206ea00f130ea54d6e85f233a3d031bdf03d35a10319362fe41866d5c59c7d7b1b0100483045022100b9daea5e3da41e305b2a283825c45c7eef169364413af043115797124033f1ce022004ae32ecab1937fac90e904be684f893ccdd1d925d6b898aef7f275dcb9791ea01483045022100e54c2f805c5ba5025c375053c4604910a30e5bf86eb16a5c9ba35cd9f817aef802201f92da76cf31562ae28e527bd537ecf930139224a8d91d10886383958aadd6bd01ffffffff01b8ed0400000000001976a914a8305457f8965a5a60a8ebe1968fb9019b42fe6c88ac00000000
2
  • 1
    You should definitely post the transaction hex that you're trying to redeem with, and the steps you took to sign it. You can edit your question to add those in.
    – arubi
    Dec 5, 2018 at 18:25
  • Scripts look good to me.
    – James C.
    Dec 5, 2018 at 18:39

1 Answer 1

0

I have one observation, not sure if this leads to the error. Multisig scripts start with a hex "0", which compensates for a very early "off by one error" in the execution routines of the checksig routines. An element too much was popped off the stack. This "bug" is so long in the system, that everyone got accustomed to it, and removing it requires an enormous effort. So it became a feature :-) Looking at your tx, I see the third signature doesn't have this zero:

TX_IN[0] Script Sig (uchar[])
1) 0047304402206558714362318FF5AA05BD1849B82726F4D3AB2545BC15379B73DE1FCA4EF6C002206EA00F130EA54D6E85F233A3D031BDF03D35A10319362FE41866D5C59C7D7B1B01
2) 00483045022100B9DAEA5E3DA41E305B2A283825C45C7EEF169364413AF043115797124033F1CE022004AE32ECAB1937FAC90E904BE684F893CCDD1D925D6B898AEF7F275DCB9791EA01
3) 483045022100E54C2F805C5BA5025C375053C4604910A30E5BF86EB16A5C9BA35CD9F817AEF802201F92DA76CF31562AE28E527BD537ECF930139224A8D91D10886383958AADD6BD01 

which is disassembled sig1:

    00: OP_0, OP_FALSE:      an empty array is pushed onto the stack.
    47: OP_DATA_0x47:        push hex 47 (decimal 71) bytes on stack
    30: DER_SEQUENCE_0x30:    type tag indicating SEQUENCE, begin sigscript
    44: DER_LENGTH_0x44:      length of R + S
    02: DER_INT_0x02:         type tag INTEGER indicating length
    20: DER_LENGTH_0x20:      this is SIG R (32 Bytes)
        6558714362318FF5:AA05BD1849B82726
        F4D3AB2545BC1537:9B73DE1FCA4EF6C0
    02: DER_INT_0x02:         type tag INTEGER indicating length
    20: DER_LENGTH_0x20:      this is SIG S (32 Bytes)
        6EA00F130EA54D6E:85F233A3D031BDF0
        3D35A10319362FE4:1866D5C59C7D7B1B
    01: OP_SIGHASHALL:       this terminates the ECDSA signature (ASN1-DER structure)

and sig2:

00: OP_0, OP_FALSE:      an empty array is pushed onto the stack.
48: OP_DATA_0x48:        push hex 48 (decimal 72) bytes on stack
30: DER_SEQUENCE_0x30:    type tag indicating SEQUENCE, begin sigscript
45: DER_LENGTH_0x45:      length of R + S
02: DER_INT_0x02:         type tag INTEGER indicating length
21: DER_LENGTH_0x21:      this is SIG R (33 Bytes)
    00B9DAEA5E3DA41E:305B2A283825C45C
    7EEF169364413AF0:43115797124033F1
    CE
02: DER_INT_0x02:         type tag INTEGER indicating length
20: DER_LENGTH_0x20:      this is SIG S (32 Bytes)
    04AE32ECAB1937FA:C90E904BE684F893
    CCDD1D925D6B898A:EF7F275DCB9791EA
01: OP_SIGHASHALL:       this terminates the ECDSA signature (ASN1-DER structure)

and sig3:

48: OP_DATA_0x48:        push hex 48 (decimal 72) bytes on stack
30: OP_SEQUENCE_0x30:    type tag indicating SEQUENCE, begin sigscript
45: DER_LENGTH_0x45:      length of R + S
02: DER_INT_0x02:         type tag INTEGER indicating length
21: DER_LENGTH_0x21:      this is SIG R (33 Bytes)
    00E54C2F805C5BA5:025C375053C46049
    10A30E5BF86EB16A:5C9BA35CD9F817AE
    F8
02: DER_INT_0x02:         type tag INTEGER indicating length
20: DER_LENGTH_0x20:      this is SIG S (32 Bytes)
    1F92DA76CF31562A:E28E527BD537ECF9
    30139224A8D91D10:886383958AADD6BD
01: OP_SIGHASHALL:       this terminates the ECDSA signature (ASN1-DER structure)
2
  • I currently can't find the details here in stackexchange on this off-by-one error, I am sure Pieter Wille or G.Maxwell explained it. Maybe it was over at bitcointalk.org... Dec 7, 2018 at 12:13
  • Thnx. I checked my code again looking where i ignored and found a bug in my signing process. i am not sure that bug resulted this issue but as this answer lead me to checking signatures i mark it as correct.
    – mhk
    Dec 7, 2018 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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