commit
8e54ab60b6
2 changed files with 20 additions and 19 deletions
|
|
@ -569,15 +569,11 @@ console.log('[profileService.js.239:walletClient:]',walletClient); //TODO
|
||||||
var fc = root.focusedClient;
|
var fc = root.focusedClient;
|
||||||
$log.info('Requesting Trezor to sign the transaction');
|
$log.info('Requesting Trezor to sign the transaction');
|
||||||
|
|
||||||
console.log('[profileService.js.570] xPub:', fc.credentials.xPubKey); //TODO
|
|
||||||
var xPubKeys = lodash.pluck(fc.credentials.publicKeyRing,'xPubKey');
|
var xPubKeys = lodash.pluck(fc.credentials.publicKeyRing,'xPubKey');
|
||||||
console.log('[profileService.js.571:xPubKeys:]',xPubKeys); //TODO
|
trezor.signTx(xPubKeys, txp, 0, function(err, result) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
trezor.signTx(xPubKeys, txp, 0, function(result) {
|
|
||||||
$log.debug('Trezor response',result);
|
$log.debug('Trezor response',result);
|
||||||
if (!result.success)
|
|
||||||
return cb(result.error || result);
|
|
||||||
|
|
||||||
txp.signatures = result.signatures;
|
txp.signatures = result.signatures;
|
||||||
return fc.signTxProposal(txp, cb);
|
return fc.signTxProposal(txp, cb);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,25 @@ angular.module('copayApp.services')
|
||||||
root.ENTROPY_INDEX_PATH = "0xb11e/";
|
root.ENTROPY_INDEX_PATH = "0xb11e/";
|
||||||
root.callbacks = {};
|
root.callbacks = {};
|
||||||
|
|
||||||
|
|
||||||
|
root._err = function(data) {
|
||||||
|
var msg = 'TREZOR Error: ' + (data.error || data.message || 'unknown');
|
||||||
|
$log.warn(msg);
|
||||||
|
return msg;
|
||||||
|
};
|
||||||
|
|
||||||
root.getEntropySource = function(account, callback) {
|
root.getEntropySource = function(account, callback) {
|
||||||
var path = root.ENTROPY_INDEX_PATH + account + "'";
|
var path = root.ENTROPY_INDEX_PATH + account + "'";
|
||||||
var xpub = root.getXPubKey(path, function(data) {
|
var xpub = root.getXPubKey(path, function(data) {
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
$log.warn(data.message);
|
return callback(root._err(data));
|
||||||
return callback(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var b = bwcService.getBitcore();
|
var b = bwcService.getBitcore();
|
||||||
|
|
||||||
var x = b.HDPublicKey(data.xpubkey);
|
var x = b.HDPublicKey(data.xpubkey);
|
||||||
data.entropySource = x.publicKey.toString();
|
data.entropySource = x.publicKey.toString();
|
||||||
return callback(data);
|
return callback(null, data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -37,19 +43,15 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
root.getInfoForNewWallet = function(account, callback) {
|
root.getInfoForNewWallet = function(account, callback) {
|
||||||
var opts = {};
|
var opts = {};
|
||||||
root.getEntropySource(account, function(data) {
|
root.getEntropySource(account, function(err, data) {
|
||||||
if (!data.success) {
|
if (err) return callback(err);
|
||||||
$log.warn(data.message);
|
|
||||||
return callback(data.message);
|
|
||||||
}
|
|
||||||
opts.entropySource = data.entropySource;
|
opts.entropySource = data.entropySource;
|
||||||
$log.debug('Waiting TREZOR to settle...');
|
$log.debug('Waiting TREZOR to settle...');
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
root.getXPubKeyForAddresses(account, function(data) {
|
root.getXPubKeyForAddresses(account, function(data) {
|
||||||
if (!data.success) {
|
if (!data.success)
|
||||||
$log.warn(data.message);
|
return callback(root._err(data));
|
||||||
return callback(data);
|
|
||||||
}
|
|
||||||
opts.extendedPublicKey = data.xpubkey;
|
opts.extendedPublicKey = data.xpubkey;
|
||||||
opts.externalSource = 'trezor';
|
opts.externalSource = 'trezor';
|
||||||
opts.externalIndex = account;
|
opts.externalIndex = account;
|
||||||
|
|
@ -225,7 +227,10 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
$log.debug('Signing with TREZOR', inputs, outputs);
|
$log.debug('Signing with TREZOR', inputs, outputs);
|
||||||
TrezorConnect.signTx(inputs, outputs, function(result) {
|
TrezorConnect.signTx(inputs, outputs, function(result) {
|
||||||
callback(result);
|
if (!data.success)
|
||||||
|
return callback(root._err(data));
|
||||||
|
|
||||||
|
callback(null, result);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue