<p>Transaction has inputs and outputs. <code>"value"</code> is Satoshi count:</p>

<pre><code>  "inputs":[
  {
...
         "prev_out":{
...
            "value":461323,
...
         },
...
      }
   ],
...
   "out":[
      {
...
         "value":295902,
...
      },
      {
...
         "value":124987,
...
      }
   ],
...
</code></pre>

<p>To calculate fee you should calculate the difference between all inputs and outputs.</p>

CC BY-SA 3.0
2017-08-15T06:00:57.347Z
Unfortunately, this doenst work out.
Skalden
CC BY-SA 3.0
2017-08-15T06:06:34.553Z
Take [this transaction](https://blockchain.info/tx/af4834da41597455946cdc01856774f324ecac7bbb129728f8646352ae3c910a) as an example [(here the JSON)](https://blockchain.info/rawtx/af4834da41597455946cdc01856774f324ecac7bbb129728f8646352ae3c910a) . Difference between in and out is 27760 Satoshi. But the real value was 2270804 Satoshi.
Skalden
CC BY-SA 3.0
2017-08-15T06:22:42.780Z
To count how many Bitcoins have been gone into your wallet. You have to look at the out Objects only and especially only at those, that have your wallet-hash as adress. Those are the recieved Bitcoins.

Now I just have to figure out how to count what has left the wallet.
Skalden
CC BY-SA 3.0
2017-08-15T08:48:43.883Z
Now I don't understand what you want. Difference between in and out is fee. I noticed this. Your number is: inputs minus fee. What does this mean? Why this is real value? I have no idea. You noticed about "your wallet-hash". I don't know which addresses is yours, the question was about satoshi calculations from json. I gave you exhaustive answer, because these are the only satoshi values that are present inside transaction. You cannot figure out by looking only on transaction, which addresses are yours, and which are not.
Zergatul
CC BY-SA 3.0
2017-08-15T08:53:01.640Z
Also your number is sum of outputs. Does this mean 2 output addresses are yours?
Zergatul
CC BY-SA 3.0
2017-08-14T14:37:35.040Z
2017-08-14T14:37:35.040Z
Zergatul
<p>I wanted to write a small script to parse all incoming transactions to a wallet. The wallet I'm looking at is from an OpenSource project I'm working for, to get an overview of the amounts given to the project in a certain time-range. I use the <a href="https://blockchain.info/api/blockchain_api" rel="nofollow noreferrer">Blockchain Data API</a> and try to parse the information from <a href="https://blockchain.info/address/dbd0788d294dd15704d232053790c555d1cb3378?format=json&amp;offset=0" rel="nofollow noreferrer">this call</a> (includes the wallet-adress). But I can't seem to get the amount of Bitcoins that were transferred to the wallet. Sometimes there are amounts as big as 266 BTC listed, even though the real transaction was just a couple of Satoshis.</p>

<p>So, the question is: When I have a JSON Transaction Block like this:</p>

<pre><code>   "ver":1,
   "inputs":[
      {
         "sequence":4294967295,
         "prev_out":{
            "spent":true,
            "tx_index":273950706,
            "type":0,
            "addr":"12tPhkHLjmkDfqTfvbagbnkYDU5UTu2pMp",
            "value":461323,
            "n":1,
            "script":"76a91414b04a7b66d06dd399bdb689df209ed688e9bcaa88ac"
         },
         "script":"483045022100f38ffd67d53b4c5a6f6a2543ca6217863be5b4f3a43e885a2520dbb768ba5df702203d9782af024ee9e213fb59cee1c788c70e66d66addb553b74610a1fed3df10390121026b138ff61ffeaf459c4916889d2c53894fc029c9729886714fe23ebd8a15bb32"
      }
   ],
   "block_height":480392,
   "relayed_by":"52.59.6.61",
   "out":[
      {
         "spent":false,
         "tx_index":274914673,
         "type":0,
         "addr":"1M3GipkG2YyHPDMPewqTpup83jitXvBg9N",
         "value":295902,
         "n":0,
         "script":"76a914dbd0788d294dd15704d232053790c555d1cb337888ac"
      },
      {
         "spent":false,
         "tx_index":274914673,
         "type":0,
         "addr":"18h2yt8cJSYwGSWV5nUodTgPZj9Vi5aCJS",
         "value":124987,
         "n":1,
         "script":"76a914545b2c20e7d8ded3853a2336ebedf7752cf823dd88ac"
      }
   ],
   "lock_time":0,
   "result":0,
   "size":226,
   "time":1502650024,
   "tx_index":274914673,
   "vin_sz":1,
   "hash":"02a7bf19417db6d975d48e27199cd65dcc415c5bf81ed447f945b2a4f3dc1d24",
   "vout_sz":2
},
</code></pre>

<p>What is the amount of Satoshis that have been added (or redeemed) from that wallet? How should I interpret the values in the json?</p>

