Added a new way of adding an output to a transaction
This commit is contained in:
parent
a34bc9e2ea
commit
aa22b9d89e
2 changed files with 17 additions and 11 deletions
2
bitcoinjs-min.js
vendored
2
bitcoinjs-min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -87,21 +87,27 @@ Transaction.prototype.addInput = function (tx, outIndex) {
|
||||||
/**
|
/**
|
||||||
* Create a new txout.
|
* Create a new txout.
|
||||||
*
|
*
|
||||||
* Can be called with an existing TransactionOut object to add it to the
|
* Can be called with:
|
||||||
* transaction. Or it can be called with an Address object and a BigInteger
|
*
|
||||||
* for the amount, in which case a new TransactionOut object with those
|
* i) An existing TransactionOut object
|
||||||
* values will be created.
|
* ii) An address object or an address and a value
|
||||||
|
* iii) An address:value string
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
Transaction.prototype.addOutput = function (address, value) {
|
Transaction.prototype.addOutput = function (address, value) {
|
||||||
if (arguments[0] instanceof TransactionOut) {
|
if (arguments[0] instanceof TransactionOut) {
|
||||||
this.outs.push(arguments[0]);
|
this.outs.push(arguments[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (arguments[0].indexOf(':') >= 0) {
|
||||||
|
var args = arguments[0].split(':');
|
||||||
|
address = args[0];
|
||||||
|
value = parseInt(args[1]);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
this.outs.push(new TransactionOut({
|
this.outs.push(new TransactionOut({
|
||||||
value: value,
|
value: value,
|
||||||
script: Script.createOutputScript(address)
|
script: Script.createOutputScript(address)
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(shtylman) crypto sha uses this also
|
// TODO(shtylman) crypto sha uses this also
|
||||||
|
|
Loading…
Add table
Reference in a new issue