<blockquote>
<p><strong>Which fields should I inspect in order to know the target address, the amount that came in and if it is confirmed?</strong></p>
</blockquote>
<p>The answer seems obvious, so I may be missing some aspect of your question</p>
<blockquote>
<p><strong>the target address</strong></p>
</blockquote>
<p>That would be both <code>JSON.0.out.0.addr</code> and <code>JSON.0.out.1.addr</code> plus any other <code>JSON.0.out.*.addr</code></p>
<p>Remember that not all Bitcoin scripts can be represented as an address.</p>
<blockquote>
<p><strong>the amount ...</strong></p>
</blockquote>
<p>The corresponding <code>value</code> fields show the amount of Satoshi being sent to each address.</p>
<blockquote>
<p><strong>...that came in</strong></p>
</blockquote>
<p>The input amount of the transaction is provided by the sum of the  <code>JSON.0.inputs.*.prev_out.value</code></p>
<blockquote>
<p><strong>and if it is confirmed?</strong></p>
</blockquote>
<p>You need to refer to other data to count confirmations. At a minimum you'd need to know the current block height and the block height of the first block containing this transaction.</p>
<p>I'm not  familiar with this API so can't make any suggestion. Maybe the API includes a function to which you can pass the transaction ID (<code>JSON.0.hash</code>) to get information about the block containing that transaction. Maybe there is an <code>onBlock()</code> method you can use to process block data?</p>

CC BY-SA 4.0
2021-12-01T20:15:42.370Z
2021-12-01T20:33:34.247Z
2021-12-01T20:33:34.247Z
RedGrittyBrick
<p>I would like to watch a set of Bitcoin addresses and be able to execute some logic as they receive a payment.</p>
<p>According to <a href="https://stackoverflow.com/a/45554321/887343">this</a> answer it can be done using <a href="https://www.npmjs.com/package/blockchain.info" rel="nofollow noreferrer">blockchain.info</a>:</p>
<pre><code>const Socket = require('blockchain.info/Socket');
const mySocket = new Socket();
mySocket.onTransaction(function() {
  console.log(arguments);
});
</code></pre>
<p>The code works just fine and I'm getting notified about transactions, I can even filter and watch specific addresses (using an <code>options</code> parameter) but I'm not clear at all about the meaning of the fields.
There are multiple fields in a transaction (here is an example one below). Which fields should I inspect in order to know the target address, the amount that came in and if it is confirmed?</p>
<p><a href="https://i.sstatic.net/C5dKp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/C5dKp.png" alt="enter image description here" /></a></p>

<transactions><client><unconfirmed-transactions><transaction-verification>
Watch incoming transaction with node.js
forhas
# Watch incoming transaction with node.js

(Asked by: username_0 on 2021-12-01)

I would like to watch a set of Bitcoin addresses and be able to execute some logic as they receive a payment.

According to [this](https://stackoverflow.com/a/45554321/887343) answer it can be done using [blockchain.info](https://www.npmjs.com/package/blockchain.info):

```
const Socket = require('blockchain.info/Socket');
const mySocket = new Socket();
mySocket.onTransaction(function() {
  console.log(arguments);
});

```

The code works just fine and I'm getting notified about transactions, I can even filter and watch specific addresses (using an `options` parameter) but I'm not clear at all about the meaning of the fields.
There are multiple fields in a transaction (here is an example one below). Which fields should I inspect in order to know the target address, the amount that came in and if it is confirmed?

[![enter image description here](https://i.sstatic.net/C5dKp.png)](https://i.sstatic.net/C5dKp.png)

**Tags:** transactions, client, unconfirmed-transactions, transaction-verification


---

## 1 answers

### Answer by username_1 on 2021-12-01. Score: 2 | Accepted answer

> **Which fields should I inspect in order to know the target address, the amount that came in and if it is confirmed?**

The answer seems obvious, so I may be missing some aspect of your question

> **the target address**

That would be both `JSON.0.out.0.addr` and `JSON.0.out.1.addr` plus any other `JSON.0.out.*.addr`

Remember that not all Bitcoin scripts can be represented as an address.

> **the amount ...**

The corresponding `value` fields show the amount of Satoshi being sent to each address.

> **...that came in**

The input amount of the transaction is provided by the sum of the `JSON.0.inputs.*.prev_out.value`

> **and if it is confirmed?**

You need to refer to other data to count confirmations. At a minimum you'd need to know the current block height and the block height of the first block containing this transaction.

I'm not familiar with this API so can't make any suggestion. Maybe the API includes a function to which you can pass the transaction ID (`JSON.0.hash`) to get information about the block containing that transaction. Maybe there is an `onBlock()` method you can use to process block data?


---

