Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looks like the library is not differentiating testnet from mainnet mostly #81

Open
vzelenko opened this issue Nov 17, 2021 · 0 comments

Comments

@vzelenko
Copy link

Example Code:

const WAValidator = require('wallet-address-validator');

const addresses = [
    '1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck',          // BTC mainnet
    'bc1qphj4muhdgs7q2rkmryvkj8jxz6ne8v26w4nu07',  // BTC mainnet
    'tb1qcha20vge9qvzt65u8u63597nr380vzrv45u7sd',  // BTC testnet
    '0xed8afcf23326fc69d7365b2773ace45c634bf199',  // ETH mainnet
    '0x12e117cdef30a4072158df55a302384779e0692a',  // ETH testnet
];

addresses.forEach(addr => {
    console.log('CHECKING ' + addr);
    let status = WAValidator.validate(addr, 'BTC') ? 'OK' : 'XX';
    console.log("     BTC [mainnet] => ", status);
    status = WAValidator.validate(addr, 'BTC', 'testnet') ? 'OK' : 'XX';
    console.log("     BTC [testnet] => ", status);
    status = WAValidator.validate(addr, 'ETH') ? 'OK' : 'XX';
    console.log("     ETH [mainnet] => ", status);
    status = WAValidator.validate(addr, 'ETH', 'testnet') ? 'OK' : 'XX';
    console.log("     ETH [testnet] => ", status);
});

Resulting Output:

➜  [DIRNAME] git:(develop) ✗ node script/test-btc-address.js
CHECKING 1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck
     BTC [mainnet] =>  OK
     BTC [testnet] =>  XX
     ETH [mainnet] =>  XX
     ETH [testnet] =>  XX
CHECKING bc1qphj4muhdgs7q2rkmryvkj8jxz6ne8v26w4nu07
     BTC [mainnet] =>  OK
     BTC [testnet] =>  OK       ---  wrong
     ETH [mainnet] =>  XX
     ETH [testnet] =>  XX
CHECKING tb1qcha20vge9qvzt65u8u63597nr380vzrv45u7sd
     BTC [mainnet] =>  OK       ---  wrong
     BTC [testnet] =>  OK
     ETH [mainnet] =>  XX
     ETH [testnet] =>  XX
CHECKING 0xed8afcf23326fc69d7365b2773ace45c634bf199
     BTC [mainnet] =>  XX
     BTC [testnet] =>  XX
     ETH [mainnet] =>  OK
     ETH [testnet] =>  OK       ---  wrong
CHECKING 0x12e117cdef30a4072158df55a302384779e0692a
     BTC [mainnet] =>  XX
     BTC [testnet] =>  XX
     ETH [mainnet] =>  OK       ---  wrong
     ETH [testnet] =>  OK
➜  [DIRNAME] git:(develop) ✗ 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant