fix export/import
This commit is contained in:
parent
6c1f9f5387
commit
5435200968
6 changed files with 97 additions and 118 deletions
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
<ion-view ng-controller="exportController" cache-view="false" ng-init="init(index.prevState)">
|
||||
<ion-view ng-controller="exportController" cache-view="false" ng-init="init()">
|
||||
<ion-nav-bar class="bar-stable">
|
||||
<ion-nav-title>Export Wallet</ion-nav-title>
|
||||
<ion-nav-buttons side="primary">
|
||||
|
|
@ -9,8 +9,10 @@
|
|||
</ion-nav-buttons>
|
||||
</ion-nav-bar>
|
||||
<ion-content class="has-header">
|
||||
<div ng-show="!index.canSign"><h4></h4></div>
|
||||
<div ng-show="index.canSign" class="create-tab small-only-text-center">
|
||||
<h4>{{wallet.name}}</h4>
|
||||
|
||||
<div ng-show="!canSign"><h4></h4></div>
|
||||
<div ng-show="canSign" class="create-tab small-only-text-center">
|
||||
<div class="row">
|
||||
<div class="tab-container small-6 columns"
|
||||
ng-class="{'selected':!exportQR}"
|
||||
|
|
@ -60,7 +62,7 @@
|
|||
<div class="text-center size-12 m10" translate>Exporting via QR not supported for this wallet</div>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-show="!exportQR && index.canSign">
|
||||
<div class="row" ng-show="!exportQR && canSign">
|
||||
<div class="columns m15t">
|
||||
<a class="button outline light-gray expand tiny p10i" ng-click="showAdvanced = !showAdvanced">
|
||||
<i class="fi-widget m3r"></i>
|
||||
|
|
@ -78,7 +80,7 @@
|
|||
</ion-toggle>
|
||||
</div>
|
||||
|
||||
<div class="box-notification p15l" ng-show="!index.canSign">
|
||||
<div class="box-notification p15l" ng-show="!canSign">
|
||||
<span class="text-warning size-14">
|
||||
<i class="fi-alert"></i>
|
||||
<span translate>
|
||||
|
|
@ -100,12 +102,12 @@
|
|||
<div class="columns">
|
||||
<button class="black round expand m20t" ng-click="downloadWalletBackup()"
|
||||
ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-style="{'background-color':wallet.color}"
|
||||
ng-show="!isSafari && !isCordova"><i class="fi-download"></i>
|
||||
<span translate>Download</span></button>
|
||||
<button class="black round expand m20t" ng-click="viewWalletBackup()"
|
||||
ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-style="{'background-color':wallet.color}"
|
||||
ng-show="isSafari && !isCordova"><i class="fi-eye"></i>
|
||||
<span translate>View</span></button>
|
||||
<div ng-show="isCordova">
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@
|
|||
spellcheck="false"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col text-center">
|
||||
<qr-scanner class="qr-icon size-24" on-scan="join.onQrCodeScanned(data)"></qr-scanner>
|
||||
</div>
|
||||
<div class="qr-scanner-input-import">
|
||||
<qr-scanner on-scan="processWalletInfo(data)"></qr-scanner>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
|
||||
|
|
|
|||
|
|
@ -12,12 +12,6 @@
|
|||
<div class="item item-divider">
|
||||
Wallet Information
|
||||
</div>
|
||||
<div class="item">
|
||||
<span translate>BETA: Android Key Derivation Test:</span>
|
||||
<span class="item-note">
|
||||
{{androidTest}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item" ng-click="saveBlack()">
|
||||
<span translate>Wallet Name (at creation)</span>
|
||||
<span class="item-note">
|
||||
|
|
@ -54,22 +48,22 @@
|
|||
{{derivationStrategy}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item" ng-show="index.externalSource">
|
||||
<div class="item" ng-show="wallet.isPrivKeyExternal()">
|
||||
<span translate>Hardware Wallet</span>
|
||||
<span class="item-note">
|
||||
{{index.externalSource}}
|
||||
{{wallet.getPrivKeyExternalSourceName()}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item" ng-show="!index.externalSource && !index.canSign">
|
||||
<div class="item" ng-show="!wallet.isPrivKeyExternal() && !wallet.canSign()">
|
||||
<span translate></span>
|
||||
<span class="item-note">
|
||||
No private key
|
||||
</span>
|
||||
</div>
|
||||
<div class="item" ng-show="index.account">
|
||||
<div class="item" ng-show="wallet.credentials.account">
|
||||
<span translate>Account</span>({{derivationStrategy}})
|
||||
<span class="item-note">
|
||||
#{{index.account}}
|
||||
#{{wallet.credentials.account}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
|
@ -77,9 +71,9 @@
|
|||
Copayers
|
||||
</div>
|
||||
|
||||
<div class="item item-icon-right" ng-repeat="copayer in index.copayers">
|
||||
<span ng-show="copayer.id == index.copayerId" translate>{{copayer.name}} ({{'Me'|translate}})</span>
|
||||
<span ng-style="{'color': 'grey';}" ng-show="copayer.id != index.copayerId" translate>{{copayer.name}}</span>
|
||||
<div class="item item-icon-right" ng-repeat="copayer in wallet.copayers">
|
||||
<span ng-show="copayer.id == wallet.copayerId" translate>{{copayer.name}} ({{'Me'|translate}})</span>
|
||||
<span ng-style="{'color': 'grey';}" ng-show="copayer.id != wallet.copayerId" translate>{{copayer.name}}</span>
|
||||
<i class="icon ion-ios-checkmark-outline"></i>
|
||||
</div>
|
||||
|
||||
|
|
@ -110,21 +104,18 @@
|
|||
<div translate>
|
||||
Only Main (not change) addresses are shown. The addresses on this list were not verified locally at this time.
|
||||
</div>
|
||||
<ul class="no-bullet m0">
|
||||
<li ng-style="{'color':index.backgroundColor}" href ui-sref="walletHome" ng-click="index.retryScan()" translate>
|
||||
<button class="button button-block" ng-style="{'color':wallet.color}" href ui-sref="walletHome" ng-click="index.retryScan()" translate>
|
||||
Scan addresses for funds
|
||||
</li>
|
||||
<li ng-style="{'color':index.backgroundColor}" ng-show="index.isCordova" ng-click="sendAddrs()" translate>
|
||||
</button>
|
||||
<button class="button button-block" ng-style="{'color':wallet.color}" ng-show="isCordova" ng-click="sendAddrs()" translate>
|
||||
Send addresses by email
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div ng-show="index.balanceByAddress" ng-if="index.balanceByAddress[0]">
|
||||
<div ng-show="wallet.balanceByAddress" ng-if="wallet.balanceByAddress[0]">
|
||||
<div class="item item-divider">
|
||||
Balance By Address
|
||||
</div>
|
||||
<div class="item" ng-repeat="a in index.balanceByAddress" ng-click="copyToClipboard(a.address)">
|
||||
<div class="item" ng-repeat="a in wallet.balanceByAddress" ng-click="copyToClipboard(a.address)">
|
||||
<span>{{a.address}}</span>
|
||||
<span class="item-note">
|
||||
{{(a.amount/1e8).toFixed(8)}} BTC
|
||||
|
|
|
|||
|
|
@ -1,40 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('exportController',
|
||||
function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, fingerprintService, configService, storageService, profileService, platformInfo, notification, go, gettext, gettextCatalog) {
|
||||
function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, storageService, profileService, platformInfo, notification, go, gettext, gettextCatalog, $state, $stateParams) {
|
||||
var prevState;
|
||||
var isWP = platformInfo.isWP;
|
||||
var isAndroid = platformInfo.isAndroid;
|
||||
var fc = profileService.focusedClient;
|
||||
$scope.isEncrypted = fc.isPrivKeyEncrypted();
|
||||
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.isEncrypted = wallet.isPrivKeyEncrypted();
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.isSafari = platformInfo.isSafari;
|
||||
$scope.error = null;
|
||||
|
||||
$scope.init = function(state) {
|
||||
$scope.init = function() {
|
||||
$scope.supported = true;
|
||||
$scope.exportQR = false;
|
||||
$scope.noSignEnabled = false;
|
||||
$scope.showAdvanced = false;
|
||||
prevState = state || 'walletHome';
|
||||
$scope.wallet = wallet;
|
||||
$scope.canSign = wallet.canSign();
|
||||
|
||||
fingerprintService.check(fc, function(err) {
|
||||
walletService.getEncodedWalletInfo(wallet, function(err, code) {
|
||||
if (err) {
|
||||
go.path(prevState);
|
||||
return;
|
||||
$log.warn(err);
|
||||
return $state.go('wallet.preferencesAdvanced')
|
||||
}
|
||||
|
||||
handleEncryptedWallet(fc, function(err) {
|
||||
if (err) {
|
||||
go.path(prevState);
|
||||
return;
|
||||
}
|
||||
if (!code)
|
||||
$scope.supported = false;
|
||||
else
|
||||
$scope.exportWalletInfo = code;
|
||||
|
||||
$scope.exportWalletInfo = encodeWalletInfo();
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -50,62 +49,9 @@ angular.module('copayApp.controllers').controller('exportController',
|
|||
*/
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
walletService.lock(fc);
|
||||
walletService.lock(wallet);
|
||||
});
|
||||
|
||||
function handleEncryptedWallet(client, cb) {
|
||||
if (!walletService.isEncrypted(client)) {
|
||||
$scope.credentialsEncrypted = false;
|
||||
return cb();
|
||||
}
|
||||
|
||||
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
|
||||
if (err) return cb(err);
|
||||
return cb(walletService.unlock(client, password));
|
||||
});
|
||||
};
|
||||
|
||||
function encodeWalletInfo() {
|
||||
var c = fc.credentials;
|
||||
var derivationPath = fc.credentials.getBaseAddressDerivationPath();
|
||||
var encodingType = {
|
||||
mnemonic: 1,
|
||||
xpriv: 2,
|
||||
xpub: 3
|
||||
};
|
||||
var info;
|
||||
|
||||
$scope.supported = (c.derivationStrategy == 'BIP44' && c.canSign());
|
||||
|
||||
if ($scope.supported) {
|
||||
if (c.mnemonic) {
|
||||
info = {
|
||||
type: encodingType.mnemonic,
|
||||
data: c.mnemonic,
|
||||
}
|
||||
} else {
|
||||
info = {
|
||||
type: encodingType.xpriv,
|
||||
data: c.xPrivKey
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
EXPORT WITHOUT PRIVATE KEY - PENDING
|
||||
|
||||
info = {
|
||||
type: encodingType.xpub,
|
||||
data: c.xPubKey
|
||||
}
|
||||
*/
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var code = info.type + '|' + info.data + '|' + c.network.toLowerCase() + '|' + derivationPath + '|' + (c.mnemonicHasPassphrase);
|
||||
return code;
|
||||
};
|
||||
|
||||
$scope.downloadWalletBackup = function() {
|
||||
$scope.getAddressbook(function(err, localAddressBook) {
|
||||
if (err) {
|
||||
|
|
@ -184,11 +130,10 @@ angular.module('copayApp.controllers').controller('exportController',
|
|||
};
|
||||
|
||||
$scope.sendWalletBackup = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
window.plugins.toast.showShortCenter(gettextCatalog.getString('Preparing backup...'));
|
||||
var name = (fc.credentials.walletName || fc.credentials.walletId);
|
||||
if (fc.alias) {
|
||||
name = fc.alias + ' [' + name + ']';
|
||||
var name = (wallet.credentials.walletName || wallet.credentials.walletId);
|
||||
if (wallet.alias) {
|
||||
name = wallet.alias + ' [' + name + ']';
|
||||
}
|
||||
$scope.getBackup(function(backup) {
|
||||
var ew = backup;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesInformation',
|
||||
function($scope, $log, $timeout, platformInfo, gettextCatalog, lodash, profileService, configService, go) {
|
||||
function($scope, $log, $timeout, platformInfo, gettextCatalog, lodash, profileService, configService, go, $stateParams) {
|
||||
var base = 'xpub';
|
||||
var fc = profileService.focusedClient;
|
||||
var c = fc.credentials;
|
||||
var walletId = c.walletId;
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var walletId = wallet.id;
|
||||
|
||||
var config = configService.getSync();
|
||||
var b = 1;
|
||||
var isCordova = platformInfo.isCordova;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
config.colorFor = config.colorFor || {};
|
||||
|
||||
$scope.init = function() {
|
||||
var c =wallet.credentials;
|
||||
var basePath = c.getBaseAddressDerivationPath();
|
||||
|
||||
$scope.wallet = wallet;
|
||||
$scope.walletName = c.walletName;
|
||||
$scope.walletId = c.walletId;
|
||||
$scope.network = c.network;
|
||||
|
|
@ -25,7 +27,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
|
|||
$scope.pubKeys = lodash.pluck(c.publicKeyRing, 'xPubKey');
|
||||
$scope.addrs = null;
|
||||
|
||||
fc.getMainAddresses({
|
||||
wallet.getMainAddresses({
|
||||
doNotVerify: true
|
||||
}, function(err, addrs) {
|
||||
if (err) {
|
||||
|
|
@ -62,7 +64,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
|
|||
};
|
||||
|
||||
$timeout(function() {
|
||||
fc.getMainAddresses({
|
||||
wallet.getMainAddresses({
|
||||
doNotVerify: true
|
||||
}, function(err, addrs) {
|
||||
if (err) {
|
||||
|
|
@ -113,7 +115,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
|
|||
};
|
||||
|
||||
$scope.copyToClipboard = function(data) {
|
||||
if (isCordova) {
|
||||
if ($scope.isCordova) {
|
||||
window.cordova.plugins.clipboard.copy(data);
|
||||
window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -818,7 +818,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
}]
|
||||
});
|
||||
pass.then(function(res) {
|
||||
console.log('Tapped!', res);
|
||||
return cb(res);
|
||||
});
|
||||
};
|
||||
|
|
@ -911,7 +910,47 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
});
|
||||
};
|
||||
root.getEncodedWalletInfo = function(wallet,cb){
|
||||
|
||||
var getCode = function() {
|
||||
var derivationPath = wallet.credentials.getBaseAddressDerivationPath();
|
||||
var encodingType = {
|
||||
mnemonic: 1,
|
||||
xpriv: 2,
|
||||
xpub: 3
|
||||
};
|
||||
var info;
|
||||
|
||||
// not supported yet
|
||||
if (wallet.credentials.derivationStrategy != 'BIP44' || !wallet.canSign())
|
||||
return null;
|
||||
|
||||
if (wallet.mnemonic) {
|
||||
info = {
|
||||
type: encodingType.mnemonic,
|
||||
data: wallet.mnemonic,
|
||||
}
|
||||
} else {
|
||||
info = {
|
||||
type: encodingType.xpriv,
|
||||
data: wallet.xPrivKey
|
||||
}
|
||||
}
|
||||
return info.type + '|' + info.data + '|' + wallet.credentials.network.toLowerCase() + '|' + derivationPath + '|' + (wallet.credentials.mnemonicHasPassphrase);
|
||||
};
|
||||
|
||||
fingerprintService.check(wallet, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
root.handleEncryptedWallet(wallet, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var code = getCode();
|
||||
console.log('[walletService.js.948:code:]',code); //TODO
|
||||
return cb(null, code);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue