No sigScript allowed when spending... hm. How do I create a witness program for a dumb script for which there is no known public and private key? Is it even possible?
The correct address should be the one provided by vjudeu from Bitcoin Core's decodescript command.
To spend it, you'll basically have to do the same as your previous transaction, but for SegWit:
01000000 < Version 1
00 < SegWit marker
01 < SegWit flag
01 < amount of input(s)
f052c63f7cc387e85f96c99dc108f53289943f03d3814e0ff5e8f54f8e22d29e < input1 txid (reverse)
00000000 < input1 index
00 < script length (0 for p2wpkh)
ffffffff < input1 nSequence
01 < amount of output(s)
60EA000000000000 < output amount (reverse)
1976a914b77e875983ee5851006ec5bd461208ebd11ea1bf88ac < output scriptPubkey
-------------------------------------------Witness for input 0--------------------------------------------
02 < Number of Stack Items
01 51 < Stack item 0 (Size OP_PUSHNUM_1)
02 7551 < Stack item 1 (Size OP_Drop 1 OP_PUSHNUM_1)
-------------------------------------------Witness for input 0--------------------------------------------
00000000 < nLocktime
Your previous transaction's scriptSig "
0x0451027551" is used as Witness.
But in P2WPKH Spend, the number of stack items must be indicated followed by those stack items with their respective sizes.
Transactions:
Spent by:
blockstream.info/testnet/tx/1b291f7cf57e827f6e8d1225657264fcee9ad4a8248e769c2788a8196a2bda6b (
the example above)
Funded by:
blockstream.info/testnet/tx/9ed2228e4ff5e8f50f4e81d3033f948932f508c19dc9965fe887c37c3fc652f0