How to monitor balance for addresses other than by using importAddress?

0

Is there any way, other than importaddress, to watch balances of specific addresses?

If not, how it is possible for wallets and explorers to give information (balance, transactions) about specific addresses even though importaddress takes some time? Because we have to rescan sooner or later.

Zohaib Sohail

Posted 2018-09-10T14:37:08.033

Reputation: 3

Answers

0

Is there any way, other than importaddress, to watch balances of specific addresses?

You can import a wallet that was exported in the dumpwallet format using the importwallet command. You can also import addresses using importmulti and importpubkey. But, in general, no, there is no way to watch balances of specific addresses in Bitcoin Core without using an import* command.

With Bitcoin Core 0.17, you can use the scantxoutset command which will scan the UTXO set for the UTXOs pertaining to an output script (defined in various ways).

If not, how it is possible for wallets and explorers to give information (balance, transactions) about specific addresses even though importaddress takes some time? Because we have to rescan sooner or later.

Wallets keep track of this information themselves. They do so in the same way that the import* command work. import* commands are wallet commands to tell a wallet to keep track of certain output scripts. They keep track of these in the same way: scan incoming blocks and transactions for outputs that match what they are looking for.

Blockchain explorers do not use Bitcoin Core nor do they use the wallet for this sort of stuff. They maintain their own databases that store the information for all transactions and their outputs. They do so in a similar way to wallets, but instead of looking for specific output scripts, they just store all output scripts.

Andrew Chow

Posted 2018-09-10T14:37:08.033

Reputation: 40 910

how Wallets are keeping track of this information?Zohaib Sohail 2018-09-11T08:09:53.407

any open Source block explorer you can refer?Zohaib Sohail 2018-09-11T08:10:16.137

Wallets keep track of this information by receiving all transactions (both in blocks and not) and then scanning the outputs of those transactions for specific scripts that they are looking for. If the scripts match, the transaction is stored and whatever internal databases are updated. As for open source block explorers, have a look at insight: https://github.com/bitpay/insight

Andrew Chow 2018-09-11T14:16:50.630

I dont know what but I m missing something. Could you please help me @Andrew ??? Lets say I made a wallet and have full synced node. A user with an address which also have some coins, comes to my wallet and sign-up. Now wallet will have to show balance of his address, but in my case I could not be able to show him without rescan - which takes some time. Then how do the already running wallets are doing it?Zohaib Sohail 2018-09-13T13:33:33.620

Users typically don't already have an address with coins when they create an account with an online wallet service. Or if they do, they aren't bringing those with them to that online service. Many online services are already indexing the blockchain anyways for all addresses. So it is very quick for them to just search through that index instead of rescanning the blockchain if a user imports their own addresses.Andrew Chow 2018-09-13T14:14:12.347

1

Is there any way, other than importaddress, to watch balances of specific addresses?

No, creating a watch-only address is the way to do this using a wallet such as Bitcoin-core.

how it is possible for wallets and explorers to give information ... even though importaddress takes some time?

Once the blockchain has been initially scanned for transactions involving an imported address, the wallet need only check new blocks for mentions of that address as it receives the new blocks, there should be no need to rescan the blockchain.

Blockchain explorers can maintain an index per address and continuously keep track of balances for all addresses. They don't need to recompute this from scratch for every new enquiry.

RedGrittyBrick

Posted 2018-09-10T14:37:08.033

Reputation: 4 815