fix sweep paper wallet flag - fix sweep process

This commit is contained in:
Javier 2016-09-08 19:50:18 -03:00
parent d6d54a4e35
commit e16e93e408
5 changed files with 122 additions and 77 deletions

View File

@ -1,84 +1,100 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Sweep paper wallet'; goBackToState = 'preferencesAdvanced';">
</div>
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Sweep paper wallet' | translate}}</ion-nav-title>
<ion-nav-back-button>
<i class="icon ion-ios-arrow-thin-left"></i>
</ion-nav-back-button>
</ion-nav-bar>
<div class="content preferences" ng-controller="paperWalletController">
<div class="row" ng-show="index.needsBackup">
<div class="columns">
<h4></h4>
<div class="size-14 text-warning m20b">
<i class="fi-alert size-12"></i>
<span class="text-warning" translate>Backup Needed</span>.
<span translate>
Before receiving funds, you must backup your wallet. If this device is lost, it is impossible to access your funds without a backup.
</span>
<ion-content ng-controller="paperWalletController" ng-init="init()">
<div class="row" ng-show="needsBackup">
<div class="columns">
<h4></h4>
<div class="size-14 text-warning m20b">
<i class="fi-alert size-12"></i>
<span class="text-warning" translate>Backup Needed</span>.
<span translate>
Before receiving funds, you must backup your wallet. If this device is lost, it is impossible to access your funds without a backup.
</span>
</div>
<div class="text-center m20t">
<a class="button outline round dark-gray" href ui-sref="tabs.preferences.preferencesAdvanced">
<span translate>Preferences</span>
</a>
</div>
</div>
<div class="text-center m20t">
<a class="button outline round dark-gray" href ui-sref="preferences" >
<span translate>Preferences</span>
</a>
</div>
</div>
</div>
<div ng-show="!index.needsBackup">
<h4 ng-show="!error"></h4>
<div class="box-notification m20b" ng-show="error">
<span class="text-warning">{{error|translate}}</span>
</div>
<form ng-show="!balance" class="oh">
<div class="row">
<div class="large-12 medium-12 columns">
<div class="input">
<label for="inputData" translate>Paper Wallet Private Key</label>
<input type="text" placeholder="{{'Paste your paper wallet private key here'|translate}}" ng-model="inputData" id="inputData" ng-change="onData(inputData)">
<div class="qr-scanner-input">
<qr-scanner on-scan="onQrCodeScanned(data)"></qr-scanner>
</div>
<div ng-show="isPkEncrypted">
<label for="passphrase">
<span translate>Password</span>
<div ng-show="!needsBackup">
<h4 ng-show="!error"></h4>
<div class="box-notification m20b" ng-show="error">
<span class="text-warning">{{error|translate}}</span>
</div>
<form ng-show="!balance" ng-submit="scanFunds()" novalidate>
<div class="list card">
<div class="row">
<div class="col col-90">
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Paper Wallet Private Key</span>
<input type="text" placeholder="{{'Paste your paper wallet private key here'|translate}}" ng-model="formData.inputData" id="inputData" ng-change="onData(formData.inputData)">
</label>
<input id="passphrase" type="password" name="passphrase" placeholder="{{'Passphrase'|translate}}" ng-model="passphrase">
<p ng-show="index.isCordova" translate class="size-12 text-gray">
</div>
<div class="col text-center">
<qr-scanner class="qr-icon size-24" on-scan="onQrCodeScanned(data)"></qr-scanner>
</div>
</div>
<div class="row" ng-show="isPkEncrypted">
<div class="col">
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Password</span>
<input type="text" name="passphrase" placeholder="{{'Passphrase'|translate}}" ng-model="passphrase">
</label>
<p ng-show="isCordova" class="card size-12 text-gray" translate>
Decrypting a paper wallet could take around 5 minutes on this device. please be patient and keep the app open.
</p>
</div>
<button
ng-disabled="scanning || !scannedKey"
ng-style="{'background-color':index.backgroundColor}"
class="button black round expand"
ng-click="scanFunds()"
translate>Scan Wallet Funds
</button>
</div>
</div>
</div>
</form>
<div ng-show="balance" class="row">
<div class="large-12 medium-12 columns">
<div class="text-center m20b">
<h4 class="text-bold" translate>Funds found</h4>
<div class="size-24">
{{balance}}
</div>
</div>
<button
ng-disabled="sending || balanceSat <= 0"
ng-style="{'background-color':index.backgroundColor}"
class="button black round expand"
ng-click="sweepWallet()"
translate>Sweep Wallet
<button type="submit"
ng-disabled="scanning || !scannedKey"
class="button button-block button-positive"
ng-style="{'background-color': wallet.color}"
translate>Scan Wallet Funds
</button>
</form>
<div class="row">
<div class="col text-center">
<div ng-show="scanned">
<h4 class="text-bold" translate>Funds found</h4>
<div class="size-24">{{balance}}</div>
</div>
<button
ng-show="balanceSat > 0"
ng-disabled="sending"
class="button button-block button-positive"
ng-style="{'background-color': wallet.color}"
ng-click="sweepWallet()"
translate>Sweep Wallet
</button>
<button
ng-show="balanceSat <= 0 && scanned"
class="button button-block button-positive"
ng-style="{'background-color': wallet.color}"
ng-click="init()"
translate>Scan Again
</button>
</div>
</div>
<div class="text-center size-12 text-gray">
<span translate>Funds will be transferred to</span>:
<b>{{walletAlias || walletName}}</b>
</div>
</div>
<div class="text-center size-12 text-gray">
<span translate>Funds will be transferred to</span>:
<b>{{index.alias || index.walletName}}</b>
</div>
</div>
</div>
<div class="extra-margin-bottom"></div>
</ion-content>
</ion-view>

