Tests for BIP72.
This commit is contained in:
parent
1be9ce39c1
commit
a4ab20abba
2 changed files with 46 additions and 3 deletions
|
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
// https://en.bitcoin.it/wiki/BIP_0072
|
||||
|
||||
(function(){
|
||||
|
||||
angular
|
||||
|
|
@ -17,9 +19,7 @@
|
|||
|
||||
return service;
|
||||
|
||||
|
||||
|
||||
function isValidCashAddr(address, network) {
|
||||
function generateTestData() {
|
||||
var privateKey = new bch.PrivateKey('testnet');
|
||||
var address1 = privateKey.toAddress();
|
||||
console.log('legacy pub:', address1.toString());
|
||||
|
|
@ -27,7 +27,13 @@
|
|||
//console.log('generated:', addrss.cashaddr);
|
||||
//bch.Address.fromString(address1, 'testnet');
|
||||
console.log('generated:', address1.toString('cashaddr'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
function isValidCashAddr(address, network) {
|
||||
|
||||
|
||||
var isValid = false;
|
||||
|
||||
var prefix = network === 'testnet' ? 'bchtest:' : 'bitcoincash:';
|
||||
|
|
@ -219,6 +225,7 @@
|
|||
parsed.address = cashAddr;
|
||||
parsed.coin = 'bch';
|
||||
// TODO: Get legacy address
|
||||
|
||||
|
||||
} else if (cashAddrRe.test(address)) {
|
||||
var cashAddr = 'bitcoincash:' + addressLowerCase;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,42 @@ fdescribe('bitcoinUriService', function() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('Bitcoin Cash BIP72', function() {
|
||||
|
||||
var parsed = bitcoinUriService.parse('bitcoincash:?r=https://bitpay.com/i/SmHdie5dvBnG5kouZzEPzu');
|
||||
|
||||
expect(parsed.isValid).toBe(true);
|
||||
expect(parsed.address).toBeUndefined()
|
||||
expect(parsed.coin).toBe('bch');
|
||||
expect(parsed.legacyAddress).toBeUndefined();
|
||||
expect(parsed.testnet).toBeUndefined();
|
||||
expect(parsed.url).toBe('https://bitpay.com/i/SmHdie5dvBnG5kouZzEPzu');
|
||||
});
|
||||
|
||||
it('Bitcoin BIP72', function() {
|
||||
|
||||
var parsed = bitcoinUriService.parse('bitcoin:?r=https://bitpay.com/i/CwzbKP3k3JNgXJBfuoerDr');
|
||||
|
||||
expect(parsed.isValid).toBe(true);
|
||||
expect(parsed.address).toBeUndefined()
|
||||
expect(parsed.coin).toBe('btc');
|
||||
expect(parsed.legacyAddress).toBeUndefined();
|
||||
expect(parsed.testnet).toBeUndefined();
|
||||
expect(parsed.url).toBe('https://bitpay.com/i/CwzbKP3k3JNgXJBfuoerDr');
|
||||
});
|
||||
|
||||
it('Bitcoin testnet address', function() {
|
||||
|
||||
var parsed = bitcoinUriService.parse('mtWcoToWhbtPoCby5fvs8xdBujT5GGenD4');
|
||||
|
||||
expect(parsed.isValid).toBe(true);
|
||||
expect(parsed.address).toBe('mtWcoToWhbtPoCby5fvs8xdBujT5GGenD4');
|
||||
expect(parsed.coin).toBeUndefined();
|
||||
expect(parsed.legacyAddress).toBe('mtWcoToWhbtPoCby5fvs8xdBujT5GGenD4');
|
||||
expect(parsed.testnet).toBe(true);
|
||||
});
|
||||
|
||||
it('Bitcoin testnet address', function() {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue