Testing addresses with Bitcore wallet client.
This commit is contained in:
parent
1da9a79296
commit
b9943c403f
2 changed files with 7 additions and 3 deletions
|
|
@ -6,13 +6,16 @@
|
|||
.module('bitcoincom.services')
|
||||
.factory('bitcoinUriService', bitcoinUriService);
|
||||
|
||||
function bitcoinUriService(bitcoinCashJsService) {
|
||||
function bitcoinUriService(bitcoinCashJsService, bwcService) {
|
||||
var bitcore = bwcService.getBitcore();
|
||||
var service = {
|
||||
parse: parse
|
||||
};
|
||||
|
||||
return service;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
For parsing:
|
||||
BIP21
|
||||
|
|
@ -152,12 +155,12 @@
|
|||
var legacyRe = /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/;
|
||||
var legacyTestnetRe = /^[mn][a-km-zA-HJ-NP-Z1-9]{25,34}$/;
|
||||
|
||||
if (legacyRe.test(address)) {
|
||||
if (legacyRe.test(address) && bitcore.Address.isValid(address, 'livenet')) {
|
||||
parsed.address = address;
|
||||
parsed.legacyAddress = address;
|
||||
parsed.testnet = false;
|
||||
|
||||
} else if (legacyTestnetRe.test(address)) {
|
||||
} else if (legacyTestnetRe.test(address) && bitcore.Address.isValid(address, 'testnet')) {
|
||||
parsed.address = address;
|
||||
parsed.legacyAddress = address;
|
||||
parsed.testnet = true;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ fdescribe('bitcoinUriService', function() {
|
|||
beforeEach(function() {
|
||||
module('bitcoinCashJsModule');
|
||||
module('bitcoincom.services');
|
||||
module('bwcModule');
|
||||
|
||||
inject(function($injector){
|
||||
bitcoinUriService = $injector.get('bitcoinUriService');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue