coinbase / mesh-bitcoin

Bitcoin Mesh API Implementation
Apache License 2.0
113 stars 123 forks source link

P2PK outputs are not indexed under the correct address #109

Open qtum-neil opened 2 years ago

qtum-neil commented 2 years ago

Is your feature request related to a problem? Please describe. P2PK outputs (OP_DATA_65 OP_CHECKSIG, OP_DATA_33 OP_CHECKSIG) are indexed under their output hex value, because bitcoin client does not return an address for those under scriptPubkey when decoding such transactions (https://github.com/coinbase/rosetta-bitcoin/blob/master/bitcoin/client.go#L777). This results in balances being incorrect for addresses that receive P2PK outputs.

Describe the solution you'd like P2PK outputs should be correctly detected and indexed under their corresponding address to avoid balance discrepancies. as it is the case in all wallets.

Describe alternatives you've considered An alternative to this could be aggregating balances for both the address and its P2PK hex script when querying the balance, but it would be best to fix this at the indexing level.