1
1
'use strict' ;
2
2
3
- angular . module ( 'copayApp.controllers' ) . controller ( 'tabSendController' , function ( $scope , $rootScope , $log , $timeout , $ionicScrollDelegate , addressbookService , profileService , lodash , $state , walletService , incomingData , popupService , platformInfo , bwcError , gettextCatalog , scannerService , $window , externalLinkService ) {
3
+ angular . module ( 'copayApp.controllers' ) . controller ( 'tabSendController' , function ( $scope , $rootScope , $log , $timeout ,
4
+ $ionicScrollDelegate , addressbookService , profileService , lodash , $state , walletService , incomingData , popupService ,
5
+ platformInfo , bwcError , gettextCatalog , scannerService , $window , externalLinkService , bitcore ) {
4
6
5
7
var originalList ;
6
8
var CONTACTS_SHOW_LIMIT ;
7
9
var currentContactsPage ;
10
+ $scope . isSweeping = false ;
8
11
$scope . isChromeApp = platformInfo . isChromeApp ;
9
12
10
13
14
+ $scope . sweepBtnDisabled = function ( ) {
15
+ var isDisabled = true ;
16
+
17
+ if ( $scope . checkPrivateKey ( $scope . formData . search ) ) {
18
+ isDisabled = false ;
19
+ }
20
+ return isDisabled ;
21
+ } ;
22
+
23
+
11
24
var hasWallets = function ( ) {
12
25
$scope . wallets = profileService . getWallets ( {
13
26
onlyComplete : true
@@ -232,6 +245,28 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
232
245
} ) ;
233
246
} ;
234
247
248
+ $scope . sweepAddressClickHandler = function ( privateKey ) {
249
+ console . log ( 'privateKey' , privateKey ) ;
250
+
251
+ $state . go ( 'tabs.home' ) . then ( function ( ) {
252
+ $timeout ( function ( ) {
253
+ $state . transitionTo ( 'tabs.home.paperWallet' , {
254
+ privateKey : privateKey
255
+ } ) ;
256
+ } , 50 ) ;
257
+ } ) ;
258
+ } ;
259
+
260
+
261
+ $scope . checkPrivateKey = function ( privateKey ) {
262
+ try {
263
+ new bitcore . PrivateKey ( privateKey , 'livenet' ) ;
264
+ } catch ( err ) {
265
+ return false ;
266
+ }
267
+ return true ;
268
+ }
269
+
235
270
$scope . $on ( "$ionicView.beforeEnter" , function ( event , data ) {
236
271
237
272
$scope . checkingBalance = true ;
@@ -250,11 +285,14 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
250
285
$scope . checkingBalance = false ;
251
286
return ;
252
287
}
253
-
254
288
updateHasFunds ( ) ;
255
289
256
290
if ( data . stateParams . address ) {
257
- $scope . formData . search = data . stateParams . address ;
291
+ if ( data . stateParams . address === 'sweep' ) {
292
+ $scope . isSweeping = true ;
293
+ } else {
294
+ $scope . formData . search = data . stateParams . address ;
295
+ }
258
296
$timeout ( function ( ) {
259
297
$scope . searchFocus = true ;
260
298
var element = $window . document . getElementById ( 'tab-send-address' ) ;
0 commit comments