init
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import type { MoneroNetwork } from '@/types/moneroWallet/MoneroNetwork';
|
||||
|
||||
// Standard + subaddress, 95 chars. Excludes integrated (106 chars).
|
||||
// Prefix bytes: monero-project/monero src/cryptonote_config.h
|
||||
// Regex shape: https://gist.github.com/masflam/84477ca88842e245dc7a4cc61ce299e3
|
||||
const BASE58 = '[1-9A-HJ-NP-Za-km-z]';
|
||||
|
||||
const NETWORK_ADDRESS_PATTERNS: Record<MoneroNetwork, RegExp> = {
|
||||
mainnet: new RegExp(`^(?:4[1-9AB]|8[2-9ABC])${BASE58}{93}$`),
|
||||
stagenet: new RegExp(`^(?:5[1-9AB]|7[2-9AB])${BASE58}{93}$`)
|
||||
};
|
||||
|
||||
export const isMoneroStandardAddress = (value: unknown, network: MoneroNetwork): boolean => {
|
||||
if (typeof value !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return NETWORK_ADDRESS_PATTERNS[network].test(value.trim());
|
||||
};
|
||||
Reference in New Issue
Block a user