This commit is contained in:
2026-08-28 17:31:02 +02:00
commit 2b30e8bd39
694 changed files with 49243 additions and 0 deletions
@@ -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());
};