matchesNwcWalletAuthInfoEvent function
Validates discovery against client key and any returned correlation state. Missing state remains accepted for wallets implementing earlier drafts.
Implementation
bool matchesNwcWalletAuthInfoEvent(
Nip01Event event, {
required String appPubkey,
required String state,
String? walletServicePubkey,
bool requireAppPubkeyTag = true,
}) {
final returnedState = event.getFirstTag('state');
return event.kind == NwcKind.INFO.value &&
(!requireAppPubkeyTag || event.pTags.contains(appPubkey.toLowerCase())) &&
(returnedState == null ||
returnedState.isEmpty ||
returnedState == state) &&
(walletServicePubkey == null || event.pubKey == walletServicePubkey);
}