add address list

This commit is contained in:
Javier 2016-11-14 16:51:11 -03:00
parent 7a63bfcc72
commit 7e7fedc402
3 changed files with 82 additions and 25 deletions

View File

@ -1,6 +1,37 @@
'use strict';
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, profileService, walletService) {
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $timeout, $ionicScrollDelegate, ongoingProcess, lodash, profileService, walletService) {
var ADDRESS_LIMIT = 5;
$scope.wallet = profileService.getWallet($stateParams.walletId);
$scope.showInfo = false;
$scope.$on("$ionicView.beforeEnter", function(event, data) {
// $scope.unusedAddresses = getUnusedAddreses(); No backend support TODO
$scope.unusedAddresses = [{
createdOn: 1479138140,
address: "0m9sad00810m0m1d2192d9u12d9",
path: 'xpub/0/1'
}];
ongoingProcess.set('extractingWalletInfo', true);
walletService.getMainAddresses($scope.wallet, ADDRESS_LIMIT, function(err, addresses) {
ongoingProcess.set('extractingWalletInfo', false);
$scope.addresses = lodash.map(addresses, function(addr) {
return {
createdOn: addr.createdOn,
address: addr.address,
path: addr.path.replace(/^m/g, 'xpub')
};
});
console.log($scope.addresses);
});
});
$scope.showInformation = function() {
$timeout(function() {
$scope.showInfo = !$scope.showInfo;
$ionicScrollDelegate.resize();
});
};
});

View File

@ -773,6 +773,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
});
};
root.getMainAddresses = function(wallet, limit, cb) {
var opts = {};
opts.reverse = true;
if (limit) opts.limit = limit;
wallet.getMainAddresses(opts, function(err, addresses) {
if (err) return cb(err);
return cb(null, addresses);
});
};
root.getAddress = function(wallet, forceNew, cb) {
storageService.getLastAddress(wallet.id, function(err, addr) {
if (err) return cb(err);

View File

@ -1,4 +1,4 @@
<ion-view class="settings" hide-tabs>
<ion-view hide-tabs>
<ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Wallet Addresses' | translate}}</ion-nav-title>
<ion-nav-back-button>
@ -6,30 +6,45 @@
</ion-nav-bar>
<ion-content>
<div class="list">
<div class="item item-divider" translate>
Translation Credits
</div>
<div class="item">kinoshitajona<span class="item-note" translate>Japanese</span></div>
<div class="item">Kirvx<span class="item-note" translate>French</span></div>
<div class="item">saschad<span class="item-note" translate>German</span></div>
<div class="item">cmgustavo83<span class="item-note" translate>Spanish</span></div>
<div class="item">RussianNeuroMancer<span class="item-note" translate>Russian</span></div>
<div class="item">HostFat<span class="item-note" translate>Italian</span></div>
<div class="item">xm2hi<span class="item-note" translate>Chinese</span></div>
<div class="item">Pirx1618<span class="item-note" translate>Polish</span></div>
<div class="item">mareksip<span class="item-note" translate>Czech</span></div>
<div class="text-center padding">
<i class="icon ion-ios-ionic-outline"></i>
</div>
<div class="padding">
<p>
<span translate>Were always looking for translation contributions! You can make corrections or help to make this app available in your native language by joining our community on Crowdin.</span>
<button class="button button-standard button-primary" ng-click="openExternalLink(true, 'Open Translation Community', 'You can make contributions by signing up on our Crowdin community translation website. Were looking forward to hearing from you!
', 'Open Crowdin', 'Go Back')" translate>Contribute Translations
</button>
</p>
<span translate>
Don't see your language on Crowdin? Contact the Owner on Crowdin! We'd love to support your language.
</span>
<div class="text-center">
<span translate>Each bitcoin wallet can generate billions of addresses from your 12-word backup. A new address is automatically generated and shown each time your recive a payment.</span><a ng-click="showInformation()" ng-if="!showInfo" translate> Why?</a>
</div>
<div class="text-center" ng-if="showInfo">
<span translate>It's a good idea to avoid reusing addresses-this both protects your privacy and keeps your bitcoins secure against hypothetical attacks by quantum computers.</span><a ng-click="showInformation()" translate> Hide</a>
</div>
<div class="list">
<div class="item item-divider item-icon-right" ng-click="addNewAddress()" translate>
Unused Addresses
<i class="icon ion-ios-plus-empty"></i>
</div>
<div ng-if="unusedAddresses[0]">
<div class="item" ng-repeat="uAddr in unusedAddresses track by $index">
{{uAddr.address}}
<span class="item-note">
{{uAddr.path}} {{uAddr.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
</span>
</div>
</div>
<div ng-if="!unusedAddresses[0]">
<span class="item" translate>Not unused addresses available</span>
</div>
<div class="item item-divider" translate>
Addresses With Balance
</div>
<div class="item" ng-repeat="addr in addresses track by $index">
{{addr.address}}
<div>{{addr.balanceStr}}</div>
</div>
</div>
</ion-content>
</ion-view>