Skip to content

Commit

Permalink
Merge pull request #6771 from JDonadio/ref/duplicate-bch-wallet
Browse files Browse the repository at this point in the history
Fix bch view and bch backup message
  • Loading branch information
matiu authored Sep 21, 2017
2 parents 1b51440 + 341be3c commit e486568
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 37 deletions.
46 changes: 31 additions & 15 deletions src/js/controllers/cashScan.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

angular.module('copayApp.controllers').controller('cashScanController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $ionicHistory, $window, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, txFormatService, bwcError, pushNotificationsService, bwcService) {
function($rootScope, $timeout, $scope, $state, $ionicHistory, gettextCatalog, lodash, ongoingProcess, profileService, walletService, $log, txFormatService, bwcError, pushNotificationsService, bwcService, externalLinkService) {
var wallet;
var errors = bwcService.getErrors();
$scope.error = null;
Expand All @@ -11,6 +11,16 @@ angular.module('copayApp.controllers').controller('cashScanController',
updateAllWallets();
});

$scope.openRecoveryToolLink = function() {
var url = 'https://bitpay.github.io/copay-recovery/';
var optIn = true;
var title = null;
var message = gettextCatalog.getString('Open the recovery tool.');
var okText = gettextCatalog.getString('Open');
var cancelText = gettextCatalog.getString('Go Back');
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};

var goHome = function() {
$ionicHistory.nextViewOptions({
disableAnimate: true,
Expand All @@ -29,11 +39,6 @@ angular.module('copayApp.controllers').controller('cashScanController',
network: 'livenet'
});

if (lodash.isEmpty(walletsBTC)) {
goHome();
return;
}

// Filter out already duplicated wallets
var walletsBCH = profileService.getWallets({
coin: 'bch',
Expand All @@ -45,19 +50,30 @@ angular.module('copayApp.controllers').controller('cashScanController',
return !xPubKeyIndex[w.credentials.xPubKey];
});

// Filter out non BIP44 wallets
var wallets = lodash.filter(walletsBTC, function(w) {
return w.credentials.derivationStrategy == 'BIP44'
var availableWallets = [];
var nonEligibleWallets = [];

lodash.each(walletsBTC, function(w) {
if (w.credentials.derivationStrategy != 'BIP44') {
w.excludeReason = gettextCatalog.getString('Non BIP44 wallet');
nonEligibleWallets.push(w);
} else if (!w.canSign()) {
w.excludeReason = gettextCatalog.getString('Read only wallet');
nonEligibleWallets.push(w);
} else if (w.needsBackup) {
w.excludeReason = gettextCatalog.getString('Backup needed');
nonEligibleWallets.push(w);
} else {
availableWallets.push(w);
}
});

$scope.wallets = wallets;
$scope.nonBIP44Wallets = lodash.filter(walletsBTC, function(w) {
return w.credentials.derivationStrategy != 'BIP44';
});
$scope.availableWallets = availableWallets;
$scope.nonEligibleWallets = nonEligibleWallets;

var i = wallets.length;
var i = availableWallets.length;
var j = 0;
lodash.each(wallets, function(wallet) {
lodash.each(availableWallets, function(wallet) {
walletService.getBalance(wallet, {
coin: 'bch'
}, function(err, balance) {
Expand Down
4 changes: 4 additions & 0 deletions src/sass/views/cashScan.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@
right: 15px;
padding-top: .5rem;
}

a {
cursor: pointer;
}
}
18 changes: 18 additions & 0 deletions src/sass/views/wallet-backup-phrase.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
#wallet-backup-phrase {
.comment {
color: #667;
font-size: 0.9em;
}
.item {
color: $v-dark-gray;
padding-top: 1.3rem;
padding-bottom: 1.3rem;
border: none;
}
.heading {
font-size: 17px;
color: $v-dark-gray;
margin: 1rem 0;
padding-top: 5px;
padding-bottom: 5px;
border: none;
}
h3 {
padding: 15px;
}
Expand Down
13 changes: 10 additions & 3 deletions www/views/backup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@
</ion-nav-back-button>
</ion-nav-bar>
<ion-content>
<div class="ng-hide" ng-show="deleted">
<div class="phrase-unavailable" translate>Wallet recovery phrase not available.</div>
<div class="phrase-unavailable-instructions" translate>You can still export it from Advanced &gt; Export.</div>
<div class="ng-hide list card" ng-show="deleted">
<div class="item heading">
<span translate>Wallet recovery phrase not available</span>
</div>
<div class="item">
<span class="comment" translate>You can still export it from Advanced &gt; Export.</span>
</div>
</div>
<div class="item">
<span class="comment" ng-if="wallet.coin == 'bch'" translate>Note: if this BCH wallet was duplicated from a BTC wallet, they share the same recovery phrase.</span>
</div>
<!--
## STEP 1
Expand Down
48 changes: 29 additions & 19 deletions www/views/cashScan.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,55 @@
<ion-content>

<div class="list card">
<div class="item" ng-if="(!wallets || !wallets[0]) && !nonBIP44Wallets[0]">
<span class="assertive" translate>No wallets eligible for Bitcoin Cash support</span>
<div ng-if="!availableWallets[0]">
<div class="item">
<span class="assertive" translate>No wallets eligible for Bitcoin Cash support</span>
</div>
</div>

<div class="item" ng-if="error">
<span class="assertive">{{error}}</span>
</div>

<div class="item heading">
<span translate>BTC Wallets</span>
</div>

<div ng-repeat="wallet in wallets track by $index" class="item wallet supported">
<i class="icon big-icon-svg" ng-include="'views/includes/walletIcon.html'"></i>
<div class="wallet-content">
<div>{{wallet.name || wallet.id}}</div>
<div class="balanced">{{wallet.bchBalance || ('Checking...' | translate)}} </div>
<div class="tab-home__wallet__multisig-number" ng-if="wallet.n > 1" translate>{{wallet.m}}-of-{{wallet.n}}</div>
<div ng-if="availableWallets[0]">
<div class="item heading">
<span translate>BTC wallets</span>
</div>

<div class="duplicate-button">
<button ng-click="duplicate(wallet)" class="button button-small button-outline button-primary" translate>Duplicate for BCH</button>
<div ng-repeat="wallet in availableWallets track by $index" class="item wallet supported">
<i class="icon big-icon-svg">
<img ng-src="img/{{wallet.network == 'testnet' ? 'icon-wallet-testnet' : (wallet.coin == 'btc' ? 'icon-btc' : 'icon-bch')}}.svg" ng-class="{'wallet-background-color-default': !wallet.color}" ng-style="{'background-color': wallet.color}" class="bg wallet"/>
</i>
<div class="wallet-content">
<div>{{wallet.name || wallet.id}}</div>
<div class="balanced">{{wallet.bchBalance || ('Checking...' | translate)}} </div>
<div class="tab-home__wallet__multisig-number" ng-if="wallet.n > 1" translate>{{wallet.m}}-of-{{wallet.n}}</div>
</div>

<div class="duplicate-button">
<button ng-click="duplicate(wallet)" class="button button-small button-outline button-primary" translate>Duplicate for BCH</button>
</div>
</div>
</div>

<div ng-if="nonBIP44Wallets[0]">
<div ng-if="nonEligibleWallets[0]">
<div class="item item-divider"></div>

<div class="item heading">
<span translate>Non eligible BTC wallets</span>
</div>

<div ng-repeat="wallet in nonBIP44Wallets track by $index" class="item item-sub item-icon-left item-big-icon-left item-button-right wallet">
<i class="icon big-icon-svg" ng-include="'views/includes/walletIcon.html'"></i>
<span class="text-disabled">{{wallet.name || wallet.id}}</span>
<div ng-repeat="wallet in nonEligibleWallets track by $index" class="item item-sub item-icon-left item-big-icon-left item-button-right wallet">
<i class="icon big-icon-svg">
<img ng-src="img/{{wallet.network == 'testnet' ? 'icon-wallet-testnet' : (wallet.coin == 'btc' ? 'icon-btc' : 'icon-bch')}}.svg" ng-class="{'wallet-background-color-default': !wallet.color}" ng-style="{'background-color': walletDisabled}" class="bg wallet"/>
</i>
<div class="text-disabled">{{wallet.name || wallet.id}}</div>
<div class="text-disabled">{{wallet.excludeReason}}</div>
</div>

<div class="item">
<span class="comment">Some of you wallets are not eligible for Bitcon Cash support because there where created before Copay v1.2. Please use our recovery tool to access your Bitcoin Cash balance for those wallets</span>
<span class="comment" translate>Some of your wallets are not eligible for Bitcoin Cash support. You can try to access BCH funds from these wallets using the</span>
<a ng-click="openRecoveryToolLink()" translate>recovery tool.</a>
</div>
</div>
</div>
Expand Down

0 comments on commit e486568

Please sign in to comment.