View File

@ -5,7 +5,7 @@
<i class="icon ion-ios-arrow-thin-left"></i>
</ion-nav-back-button>
</ion-nav-bar>
<ion-content>
<ion-content ng-controller="preferencesAdvancedController">
<div class="list">
<div class="item item-divider">
</div>
@ -13,7 +13,7 @@
<span translate>Wallet Information</span>
<i class="icon nav-item-arrow-right"></i>
</a>
<a class="item item-icon-right" ng-show="index.network == 'livenet'" ui-sref="tabs.preferences.paperWallet">
<a class="item item-icon-right" ng-show="network == 'livenet'" ui-sref="tabs.preferences.paperWallet">
<span translate>Sweep paper wallet</span>
<i class="icon nav-item-arrow-right"></i>
</a>

View File

@ -95,7 +95,10 @@ angular.module('copayApp.controllers').controller('backupController',
if (val) {
confirmBackupPopup.close();
if ($stateParams.fromOnboarding) $state.go('onboarding.disclaimer');
else $state.go('tabs.home')
else {
$ionicHistory.clearHistory();
$state.go('tabs.home');
}
} else {
confirmBackupPopup.close();
$scope.goToStep(1);

View File

@ -1,11 +1,27 @@
angular.module('copayApp.controllers').controller('paperWalletController',
function($scope, $timeout, $log, $ionicModal, $ionicHistory, configService, profileService, $state, addressService, bitcore, ongoingProcess, txFormatService, $stateParams, walletService) {
function($scope, $timeout, $log, $ionicModal, $ionicHistory, platformInfo, configService, profileService, $state, addressService, bitcore, ongoingProcess, txFormatService, $stateParams, walletService) {
var wallet = profileService.getWallet($stateParams.walletId);
var rawTx;
$scope.init = function() {
$scope.wallet = wallet;
$scope.isCordova = platformInfo.isCordova;
$scope.needsBackup = wallet.needsBackup;
$scope.walletAlias = wallet.name;
$scope.walletName = wallet.credentials.walletName;
$scope.formData = {};
$scope.formData.inputData = null;
$scope.scannedKey = null;
$scope.balance = null;
$scope.balanceSat = null;
$scope.scanned = false;
$timeout(function() {
$scope.$apply();
}, 10);
};
$scope.onQrCodeScanned = function(data) {
$scope.inputData = data;
$scope.formData.inputData = data;
$scope.onData(data);
};
@ -62,6 +78,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
$scope.balanceSat = balance;
var config = configService.getSync().wallet.settings;
$scope.balance = txFormatService.formatAmount(balance) + ' ' + config.unitName;
$scope.scanned = true;
}
$scope.$apply();
@ -125,5 +142,4 @@ angular.module('copayApp.controllers').controller('paperWalletController',
$scope.txStatusModal.show();
});
};
});

View File

@ -0,0 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAdvancedController', function($scope, $timeout, $stateParams, profileService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.network = wallet.network;
$timeout(function() {
$scope.$apply();
}, 1);
});