0

There seem to be two calls. What's the difference between them ? I basically want to know the total amount available to spend on each address(actually on the whole wallet but there is no such api call so I have to calculate the amount from all the addresses).

Unspent outputs

https://blockchain.info/unspent?active=$address

Multiple Addresses Allowed separated by "|" Address can be base58 or xpub

Optional limit parameter to show n transactions e.g. &limit=50 (Default: 250, Max: 1000) Optional confirmations parameter to limit the minimum confirmations e.g. &confirmations=6

The tx hash is in reverse byte order. What this means is that in order to get the html transaction hash from the JSON tx hash for the following transaction, you need to decode the hex (using this site for example). This will produce a binary output, which you need to reverse (the last 8bits/1byte move to the front, second to last 8bits/1byte needs to be moved to second, etc.). Then once the reversed bytes are decoded, you will get the html transaction hash.

{
    "unspent_outputs":[
        {
            "tx_age":"1322659106",
            "tx_hash":"e6452a2cb71aa864aaa959e647e7a4726a22e640560f199f79b56b5502114c37",
            "tx_index":"12790219",
            "tx_output_n":"0",
            "script":"76a914641ad5051edd97029a003fe9efb29359fcee409d88ac", (Hex encoded)
            "value":"5000661330"
        }
    ]
}

Balance

https://blockchain.info/balance?active=$address

Multiple Addresses Allowed separated by "|"
Address can be base58 or xpub

List the balance summary of each address listed.

{
    "1MDUoxL1bGvMxhuoDYx6i11ePytECAk9QK": {
        "final_balance": 0,
        "n_tx": 0,
        "total_received": 0
    },
    "15EW3AMRm2yP6LEF5YKKLYwvphy3DmMqN6": {
        "final_balance": 0,
        "n_tx": 2,
        "total_received": 310630609
    }
}
1

Your question:

How to get the available balance of a specific address using blockchain.info

The description for the /balance API:

List the balance summary of each address listed.

So use /balance.

/unspent lists all the outputs for all addresses you provide in one big list, not grouped by address. But since you're just adding them all anyway, it doesn't make much difference for you. The /balance result is shorter and simpler.

basically want to know the total amount available to spend on each address(actually on the whole wallet but there is no such api call

Have you checked the Wallet API? "Fetching the wallet balance" looks like what you need.

  • Ok, I will use the /balance call. The wallet API is confusing and basically useless because it says it may include double spends and unconfirmed transactions...why would I need that? I just want to send the total amount from one address to another one...I don't want to generate invalid transactions. – Books Dec 18 '17 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.