1

I am trying to sign a raw transaction that spends output #2 (txindex 1) from this transaction: 267c6d75851efa18afb7edeb2da00c09afc575231db84b3277fc7ea3e174ecbd

The output is a 1-of-4 multisig P2SH and I think I may have a mistake in the transaction structure used to generate the signature. The signature I calculate is different (as in cryptographically different) to the one that bitcoin core gives me using signrawtransaction.

As I see it this is the transaction structure which must be signed:

Version:   01000000
TxIn:      01 bdec74e1a37efc77324bb81d2375c5af090ca02debedb7af18fa1e85756d7c26 01000000 
subScript: 17 a9 14 37fe3f20433380be4c742c978d3a9712c509656e 87 
Sequence:  ffffffff 
TxOut:     OUTPUTDATA
Locktime:  00000000 
Hashtype:  01000000

The double-sha256 value used to calculate the signature is 9d384de385512525b4faf08c97651e410e77f2906aa8baeefdee151cc0994655

But the Bitcoin network rejects my transaction calculated from this transaction structure.

I will happily provide more information such as redeemScript and pubKeys/privateKeys if the mistake should not be in the transaction structure.

Any help is appreciated! Thanks!

1

For P2SH transactions, the redeemScript is what is put in the scriptSig for the transaction preimage, not the scriptPubKey of the output.

  • I still cannot make it work. The redeemScript that hashes to "37fe3f20433380be4c742c978d3a9712c509656e" is "512102930a11e92103daefde0d30b552f57d303e94a128e763ca9e69ff2006446934442103e74d2113dec75d75cde09a5b46297b1067e4b8b35e63c4c32b8cdbadfdffda1e2103067fcc39ee36d2417684511d1055fdc7d35e54911cb9de9ae30c988b666f675c2102dfb1c2a1c3456c8cb76714706dba77b3f4e7fe5afffc2503b121323a48ebbdcf54ae", with a length of "8b". – Bjarne Oct 9 '17 at 19:30
  • My new preimage is as above but changning subScript to: "4c8b512102930a11e92103daefde0d30b552f57d303e94a128e763ca9e69ff2006446934442103e74d2113dec75d75cde09a5b46297b1067e4b8b35e63c4c32b8cdbadfdffda1e2103067fcc39ee36d2417684511d1055fdc7d35e54911cb9de9ae30c988b666f675c2102dfb1c2a1c3456c8cb76714706dba77b3f4e7fe5afffc2503b121323a48ebbdcf54ae" – Bjarne Oct 9 '17 at 19:31
  • But I still get the same error messages and when using the valid signature from bitcoin core cannot validate it using this preimage. – Bjarne Oct 9 '17 at 19:31
  • 1
    After checking it for a hundred times I saw that in the pastebin I uploaded I forgot to add the OP_0 (0x00) in the front of the scriptSig. After adding this it works! Thanks a lot for pointing out that the redeemScript is used in the preimage! This was the final signed transaction: – Bjarne Oct 10 '17 at 15:00
  • 1
    0100000001bdec74e1a37efc77324bb81d2375c5af090ca02debedb7af18fa1e85756d7c2601000000d60047304402204887a352b503da6f212c09ed7e973384d7660f62d2319a15b968252012d134810220695130bc101f44348203c51a50e46f37ed4bc5622795f5dfbddef2affb27e2a8014c8b512102930a11e92103daefde0d30b552f57d303e94a128e763ca9e69ff2006446934442103e74d2113dec75d75cde09a5b46297b1067e4b8b35e63c4c32b8cdbadfdffda1e2103067fcc39ee36d2417684511d1055fdc7d35e54911cb9de9ae30c988b666f675c2102dfb1c2a1c3456c8cb76714706dba77b3f4e7fe5afffc2503b121323a48ebbdcf54aeffffffff01c05d00000000000017a914de5462e6e84cdab5064220343b9331a3af6dbbf18700000000 – Bjarne Oct 10 '17 at 15:05

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.