classifyWalletInput function
Classifies locally recognizable wallet input without performing network I/O.
Implementation
WalletInputKind? classifyWalletInput(String input) {
final value = _normalizeWalletInput(input);
if (value.isEmpty) return null;
final uri = Uri.tryParse(value);
if (uri?.scheme.toLowerCase() == 'nostr+walletconnect') {
try {
NostrWalletConnectUri.parseConnectionUri(value);
return WalletInputKind.nwc;
} catch (_) {
return null;
}
}
final normalizedLower = value.toLowerCase();
if (normalizedLower.startsWith('lno1') ||
(uri?.scheme.toLowerCase() == 'bitcoin' &&
uri!.queryParameters.entries.any(
(entry) =>
entry.key.toLowerCase() == 'lno' && entry.value.isNotEmpty,
))) {
return WalletInputKind.bolt12;
}
var address = value;
if (address.startsWith('₿')) address = address.substring(1);
final addressParts = address.split('@');
if (addressParts.length == 2 &&
addressParts.every((part) => part.isNotEmpty) &&
!address.contains(RegExp(r'\s'))) {
return WalletInputKind.lightningAddress;
}
if (uri?.scheme.toLowerCase() == 'https' && uri!.host.isNotEmpty) {
return WalletInputKind.cashuMint;
}
return null;
}