got address book working with bitcoin cash addresses
This commit is contained in:
parent
1d3da45e32
commit
1c8990fc08
10 changed files with 41 additions and 23 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('addressbookListController', function($scope, $log, $timeout, addressbookService, lodash, popupService, gettextCatalog, platformInfo) {
|
||||
angular.module('copayApp.controllers').controller('addressbookListController', function($scope, $log, $timeout, addressbookService, lodash, popupService, gettextCatalog, platformInfo, bitcoinCashJsService) {
|
||||
|
||||
var contacts;
|
||||
|
||||
|
|
@ -15,10 +15,18 @@ angular.module('copayApp.controllers').controller('addressbookListController', f
|
|||
|
||||
contacts = [];
|
||||
lodash.each(ab, function(v, k) {
|
||||
var c = lodash.isObject(v) ? v.coin : null;
|
||||
var a = null;
|
||||
if (c && c == 'bch') {
|
||||
a = bitcoinCashJsService.readAddress(v.address).cashaddr.replace('bitcoincash:', '');
|
||||
} else {
|
||||
a = v.address;
|
||||
}
|
||||
contacts.push({
|
||||
name: lodash.isObject(v) ? v.name : v,
|
||||
address: k,
|
||||
email: lodash.isObject(v) ? v.email : null
|
||||
address: a,
|
||||
email: lodash.isObject(v) ? v.email : null,
|
||||
coin: c
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('addressbookAddController', function($scope, $state, $stateParams, $timeout, $ionicHistory, gettextCatalog, addressbookService, popupService, configService) {
|
||||
angular.module('copayApp.controllers').controller('addressbookAddController', function($scope, $state, $stateParams, $timeout, $ionicHistory, gettextCatalog, addressbookService, popupService, configService, bitcoinCashJsService) {
|
||||
|
||||
var config = configService.getSync();
|
||||
var defaults = configService.getDefaults();
|
||||
|
|
@ -14,7 +14,7 @@ angular.module('copayApp.controllers').controller('addressbookAddController', fu
|
|||
'address': $stateParams.addressbookEntry || '',
|
||||
'name': '',
|
||||
'email': '',
|
||||
'coin': 'btc'
|
||||
'coin': 'bch'
|
||||
};
|
||||
|
||||
$scope.onQrCodeScannedAddressBook = function(data, addressbookForm) {
|
||||
|
|
@ -31,6 +31,10 @@ angular.module('copayApp.controllers').controller('addressbookAddController', fu
|
|||
};
|
||||
|
||||
$scope.add = function(addressbook) {
|
||||
if ($scope.addressbookEntry.coin == 'bch') {
|
||||
var translated = bitcoinCashJsService.readAddress(addressbook.address);
|
||||
addressbook.address = translated.legacy;
|
||||
}
|
||||
$timeout(function() {
|
||||
addressbookService.add(addressbook, function(err, ab) {
|
||||
if (err) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, lodash, addressbookService, popupService, $ionicHistory, platformInfo, gettextCatalog, configService) {
|
||||
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, lodash, addressbookService, popupService, $ionicHistory, platformInfo, gettextCatalog, configService, bitcoinCashJsService) {
|
||||
|
||||
var config = configService.getSync();
|
||||
var defaults = configService.getDefaults();
|
||||
|
|
@ -24,8 +24,15 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
|
|||
$ionicHistory.removeBackView();
|
||||
$state.go('tabs.send');
|
||||
$timeout(function() {
|
||||
var to = '';
|
||||
if ($scope.addressbookEntry.coin == 'bch') {
|
||||
var a = 'bitcoincash:' + $scope.addressbookEntry.address;
|
||||
to = bitcoinCashJsService.readAddress(a).legacy;
|
||||
} else {
|
||||
to = $scope.addressbookEntry.address;
|
||||
}
|
||||
$state.transitionTo('tabs.send.amount', {
|
||||
toAddress: $scope.addressbookEntry.address,
|
||||
toAddress: to,
|
||||
toName: $scope.addressbookEntry.name,
|
||||
toEmail: $scope.addressbookEntry.email,
|
||||
coin: $scope.addressbookEntry.coin
|
||||
|
|
|
|||
|
|
@ -63,11 +63,8 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
a.translatedAddresses = bitcoinCashJsService.translateAddresses(a.address);
|
||||
});
|
||||
|
||||
var cashaddrDate = new Date(2018, 0, 15);
|
||||
var currentDate = new Date();
|
||||
|
||||
$scope.addressType = {
|
||||
type: currentDate >= cashaddrDate ? 'cashaddr' : 'legacy'
|
||||
type: 'cashaddr'
|
||||
};
|
||||
$scope.showAddressTypes = true;
|
||||
}
|
||||
|
|
@ -141,7 +138,7 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
if ($scope.wallet.coin == 'bch') {
|
||||
_addr[0].translatedAddresses = bitcoinCashJsService.translateAddresses(_addr[0].address);
|
||||
}
|
||||
|
||||
|
||||
$scope.noBalance = [_addr[0]].concat($scope.noBalance);
|
||||
$scope.latestUnused = lodash.slice($scope.noBalance, 0, UNUSED_ADDRESS_LIMIT);
|
||||
$scope.viewAll = {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
angular.module('copayApp.controllers').controller('tabReceiveController', function($rootScope, $scope, $timeout, $log, $ionicModal, $state, $ionicHistory, $ionicPopover, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService, bwcError, bitcoinCashJsService) {
|
||||
|
||||
var listeners = [];
|
||||
var cashaddrDate = new Date(2018, 0, 15);
|
||||
var currentDate = new Date();
|
||||
$scope.bchAddressType = currentDate >= cashaddrDate ? 'cashaddr' : 'legacy';
|
||||
$scope.bchAddressType = 'cashaddr';
|
||||
var bchAddresses = {};
|
||||
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue