0

I'm studying Bitcoin's Protocol and I want to replicate P2MS in regtest. Yes I know that I can use P2SH but I'd like to understand it more in depth.

I Have 3 addresses P2PKH (A and B and C). A has 50 bitcoin and move 49,99 to B.

B wants to have 1-2 Multisig, for that reason A puts B's conditions in locking script.

0200000001a29959c78ff03a2a019aac9cb3ea5a6fc7f55693d6485cb153f1e3ef9df42c290000000000ffffffff01606b042a010000008751410438323fc5794ce06ef9326c4aed86d0f66b590722b914cacf256ebd37b9409ef32f9c0ce5dbded7671338d365d377838da07d4cfc0b79f9080734da0e7e74d6664104c7f443de0ca4063c75d4d6757c02400a45e6e1f7229ee5e8d4300ad64f36826de63299b3792033edbaa2fd3ae14cfcec4970a2f58700f1790971e6b69a6512a952AE00000000

The transaction works and it is mined.

Now, I want to move From B to C. Todo that, B has to get at least one signature. B signs with its private key, which is the first public key in the locking script.

bitcoin-cli signrawtransactionwithkey $TX_DATA '["'$PK'"]'

but I get that error:

{
  "hex": "020000000171c13748ac39ba0b28c3ca4ddb65687e24d11d2e75330b297440b77d73ef4a4400000000020000ffffffff01c0aff6290100000017a91423129d3a243e4ffebecf9cecfab2e16ebbeff1998700000000",
  "complete": false,
  "errors": [
    {
      "txid": "444aef737db74074290b33752e1dd1247e6865db4dcac3280bba39ac4837c171",
      "vout": 0,
      "witness": [
      ],
      "scriptSig": "0000",
      "sequence": 4294967295,
      "error": "Script evaluated without error but finished with a false/empty top stack element"
    }
  ]
}

Now, Can I get the signature in another way in order to add OP_0 for CHECKMULTISIG bug? In That way I can Put the signature in scriptSig.

Thanks

  • I would try modifying the raw, signed transaction. Since the input script is replaced by the previous output's locking script, and is therefore not signed, this should be possible. Export the raw, signed transaction in hex form and adjust the input's scriptSig: increment the script length's size indicator (a VarInt) by 1, and add "00" in front of the scriptSig itself. Then try to push the new raw signed transaction. – Septem151 Jan 25 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.