got address book working with bitcoin cash addresses

This commit is contained in:
Kadir Sekha 2018-01-11 19:07:12 +09:00
commit 1c8990fc08
10 changed files with 41 additions and 23 deletions

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.directives')
.directive('validAddress', ['$rootScope', 'bitcore', 'bitcoreCash',
function($rootScope, bitcore, bitcoreCash) {
.directive('validAddress', ['$rootScope', 'bitcore', 'bitcoreCash', 'bitcoinCashJsService',
function($rootScope, bitcore, bitcoreCash, bitcoinCashJsService) {
return {
require: 'ngModel',
link: function(scope, elem, attrs, ctrl) {
@ -15,6 +15,10 @@ angular.module('copayApp.directives')
var validator = function(value) {
if (value.indexOf('bitcoincash:') >= 0 || value[0] == 'C' || value[0] == 'H') {
value = bitcoinCashJsService.readAddress(value).legacy;
}
// Regular url
if (/^https?:\/\//.test(value)) {
ctrl.$setValidity('validAddress', true);