add coin to preferences/info
+ refactor duplicate
This commit is contained in:
parent
fbda525e6d
commit
acc1549633
13 changed files with 212 additions and 146 deletions
|
|
@ -56,7 +56,7 @@
|
|||
"bezier-easing": "^2.0.3",
|
||||
"bhttp": "1.2.1",
|
||||
"bitauth": "^0.2.1",
|
||||
"bitcore-wallet-client": "6.0.0",
|
||||
"bitcore-wallet-client": "6.0.1",
|
||||
"bower": "^1.7.9",
|
||||
"cordova-android": "5.1.1",
|
||||
"cordova-custom-config": "^3.0.5",
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
"run:android": "cordova run android --device",
|
||||
"run:android-release": "cordova run android --device --release",
|
||||
"log:android": "adb logcat | grep chromium",
|
||||
"sign:android": "rm -f platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../copay.keystore -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk copay_play && ../android-sdk-macosx/build-tools/25.0.3/zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-signed-aligned.apk",
|
||||
"sign:android": "rm -f platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../copay.keystore -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk copay_play && $ANDROID_HOME/build-tools/26.0.1/zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-signed-aligned.apk",
|
||||
"apply:copay": "npm i fs-extra && cd app-template && node apply.js copay && npm i && cordova prepare",
|
||||
"apply:bitpay": "npm i fs-extra && cd app-template && node apply.js bitpay && npm i && cordova prepare",
|
||||
"test": "echo \"no package tests configured\"",
|
||||
|
|
|
|||
|
|
@ -50,16 +50,6 @@ angular.module('copayApp.controllers').controller('advancedSettingsController',
|
|||
});
|
||||
};
|
||||
|
||||
$scope.openBitcoinCashWeb = function() {
|
||||
var url = 'https://www.bitcoincash.org/';
|
||||
var optIn = true;
|
||||
var title = null;
|
||||
var message = gettextCatalog.getString('Open bitcoincash.org?');
|
||||
var okText = gettextCatalog.getString('Open');
|
||||
var cancelText = gettextCatalog.getString('Go Back');
|
||||
externalLinkService.open(url, optIn, title, message, okText, cancelText);
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
||||
updateConfig();
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('otherBalanceController',
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, bwcError ) {
|
||||
var wallet;
|
||||
var listeners = [];
|
||||
var notifications = [];
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.isAndroid = platformInfo.isAndroid;
|
||||
$scope.isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
||||
$scope.isNW = platformInfo.isNW;
|
||||
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
updateAllWallets();
|
||||
});
|
||||
|
||||
var updateAllWallets = function() {
|
||||
var wallets = profileService.getWallets({coin:'btc', onlyComplete:true, network: 'livenet' });
|
||||
|
||||
|
||||
// TODO ?
|
||||
if (lodash.isEmpty(wallets)) return;
|
||||
console.log('[otherBalance.js.24:wallets:]',wallets); //TODO
|
||||
|
||||
|
||||
var walletsBCH = profileService.getWallets({coin:'bch', network: 'livenet' });
|
||||
var xPubKeyIndex = lodash.indexBy(walletsBCH,"credentials.xPubKey");
|
||||
console.log('[otherBalance.js.28:xPubKeyIndex:]',xPubKeyIndex); //TODO
|
||||
|
||||
wallets= lodash.filter(wallets,function(w) { return xPubKeyIndex[w.credentials.xPubKey]; });
|
||||
console.log('[otherBalance.js.31:wallets:]',wallets); //TODO
|
||||
|
||||
|
||||
// TODO Filterout already duplicated walelts
|
||||
// TODO filterout balance=0 wallets
|
||||
//
|
||||
//
|
||||
|
||||
$scope.wallets = wallets;
|
||||
|
||||
var i = wallets.length;
|
||||
var j = 0;
|
||||
lodash.each(wallets, function(wallet) {
|
||||
walletService.getBalance(wallet, {coin:'bch'}, function(err, status) {
|
||||
if (err) {
|
||||
|
||||
wallet.error = (err === 'WALLET_NOT_REGISTERED') ? gettextCatalog.getString('Wallet not registered') : bwcError.msg(err);
|
||||
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
||||
console.log('[otherBalance.js.28:status:]',status); //TODO
|
||||
wallet.error = null;
|
||||
wallet.status = status;
|
||||
if (++j == i) {
|
||||
//
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.duplicate = function(wallet) {
|
||||
$log.debug('Duplicating wallet for BCH:' + wallet.id + ':' + wallet.name);
|
||||
|
||||
var opts = {};
|
||||
opts.name = wallet.name + '[BCH]';
|
||||
opts.m = wallet.m;
|
||||
opts.n = wallet.n;
|
||||
opts.myName = wallet.credentials.copayerName;
|
||||
opts.networkName = wallet.network;
|
||||
opts.coin = 'bch';
|
||||
|
||||
// TODO: finger print / decrypt
|
||||
$log.warn('TODO finger print / decrypt');
|
||||
|
||||
|
||||
opts.walletPrivKey = wallet.credentials.walletPrivKey;
|
||||
|
||||
walletService.getStatus(wallet, {}, function(err, status){
|
||||
if (err) {
|
||||
// TODO
|
||||
$log.err('TODO Err');
|
||||
return;
|
||||
}
|
||||
opts.singleAddress = status.wallet.singleAddress;
|
||||
|
||||
// create and store a wallet
|
||||
profileService.createWallet(opts, function(err) {
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
117
src/js/controllers/cashScan.js
Normal file
117
src/js/controllers/cashScan.js
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('cashScanController',
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, txFormatService, bwcError, pushNotificationsService, bwcService) {
|
||||
var wallet;
|
||||
var errors = bwcService.getErrors();
|
||||
$scope.error = null;
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
updateAllWallets();
|
||||
});
|
||||
|
||||
var updateAllWallets = function() {
|
||||
var wallets = profileService.getWallets({coin:'btc', onlyComplete:true, network: 'livenet' });
|
||||
|
||||
|
||||
var kk = lodash.indexBy(wallets,"credentials.xPubKey");
|
||||
|
||||
|
||||
// TODO ?
|
||||
if (lodash.isEmpty(wallets)) return;
|
||||
|
||||
|
||||
var walletsBCH = profileService.getWallets({coin:'bch', network: 'livenet' });
|
||||
var xPubKeyIndex = lodash.indexBy(walletsBCH,"credentials.xPubKey");
|
||||
|
||||
// wallets= lodash.filter(wallets,function(w) { return !xPubKeyIndex[w.credentials.xPubKey]; });
|
||||
|
||||
$scope.wallets = wallets;
|
||||
|
||||
var i = wallets.length;
|
||||
var j = 0;
|
||||
lodash.each(wallets, function(wallet) {
|
||||
walletService.getBalance(wallet, {coin:'bch'}, function(err, balance) {
|
||||
if (err) {
|
||||
|
||||
wallet.error = (err === 'WALLET_NOT_REGISTERED') ? gettextCatalog.getString('Wallet not registered') : bwcError.msg(err);
|
||||
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
||||
console.log('[otherBalance.js.28:balance:]',balance); //TODO
|
||||
wallet.error = null;
|
||||
wallet.bchBalance = txFormatService.formatAmountStr('bch', balance.availableAmount);
|
||||
if (++j == i) {
|
||||
|
||||
//Done
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
}, 10);
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.duplicate = function(wallet) {
|
||||
$scope.error = null;
|
||||
$log.debug('Duplicating wallet for BCH:' + wallet.id + ':' + wallet.name);
|
||||
|
||||
var opts = {};
|
||||
opts.name = wallet.name + '[BCH]';
|
||||
opts.m = wallet.m;
|
||||
opts.n = wallet.n;
|
||||
opts.myName = wallet.credentials.copayerName;
|
||||
opts.networkName = wallet.network;
|
||||
opts.coin = 'bch';
|
||||
|
||||
// TODO: finger print / decrypt
|
||||
$log.warn('TODO finger print / decrypt');
|
||||
opts.extendedPrivateKey = wallet.credentials.xPrivKey;
|
||||
|
||||
function setErr(err, cb) {
|
||||
$scope.error = bwcError.cb(err, gettextCatalog.getString('Could not duplicate'), function() {
|
||||
return cb(err);
|
||||
});
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
}, 10);
|
||||
}
|
||||
|
||||
function importOrCreate(cb) {
|
||||
walletService.getStatus(wallet, {}, function(err, status){
|
||||
if (err) return cb(err);
|
||||
|
||||
opts.singleAddress = status.wallet.singleAddress;
|
||||
|
||||
// first try to import
|
||||
profileService.importExtendedPrivateKey(opts.extendedPrivateKey, opts, function(err, client) {
|
||||
if (err && !(err instanceof errors.NOT_AUTHORIZED) ) {
|
||||
return setErr(err, cb);
|
||||
}
|
||||
if (err) {
|
||||
// create and store a wallet
|
||||
return profileService.createWallet(opts, function(err, client) {
|
||||
if (err) return setErr(err, cb);
|
||||
return cb(null, client, true);
|
||||
});
|
||||
}
|
||||
return cb(null, client);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
importOrCreate(function(err, client, isNew) {
|
||||
if (err) return;
|
||||
walletService.updateRemotePreferences(client);
|
||||
pushNotificationsService.updateSubscription(client);
|
||||
walletService.startScan(wallet, function() { });
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesCashController', function($scope, $log, $timeout, appConfigService, lodash, configService, platformInfo, pushNotificationsService, emailService) {
|
||||
angular.module('copayApp.controllers').controller('preferencesCashController', function($scope, $log, $timeout, appConfigService, lodash, configService, gettextCatalog, externalLinkService) {
|
||||
var updateConfig = function() {
|
||||
|
||||
var config = configService.getSync();
|
||||
$scope.appName = appConfigService.nameCase;
|
||||
|
||||
$scope.cashSupport = {
|
||||
value: config.wallet.cashSupport.enabled
|
||||
value: config.cashSupport
|
||||
};
|
||||
|
||||
$timeout(function() {
|
||||
|
|
@ -16,15 +17,25 @@ angular.module('copayApp.controllers').controller('preferencesCashController', f
|
|||
|
||||
$scope.cashSupportChange = function() {
|
||||
var opts = {
|
||||
wallet: {
|
||||
cashSupport: $scope.cashSupport.value
|
||||
}
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
$scope.openBitcoinCashWeb = function() {
|
||||
var url = 'https://www.bitcoincash.org/';
|
||||
var optIn = true;
|
||||
var title = null;
|
||||
var message = gettextCatalog.getString('Open bitcoincash.org?');
|
||||
var okText = gettextCatalog.getString('Open');
|
||||
var cancelText = gettextCatalog.getString('Go Back');
|
||||
externalLinkService.open(url, optIn, title, message, okText, cancelText);
|
||||
};
|
||||
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
updateConfig();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
|
|||
});
|
||||
|
||||
$scope.cashSupport = {
|
||||
value: config.cashSupport.enabled
|
||||
value: config.cashSupport
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -244,15 +244,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.scan', {
|
||||
url: '/scan',
|
||||
views: {
|
||||
'tab-scan': {
|
||||
controller: 'tabScanController',
|
||||
templateUrl: 'views/tab-scan.html',
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('scanner', {
|
||||
url: '/scanner',
|
||||
params: {
|
||||
|
|
@ -374,6 +365,16 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*
|
||||
*/
|
||||
|
||||
.state('tabs.preferencesCash', {
|
||||
url: '/preferencesCash',
|
||||
views: {
|
||||
'tab-settings@tabs': {
|
||||
controller: 'preferencesCashController',
|
||||
templateUrl: 'views/preferencesCash.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.state('tabs.notifications', {
|
||||
url: '/notifications',
|
||||
views: {
|
||||
|
|
@ -464,15 +465,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.cash', {
|
||||
url: '/cash',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'cashController',
|
||||
templateUrl: 'views/tab-cash.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -590,6 +582,30 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
|
||||
.state('tabs.preferencesCash.scan', {
|
||||
url: '/cashScan',
|
||||
views: {
|
||||
'tab-settings@tabs': {
|
||||
controller: 'cashScanController',
|
||||
templateUrl: 'views/cashScan.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// TODO remove
|
||||
.state('tabs.scan', {
|
||||
url: '/cashScan2',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'cashScanController',
|
||||
templateUrl: 'views/cashScan.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Addressbook
|
||||
|
|
|
|||
|
|
@ -339,7 +339,12 @@ angular.module('copayApp.services')
|
|||
}
|
||||
} else if (opts.extendedPrivateKey) {
|
||||
try {
|
||||
walletClient.seedFromExtendedPrivateKey(opts.extendedPrivateKey);
|
||||
walletClient.seedFromExtendedPrivateKey(opts.extendedPrivateKey, {
|
||||
network: network,
|
||||
account: opts.account || 0,
|
||||
derivationStrategy: opts.derivationStrategy || 'BIP44',
|
||||
coin: opts.coin,
|
||||
});
|
||||
} catch (ex) {
|
||||
$log.warn(ex);
|
||||
return cb(gettextCatalog.getString('Could not create using the specified extended private key'));
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
<div class="item item-icon-right item-heading">
|
||||
<span translate>BTC Wallets</span>
|
||||
</div>
|
||||
|
||||
<span class="assertive" ng-if="wallet.error">{{wallet.error}}</span>
|
||||
<div>
|
||||
<div ng-repeat="wallet in wallets track by $index"
|
||||
class="item item-sub item-icon-left item-big-icon-left item-icon-right wallet"
|
||||
|
|
@ -24,7 +26,7 @@
|
|||
{{wallet.name || wallet.id}}
|
||||
</span>
|
||||
<p>
|
||||
<span > {{wallet.status.totalBalanceStr ? wallet.status.totalBalanceStr : ( wallet.cachedBalance ? wallet.cachedBalance + (wallet.cachedBalanceUpdatedOn ? ' · ' + ( wallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' ) }} </span>
|
||||
<span > {{wallet.bchBalance || 'Checking...'}} </span>
|
||||
|
||||
<span class="tab-home__wallet__multisig-number" ng-if="wallet.n > 1">
|
||||
{{wallet.m}}-of-{{wallet.n}}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,16 @@
|
|||
<ion-toggle class="has-comment" ng-model="cashSupport.value" toggle-class="toggle-balanced" ng-change="cashSupportChange()">
|
||||
<span class="toggle-label" translate>Support Bitcoin Cash</span>
|
||||
</ion-toggle>
|
||||
</div>
|
||||
|
||||
<div ng-show="!cashSupport.value">
|
||||
<div class="settings-explanation">
|
||||
<div class="settings-description" ng-show="!cashSupport.value">
|
||||
<span translate>Enable Bitcoin Cash wallet creation and operation within the App.</span>
|
||||
<a ng-click="openBitcoinCashWeb()">Learn more</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-if="cashSupport.value">
|
||||
<span class="setting-value" translate>
|
||||
<button ng-show="cashSupport.value" ui-sref="tabs.cash" translate>Check your current wallets for Bitcoin Cash</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="padding" ng-if="cashSupport.value">
|
||||
<a class="button button-standard button-primary" ui-sref="tabs.preferencesCash.scan" translate>Scan your wallets for Bitcoin Cash</a>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@
|
|||
{{walletName}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item" copy-to-clipboard="walletId">
|
||||
<span translate>Coin</span>
|
||||
<span class="item-note">
|
||||
{{wallet.coin}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item" copy-to-clipboard="walletId">
|
||||
<span translate>Wallet Id</span>
|
||||
<span class="item-note">
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@
|
|||
on-refresh="onRefresh()">
|
||||
</ion-refresher>
|
||||
|
||||
TODO Remove:
|
||||
<a class="button button-standard button-primary" ui-sref="tabs.scan" translate>Scan your wallets for Bitcoin Cash</a>
|
||||
|
||||
|
||||
<div class="list card release ng-hide" ng-show="newRelease">
|
||||
<i class="item icon big-icon-svg">
|
||||
<img src="img/icon-update.svg" class="bg"/>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,20 @@
|
|||
|
||||
<div class="item item-divider">{{'Preferences' | translate}}</div>
|
||||
|
||||
|
||||
<a class="item has-setting-value item-icon-left item-icon-right" ui-sref="tabs.preferencesCash">
|
||||
<i class="icon ion-ios-locked-outline" ng-if="cashSupport.value"></i>
|
||||
<i class="icon ion-ios-unlocked-outline" ng-if="!cashSupport.value"></i>
|
||||
<span class="setting-title">{{'Bitcoin Cash Support' | translate}}</span>
|
||||
<span class="setting-value">
|
||||
<span translate ng-if="cashSupport.value">Enabled</span>
|
||||
<span translate ng-if="!cashSupport.value">Disabled</span>
|
||||
</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<a class="item item-icon-left item-icon-right" ui-sref="tabs.notifications">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-notifications.svg" class="bg"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue