Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #251 from blockchain/import-address
Browse files Browse the repository at this point in the history
Import address
  • Loading branch information
Sjors committed Jan 20, 2016
2 parents c5ad657 + 98973c3 commit 79cb3e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/partials/settings/import-address.jade
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
name="privateKey"
is-valid="isValidAddressOrPrivateKey(fields.addressOrPrivateKey)"
ng-change="importForm.privateKey.$setValidity('present', true); importForm.privateKey.$setValidity('check', true);"
on-enter="importForm.$valid && import()"
required
autocomplete="off"
autofocus
)
Expand All @@ -34,6 +36,7 @@
ng-model="fields.bip38passphrase"
ng-required="BIP38"
ng-change="importForm.bipPassphrase.$setValidity('wrong', true)"
on-enter="importForm.$valid && import()"
)
div(ng-show="importForm.bipPassphrase.$dirty")
span.help-block(translate="INCORRECT_PASSWORD" ng-show="importForm.bipPassphrase.$error.wrong")
Expand Down Expand Up @@ -86,7 +89,7 @@
button.button-muted.mrm(ng-click="close()", translate="CANCEL", ng-show="step == 1 && !status.busy")
span(ng-if="step == 1")
button.btn.btn-info(ng-click="cameraOn()" ng-disabled="status.busy" ng-if="browserWithCamera" translate="QR")
button.btn.btn-primary(ui-ladda="status.busy" ng-click="import()" ng-disabled="importForm.$invalid && !importForm.bipPassphrase.$error.wrong" ladda-translate="IMPORT" data-style="expand-left")
button.btn.btn-primary(ui-ladda="status.busy" ng-click="import()" ng-disabled="importForm.$invalid" ladda-translate="IMPORT" data-style="expand-left")
button.btn.btn-info(ng-show="step == 2", ng-click="close()", translate="CLOSE")
button.btn.btn-primary(ng-show="step == 2 && !address.isWatchOnly && address.balance > 0" ng-click="goToTransfer()" translate="SWEEP")
span(ng-if="step == 3")
Expand Down
7 changes: 6 additions & 1 deletion assets/js/controllers/settings/addressImport.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,25 @@ function AddressImportCtrl($scope, $log, Wallet, Alerts, $uibModalInstance, $tra

$scope.import = () => {
$scope.status.busy = true;
$scope.$safeApply();
let addressOrPrivateKey = $scope.fields.addressOrPrivateKey.trim();
let bip38passphrase = $scope.fields.bip38passphrase.trim();

const success = (address) => {
$scope.status.busy = false;
$scope.address = address;
$scope.step = 2;
$scope.$safeApply();
};

const error = (err) => {
$scope.status.busy = false;
$scope.$safeApply();

switch (err) {
case 'presentInWallet':
$scope.importForm.privateKey.$setValidity('present', false);
$scope.BIP38 = false;
break;
case 'wrongBipPass':
$scope.importForm.bipPassphrase.$setValidity('wrong', false);
Expand All @@ -60,12 +64,13 @@ function AddressImportCtrl($scope, $log, Wallet, Alerts, $uibModalInstance, $tra

const needsBipPassphrase = (proceed) => {
$scope.status.busy = false;
$scope.BIP38 = true;
$scope.proceedWithBip38 = proceed;
$timeout(() => { $scope.BIP38 = true; });
};

const cancel = () => {
$scope.status.busy = false;
$scope.$safeApply();
};

$timeout(() => {
Expand Down

0 comments on commit 79cb3e9

Please sign in to comment.