Returning addresses from cashAddr with bitcoincash: prefix.
This commit is contained in:
parent
ab0b8b19b0
commit
93d061c96a
2 changed files with 15 additions and 4 deletions
|
|
@ -152,10 +152,11 @@
|
|||
parsed.legacyAddress = address;
|
||||
|
||||
} else if (cashAddrRe.test(address)) {
|
||||
parsed.address = address;
|
||||
var cashAddr = 'bitcoincash:' + address.toLowerCase();
|
||||
parsed.address = cashAddr;
|
||||
parsed.coin = 'bch';
|
||||
|
||||
var bchAddresses = bitcoinCashJsService.readAddress('bitcoincash:' + address);
|
||||
var bchAddresses = bitcoinCashJsService.readAddress(cashAddr);
|
||||
parsed.legacyAddress = bchAddresses['legacy'];
|
||||
|
||||
} // TODO: Check for private key
|
||||
|
|
|
|||
|
|
@ -20,12 +20,22 @@ fdescribe('bitcoinUriService', function() {
|
|||
expect(parsed.legacyAddress).toBe('1JXeGEu7bNEAYu6URT6dU6g1Ys6ffSAWYW');
|
||||
});
|
||||
|
||||
it('cashAddr', function() {
|
||||
it('cashAddr with prefix', function() {
|
||||
|
||||
var parsed = bitcoinUriService.parse('bitcoincash:qrq9p82a247lecv08ldk5p5h6ahtnjzpqcnh8yhq92');
|
||||
|
||||
expect(parsed.isValid).toBe(true);
|
||||
expect(parsed.address).toBe('bitcoincash:qrq9p82a247lecv08ldk5p5h6ahtnjzpqcnh8yhq92');
|
||||
expect(parsed.coin).toBe('bch');
|
||||
expect(parsed.legacyAddress).toBe('1JXsK3HSFqoMnwh4Mevf5bTgqPcgNWX7ic');
|
||||
});
|
||||
|
||||
it('cashAddr without prefix', function() {
|
||||
|
||||
var parsed = bitcoinUriService.parse('qqen2y3l28dpk0dzsag8w027ds96u7z4pc0uxtl0nq');
|
||||
|
||||
expect(parsed.isValid).toBe(true);
|
||||
expect(parsed.address).toBe('qqen2y3l28dpk0dzsag8w027ds96u7z4pc0uxtl0nq');
|
||||
expect(parsed.address).toBe('bitcoincash:qqen2y3l28dpk0dzsag8w027ds96u7z4pc0uxtl0nq');
|
||||
expect(parsed.coin).toBe('bch');
|
||||
expect(parsed.legacyAddress).toBe('15fm3EwqgBYcxkndALBfforueps5yWKReJ');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue