poll address unspent until non-empty or timeout
This commit is contained in:
parent
a2b4558a0b
commit
713f038583
3 changed files with 22 additions and 4 deletions
test/integration
|
@ -7,6 +7,22 @@ function faucetWithdraw(address, amount, done) {
|
|||
}).on('error', done)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
faucetWithdraw: faucetWithdraw
|
||||
function pollUnspent(blockchain, address, done) {
|
||||
blockchain.addresses.unspents(address, function (err, unspents) {
|
||||
if (err) return done(err)
|
||||
|
||||
if(unspents == null || unspents.length === 0) {
|
||||
return setTimeout(function() {
|
||||
pollUnspent(blockchain, address, done)
|
||||
}, 200)
|
||||
}
|
||||
|
||||
done(null, unspents)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
faucetWithdraw: faucetWithdraw,
|
||||
pollUnspent: pollUnspent
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue