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?