janoside / btc-rpc-explorer

Database-free, self-hosted Bitcoin explorer, via RPC to Bitcoin Core.
https://bitcoinexplorer.org
MIT License
1.54k stars 1.16k forks source link

Old legacy mined address and coinbase address history missing #417

Open blackdimund opened 2 years ago

blackdimund commented 2 years ago

Describe the bug

Older mined history sometimes doesn't show up on the webui. I noticed two things going on, some very old addresses that mined bitcoin (usually P2PK) do not have any history at all when it definitely does. The other thing is older coinbase tx's, they don't show what address the coinbase was sent to (also usually P2PK)

Environment (please complete the following information):

Bitcoin Core / Node Version 22.0.0
NodeJS Version 16.13.2
Browser firefox
Code Version / Commit https://github.com/janoside/btc-rpc-explorer/commit/581ad524cd31355394a2f6a63a3b6f49b9787c77
Installation Method npm

Configuration file content

Please include the content from the following files. BE SURE TO MODIFY YOUR CREDENTIALS BEFORE SUBMITTING!!!

bitcoin.conf
server=1
txindex=1
rpcuser=wen_100k
rpcpassword=wen_100k
rpcallowip=192.168.1.0/24
rpcbind=0.0.0.0

Your btc-rpc-explorer environment configuration
BTCEXP_HOST=0.0.0.0
BTCEXP_BITCOIND_USER=wen100k
BTCEXP_BITCOIND_PASS=wen100k
Options: electrumx
BTCEXP_ADDRESS_API=electrumx
BTCEXP_ELECTRUM_SERVERS=tcp://127.0.0.1:50001
BTCEXP_SLOW_DEVICE_MODE=false
BTCEXP_BASIC_AUTH_PASSWORK=wouldntyouliketoknow

To Reproduce

Steps to reproduce the behavior: this address has history as seen on blockchaininfo, but the address has no history on btc-rpc-explorer https://www.blockchain.com/btc/address/15NdaX7vQdzphXKjTQ8NWFZCKAJ4iYoj3k https://bitcoinexplorer.org/address/15NdaX7vQdzphXKjTQ8NWFZCKAJ4iYoj3k

block #0 look correct, but block #1 and most the blocks up to # 200,000 do not show where the coinbase went to https://bitcoinexplorer.org/block-height/1 https://bitcoinexplorer.org/block-height/205000

jsarenik commented 2 years ago

Please have a look at https://learnmeabitcoin.com/technical/p2pk

And also this one: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses

Notice the genesis block sends the reward to P2PK and the address you can see in the explorers is just a placeholder as P2PK does not have an address.

blackdimund commented 2 years ago

Ah I remember this now, they technically have no real address but the explorers are taking the public key from inside the P2PK script and converting that to an address. I actually helped the learnmeabitcoin guy find some bugs few years back from this old stuff. So is there any plans to be able to follow these coins through the blockchain whether through these placeholder addresses, or maybe through the locking script/pubkey?

cricktor commented 2 years ago

So is there any plans to be able to follow these coins through the blockchain whether through these placeholder addresses, or maybe through the locking script/pubkey?

To my still limited knowledge this is also related to that Electrum servers (or maybe the Electrum protocol) don't find/retrieve such transactions when the output is a P2PK.

I am currently in the process to find a way to create a watch-only wallet for the Patoshi attributed blocks. Of course no success with Electrum. Apparently no success with Bitcoin Core too, if you only use the PK substitute public address. I assume, I will have to figure out if and how to import the "output script" as "thing to watch" if that is possible in whatever suitable wallet for my educational Bitcoin history research project. Not sure what other public Bitcoin blockchain explorers do, the bigger ones are clearly able to display the full UTXO amount of coins for such legacy P2PK public addresses.

blackdimund commented 2 years ago

I know if you have the private key for a p2pk address you can getaddressinfo and grab the "pkh([000000000]AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)#AAAAAAA", then do on the online wallet that has no privkey: importmulti '[{desc:"pkh([000000000]AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)#AAAAAAA",label:"",timestamp:0,watchonly:true}]' '{rescan:false}' and you can watchonly the wallet that way. might have to check my syntax on that. but idk how to do that with an address i dont have the privkey for, idk if that helps

cricktor commented 2 years ago

@blackdimund I am more focused on commands like importaddress which accepts also some kind of hex script instead of only the public address. So I need to figure out what is meant by script and if and what could be suitable for such P2PK transactions. Then there is also importpubkey which sounds most promising to me. Will have to check this and brush up my knowledge (or gain missing).

Of course, any further hints are still welcome!