<p>For this example, we will use a transaction that spends two outputs from a previous transaction. The first output (1N2) is paid to the pubkey script &quot;P2SH-P2WPKH&quot; and the second output (1N3) is paid to the pubkey script &quot;P2SH&quot;.</p>
<ol>
<li>Create the first transaction that spends the two outputs from a previous transaction. In this example, the first output (1N2) is paid to the pubkey script &quot;P2SH-P2WPKH&quot; and the second output (1N3) is paid to the pubkey script &quot;P2SH&quot;.</li>
</ol>
<p>bitcoin-cli sendtoaddress 1N2 P2SH-P2WPKH
bitcoin-cli sendtoaddress 1N3 P2SH</p>
<ol start="2">
<li>Get the hex encoded transaction data for the first transaction.</li>
</ol>
<p>bitcoin-cli gettransaction 1N2</p>

CC BY-SA 4.0
2022-04-20T02:01:35.297Z
you might want to use markup and/or example values or otherwise somehow make it more clear what strings in your answer are variables, flags, commands, etc
Luke Mlsna
CC BY-SA 4.0
2022-04-20T02:02:00.633Z
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Luke Mlsna
CC BY-SA 4.0
2022-04-08T18:18:20.043Z
2022-04-08T18:18:20.043Z
akaBTC
<p>Can you give a simple step-by-step example on how to create a transaction with an output of P2SH-P2WPKH using bitcoin-cli on Regtest?</p>

CC BY-SA 4.0
2022-04-08T16:54:13.317Z
By P2SH-P2WPKH transaction, you mean a transaction that has such an output, or has an input spending such an output?
Pieter Wuille
CC BY-SA 4.0
2022-04-08T19:21:34.033Z
Thx, I modified the question to clarify that is a transaction with such an output
Bitcoin_1o1
<transactions><segregated-witness><p2sh-p2wpkh>
How to make a P2SH-P2WPKH output using bitcoin-cli?
Bitcoin_1o1
# How to make a P2SH-P2WPKH output using bitcoin-cli?

(Asked by: username_0 on 2022-04-08)

Can you give a simple step-by-step example on how to create a transaction with an output of P2SH-P2WPKH using bitcoin-cli on Regtest?

**Tags:** transactions, segregated-witness, p2sh-p2wpkh

> **Comments:**
> **username_1**: By P2SH-P2WPKH transaction, you mean a transaction that has such an output, or has an input spending such an output?  
> **username_0**: Thx, I modified the question to clarify that is a transaction with such an output  

---

## 1 answers

### Answer by username_2 on 2022-04-08. Score: -1

For this example, we will use a transaction that spends two outputs from a previous transaction. The first output (1N2) is paid to the pubkey script "P2SH-P2WPKH" and the second output (1N3) is paid to the pubkey script "P2SH".

1. Create the first transaction that spends the two outputs from a previous transaction. In this example, the first output (1N2) is paid to the pubkey script "P2SH-P2WPKH" and the second output (1N3) is paid to the pubkey script "P2SH".

bitcoin-cli sendtoaddress 1N2 P2SH-P2WPKH
bitcoin-cli sendtoaddress 1N3 P2SH

2. Get the hex encoded transaction data for the first transaction.

bitcoin-cli gettransaction 1N2

> **Comments:**
> **username_3**: you might want to use markup and/or example values or otherwise somehow make it more clear what strings in your answer are variables, flags, commands, etc  
> **username_3**: As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).  

---

