Skip to content

Commit

Permalink
fix signing multiple inputs with ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
matiu committed Sep 14, 2015
1 parent a313222 commit 9dc2c40
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/js/controllers/walletHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
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'));
$timeout(function() {
var comment = form.comment.$modelValue;
var paypro = self._paypro;
var address, amount;

Expand Down
2 changes: 2 additions & 0 deletions src/js/services/bwsError.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ angular.module('copayApp.services')
body = err.message || err.code;
break;
}
} else {
body = gettextCatalog.getString(err);
}

var msg = prefix + ( body ? ': ' + body : '');
Expand Down
17 changes: 8 additions & 9 deletions src/js/services/profileService.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ angular.module('copayApp.services')

if (opts.mnemonic && opts.mnemonic.indexOf('m/') == 0) {
var xPrivKey = root._preDerivation(opts.mnemonic, network);
if (!xPrivKey)
if (!xPrivKey)
return bwsError.cb('Bad derivation', gettext('Could not import'), cb);
opts.mnemonic = null;
opts.extendedPrivateKey = xPrivKey;
Expand Down Expand Up @@ -389,7 +389,7 @@ angular.module('copayApp.services')

if (words.indexOf('m/') == 0) {
var xPrivKey = root._preDerivation(words, opts.networkName);
if (!xPrivKey)
if (!xPrivKey)
return bwsError.cb('Bad derivation', gettext('Could not import'), cb);
return root.importExtendedPrivateKey(xPrivKey, cb);
}
Expand Down Expand Up @@ -562,19 +562,18 @@ angular.module('copayApp.services')
return lodash.sortBy(ret, 'name');
};

root._signWithLedger = function(txp,cb) {
root._signWithLedger = function(txp, cb) {
var fc = root.focusedClient;
$log.info('Requesting Ledger Chrome app to sign the transaction');

ledger.signTx(txp, 0, function(result) {
if (!result.success)
if (!result.success)
return cb(result);

txp.signatures = [];
for (var i=0; i<result.signatures.length; i++) {
txp.signatures.push(result.signatures[i].substring(0, result.signatures[i].length - 2));
txp.signatures = lodash.map(result.signatures, function(s) {
return s.substring(0, s.length - 2);
});
return fc.signTxProposal(txp, cb);
}
});
};

Expand All @@ -587,7 +586,7 @@ angular.module('copayApp.services')
$log.error(msg);
return cb(msg);
}
return root._signWithLedger(txp,cb);
return root._signWithLedger(txp, cb);
} else {
return fc.signTxProposal(txp, function(err, signedTxp) {
root.lockFC();
Expand Down

0 comments on commit 9dc2c40

Please sign in to comment.