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.


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.


  • 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.