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 community
If 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.