How can I create an anyone-can-spend transaction using p2pkh outputs?
Also how would such a transaction in hex look like?
Bitcoin Stack Exchange is a question and answer site for Bitcoin users, developers, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityIf it's a P2PKH output, it's not anyone-can-spend. P2PKH implies there is a public key that needs to sign for spending.
You can use a P2SH or P2WSH output which sends to an OP_TRUE
script, though.
You can also manually craft a transaction with a scriptPubKey that is literally OP_TRUE
. No address corresponds to such an output, so you couldn't use off the shelf wallet software for it.
For a P2PKH anyone-can-spend, just send to the address 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH -- its private key is the integer 1, or in WIF format, KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn. Anyone can spend from this address since the private key is known to all.