i transferred some coins to a testnet address 2MwP5KwNRsQV5cf3T7VcFU4Vhj2LcUeMiLM with a locking script just to play with scripts. the locking script is OP_1 OP_2 OP_ADD (always evaluates to true).

how can i get the coins from this address? (not for the coins, but to learn bitcoin script)

the address was made with bitcoin-cli decodescript 515293

  "p2sh-segwit": "2MwP5KwNRsQV5cf3T7VcFU4Vhj2LcUeMiLM"

(btw i know you can now claim the 1000 test sat, but please tell me how)

2 Answers 2


Take a look at the section about spending a p2sh in the learning bitcoin from the command line course. It mainly refers back to previous sections explaining the single steps but I think your question is about the variables that you need to put into the signing-transactions-command.

In the example it says:

[...] signing requires entering extra information for the (1) scriptPubKey; (2) the redeemScript; and (3) any required private keys.

Here's the example of doing so for that P2SH-embedded multisig in §6.2: $ bitcoin-cli -named signrawtransactionwithkey hexstring=$rawtxhex prevtxs='''[ { "txid": "'$utxo_txid'", "vout": '$utxo_vout', "scriptPubKey": "'$utxo_spk'", "redeemScript": "'$redeem_script'" } ]''' privkeys='["cNPhhGjatADfhLD5gLfrR2JZKDE99Mn26NCbERsvnr24B3PcSbtR"]'

With any other sort of P2SH you're going to be including a different redeemscript, but otherwise the practice is exactly the same.

Does that help?


The scriptPubkey above is a P2WSH nested in P2SH.

In order to unlock this coin:

  • Put P2WSH payload into input scriptSig.00204a3babc5f8f8f5f67b6331c18931e6f198b6cf576b0f3747314d11dedddf97c5
  • Put P2WSH's witnessScript(redeemScript) into input witness. 515293


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.