简体   繁体   中英

sendrawtransaction is returning error when sending P2SH script to redeem funds

When I try to send the transaction:

0200000001359a74bdcfa7aea6f9f4e4cca17bc870d46269c0f0a6eaa6b5247b8c24f10ba200000000fdfd0047304402203c12558ab599bcbf7dca30b470dd3dd80cca2168f53d8a031818423a612f08b402201c6734b0fa540cc3957be654e00c9c810d7efa01efb3910d99d70dcfafaeebf9014cb3762103a0a6cc874c5f5d0726db4cf2662b99cc67944bde42ea857ce66a3024d233f638ac6300675368210227291539143aa8fb680298371d696fb79b7ce3100ee0e9c8a166e89ce361c4392102eadb538360917f81e7213db80232243c8132a13abea6c2c88ee878cc6008f3f02102502c4c66c19d5b864b529d80798158a7b5d8e9990c8724d7c517e3ecc4ddc7482102d7ba62e857e15ff3110345d815555952148b3cd3c7e141cd446935776a4cba6d54aeffffffff02e8030000000000001976a914f7418c7b078c301f13f6b68ea510d6a1ff419e3388ac282300000000000017a91443f661d060dab7f8fae42434f4165ea24c491c548700000000

I get the following error:

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

I'm signing the hash_256 digest of the raw transaction with SIGNHASH_ALL concantenated in 4 bytes:

0200000001359a74bdcfa7aea6f9f4e4cca17bc870d46269c0f0a6eaa6b5247b8c24f10ba20000000000ffffffff02e8030000000000001976a914f7418c7b078c301f13f6b68ea510d6a1ff419e3388ac282300000000000017a91443f661d060dab7f8fae42434f4165ea24c491c54870000000001000000
//Double SHA-256 Result:
56a472756ad48b81d851a984aea8c75147f472753b793fa497b894b8f796b7de

//Signature:
304402203c12558ab599bcbf7dca30b470dd3dd80cca2168f53d8a031818423a612f08b402201c6734b0fa540cc3957be654e00c9c810d7efa01efb3910d99d70dcfafaeebf9

//RedeemScript:
762103a0a6cc874c5f5d0726db4cf2662b99cc67944bde42ea857ce66a3024d233f638ac6300675368210227291539143aa8fb680298371d696fb79b7ce3100ee0e9c8a166e89ce361c4392102eadb538360917f81e7213db80232243c8132a13abea6c2c88ee878cc6008f3f02102502c4c66c19d5b864b529d80798158a7b5d8e9990c8724d7c517e3ecc4ddc7482102d7ba62e857e15ff3110345d815555952148b3cd3c7e141cd446935776a4cba6d54ae

Why is this occurring? What am I missing from my transaction/signing process.

Turns out for P2SH, the redeemScript hex goes into the scriptSig of the transaction data that's to be signed. Example:

0200000001359a74bdcfa7aea6f9f4e4cca17bc870d46269c0f0a6eaa6b5247b8c24f10ba2<# of bytes in Redeemscript><RedeemScript>0000000000ffffffff02e8030000000000001976a914f7418c7b078c301f13f6b68ea510d6a1ff419e3388ac282300000000000017a91443f661d060dab7f8fae42434f4165ea24c491c54870000000001000000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM