Answer the question
In order to leave comments, you need to log in
How to find out the balance of a bitcoin address?
The server has a bitcoind client.
For each "client" an account is created and it has 4 addresses
var name = ['myaccount'];
var batch = [{method: 'getnewaddress', params: name}, {method: 'getnewaddress', params: name}, {method: 'getnewaddress', params: name}, {method: 'getnewaddress', params: name}];
client.cmd(batch, function(err, address, resHeaders) {
if (err) return console.log(err);
console.log('Address:', address);
});
client.cmd('getbalance', 'myaccount', 4, function(err, balance, resHeaders) {
if (err) return console.log(err);
console.log('Balance:', balance);
})
Answer the question
In order to leave comments, you need to log in
As far as I know, you can call the getbalance function in bitcoind
On the example of Linux:
The appearance of the line in the terminal [email protected]:~ bitcoind getbalance $address
$address is one of the addresses of the created bitcoin account
About "received a transfer" - in my opinion, there is no such function, you can try to track transactions on the wallet address:
With the help listtransaction
of every N minutes, receive the latest transactions, run them through the API of some bitcoin blockchain, take the date from the json decryption and compare it with the current one.
There are a lot of drawbacks to this option, but you can probably come up with a better scheme. This is just the first thing that came to mind
. Here is a list of bitcoind calls, you may find it useful:
code.gogulski.com/bitcoin-php/class_bitcoin_client.html
We canceled the address parameter in this function, now it returns the balance of the entire wallet :(
see https://bitcoincore.org/en/doc/0.18.0/rpc/wallet/g
... sum unspent for the desired address.This
is faster and more convenient than using listtransaction (sprocker) to parse the entire blockchain.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question