Merge pull request #454 from matiu/feature/builder02

accept amount a strings in setOutput
This commit is contained in:
Ryan X. Charles 2014-07-24 19:17:06 -04:00
commit b4a56eb454
1 changed files with 6 additions and 6 deletions

View File

@ -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;
@ -445,7 +445,7 @@ TransactionBuilder._mapKeys = function(keys) {
}
var addr = wk.storeObj().addr;
walletKeyMap[addr] = wk;
}
return walletKeyMap;
};
@ -766,7 +766,7 @@ TransactionBuilder.prototype.sign = function(keys) {
ins = tx.ins,
l = ins.length,
walletKeyMap = TransactionBuilder._mapKeys(keys);
for (var i = 0; i < l; i++) {
var input = this.inputMap[i];