Bitcoin Forum
May 03, 2024, 03:26:37 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Help querying blockchain API  (Read 911 times)
jackpf (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
February 20, 2014, 09:43:47 PM
 #1

Hi all,

I need a bit of help using the blockchain API. I am querying it like this: https://blockchain.info/address/18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp?format=json
But the transaction results seem skewed, for example the transaction hash and result for the first few transactions are:
fcd4187e00b13575fd7859d2530bb90596e3f2c73063d9b959d37706447c1d95: 0
516de45c60a4ec58cb57b6d5fa2f6fabc454a25db29c0970d05366c9f99795d3: -410000
a623c4c5bc598cd8214196262905583eff7cb124b618aa72940d029f25c07b00: 30000000

Whereas if you look at the actual address page: https://blockchain.info/address/18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp
It should be more like this:
fcd4187e00b13575fd7859d2530bb90596e3f2c73063d9b959d37706447c1d95: -410000
516de45c60a4ec58cb57b6d5fa2f6fabc454a25db29c0970d05366c9f99795d3: 30000000
a623c4c5bc598cd8214196262905583eff7cb124b618aa72940d029f25c07b00: 10000000

Why is the first result always 0, which then offsets the rest of the results to be incorrect? Is this a bug in the api or am I doing it wrong?

Any help is much appreciated.

Thank you,
jackpf
1714706797
Hero Member
*
Offline Offline

Posts: 1714706797

View Profile Personal Message (Offline)

Ignore
1714706797
Reply with quote  #2

1714706797
Report to moderator
1714706797
Hero Member
*
Offline Offline

Posts: 1714706797

View Profile Personal Message (Offline)

Ignore
1714706797
Reply with quote  #2

1714706797
Report to moderator
1714706797
Hero Member
*
Offline Offline

Posts: 1714706797

View Profile Personal Message (Offline)

Ignore
1714706797
Reply with quote  #2

1714706797
Report to moderator
According to NIST and ECRYPT II, the cryptographic algorithms used in Bitcoin are expected to be strong until at least 2030. (After that, it will not be too difficult to transition to different algorithms.)
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4615



View Profile
February 21, 2014, 12:20:30 AM
 #2

What is the "result" value supposed to represent?

I don't see it on the API documentation page:
https://blockchain.info/api/blockchain_api
jackpf (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
February 21, 2014, 12:48:38 AM
 #3

I believe it is the amount of btc given/taken from the address for a given transaction. If you look at the "single address" API call in that documention, in the response you see:
"tx":[--Array of Transactions--]

In this array is a set of transactions for the given address.

As you can see in this screenshot:
https://www.dropbox.com/s/1j4rwqhosdtoghq/Screenshot_2014-02-21-00-43-48.png
It is (almost) the same as the blockchain address page:
https://blockchain.info/address/18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp

However, in the first screenshot the first result is 0, and every transaction hash has the next transaction's value, if that makes sense.
And in the json, I can clearly see the first transaction has result: 0, so I don't think I am querying it wrong. Is this a bug in their API?

Thanks for the response,
jackpf
jackpf (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
February 21, 2014, 02:21:07 PM
 #4

Polite bump, really need help with this! Don't understand why the API is returning these values Sad
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4615



View Profile
February 21, 2014, 04:17:25 PM
 #5

I believe it is the amount of btc given/taken from the address for a given transaction. If you look at the "single address" API call in that documention, in the response you see:
"tx":[--Array of Transactions--]

In this array is a set of transactions for the given address.

As you can see in this screenshot:
https://www.dropbox.com/s/1j4rwqhosdtoghq/Screenshot_2014-02-21-00-43-48.png
It is (almost) the same as the blockchain address page:
https://blockchain.info/address/18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp

However, in the first screenshot the first result is 0, and every transaction hash has the next transaction's value, if that makes sense.
And in the json, I can clearly see the first transaction has result: 0, so I don't think I am querying it wrong. Is this a bug in their API?

Thanks for the response,
jackpf

It may be a bug in the API.  As I said, the "result" label:value pair is not in the documentation for the API.  An [--Array of Transactions--] should be a set of "single transactions".  Take a look at the "single transaction" API call in that documentation, you'll see that "result" isn't in the specified output.

Perhaps a more reliable way to determine how much was spent and/or received would be to add up the inputs and/or outputs.

For example you can see in this txs array element:

Code:
{
    "result":0,
    "block_height":286985,
    "time":1392950149,
    "inputs":[
        {
            "prev_out":{
                "n":12,
                "value":100000000,
                "addr":"1PyZ3PT8bv6dy4HcNzX2ba2zQm1sAgmEqE",
                "tx_index":113566887,
                "type":0
            }
        }
    ],
    "vout_sz":2,
    "relayed_by":"178.63.63.214",
    "hash":"5f9b073f26a3b7b86d44b6aed164d7973867e1ed5388ad327e02ee95232e8123",
    "vin_sz":1,
    "tx_index":113580991,
    "ver":1,
    "out":[
        {
            "n":0,
            "value":10000000,
            "addr":"18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp",
            "tx_index":113580991,
            "type":0
        },{
            "n":1,
            "value":89990000,
            "addr":"1LWxoxVx4dC5FrwmWiVL3uCTS5frj8sbGv",
            "tx_index":113580991,
            "type":0
        }
    ],
    "size":226
},

That there are no "inputs" array elements with a "prev_out" that was sent to an "addr" of 18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp.  Therefore nothing is "spent"

Meanwhile there is a single "out" array element that was sent to an "addr" of 18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp. That one array element has a "value" of 10000000.  Therefore 10000000 satoshis (0.1 BTC) were "received" at that address with this transaction.

Meanwhile you can see in this txs array element:

Code:
{
    "result":10000000,
    "block_height":286604,
    "time":1392772520,
    "inputs":[
        {
            "prev_out":{
                "n":1,
                "value":4720000,
                "addr":"18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp",
                "tx_index":113271796,
                "type":0
            }
        }
    ],
    "vout_sz":2,
    "relayed_by":"176.9.104.178",
    "hash":"fcd4187e00b13575fd7859d2530bb90596e3f2c73063d9b959d37706447c1d95",
    "vin_sz":1,
    "tx_index":113417334,
    "ver":1,
    "out":[
        {
            "n":0,
            "value":400000,
            "addr":"15xb5bwoCbSprTNjotfc5VSFSMkUpCQsig",
            "tx_index":113417334,
            "type":0
        },{
            "n":1,
            "value":4310000,
            "addr":"18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp",
            "tx_index":113417334,
            "type":0
        }
    ],
    "size":226
},

That there is one "inputs" array elements with a "prev_out" that was sent to an "addr" of 18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp.  That one array element has a "value" of 4720000. Therefore a previously unspent output received previously at 18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp valued at 4720000 satoshis (0.0472 BTC) are "spent" with this transaction.

Meanwhile there is also a single "out" array element that was sent to an "addr" of 18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp. That one array element has a "value" of 4310000.  Therefore 4310000 satoshis (0.0431 BTC) were "received" at that address with this transaction.

4310000 received less 4720000 spent equals a net change of -410000 (-0.0041 BTC). Therefore this transaction results in a net change of -410000 (-0.0041 BTC) to the value associated with the address 18Zbf9aEKwZTeR92u4tuhQenoen9prSeNp.

jackpf (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
February 23, 2014, 09:43:15 AM
 #6

Wow thanks for the response, I'll give this a go. I tried doing something similar but couldn't get it quite right but hopefully I can now.I opened a ticket on blockchain support but they're not convinced its a bug because nobody else has complained about it, so guess I'll have to do it this way! Thanks!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!