0

During parsing of Bitcoin data from blockchain, I found many transactions which has invalid script (example 37b828de0da38f0b3b9ec09f6f8b7883c3202a99a285b0b0087f19f9cbf526d9,f6502e80d8a8dc9e59bb518a62a6443479dd72cd153929272ac21bab26317226)

Is there a way to parse these scripts to pull out the output address? If not, what happened to the BTC send to these invalid script?

2

1 Answer 1

2

During parsing of Bitcoin data from blockchain, I found many transactions which has invalid script (example 37b828de0da38f0b3b9ec09f6f8b7883c3202a99a285b0b0087f19f9cbf526d9,f6502e80d8a8dc9e59bb518a62a6443479dd72cd153929272ac21bab26317226)

Is there a way to parse these scripts to pull out the output address?

Addresses are human-readable shorthand ways of writing scriptPubKeys that follow a certain template. Not every script has a corresponding address. Only these are defined:

  • P2PKH addresses (1...): OP_DUP OP_HASH160 <keyhash> OP_EQUALVERIFY OP_CHECKSIG.
  • P2SH addresses (3..., defined in BIP13): OP_HASH160 <scripthash> OP_EQUAL (defined in BIP16).
  • P2WPKH addresses (42-character bc1q..., defined in BIP173): OP_0 <pubkeyhash> (defined in BIP141).
  • P2WSH addresses (62-character bc1q..., defined in BIP173): OP_0 <scripthash> (defined in BIP141).
  • P2TR addresses (62-character bc1p..., defined in BIP350): OP_1 <tweaked key> (defined in BIP341).
  • Future native witness addresses (bc1..., defined in BIP350): OP_n <program>.

Any scriptPubKey not matching any of the above templates doesn't have a corresponding script. Unparseable scripts are among those.

If not, what happened to the BTC send to these invalid script?

Those coins are lost. There is no way to spend them, because the script can't be executed if it can't be parsed, and without it executing successfully it can't be spent.

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.