Saturday, May 9, 2026
HomeBitcoinbitcoinjs - Monitoring incoming transactions utilizing nodejs and personal node

bitcoinjs – Monitoring incoming transactions utilizing nodejs and personal node

I must confirm that person from my database has despatched btc to my pockets.

Ideally I wish to generate a novel deal with for every person transaction after which monitor all these addresses however I suppose will probably be troublesome to implement attributable to deal with hole restrict, so I made a decision to simply ask customers for his or her bitcoin deal with after which anticipating tx with funds switch from that deal with to my pockets so I can confirm funds have been despatched by them.

I’ve personal bitcoin node which I wish to use for monitoring all of the transactions to my pockets.

So to illustrate I wish to monitor all txs simply to my pockets deal with.

I used to be following the information methods to implement this with ZEROMQ. I’ve up to date bitcoind config file with to can hear for uncooked txs by way of 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 = operate (app) {

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

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

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

            console.log("deal with ", deal with)
            console.log('obtained transaction', txid, tx);
        }
    });
}

As I perceive, once I hook up with node in stay community from this code, I will be notified about all txs which are taking place within the community?

How can I validate transactions with transferring funds solely to my pockets and decode deal with from which funds have been transferred?

Are there some simple methods to implement this and perhaps some code/mission examples?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments