<p>Take a look at the <a href="https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/10_6_Spending_a_P2SH_Transaction.md" rel="nofollow noreferrer">section about spending a p2sh</a> 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.</p>
<p>In the example it says:</p>
<blockquote>
<p>[...] signing requires entering extra information for the (1)
scriptPubKey; (2) the redeemScript; and (3) any required private keys.</p>
<p>Here's the example of doing so for that P2SH-embedded multisig in
§6.2: <code>$ bitcoin-cli -named signrawtransactionwithkey hexstring=$rawtxhex prevtxs='''[ { &quot;txid&quot;: &quot;'$utxo_txid'&quot;, &quot;vout&quot;: '$utxo_vout', &quot;scriptPubKey&quot;: &quot;'$utxo_spk'&quot;, &quot;redeemScript&quot;: &quot;'$redeem_script'&quot; } ]''' privkeys='[&quot;cNPhhGjatADfhLD5gLfrR2JZKDE99Mn26NCbERsvnr24B3PcSbtR&quot;]'</code></p>
<p>With any other sort of P2SH you're going to be including a different
redeemscript, but otherwise the practice is exactly the same.</p>
</blockquote>
<p>Does that help?</p>

CC BY-SA 4.0
2021-12-14T06:29:20.913Z
2021-12-14T06:29:20.913Z
zerotobtc
<p>The scriptPubkey above is a P2WSH nested in P2SH.</p>
<p>In order to unlock this coin:</p>
<ul>
<li>Put P2WSH payload into input scriptSig.<code>00204a3babc5f8f8f5f67b6331c18931e6f198b6cf576b0f3747314d11dedddf97c5</code></li>
<li>Put P2WSH's witnessScript(redeemScript) into input witness. <code>515293</code></li>
</ul>
<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WSH_nested_in_BIP16_P2SH" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WSH_nested_in_BIP16_P2SH</a></p>

CC BY-SA 4.0
2021-12-14T04:43:46.657Z
2021-12-14T04:43:46.657Z
Shigeyuki Azuchi
<p>i transferred some coins to a testnet address <code>2MwP5KwNRsQV5cf3T7VcFU4Vhj2LcUeMiLM</code> with a locking script just to play with scripts. the locking script is <code>OP_1 OP_2 OP_ADD</code> (always evaluates to true).</p>
<p>how can i get the coins from this address? (not for the coins, but to learn bitcoin script)</p>
<p>the address was made with <code>bitcoin-cli decodescript 515293</code></p>
<pre><code>...
  &quot;p2sh-segwit&quot;: &quot;2MwP5KwNRsQV5cf3T7VcFU4Vhj2LcUeMiLM&quot;
...
</code></pre>
<p>(btw i know you can now claim the 1000 test sat, but please tell me how)</p>

<script><raw-transaction>
unlock non standard script
Antoni
# unlock non standard script

(Asked by: username_0 on 2021-12-13)

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)

**Tags:** script, raw-transaction


---

## 2 answers

### Answer by username_1 on 2021-12-14. Score: 2 | Accepted answer

Take a look at the [section about spending a p2sh](https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/10_6_Spending_a_P2SH_Transaction.md) 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?


---

### Answer by username_2 on 2021-12-14. Score: 0

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`

<https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WSH_nested_in_BIP16_P2SH>


---

