make wallet async functions truly async

This commit is contained in:
Wei Lu 2014-03-26 20:02:12 +08:00
parent 7820ea7ea0
commit 4d4388f6bf
2 changed files with 42 additions and 32 deletions

View file

@ -84,13 +84,14 @@ var Wallet = function (seed, options) {
}
this.setUnspentOutputsAsync = function(utxo, callback) {
var error = null
try {
this.setUnspentOutputs(utxo)
} catch(err) {
return callback(err)
error = err
} finally {
process.nextTick(function(){ callback(error) })
}
return callback()
}
function outputToUnspentOutput(output){
@ -206,14 +207,15 @@ var Wallet = function (seed, options) {
fixedFee = undefined
}
var tx = null
var error = null
try {
tx = this.createTx(to, value, fixedFee)
} catch(err) {
return callback(err)
error = err
} finally {
process.nextTick(function(){ callback(error, tx) })
}
callback(null, tx)
}
this.dustThreshold = 5430