Wallet: use assert for consistency

This commit is contained in:
Daniel Cousens 2014-05-31 12:16:01 +10:00
parent 5b7873d05b
commit 3bce535e36
2 changed files with 5 additions and 6 deletions

View file

@ -1,3 +1,4 @@
var assert = require('assert')
var networks = require('./networks')
var rng = require('secure-random')
@ -169,7 +170,7 @@ function Wallet(seed, network) {
}
this.createTx = function(to, value, fixedFee, changeAddress) {
if (value <= this.dustThreshold) throw new Error("Value must be above dust threshold")
assert(value > this.dustThreshold, value + ' must be above dust threshold (' + this.dustThreshold + ' Satoshis)')
var utxos = getCandidateOutputs(value)
var accum = 0
@ -198,9 +199,7 @@ function Wallet(seed, network) {
}
}
if (accum < subTotal) {
throw new Error('Not enough funds: ' + accum + ' < ' + subTotal)
}
assert(accum >= subTotal, 'Not enough funds (incl. fee): ' + accum + ' < ' + subTotal)
this.sign(tx)
return tx