paypro: reorganize createPaymentTxSync.

This commit is contained in:
Christopher Jeffrey 2014-08-05 16:14:50 -07:00 committed by Manuel Araoz
commit 18d1e4f6e7
2 changed files with 36 additions and 36 deletions

View file

@ -1133,18 +1133,6 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
.setUnspent(unspent)
.setOutputs(outs);
var selectedUtxos = b.getSelectedUnspent();
var inputChainPaths = selectedUtxos.map(function(utxo) {
return pkr.pathForAddress(utxo.address);
});
b = b.setHashToScriptMap(pkr.getRedeemScriptMap(inputChainPaths));
if (priv) {
var keys = priv.getForPaths(inputChainPaths);
var signed = b.sign(keys);
}
merchantData.total = bignum(merchantData.total, 10);
merchantData.pr.pd.outputs.forEach(function(output, i) {
@ -1178,6 +1166,18 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
merchantData.total = merchantData.total.toString(10);
var selectedUtxos = b.getSelectedUnspent();
var inputChainPaths = selectedUtxos.map(function(utxo) {
return pkr.pathForAddress(utxo.address);
});
b = b.setHashToScriptMap(pkr.getRedeemScriptMap(inputChainPaths));
if (priv) {
var keys = priv.getForPaths(inputChainPaths);
var signed = b.sign(keys);
}
if (options.fetch) return;
this.log('');