<p>I was doing almost the same thing you need, to accomplish that I created a database with the addresses I wanted to monitor and keep track of them on the mempool of my fullnode which I could read the transactions and check each one of them if any of my addresses is there if it is I record the txid for further checking.
If the transfer gets confirmed before it is in my mempool (never happened to me) but the logic would simply be to check the block sent by ZMQ scraping all transactions and looking for any of the addresses.</p>

CC BY-SA 4.0
2020-01-09T19:20:53.180Z
2020-01-09T19:20:53.180Z
Allan Romanato
<p>I need to verify that user from my database has sent btc to my wallet.</p>

<p>Ideally I want to generate a unique address for each user transaction and then track all those addresses but I suppose it will be difficult to implement due to address gap limit, so I decided to just ask users for their bitcoin address and then expecting tx with funds transfer from that address to my wallet so I can verify funds were sent by them.</p>

<p>I have own bitcoin node which I want to use for tracking all the transactions to my wallet.</p>

<p>So let's say I want to track all txs just to my wallet address.</p>

<p>I was following the guide how to implement this with ZEROMQ. I've updated bitcoind config file with to can listen for raw txs via zeromq.
There are my nodejs code:</p>

<pre><code>const bitcoin = require('bitcoinjs-lib');
const zmq = require('zeromq');

const sock = zmq.socket('sub');
const addr = 'tcp://127.0.0.1:3000';

module.exports = function (app) {

    sock.connect(addr);
    sock.subscribe('rawtx');

    sock.on('message', function (topic, message) {
        if (topic.toString() === 'rawtx') {
            let rawTx = message.toString('hex');
            let tx = bitcoin.Transaction.fromHex(rawTx);
            let txid = tx.getId();

            const address = bitcoin.address.fromOutputScript(tx.outs[0].script, bitcoin.networks.testnet);

            console.log("address ", address)
            console.log('received transaction', txid, tx);
        }
    });
}
</code></pre>

<p>As I understand, when I connect to node in live network from this code, I'll be notified about all txs that are happening in the network?</p>

<p>How can I validate transactions with transferring funds only to my wallet and decode address from which funds were transferred?</p>

<p>Are there some easy ways to implement this and maybe some code/project examples?</p>

CC BY-SA 4.0
2024-01-21T14:39:52.167Z
It's also a good practice to handle block rewards
jaonoctus
<bitcoinjs><zeromq><nodejs>
Tracking incoming transactions using nodejs and own node
idknabit
# Tracking incoming transactions using nodejs and own node

(Asked by: username_0 on 2020-01-08)

I need to verify that user from my database has sent btc to my wallet.

Ideally I want to generate a unique address for each user transaction and then track all those addresses but I suppose it will be difficult to implement due to address gap limit, so I decided to just ask users for their bitcoin address and then expecting tx with funds transfer from that address to my wallet so I can verify funds were sent by them.

I have own bitcoin node which I want to use for tracking all the transactions to my wallet.

So let's say I want to track all txs just to my wallet address.

I was following the guide how to implement this with ZEROMQ. I've updated bitcoind config file with to can listen for raw txs via zeromq.
There are my nodejs code:

```
const bitcoin = require('bitcoinjs-lib');
const zmq = require('zeromq');

const sock = zmq.socket('sub');
const addr = 'tcp://127.0.0.1:3000';

module.exports = function (app) {

    sock.connect(addr);
    sock.subscribe('rawtx');

    sock.on('message', function (topic, message) {
        if (topic.toString() === 'rawtx') {
            let rawTx = message.toString('hex');
            let tx = bitcoin.Transaction.fromHex(rawTx);
            let txid = tx.getId();

            const address = bitcoin.address.fromOutputScript(tx.outs[0].script, bitcoin.networks.testnet);

            console.log("address ", address)
            console.log('received transaction', txid, tx);
        }
    });
}

```

As I understand, when I connect to node in live network from this code, I'll be notified about all txs that are happening in the network?

How can I validate transactions with transferring funds only to my wallet and decode address from which funds were transferred?

Are there some easy ways to implement this and maybe some code/project examples?

**Tags:** bitcoinjs, zeromq, nodejs

> **Comments:**
> **username_1**: It's also a good practice to handle block rewards  

---

## 1 answers

### Answer by username_2 on 2020-01-09. Score: 0

I was doing almost the same thing you need, to accomplish that I created a database with the addresses I wanted to monitor and keep track of them on the mempool of my fullnode which I could read the transactions and check each one of them if any of my addresses is there if it is I record the txid for further checking.
If the transfer gets confirmed before it is in my mempool (never happened to me) but the logic would simply be to check the block sent by ZMQ scraping all transactions and looking for any of the addresses.


---

