Browse Source

Merge pull request #454 from matiu/feature/builder02

accept amount a strings in setOutput
patch-2
Ryan X. Charles 11 years ago
parent
commit
b4a56eb454
  1. 8
      lib/TransactionBuilder.js

8
lib/TransactionBuilder.js

@ -386,7 +386,8 @@ TransactionBuilder.prototype._setFeeAndRemainder = function(txobj) {
//
// Note that only some of this outputs will be selected
// to create the transaction. The selected ones can be checked
// after calling `setOutputs`, with `.getSelectedUnspent`
// after calling `setOutputs`, with `.getSelectedUnspent`.
// amountSatStr could be used to pass in the amount in satoshis, as a string.
//
TransactionBuilder.prototype.setOutputs = function(outs) {
@ -401,7 +402,7 @@ TransactionBuilder.prototype.setOutputs = function(outs) {
var l = outs.length;
for (var i = 0; i < l; i++) {
var amountSat = outs[i].amountSat || util.parseValue(outs[i].amount);
var amountSat = outs[i].amountSat || outs[i].amountSatStr ? bignum(outs[i].amountSatStr) : util.parseValue(outs[i].amount);
var value = util.bigIntToValue(amountSat);
var script = TransactionBuilder._scriptForOut(outs[i]);
var txout = {
@ -410,8 +411,7 @@ TransactionBuilder.prototype.setOutputs = function(outs) {
};
txobj.outs.push(txout);
var sat = outs[i].amountSat || util.parseValue(outs[i].amount);
valueOutSat = valueOutSat.add(sat);
valueOutSat = valueOutSat.add(amountSat);
}
this.valueOutSat = valueOutSat;

Loading…
Cancel
Save