Types of ScriptPubKey that can contain addresses

1

I'm trying to get the addresses from the ScriptPubKeys in each transaction (where possible). So far, I know of two patterns of ScriptPubKey where an address can be found:

1. Pay-To-Pubkey

04e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93 OP_CHECKSIG

In this locking script, the code before OP_CHECKSIG is a public key, so that can be converted in to an address.

2. Pay-To-Pubkey-Hash

OP_DUP OP_HASH160 3d37cde30fdfcf29b2996a7ceefd220ba32c9f4b OP_EQUALVERIFY OP_CHECKSIG

In this one, the code after OP_HASH160 (and before the next OP code) is the hash160 of a public key, so that can be converted to an address also.

Question:

Are there any other patterns of ScriptPubKey where addresses can be found?

Or in other words, will I be able to capture every address by working on all non-opcodes before OP_CHECKSIG, and all non-opcodes after OP_HASH160?

inersha

Posted 2016-11-01T14:44:01.397

Reputation: 2 236

Answers

1

Technically, pay-to-pubkey doesn't have an address type. You can derive an address as if it were a pay-to-pubkeyhash scriptPubKey, but there is a subtle difference.

The other type you are forgetting is a pay-to-scripthash type. It's of the format

OP_HASH160 <Hash160(redeemScript)> OP_EQUAL

Then, you get a p2sh adddress by prepending the version byte and appending the checksum to <Hash160(redeemScript)>

Chris Stewart

Posted 2016-11-01T14:44:01.397

Reputation: 865

1

OP_1 [pubkey] OP_1 OP_CHECKMULTISIG

amaclin

Posted 2016-11-01T14:44:01.397

Reputation: 5 763