CC BY-SA 3.0
2017-08-14T14:43:35.410Z
https://bitcoin.stackexchange.com/questions/58060/answer/submit
Zakria Khan
CC BY-SA 3.0
2017-08-15T05:17:36.970Z
@ZakriaKhan You only posted a link to this thread
Skalden
<transactions><blockchain.info><api>
Blockchain API Bitcoin transaction list to a wallet
Skalden
# Blockchain API Bitcoin transaction list to a wallet

(Asked by: username_0 on 2017-08-14)

I wanted to write a small script to parse all incoming transactions to a wallet. The wallet I'm looking at is from an OpenSource project I'm working for, to get an overview of the amounts given to the project in a certain time-range. I use the [Blockchain Data API](https://blockchain.info/api/blockchain_api) and try to parse the information from [this call](https://blockchain.info/address/dbd0788d294dd15704d232053790c555d1cb3378?format=json&offset=0) (includes the wallet-adress). But I can't seem to get the amount of Bitcoins that were transferred to the wallet. Sometimes there are amounts as big as 266 BTC listed, even though the real transaction was just a couple of Satoshis.

So, the question is: When I have a JSON Transaction Block like this:

```
   "ver":1,
   "inputs":[
      {
         "sequence":4294967295,
         "prev_out":{
            "spent":true,
            "tx_index":273950706,
            "type":0,
            "addr":"12tPhkHLjmkDfqTfvbagbnkYDU5UTu2pMp",
            "value":461323,
            "n":1,
            "script":"76a91414b04a7b66d06dd399bdb689df209ed688e9bcaa88ac"
         },
         "script":"483045022100f38ffd67d53b4c5a6f6a2543ca6217863be5b4f3a43e885a2520dbb768ba5df702203d9782af024ee9e213fb59cee1c788c70e66d66addb553b74610a1fed3df10390121026b138ff61ffeaf459c4916889d2c53894fc029c9729886714fe23ebd8a15bb32"
      }
   ],
   "block_height":480392,
   "relayed_by":"52.59.6.61",
   "out":[
      {
         "spent":false,
         "tx_index":274914673,
         "type":0,
         "addr":"1M3GipkG2YyHPDMPewqTpup83jitXvBg9N",
         "value":295902,
         "n":0,
         "script":"76a914dbd0788d294dd15704d232053790c555d1cb337888ac"
      },
      {
         "spent":false,
         "tx_index":274914673,
         "type":0,
         "addr":"18h2yt8cJSYwGSWV5nUodTgPZj9Vi5aCJS",
         "value":124987,
         "n":1,
         "script":"76a914545b2c20e7d8ded3853a2336ebedf7752cf823dd88ac"
      }
   ],
   "lock_time":0,
   "result":0,
   "size":226,
   "time":1502650024,
   "tx_index":274914673,
   "vin_sz":1,
   "hash":"02a7bf19417db6d975d48e27199cd65dcc415c5bf81ed447f945b2a4f3dc1d24",
   "vout_sz":2
},

```

What is the amount of Satoshis that have been added (or redeemed) from that wallet? How should I interpret the values in the json?

**Tags:** transactions, blockchain.info, api

> **Comments:**
> **username_1**: https://bitcoin.stackexchange.com/questions/58060/answer/submit  
> **username_0**: @username_1 You only posted a link to this thread  

---

## 1 answers

### Answer by username_2 on 2017-08-14. Score: 1

Transaction has inputs and outputs. `"value"` is Satoshi count:

```
  "inputs":[
  {
...
         "prev_out":{
...
            "value":461323,
...
         },
...
      }
   ],
...
   "out":[
      {
...
         "value":295902,
...
      },
      {
...
         "value":124987,
...
      }
   ],
...

```

To calculate fee you should calculate the difference between all inputs and outputs.

> **Comments:**
> **username_0**: Unfortunately, this doenst work out.  
> **username_0**: Take [this transaction](https://blockchain.info/tx/af4834da41597455946cdc01856774f324ecac7bbb129728f8646352ae3c910a) as an example [(here the JSON)](https://blockchain.info/rawtx/af4834da41597455946cdc01856774f324ecac7bbb129728f8646352ae3c910a) . Difference between in and out is 27760 Satoshi. But the real value was 2270804 Satoshi.  
> **username_0**: To count how many Bitcoins have been gone into your wallet. You have to look at the out Objects only and especially only at those, that have your wallet-hash as adress. Those are the recieved Bitcoins.  Now I just have to figure out how to count what has left the wallet.  
> **username_2**: Now I don't understand what you want. Difference between in and out is fee. I noticed this. Your number is: inputs minus fee. What does this mean? Why this is real value? I have no idea. You noticed about "your wallet-hash". I don't know which addresses is yours, the question was about satoshi calculations from json. I gave you exhaustive answer, because these are the only satoshi values that are present inside transaction. You cannot figure out by looking only on transaction, which addresses are yours, and which are not.  
> **username_2**: Also your number is sum of outputs. Does this mean 2 output addresses are yours?  

---

