commit
8677bbe3b2
10 changed files with 278 additions and 104 deletions
45
public/views/modals/wallets.html
Normal file
45
public/views/modals/wallets.html
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<nav class="tab-bar">
|
||||||
|
<section class="left-small">
|
||||||
|
<a ng-click="cancel()" class="p10">
|
||||||
|
<span class="text-close" translate>Close</span>
|
||||||
|
</a>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="middle tab-bar-section">
|
||||||
|
<h1 class="title ellipsis" ng-style="{'color':color}" translate>
|
||||||
|
Choose a wallet to send funds
|
||||||
|
</h1>
|
||||||
|
</section>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="onGoingProcess" ng-if="gettingAddress">
|
||||||
|
<div class="onGoingProcess-content" ng-style="{'background-color':'#222'}">
|
||||||
|
<div class="spinner">
|
||||||
|
<div class="rect1"></div>
|
||||||
|
<div class="rect2"></div>
|
||||||
|
<div class="rect3"></div>
|
||||||
|
<div class="rect4"></div>
|
||||||
|
<div class="rect5"></div>
|
||||||
|
</div>
|
||||||
|
<span translate> Getting address for wallet {{selectedWalletName}} ...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ng-if="!gettingAddress">
|
||||||
|
<ul class="no-bullet">
|
||||||
|
<li class="panel" ng-repeat="w in wallets">
|
||||||
|
<a ng-click="selectWallet(w.id, w.name)">
|
||||||
|
<div class="avatar-wallet"
|
||||||
|
ng-style="{'background-color':w.color}">{{(w.name || w.id) | limitTo: 1}}</div>
|
||||||
|
<div class="ellipsis">{{w.name || w.id}}</div>
|
||||||
|
<div class="size-12">{{w.m}} of {{w.n}}
|
||||||
|
<span ng-show="w.network=='testnet'">[Testnet]</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="extra-margin-bottom"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="panel text-center" ng-if="!payment.uri">
|
<div class="panel text-center" ng-if="!payment.uri">
|
||||||
<h1 translate>Bitcoin URI is NOT valid!</h1>
|
<h1 translate>Bitcoin URI is NOT valid!</h1>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="payment.uri">
|
<div ng-if="payment.uri" ng-init="wallets = payment.getWallets(payment.uri.network)">
|
||||||
<h1 translate>Make a payment to</h1>
|
<h1 translate>Make a payment to</h1>
|
||||||
<div class="panel size-14">
|
<div class="panel size-14">
|
||||||
<div class="ellipsis"><b translate>Address</b>: {{payment.uri.address.toString()}}</div>
|
<div class="ellipsis"><b translate>Address</b>: {{payment.uri.address.toString()}}</div>
|
||||||
|
|
@ -17,19 +17,30 @@
|
||||||
<div ng-show="payment.uri.message"><b translate>Message</b>: {{payment.uri.message}}</div>
|
<div ng-show="payment.uri.message"><b translate>Message</b>: {{payment.uri.message}}</div>
|
||||||
<div ng-show="payment.uri.network == 'testnet'"><b translate>Network</b>: {{payment.uri.network}}</div>
|
<div ng-show="payment.uri.network == 'testnet'"><b translate>Network</b>: {{payment.uri.network}}</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 translate>Select a wallet</h2>
|
<div ng-if="!wallets || !wallets.length">
|
||||||
<ul class="no-bullet" ng-init="wallets = payment.getWallets(payment.uri.network)">
|
<div class="box-notification">
|
||||||
<li class="panel" ng-repeat="w in wallets">
|
<span class="text-warning" translate>
|
||||||
<a ng-click="payment.selectWallet(w.id)">
|
There are not wallets to make this payment
|
||||||
<div class="avatar-wallet"
|
<span ng-show="payment.uri.network == 'testnet'">[testnet]</span>
|
||||||
ng-style="{'background-color':w.color}">{{(w.name || w.id) | limitTo: 1}}</div>
|
</span>
|
||||||
<div class="ellipsis">{{w.name || w.id}}</div>
|
</div>
|
||||||
<div class="size-12">{{w.m}} of {{w.n}}
|
</div>
|
||||||
<span ng-show="w.network=='testnet'">[Testnet]</span>
|
|
||||||
</div>
|
<div ng-if="wallets.length">
|
||||||
</a>
|
<h2 translate>Select a wallet</h2>
|
||||||
</li>
|
<ul class="no-bullet">
|
||||||
</ul>
|
<li class="panel" ng-repeat="w in wallets">
|
||||||
|
<a ng-click="payment.selectWallet(w.id)">
|
||||||
|
<div class="avatar-wallet"
|
||||||
|
ng-style="{'background-color':w.color}">{{(w.name || w.id) | limitTo: 1}}</div>
|
||||||
|
<div class="ellipsis">{{w.name || w.id}}</div>
|
||||||
|
<div class="size-12">{{w.m}} of {{w.n}}
|
||||||
|
<span ng-show="w.network=='testnet'">[Testnet]</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row m20t">
|
<div class="row m20t">
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<button class="button black expand round" ng-click="home.setNewAddress()"
|
<button class="button black expand round" ng-click="home.setAddress(true)"
|
||||||
ng-style="{'background-color':index.backgroundColor}" ng-disabled="home.blockUx || index.isOffline ||home.generatingAddress" translate>
|
ng-style="{'background-color':index.backgroundColor}" ng-disabled="home.blockUx || index.isOffline ||home.generatingAddress" translate>
|
||||||
Generate new address
|
Generate new address
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -266,7 +266,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center" ng-show="!home.generatingAddress && home.addr[index.walletId]">
|
<div class="text-center" ng-show="!home.generatingAddress && home.addr[index.walletId]">
|
||||||
<a class="size-12" ng-click="home.openCustomizedAmountModal(home.addr[index.walletId])" translate>
|
<a class="size-12" ng-click="home.openCustomizedAmountModal(home.addr[index.walletId])" translate>
|
||||||
Request a specific amount
|
Receive a specific amount
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -327,6 +327,11 @@
|
||||||
<div ng-hide="home._paypro || home.hideAddress">
|
<div ng-hide="home._paypro || home.hideAddress">
|
||||||
<div class="row collapse">
|
<div class="row collapse">
|
||||||
|
|
||||||
|
<div class="right size-12 m0 text-gray" ng-click="openWalletsModal(index.otherWallets)" ng-if="index.otherWallets">
|
||||||
|
send to my wallets
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<label for="address" class="left" >
|
<label for="address" class="left" >
|
||||||
<span translate>To</span>
|
<span translate>To</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ a.missing-copayers {
|
||||||
background-color: #122232;
|
background-color: #122232;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar .avatar-wallet, .payment-uri .avatar-wallet {
|
.sidebar .avatar-wallet, .payment-uri .avatar-wallet, .modal-content .avatar-wallet {
|
||||||
background-color: #2C3E50;
|
background-color: #2C3E50;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, gettextCatalog, gettext, amMoment) {
|
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
self.isCordova = isCordova;
|
self.isCordova = isCordova;
|
||||||
|
|
@ -237,6 +237,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.copayers = walletStatus.wallet.copayers;
|
self.copayers = walletStatus.wallet.copayers;
|
||||||
self.preferences = walletStatus.preferences;
|
self.preferences = walletStatus.preferences;
|
||||||
self.setBalance(walletStatus.balance);
|
self.setBalance(walletStatus.balance);
|
||||||
|
self.otherWallets = lodash.filter(profileService.getWallets(self.network), function(w) {
|
||||||
|
return w.id != self.walletId;
|
||||||
|
});;
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -463,7 +466,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.alternativeIsoCode = config.alternativeIsoCode;
|
self.alternativeIsoCode = config.alternativeIsoCode;
|
||||||
|
|
||||||
// Check address
|
// Check address
|
||||||
self.checkLastAddress(balance.byAddress);
|
addressService.isUsed(self.walletId, balance.byAddress, function(err, used){
|
||||||
|
if (used) {
|
||||||
|
$log.debug('Address used. Creating new');
|
||||||
|
$rootScope.$emit('Local/NeedNewAddress');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
|
|
||||||
|
|
@ -487,20 +495,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.checkLastAddress = function(byAddress, cb) {
|
|
||||||
storageService.getLastAddress(self.walletId, function(err, addr) {
|
|
||||||
var used = lodash.find(byAddress, {
|
|
||||||
address: addr
|
|
||||||
});
|
|
||||||
if (used) {
|
|
||||||
$log.debug('Address ' + addr + ' was used. Cleaning Cache.')
|
|
||||||
storageService.clearLastAddress(self.walletId, function(err) {
|
|
||||||
$rootScope.$emit('Local/NeedNewAddress', err);
|
|
||||||
if (cb) return cb();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
self.clientError = function(err) {
|
self.clientError = function(err) {
|
||||||
if (isCordova) {
|
if (isCordova) {
|
||||||
|
|
@ -728,7 +722,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
$rootScope.$on('Local/WalletImported', function(event, walletId) {
|
$rootScope.$on('Local/WalletImported', function(event, walletId) {
|
||||||
self.needsBackup = false;
|
self.needsBackup = false;
|
||||||
storageService.setBackupFlag(walletId, function() {
|
storageService.setBackupFlag(walletId, function() {
|
||||||
storageService.clearLastAddress(walletId, function(err) {
|
addressService.expireAddress(walletId, function(err) {
|
||||||
self.startScan(walletId);
|
self.startScan(walletId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -791,7 +785,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
if (val) {
|
if (val) {
|
||||||
$log.debug('Clear last address cache and Scan');
|
$log.debug('Clear last address cache and Scan');
|
||||||
lodash.each(lodash.keys(profileService.walletClients), function(walletId) {
|
lodash.each(lodash.keys(profileService.walletClients), function(walletId) {
|
||||||
storageService.clearLastAddress(walletId, function(err) {
|
addressService.expireAddress(walletId, function(err) {
|
||||||
self.startScan(walletId);
|
self.startScan(walletId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -38,24 +38,7 @@ angular.module('copayApp.controllers').controller('paymentUriController',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getWallets = function(network) {
|
this.getWallets = function(network) {
|
||||||
if (!profileService.profile) return;
|
return profileService.getWallets(network);
|
||||||
var config = configService.getSync();
|
|
||||||
config.colorFor = config.colorFor || {};
|
|
||||||
config.aliasFor = config.aliasFor || {};
|
|
||||||
var ret = lodash.map(profileService.profile.credentials, function(c) {
|
|
||||||
return {
|
|
||||||
m: c.m,
|
|
||||||
n: c.n,
|
|
||||||
name: config.aliasFor[c.walletId] || c.walletName,
|
|
||||||
id: c.walletId,
|
|
||||||
network: c.network,
|
|
||||||
color: config.colorFor[c.walletId] || '#2C3E50'
|
|
||||||
};
|
|
||||||
});
|
|
||||||
ret = lodash.filter(ret, function(w) {
|
|
||||||
return (w.network == network);
|
|
||||||
});
|
|
||||||
return lodash.sortBy(ret, 'name');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectWallet = function(wid) {
|
this.selectWallet = function(wid) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit) {
|
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
$rootScope.hideMenuBar = false;
|
$rootScope.hideMenuBar = false;
|
||||||
|
|
@ -38,7 +38,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
});
|
});
|
||||||
|
|
||||||
var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() {
|
var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() {
|
||||||
self.setNewAddress();
|
self.setAddress(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
|
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
|
||||||
|
|
@ -90,6 +90,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
|
|
||||||
|
|
||||||
var parseError = function(err) {
|
var parseError = function(err) {
|
||||||
|
if (!err) return;
|
||||||
|
|
||||||
if (err.message) {
|
if (err.message) {
|
||||||
// TODO : this is not used anymore?
|
// TODO : this is not used anymore?
|
||||||
if (err.message.indexOf('CORS') >= 0) {
|
if (err.message.indexOf('CORS') >= 0) {
|
||||||
|
|
@ -125,6 +127,52 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$scope.openWalletsModal = function(wallets) {
|
||||||
|
|
||||||
|
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||||
|
$scope.wallets = wallets;
|
||||||
|
$scope.cancel = function() {
|
||||||
|
$modalInstance.dismiss('cancel');
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.selectWallet = function(walletId, walletName) {
|
||||||
|
$scope.gettingAddress=true;
|
||||||
|
$scope.selectedWalletName=walletName;
|
||||||
|
$timeout(function(){
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
|
addressService.getAddress(walletId, false, function(err,addr) {
|
||||||
|
$scope.gettingAddress=false;
|
||||||
|
if (!err || addr)
|
||||||
|
$modalInstance.close(addr);
|
||||||
|
else {
|
||||||
|
parseError(err);
|
||||||
|
self.error = err;
|
||||||
|
$modalInstance.dismiss('cancel');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var modalInstance = $modal.open({
|
||||||
|
templateUrl: 'views/modals/wallets.html',
|
||||||
|
windowClass: 'full animated slideInUp',
|
||||||
|
controller: ModalInstanceCtrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
modalInstance.result.finally(function() {
|
||||||
|
var m = angular.element(document.getElementsByClassName('reveal-modal'));
|
||||||
|
m.addClass('slideOutDown');
|
||||||
|
});
|
||||||
|
|
||||||
|
modalInstance.result.then(function(addr) {
|
||||||
|
if (addr) {
|
||||||
|
self.setForm(addr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
this.openTxpModal = function(tx, copayers) {
|
this.openTxpModal = function(tx, copayers) {
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
var refreshUntilItChanges = false;
|
var refreshUntilItChanges = false;
|
||||||
|
|
@ -339,56 +387,31 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Receive
|
this.setAddress = function(forceNew) {
|
||||||
this.setNewAddress = function() {
|
|
||||||
var fc = profileService.focusedClient;
|
|
||||||
self.generatingAddress = true;
|
|
||||||
self.addrError = null;
|
|
||||||
fc.createAddress(function(err, addr) {
|
|
||||||
self.generatingAddress = false;
|
|
||||||
if (err) {
|
|
||||||
if (err.error && err.error.match(/locked/gi)) {
|
|
||||||
$log.debug(err.error);
|
|
||||||
$timeout(function() {
|
|
||||||
self.setNewAddress();
|
|
||||||
}, 5000);
|
|
||||||
} else {
|
|
||||||
$log.debug('Creating address ERROR:', err);
|
|
||||||
parseError(err);
|
|
||||||
self.addrError = err.message || gettext('Could not create address. Check you connection and try again');
|
|
||||||
$scope.$digest();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.addrError = null;
|
|
||||||
self.addr[fc.credentials.walletId] = addr.address;
|
|
||||||
storageService.storeLastAddress(fc.credentials.walletId, addr.address, function() {
|
|
||||||
|
|
||||||
self.generatingAddress = false;
|
|
||||||
$scope.$digest();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setAddress = function() {
|
|
||||||
self.addrError = null;
|
self.addrError = null;
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
if (!fc)
|
if (!fc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (self.addr[fc.credentials.walletId]) {
|
// Address already set?
|
||||||
|
if (!forceNew && self.addr[fc.credentials.walletId]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.generatingAddress = true;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
storageService.getLastAddress(fc.credentials.walletId, function(err, addr) {
|
addressService.getAddress(fc.credentials.walletId, forceNew, function(err,addr){
|
||||||
if (addr) {
|
self.generatingAddress = false;
|
||||||
self.addr[fc.credentials.walletId] = addr;
|
|
||||||
$scope.$digest();
|
if (err) {
|
||||||
} else {
|
parseError(err);
|
||||||
self.setNewAddress();
|
self.addrError = err.message || gettext('Could not create address. Check you connection and try again');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addr)
|
||||||
|
self.addr[fc.credentials.walletId] = addr;
|
||||||
|
|
||||||
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -1028,6 +1051,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Start setup */
|
||||||
|
|
||||||
this.bindTouchDown();
|
this.bindTouchDown();
|
||||||
this.setAddress();
|
this.setAddress();
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,15 @@ angular.element(document).ready(function() {
|
||||||
var startAngular = function() {
|
var startAngular = function() {
|
||||||
angular.bootstrap(document, ['copayApp']);
|
angular.bootstrap(document, ['copayApp']);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var handleBitcoinURI = function(url) {
|
||||||
|
if (!url) return;
|
||||||
|
setTimeout(function() {
|
||||||
|
window.location = '#/uri-payment/' + url;
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Cordova specific Init */
|
/* Cordova specific Init */
|
||||||
if (window.cordova !== undefined) {
|
if (window.cordova !== undefined) {
|
||||||
|
|
||||||
|
|
@ -37,8 +46,7 @@ angular.element(document).ready(function() {
|
||||||
var loc = window.location;
|
var loc = window.location;
|
||||||
if (loc.toString().match(/index\.html#\/$/)) {
|
if (loc.toString().match(/index\.html#\/$/)) {
|
||||||
navigator.app.exitApp();
|
navigator.app.exitApp();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
window.location = '#/cordova/walletHome';
|
window.location = '#/cordova/walletHome';
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
@ -53,13 +61,6 @@ angular.element(document).ready(function() {
|
||||||
navigator.splashscreen.hide();
|
navigator.splashscreen.hide();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
function handleBitcoinURI(url) {
|
|
||||||
if (!url) return;
|
|
||||||
setTimeout(function() {
|
|
||||||
window.location = '#/uri-payment/' + url;
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.plugins.webintent.getUri(handleBitcoinURI);
|
window.plugins.webintent.getUri(handleBitcoinURI);
|
||||||
window.plugins.webintent.onNewIntent(handleBitcoinURI);
|
window.plugins.webintent.onNewIntent(handleBitcoinURI);
|
||||||
window.handleOpenURL = handleBitcoinURI;
|
window.handleOpenURL = handleBitcoinURI;
|
||||||
|
|
@ -67,6 +68,13 @@ angular.element(document).ready(function() {
|
||||||
startAngular();
|
startAngular();
|
||||||
}, false);
|
}, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
window.handleOpenURL = handleBitcoinURI;
|
||||||
|
window.plugins.webintent.getUri(handleBitcoinURI);
|
||||||
|
window.plugins.webintent.onNewIntent(handleBitcoinURI);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
startAngular();
|
startAngular();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
75
src/js/services/addressService.js
Normal file
75
src/js/services/addressService.js
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
'use strict';
|
||||||
|
'use strict';
|
||||||
|
angular.module('copayApp.services')
|
||||||
|
.factory('addressService', function(storageService, profileService, $log, $timeout, lodash) {
|
||||||
|
var root = {};
|
||||||
|
|
||||||
|
|
||||||
|
root.expireAddress = function(walletId,cb) {
|
||||||
|
$log.debug('Cleaning Address ' + addr );
|
||||||
|
storageService.clearLastAddress(walletId, function(err) {
|
||||||
|
return cb(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
root.isUsed = function(walletId, byAddress, cb) {
|
||||||
|
storageService.getLastAddress(walletId, function(err, addr) {
|
||||||
|
var used = lodash.find(byAddress, {
|
||||||
|
address: addr
|
||||||
|
});
|
||||||
|
return cb(null, used);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
root._createAddress = function(walletId, cb) {
|
||||||
|
var client = profileService.getClient(walletId);
|
||||||
|
|
||||||
|
$log.debug('Creating address for wallet:', walletId);
|
||||||
|
|
||||||
|
client.createAddress(function(err, addr) {
|
||||||
|
if (err) {
|
||||||
|
if (err.error && err.error.match(/locked/gi)) {
|
||||||
|
$log.debug(err.error);
|
||||||
|
return $timeout(function() {
|
||||||
|
root._createAddress(walletId, cb);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
$log.debug('Creating address ERROR:', err);
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
return cb(null, addr.address);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
root.getAddress = function(walletId, forceNew, cb) {
|
||||||
|
|
||||||
|
var firstStep;
|
||||||
|
if (forceNew) {
|
||||||
|
firstStep = storageService.clearLastAddress;
|
||||||
|
} else {
|
||||||
|
firstStep = function(walletId, cb) {
|
||||||
|
return cb();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
firstStep(walletId, function(err) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
storageService.getLastAddress(walletId, function(err, addr) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
if (addr) return cb(null, addr);
|
||||||
|
|
||||||
|
root._createAddress(walletId, function(err, addr) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
storageService.storeLastAddress(walletId, addr, function() {
|
||||||
|
if (err) return cb(err);
|
||||||
|
return cb(null, addr);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return root;
|
||||||
|
});
|
||||||
|
|
@ -233,6 +233,11 @@ angular.module('copayApp.services')
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
root.getClient = function(walletId) {
|
||||||
|
return root.walletClients[walletId];
|
||||||
|
};
|
||||||
|
|
||||||
root.deleteWalletFC = function(opts, cb) {
|
root.deleteWalletFC = function(opts, cb) {
|
||||||
var fc = root.focusedClient;
|
var fc = root.focusedClient;
|
||||||
$log.debug('Deleting Wallet:', fc.credentials.walletName);
|
$log.debug('Deleting Wallet:', fc.credentials.walletName);
|
||||||
|
|
@ -396,5 +401,29 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.getWallets = function(network) {
|
||||||
|
if (!root.profile) return [];
|
||||||
|
|
||||||
|
var config = configService.getSync();
|
||||||
|
config.colorFor = config.colorFor || {};
|
||||||
|
config.aliasFor = config.aliasFor || {};
|
||||||
|
var ret = lodash.map(root.profile.credentials, function(c) {
|
||||||
|
return {
|
||||||
|
m: c.m,
|
||||||
|
n: c.n,
|
||||||
|
name: config.aliasFor[c.walletId] || c.walletName,
|
||||||
|
id: c.walletId,
|
||||||
|
network: c.network,
|
||||||
|
color: config.colorFor[c.walletId] || '#2C3E50'
|
||||||
|
};
|
||||||
|
});
|
||||||
|
ret = lodash.filter(ret, function(w) {
|
||||||
|
return (w.network == network);
|
||||||
|
});
|
||||||
|
return lodash.sortBy(ret, 'name');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue