UNPKG

@fordefi-public/crypto-address-validator-ts

Version:

Crypto address validator for Bitcoin and other Altcoins, forked to be used with typescript

12 lines 543 B
import { toHex, keccak256Checksum } from '../crypto/utils'; const base32 = require('../crypto/externals/base32'); export function isValidAddress(_address) { const address = _address.toString().toUpperCase().replace(/-/g, ''); if (!address || address.length !== 40) { return false; } const decoded = toHex(base32.b32decode(address)); const stepThreeChecksum = keccak256Checksum(Buffer.from(decoded.slice(0, 42), 'hex')); return stepThreeChecksum === decoded.slice(42); } //# sourceMappingURL=nem_validator.js.map