0

I want to find all transactions of address in regtest. How it is possible to do? I have this solution, but I get response (201) before for ends. I think it's bitcoin timeout false.

    bitcoin.getReceivedByAddress(user_address).then ((current_balance) => {
        //get current address balance\
    //if balance has changed, check latest transactions
    if (current_balance > 0) {
        bitcoin.getBlockCount().then ((n) =>{

            for (let i = n; i > current_balance !== 0 && i > 0; i--) {
            bitcoin.getBlockHash(i).then((hash) => {
                bitcoin.getBlock(hash).then( (block) => {
                for (let j in block.tx) {
                bitcoin.getTransaction(block.tx[j]).then ((transaction) => {
                    if (transaction.details[1].address === user_address
                && transaction.details[1].category === "receive") {
                    current_balance -= transaction.details[1].amount;
                }

            });

            }


        });

        });

        }

    });
    }






}).then(() => {
        res.send(201);
    })
  • You should specify which library and api you are using. "bitcoin api" is not enough information. – Jestin Feb 4 '18 at 23:06
  • I use bitcoin core lib. – Agniezhk Feb 5 '18 at 8:21
  • 1
    Welcome to Bitcoin.SE! Your question can be improved if you edit it and specify additional information to assist those researching an answer. More is generally better! – Willtech Feb 5 '18 at 11:45

Your Answer

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

Browse other questions tagged or ask your own question.