fix signing in trezor

This commit is contained in:
Matias Alejo Garcia 2015-11-04 12:50:15 -03:00
parent 5214074d05
commit 7d3b31dc0a
2 changed files with 9 additions and 2 deletions

View File

@ -594,7 +594,7 @@ angular.module('copayApp.services')
var fc = root.focusedClient;
$log.info('Requesting Ledger Chrome app to sign the transaction');
ledger.signTx(txp, 0, function(result) {
ledger.signTx(txp, fc.credentials.account, function(result) {
$log.debug('Ledger response', result);
if (!result.success)
return cb(result.message || result.error);
@ -612,7 +612,7 @@ angular.module('copayApp.services')
$log.info('Requesting Trezor to sign the transaction');
var xPubKeys = lodash.pluck(fc.credentials.publicKeyRing, 'xPubKey');
trezor.signTx(xPubKeys, txp, 0, function(err, result) {
trezor.signTx(xPubKeys, txp, fc.credentials.account, function(err, result) {
if (err) return cb(err);
$log.debug('Trezor response', result);

View File

@ -91,8 +91,11 @@ angular.module('copayApp.services')
if (txp.addressType == 'P2PKH') {
$log.debug("Trezor signing uni-sig p2pkh. Account:", account);
var inAmount = 0;
inputs = lodash.map(txp.inputs, function(i) {
$log.debug("Trezor TX input path:", i.path);
var pathArr = i.path.split('/');
var n = [hwWallet.UNISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
inAmount += i.satoshis;
@ -105,6 +108,7 @@ angular.module('copayApp.services')
var change = inAmount - txp.fee - txp.amount;
if (change > 0) {
$log.debug("Trezor TX change path:", txp.changeAddress.path);
var pathArr = txp.changeAddress.path.split('/');
var n = [hwWallet.UNISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
@ -119,6 +123,7 @@ angular.module('copayApp.services')
// P2SH Wallet, multisig wallet
var inAmount = 0;
$log.debug("Trezor signing multi-sig p2sh. Account:", account);
var sigs = xPubKeys.map(function(v) {
return '';
@ -126,6 +131,7 @@ angular.module('copayApp.services')
inputs = lodash.map(txp.inputs, function(i) {
$log.debug("Trezor TX input path:", i.path);
var pathArr = i.path.split('/');
var n = [hwWallet.MULTISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
var np = n.slice(3);
@ -155,6 +161,7 @@ angular.module('copayApp.services')
var change = inAmount - txp.fee - txp.amount;
if (change > 0) {
$log.debug("Trezor TX change path:", txp.changeAddress.path);
var pathArr = txp.changeAddress.path.split('/');
var n = [hwWallet.MULTISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
var np = n.slice(3);