0

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?

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.