romanz / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
1.06k stars 396 forks source link

Accounting of old P2PK transactions #248

Closed landergate closed 4 years ago

landergate commented 4 years ago

Looks like some old P2PK transactions are not accounted with corresponding addresses:

tx: 67c16524db1f29de5f5d77c91abd149ab0c28f7d27adca359e6ddf7135eea459
address: 16erb3D9TbmnW2U1bFnKSjQuqohXasMARi

It shows 0 transactions/received/spent while other engines display some activity on that address.

77 could be related?

romanz commented 4 years ago

There is a ambiguity when encoding P2PK output into an address - since given a public key, we can create two different scripts that can be authorized by its corresponding private key:

  1. https://learnmeabitcoin.com/guide/p2pk
  2. https://learnmeabitcoin.com/guide/p2pkh

Those scripts are are different - so their "scripthash" (used by Electrum for querying and Electrs for indexing) are different as well.

Some explorers are encoding P2PK output scripts using a "related" P2PKH by hashing the corresponding public key (e.g. Blockchain.info) - but not all of them (e.g. Esplora).

Personally, I am not sure what is the optimal solution here though :)