0

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
1

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.

| improve this answer | |
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.