Browse Source

Added a new way of adding an output to a transaction

hk-custom-address
vub 12 years ago
parent
commit
aa22b9d89e
  1. 2
      bitcoinjs-min.js
  2. 18
      src/transaction.js

2
bitcoinjs-min.js

File diff suppressed because one or more lines are too long

18
src/transaction.js

@ -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…
Cancel
Save