Wallet: remove async interface

This commit is contained in:
Daniel Cousens 2014-05-20 16:11:01 +10:00
parent 50e9a09a8c
commit bd3690bdc0
2 changed files with 0 additions and 110 deletions

View file

@ -84,17 +84,6 @@ function Wallet(seed, options) {
this.outputs = outputs this.outputs = outputs
} }
this.setUnspentOutputsAsync = function(utxo, callback) {
var error = null
try {
this.setUnspentOutputs(utxo)
} catch(err) {
error = err
} finally {
process.nextTick(function(){ callback(error) })
}
}
function outputToUnspentOutput(output){ function outputToUnspentOutput(output){
var hashAndIndex = output.receive.split(":") var hashAndIndex = output.receive.split(":")
@ -216,22 +205,6 @@ function Wallet(seed, options) {
return tx return tx
} }
this.createTxAsync = function(to, value, fixedFee, callback){
if(fixedFee instanceof Function) {
callback = fixedFee
fixedFee = undefined
}
var tx = null
var error = null
try {
tx = this.createTx(to, value, fixedFee)
} catch(err) {
error = err
} finally {
process.nextTick(function(){ callback(error, tx) })
}
}
this.dustThreshold = 5430 this.dustThreshold = 5430
function isDust(amount) { function isDust(amount) {

View file

@ -277,38 +277,6 @@ describe('Wallet', function() {
assert.equal(output.address, utxo[0].address) assert.equal(output.address, utxo[0].address)
} }
}) })
describe('setUnspentOutputsAsync', function(){
var utxo
beforeEach(function(){
utxo = cloneObject([expectedUtxo])
})
afterEach(function(){
wallet.setUnspentOutputs.restore()
})
it('calls setUnspentOutputs', function(done){
sinon.stub(wallet, "setUnspentOutputs")
var callback = function(){
assert(wallet.setUnspentOutputs.calledWith(utxo))
done()
}
wallet.setUnspentOutputsAsync(utxo, callback)
})
it('when setUnspentOutputs throws an error, it invokes callback with error', function(done){
sinon.stub(wallet, "setUnspentOutputs").throws()
var callback = function(err){
assert(err instanceof Error)
done()
}
wallet.setUnspentOutputsAsync(utxo, callback)
})
})
}) })
describe('processTx', function(){ describe('processTx', function(){
@ -620,57 +588,6 @@ describe('Wallet', function() {
}) })
}) })
describe('createTxAsync', function(){
var to, value, fee
beforeEach(function(){
to = '15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3'
value = 500000
fee = 10000
})
afterEach(function(){
wallet.createTx.restore()
})
it('calls createTx', function(done){
sinon.stub(wallet, "createTx").returns("fakeTx")
var callback = function(err, tx){
assert(wallet.createTx.calledWith(to, value))
assert.equal(err, null)
assert.equal(tx, "fakeTx")
done()
}
wallet.createTxAsync(to, value, callback)
})
it('calls createTx correctly when fee is specified', function(done){
sinon.stub(wallet, "createTx").returns("fakeTx")
var callback = function(err, tx){
assert(wallet.createTx.calledWith(to, value, fee))
assert.equal(err, null)
assert.equal(tx, "fakeTx")
done()
}
wallet.createTxAsync(to, value, fee, callback)
})
it('when createTx throws an error, it invokes callback with error', function(done){
sinon.stub(wallet, "createTx").throws()
var callback = function(err, tx){
assert(err instanceof Error)
done()
}
wallet.createTxAsync(to, value, callback)
})
})
function assertEqual(obj1, obj2){ function assertEqual(obj1, obj2){
assert.equal(obj1.toString(), obj2.toString()) assert.equal(obj1.toString(), obj2.toString())
} }