How to check Bitcoin address balance from my application?

大城市里の小女人 提交于 2019-12-05 15:42:17

Use blockexplorer.com model and piggy back off their server or run your own using open source version at github.com/lirazsiri/blockexplorer

For now there is no simple way to get balance of a address that not in the wallet with bitcoin core. Maybe this function is under developing.

To get a address's balance, you need to compute the utxos on the address from the whole block chain. (I guess fornow there maybe no record of balance on each address, so you've to calculate it form the whole block chain)

You said in your question, you didn't want to use third site's API

(For example https://api.blockcypher.com/v1/btc/main/addrs/38DGj87axzmQiZeAd1w1y5FEmuu5a7pfBa).

You can run a bitcoin browser in you device, for example bitcoin explorer

It is not necessary to use web wallets to create addresses. You can install your own bitcoin server/daemon and act like your own bank.

This is the place to start if you want to know how to do it (https://en.bitcoin.it/wiki/Main_Page).

Bitcoin can be queried using JSON RPC methods. So if you are running a bitcoin daemon locally you can just query them. The documentation for the same is located at

Running Bitcoin - https://en.bitcoin.it/wiki/Running_Bitcoin

API Reference - https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)

API Call List - https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

Hope this helps.

user3392193

You can use JSON-RPC method. bitcoind widely supports JSON-RPC calls. So just go to the official website of bitcoin and find all of the methods.

Here is an example in PHP. Just include the jsonClient.php file

<\?php
 require_once jsonRPCClient.php'; <br />
$bitcoin = 'https://' . $rpcusername . ':' . $rpcpassword . 
                    '@' . $rpcip . ':' . $rpcport . '/'; <br />

print_r($bitcoin->getnewaddress()); 

?>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!