fix signing multiple inputs with ledger

This commit is contained in:
Matias Alejo Garcia 2015-09-14 12:12:24 -03:00
parent a313222675
commit 9dc2c40242
3 changed files with 19 additions and 10 deletions

View File

@ -740,9 +740,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return; return;
}; };
var comment = form.comment.$modelValue;
// ToDo: use a credential's (or fc's) function for this
if (comment && !fc.credentials.sharedEncryptingKey) {
var msg = 'Could not add message to imported wallet without shared encrypting key';
$log.warn(msg);
return self.setSendError(gettext(msg));
}
self.setOngoingProcess(gettext('Creating transaction')); self.setOngoingProcess(gettext('Creating transaction'));
$timeout(function() { $timeout(function() {
var comment = form.comment.$modelValue;
var paypro = self._paypro; var paypro = self._paypro;
var address, amount; var address, amount;

View File

@ -103,6 +103,8 @@ angular.module('copayApp.services')
body = err.message || err.code; body = err.message || err.code;
break; break;
} }
} else {
body = gettextCatalog.getString(err);
} }
var msg = prefix + ( body ? ': ' + body : ''); var msg = prefix + ( body ? ': ' + body : '');

View File

@ -172,7 +172,7 @@ angular.module('copayApp.services')
if (opts.mnemonic && opts.mnemonic.indexOf('m/') == 0) { if (opts.mnemonic && opts.mnemonic.indexOf('m/') == 0) {
var xPrivKey = root._preDerivation(opts.mnemonic, network); var xPrivKey = root._preDerivation(opts.mnemonic, network);
if (!xPrivKey) if (!xPrivKey)
return bwsError.cb('Bad derivation', gettext('Could not import'), cb); return bwsError.cb('Bad derivation', gettext('Could not import'), cb);
opts.mnemonic = null; opts.mnemonic = null;
opts.extendedPrivateKey = xPrivKey; opts.extendedPrivateKey = xPrivKey;
@ -389,7 +389,7 @@ angular.module('copayApp.services')
if (words.indexOf('m/') == 0) { if (words.indexOf('m/') == 0) {
var xPrivKey = root._preDerivation(words, opts.networkName); var xPrivKey = root._preDerivation(words, opts.networkName);
if (!xPrivKey) if (!xPrivKey)
return bwsError.cb('Bad derivation', gettext('Could not import'), cb); return bwsError.cb('Bad derivation', gettext('Could not import'), cb);
return root.importExtendedPrivateKey(xPrivKey, cb); return root.importExtendedPrivateKey(xPrivKey, cb);
} }
@ -562,19 +562,18 @@ angular.module('copayApp.services')
return lodash.sortBy(ret, 'name'); return lodash.sortBy(ret, 'name');
}; };
root._signWithLedger = function(txp,cb) { root._signWithLedger = function(txp, cb) {
var fc = root.focusedClient; var fc = root.focusedClient;
$log.info('Requesting Ledger Chrome app to sign the transaction'); $log.info('Requesting Ledger Chrome app to sign the transaction');
ledger.signTx(txp, 0, function(result) { ledger.signTx(txp, 0, function(result) {
if (!result.success) if (!result.success)
return cb(result); return cb(result);
txp.signatures = []; txp.signatures = lodash.map(result.signatures, function(s) {
for (var i=0; i<result.signatures.length; i++) { return s.substring(0, s.length - 2);
txp.signatures.push(result.signatures[i].substring(0, result.signatures[i].length - 2)); });
return fc.signTxProposal(txp, cb); return fc.signTxProposal(txp, cb);
}
}); });
}; };
@ -587,7 +586,7 @@ angular.module('copayApp.services')
$log.error(msg); $log.error(msg);
return cb(msg); return cb(msg);
} }
return root._signWithLedger(txp,cb); return root._signWithLedger(txp, cb);
} else { } else {
return fc.signTxProposal(txp, function(err, signedTxp) { return fc.signTxProposal(txp, function(err, signedTxp) {
root.lockFC(); root.lockFC();