<blockquote>
  <p>Does this mean that in order for me to test my segwit code, I will have to wait till I get a segwit input somehow?</p>
</blockquote>

<p>Yes. You have non-segwit inputs. You cannot create a segwit transaction when your transaction has only non-segwit inputs.</p>

<p>To get a segwit input, just send some of your Bitcoin to a segwit address that you own.</p>

CC BY-SA 4.0
2020-03-22T01:46:35.167Z
2020-03-22T01:46:35.167Z
Ava Chow
<p>Only segwit outputs can be spent using segwit inputs.</p>

<p>A segwit transaction is a transaction with at least one segwit input.</p>

<p>You'll first need to create a segwit output to test segwit spending.</p>

CC BY-SA 4.0
2020-03-22T01:46:18.370Z
2020-03-22T01:46:18.370Z
Pieter Wuille
<p>I am trying to build a segwit transaction between a regular p2pkh address and a p2sh 2-of-2 multi-signature address. I have successfully transacted back and forth between these two addresses before (Testnet), but now I want to implement a segwit transaction. However, when I try to broadcast the transaction, it says "unexpected witness payload for non-witness script..". I am seeing the default witness field as "b'\x00'".</p>

<p>Documenting myself more about the subject, I found that "If all txins in a transaction are not associated with any witness data, the transaction MUST be serialized in the original transaction format, without marker, flag, and witness".</p>

<p>Does this mean that in order for me to test my segwit code, I will have to wait till I get a segwit input somehow?</p>

<p>This is my transaction hex:</p>

<pre><code>01000000000102575307b5cd2a1364c48501434790c0e83c22a16a4b5a902b62e46a34bca06a81000000006b483045022100e07aeaa18e08dedbeebfa7c7299dad2a5dd18df0b31af2f654f2a139d5c6f3900220286b641f4a444d23c952cded85939177abbc7510f909f156fadef5399e20dbe8012103e07f96e5ba598431c0c994493a4ae988c9854c171d5d4bb140db0a27a4c853e4fffffffff53d3533ab79d8425526a7378c91a718e8b526ca32e317b4193333949c261ec9000000006a4730440220780a21e18feeddecb6ca999370fe76a8b612dbaca18ea1249bc312da32f4534c02207342a4d9daea5bbc314e1965f952fbc7fcfcfa5b3b208efc9f2fe0f380afa39b012103e07f96e5ba598431c0c994493a4ae988c9854c171d5d4bb140db0a27a4c853e4ffffffff02102700000000000017a914c104b576f5436309587aefa3ddddd5c295b904808702db1d00000000001976a91452903efc1004de01883ba3687be2a8ea4f6b1b1988ac0100010000000000
</code></pre>

<segregated-witness><raw-transaction>
Can I build a raw segwit transaction with no segwit inputs?
Oscar Serna
# Can I build a raw segwit transaction with no segwit inputs?

(Asked by: username_0 on 2020-03-22)

I am trying to build a segwit transaction between a regular p2pkh address and a p2sh 2-of-2 multi-signature address. I have successfully transacted back and forth between these two addresses before (Testnet), but now I want to implement a segwit transaction. However, when I try to broadcast the transaction, it says "unexpected witness payload for non-witness script..". I am seeing the default witness field as "b'\x00'".
Documenting myself more about the subject, I found that "If all txins in a transaction are not associated with any witness data, the transaction MUST be serialized in the original transaction format, without marker, flag, and witness".
Does this mean that in order for me to test my segwit code, I will have to wait till I get a segwit input somehow?
This is my transaction hex:
01000000000102575307b5cd2a1364c48501434790c0e83c22a16a4b5a902b62e46a34bca06a81000000006b483045022100e07aeaa18e08dedbeebfa7c7299dad2a5dd18df0b31af2f654f2a139d5c6f3900220286b641f4a444d23c952cded85939177abbc7510f909f156fadef5399e20dbe8012103e07f96e5ba598431c0c994493a4ae988c9854c171d5d4bb140db0a27a4c853e4fffffffff53d3533ab79d8425526a7378c91a718e8b526ca32e317b4193333949c261ec9000000006a4730440220780a21e18feeddecb6ca999370fe76a8b612dbaca18ea1249bc312da32f4534c02207342a4d9daea5bbc314e1965f952fbc7fcfcfa5b3b208efc9f2fe0f380afa39b012103e07f96e5ba598431c0c994493a4ae988c9854c171d5d4bb140db0a27a4c853e4ffffffff02102700000000000017a914c104b576f5436309587aefa3ddddd5c295b904808702db1d00000000001976a91452903efc1004de01883ba3687be2a8ea4f6b1b1988ac0100010000000000

**Tags:** segregated-witness, raw-transaction


---

## 2 answers

### Answer by username_1 on 2020-03-22. Score: 2 | Accepted answer

> Does this mean that in order for me to test my segwit code, I will have to wait till I get a segwit input somehow?

Yes. You have non-segwit inputs. You cannot create a segwit transaction when your transaction has only non-segwit inputs.

To get a segwit input, just send some of your Bitcoin to a segwit address that you own.


---

### Answer by username_2 on 2020-03-22. Score: 1

Only segwit outputs can be spent using segwit inputs.

A segwit transaction is a transaction with at least one segwit input.

You'll first need to create a segwit output to test segwit spending.


---

