mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
in isValidAddress check that address starting with 'r'
because UInt160 considers valid hex values
This commit is contained in:
@@ -12,7 +12,9 @@ const ValidationError = require('./errors').ValidationError;
|
||||
let SCHEMAS = {};
|
||||
|
||||
function isValidAddress(address: string): boolean {
|
||||
return core.UInt160.is_valid(address);
|
||||
return typeof address === 'string' && address.length > 0 &&
|
||||
address[0] === 'r' &&
|
||||
core.UInt160.is_valid(address);
|
||||
}
|
||||
|
||||
function isValidLedgerHash(ledgerHash) {
|
||||
|
||||
@@ -803,4 +803,11 @@ describe('RippleAPI - offline', function() {
|
||||
const api = new RippleAPI();
|
||||
assert(!api.isValidAddress(address.slice(0, -1) + 'a'));
|
||||
});
|
||||
|
||||
it('isValidAddress - invalid - hex representation', function() {
|
||||
const api = new RippleAPI();
|
||||
const hex = '6e3efa86a5eb0a3c5dc9beb3a204783bb00e1913';
|
||||
assert(!api.isValidAddress(hex));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user