1
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 – 2018-02-04T23:06:51.847
I use bitcoin core lib. – Agniezhk – 2018-02-05T08:21:51.597
1Welcome 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 – 2018-02-05T11:45:24.720