Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: linuxqq on July 09, 2020, 03:48:47 AM



Title: scripthash to address
Post by: linuxqq on July 09, 2020, 03:48:47 AM
Maybe I don’t have a special understanding of the principles of Bitcoin, but I’m working hard to learn. I currently read the electrumx rosksdb directly. It seems that electrumx stores scripthash, but I want to get all the wallet addresses, a lot of BTC explorer How did they get the wallet address? electrumx's database does not store scriptPubKey,I have used electrumx to synchronize all the data, but I can’t get all the addresses because the scripthash is stored


Title: Re: scripthash to address
Post by: pooya87 on July 09, 2020, 04:59:11 AM
you can't reverse a hash so you can't go from the hash that ElectrumX database stores to the address.
it is not meant to be used like that anyways, the purpose of this design is for a user to hash their own address then send that hash to the Electrum node, then the node that has stored simple fixed length hashes can easily look up the balance and history and return it.


Title: Re: scripthash to address
Post by: linuxqq on July 09, 2020, 05:45:59 AM
If all I get is an address hash, does that mean I can't get all wallet addresses from electrumx?


Title: Re: scripthash to address
Post by: bob123 on July 09, 2020, 08:00:28 AM
If all I get is an address hash, does that mean I can't get all wallet addresses from electrumx?

Not directly in terms of calculate the input out of the resulting hash.
But in this case you could just create a list of all addresses and their hash. Then lookup the hash in your table and you got the corresponding address.


[...] It seems that electrumx stores scripthash, but I want to get all the wallet addresses, a lot of BTC explorer How did they get the wallet address?

Block explorer run a full node (e.g. bitcoin core) with txindex=1 and some custom software to query the needed data.
They most likely don't run an electrum server. There is no obvious reason to do so.


Title: Re: scripthash to address
Post by: linuxqq on July 09, 2020, 10:36:56 AM
If all I get is an address hash, does that mean I can't get all wallet addresses from electrumx?

Not directly in terms of calculate the input out of the resulting hash.
But in this case you could just create a list of all addresses and their hash. Then lookup the hash in your table and you got the corresponding address.


[...] It seems that electrumx stores scripthash, but I want to get all the wallet addresses, a lot of BTC explorer How did they get the wallet address?

Block explorer run a full node (e.g. bitcoin core) with txindex=1 and some custom software to query the needed data.
They most likely don't run an electrum server. There is no obvious reason to do so.

Thank you very much, I think your suggestion is very good, I can create my own database to map hash and publickey in redis