Fixes Transaction.addOutput(Address, Number)
This commit is contained in:
parent
695eb64a3a
commit
4012b82bec
2 changed files with 14 additions and 9 deletions
|
@ -96,20 +96,20 @@ Transaction.prototype.addOutput = function (address, value, network) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof address === 'string') {
|
||||||
if (arguments[0].indexOf(':') >= 0) {
|
if (arguments[0].indexOf(':') >= 0) {
|
||||||
network = value
|
|
||||||
|
|
||||||
var args = arguments[0].split(':')
|
var args = arguments[0].split(':')
|
||||||
address = args[0]
|
address = args[0]
|
||||||
value = parseInt(args[1])
|
value = parseInt(args[1])
|
||||||
|
|
||||||
|
network = arguments[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
address = Address.fromBase58Check(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
network = network || Network.bitcoin
|
network = network || Network.bitcoin
|
||||||
|
|
||||||
if (typeof address === 'string') {
|
|
||||||
address = Address.fromBase58Check(address)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.outs.push(new TransactionOut({
|
this.outs.push(new TransactionOut({
|
||||||
value: value,
|
value: value,
|
||||||
script: Script.createOutputScript(address, network)
|
script: Script.createOutputScript(address, network)
|
||||||
|
|
|
@ -154,6 +154,11 @@ describe('Transaction', function() {
|
||||||
verifyTransactionOut()
|
verifyTransactionOut()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('allows an Address object and value to be passed in', function(){
|
||||||
|
tx.addOutput(Address.fromBase58Check('15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3'), 40000)
|
||||||
|
verifyTransactionOut()
|
||||||
|
})
|
||||||
|
|
||||||
it('allows a string in the form of address:index to be passed in', function(){
|
it('allows a string in the form of address:index to be passed in', function(){
|
||||||
tx.addOutput("15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3:40000")
|
tx.addOutput("15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3:40000")
|
||||||
verifyTransactionOut()
|
verifyTransactionOut()
|
||||||
|
|
Loading…
Reference in a new issue