mirror of https://github.com/BTCPrivate/copay.git
fix signing in trezor
This commit is contained in:
parent
5214074d05
commit
7d3b31dc0a
|
@ -594,7 +594,7 @@ angular.module('copayApp.services')
|
||||||
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, fc.credentials.account, function(result) {
|
||||||
$log.debug('Ledger response', result);
|
$log.debug('Ledger response', result);
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return cb(result.message || result.error);
|
return cb(result.message || result.error);
|
||||||
|
@ -612,7 +612,7 @@ angular.module('copayApp.services')
|
||||||
$log.info('Requesting Trezor to sign the transaction');
|
$log.info('Requesting Trezor to sign the transaction');
|
||||||
|
|
||||||
var xPubKeys = lodash.pluck(fc.credentials.publicKeyRing, 'xPubKey');
|
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);
|
if (err) return cb(err);
|
||||||
|
|
||||||
$log.debug('Trezor response', result);
|
$log.debug('Trezor response', result);
|
||||||
|
|
|
@ -91,8 +91,11 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
if (txp.addressType == 'P2PKH') {
|
if (txp.addressType == 'P2PKH') {
|
||||||
|
|
||||||
|
$log.debug("Trezor signing uni-sig p2pkh. Account:", account);
|
||||||
|
|
||||||
var inAmount = 0;
|
var inAmount = 0;
|
||||||
inputs = lodash.map(txp.inputs, function(i) {
|
inputs = lodash.map(txp.inputs, function(i) {
|
||||||
|
$log.debug("Trezor TX input path:", i.path);
|
||||||
var pathArr = i.path.split('/');
|
var pathArr = i.path.split('/');
|
||||||
var n = [hwWallet.UNISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
|
var n = [hwWallet.UNISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
|
||||||
inAmount += i.satoshis;
|
inAmount += i.satoshis;
|
||||||
|
@ -105,6 +108,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
var change = inAmount - txp.fee - txp.amount;
|
var change = inAmount - txp.fee - txp.amount;
|
||||||
if (change > 0) {
|
if (change > 0) {
|
||||||
|
$log.debug("Trezor TX change path:", txp.changeAddress.path);
|
||||||
var pathArr = txp.changeAddress.path.split('/');
|
var pathArr = txp.changeAddress.path.split('/');
|
||||||
var n = [hwWallet.UNISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
|
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
|
// P2SH Wallet, multisig wallet
|
||||||
var inAmount = 0;
|
var inAmount = 0;
|
||||||
|
$log.debug("Trezor signing multi-sig p2sh. Account:", account);
|
||||||
|
|
||||||
var sigs = xPubKeys.map(function(v) {
|
var sigs = xPubKeys.map(function(v) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -126,6 +131,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
|
|
||||||
inputs = lodash.map(txp.inputs, function(i) {
|
inputs = lodash.map(txp.inputs, function(i) {
|
||||||
|
$log.debug("Trezor TX input path:", i.path);
|
||||||
var pathArr = i.path.split('/');
|
var pathArr = i.path.split('/');
|
||||||
var n = [hwWallet.MULTISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
|
var n = [hwWallet.MULTISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
|
||||||
var np = n.slice(3);
|
var np = n.slice(3);
|
||||||
|
@ -155,6 +161,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
var change = inAmount - txp.fee - txp.amount;
|
var change = inAmount - txp.fee - txp.amount;
|
||||||
if (change > 0) {
|
if (change > 0) {
|
||||||
|
$log.debug("Trezor TX change path:", txp.changeAddress.path);
|
||||||
var pathArr = txp.changeAddress.path.split('/');
|
var pathArr = txp.changeAddress.path.split('/');
|
||||||
var n = [hwWallet.MULTISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
|
var n = [hwWallet.MULTISIG_ROOTPATH | 0x80000000, 0 | 0x80000000, account | 0x80000000, parseInt(pathArr[1]), parseInt(pathArr[2])];
|
||||||
var np = n.slice(3);
|
var np = n.slice(3);
|
||||||
|
|
Loading…
Reference in New Issue