Catch error when TransactionBuilder

This commit is contained in:
Gustavo Maximiliano Cortez 2014-10-06 20:13:57 -03:00
commit d8c3f9451d

View file

@ -2177,7 +2177,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, comment, opts, cb)
var ntxid = self.createTxSync(toAddress, amountSatStr, comment, safeUnspent, opts); var ntxid = self.createTxSync(toAddress, amountSatStr, comment, safeUnspent, opts);
if (!ntxid) { if (!ntxid) {
return cb(new Error('Error creating TX')); return cb(new Error('Error creating the Transaction'));
} }
self.sendIndexes(); self.sendIndexes();
@ -2212,12 +2212,19 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
opts[k] = Wallet.builderOpts[k]; opts[k] = Wallet.builderOpts[k];
} }
var b = new Builder(opts) var b;
try {
b = new Builder(opts)
.setUnspent(utxos) .setUnspent(utxos)
.setOutputs([{ .setOutputs([{
address: toAddress, address: toAddress,
amountSatStr: amountSatStr, amountSatStr: amountSatStr,
}]); }]);
} catch (e) {
log.debug(e.message);
return;
};
var selectedUtxos = b.getSelectedUnspent(); var selectedUtxos = b.getSelectedUnspent();
var inputChainPaths = selectedUtxos.map(function(utxo) { var inputChainPaths = selectedUtxos.map(function(utxo) {