Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Jessica432 on September 26, 2018, 09:24:23 AM



Title: Questions for developing application for bitcoin
Post by: Jessica432 on September 26, 2018, 09:24:23 AM
I am new to bitcoin world. I want to set up a local bitcoin full running node and develop my Node JS code talks to node, and provides web api for:
1) Getting balance for any bitcoin address
2) Doing a transfer of bitcoins from any account to any other account. (It may need private key of sender for transfer)

I tried bitcoin core earlier, but seems I can not get balance of any address there.

I will really appreciate any pointers how can I achieve this.

Thanks,
Jessica


Title: Re: Questions for developing application for bitcoin
Post by: aleksej996 on September 26, 2018, 10:32:33 AM
In order to get balance for an address that isn't in your wallet in Bitcoin Core, you need to import it first and do a rescan of the blockchain.

You can use importaddress command for this, which will by default do a rescan automatically once the address is imported, unless specified otherwise in an argument.

Furthermore, when checking the balance of an address with getbalance command, you need to set include_watchonly argument to true, in case you imported an address without importing it's private keys.


Title: Re: Questions for developing application for bitcoin
Post by: Jessica432 on September 27, 2018, 12:19:23 AM
In order to get balance for an address that isn't in your wallet in Bitcoin Core, you need to import it first and do a rescan of the blockchain.

Can above be done programmatically? If yes, would it slow down the execution significantly?


Title: Re: Questions for developing application for bitcoin
Post by: NeuroticFish on September 27, 2018, 06:28:57 AM
While researching I've found this "Bitcoin transaction explorer" code (https://github.com/yogh-io/bitcoin-transaction-explorer).
What caught my eyes and may be interesting for this topic was:
Quote
If this explorer is run on top of a node that has an address index such as this one: https://github.com/btcdrak/bitcoin/tree/addrindex-0.11 then this explorer will be able to look up the balance of an address and show every output associated with it.
The problem is that I didn't understand that "address index" part, nor what's at that link. However, it can be a direction...