Skip to content

feat: Namecoin .bit NIP-05 identity verification#79

Open
mstrofnone wants to merge 1 commit into
YakiHonne:mainfrom
mstrofnone:feat/namecoin-nip05-support
Open

feat: Namecoin .bit NIP-05 identity verification#79
mstrofnone wants to merge 1 commit into
YakiHonne:mainfrom
mstrofnone:feat/namecoin-nip05-support

Conversation

@mstrofnone
Copy link
Copy Markdown

Summary

Adds Namecoin blockchain-based NIP-05 identity verification for .bit domains. When a user's NIP-05 address ends in .bit (e.g. [email protected]), or uses Namecoin's d/ or id/ namespace, the app queries the Namecoin blockchain via ElectrumX servers instead of making HTTP requests.

Ported from Amethyst (MIT License, Vitor Pamplona).

New Files (12)

Core Services (lib/services/namecoin/)

  • electrumx_server.dart — Data models, exception types, default server lists
  • electrumx_client.dart — TCP/TLS client querying ElectrumX servers with fallback
  • namecoin_name_resolver.dart — Parses identifiers and extracts Nostr pubkeys + relays
  • namecoin_lookup_cache.dart — LRU cache with 1-hour TTL (500 entries max)
  • namecoin_settings.dart — Settings model with custom ElectrumX server support
  • namecoin_name_service.dart — App-level singleton: resolve(), verifyNip05(), resolvePubkey()
  • namecoin_shared_preferences.dart — Persistence for enabled state + custom servers
  • namecoin.dart — Barrel export file

UI

  • settings_view/widgets/property_namecoin.dart — Settings list entry tile
  • settings_view/widgets/namecoin_settings_view.dart — Full settings screen with enable/disable toggle, custom server management, and live test lookup
  • widgets/nip05_namecoin_component.dart — Enhanced NIP-05 badge with chain-link icon for verified .bit identifiers

Tests

  • test/services/namecoin/namecoin_name_resolver_test.dart — 24 unit tests covering identifier detection, settings parsing, and JSON value extraction

Modified Files (6)

  • globals.dart — Added namecoinService and namecoinPreferences globals
  • initializers.dart — Initialize Namecoin service on startup with graceful fallback
  • http_functions_repository.dart — Route .bit domains to Namecoin verification
  • metadata_cubit.dart — Route .bit identifiers to Namecoin resolution
  • search_cubit.dart — Route .bit search queries through Namecoin resolver, skip relay connectivity check for .bit domains
  • settings_view.dart — Add Namecoin settings tile

Supported Identifier Formats

Format Example Resolution
NIP-05 style [email protected] Look up d/example, find alice in names
Bare domain example.bit Look up d/example, use root entry
Domain namespace d/example Direct lookup, root entry
Identity namespace id/alice Direct lookup

Testing

  • 24/24 unit tests pass
  • Tested on Android emulator (Pixel 6, API 35) — search for [email protected] resolves correctly via ElectrumX
  • No new dependencies — uses crypto (already in pubspec.yaml) and dart:io for TCP/TLS sockets

Add Namecoin blockchain-based NIP-05 identity verification for .bit domains.
When a user's NIP-05 address ends in .bit (e.g. [email protected]), or uses
Namecoin's d/ or id/ namespace, the app queries the Namecoin blockchain via
ElectrumX servers instead of making HTTP requests.

Ported from Amethyst (MIT License, Vitor Pamplona).

New files (12):
- lib/services/namecoin/ - 8 service files (ElectrumX client, name resolver,
  LRU cache, settings, SharedPreferences persistence)
- lib/views/settings_view/widgets/property_namecoin.dart - Settings tile
- lib/views/settings_view/widgets/namecoin_settings_view.dart - Full settings
  screen with enable/disable, custom server management, live test lookup
- lib/views/widgets/nip05_namecoin_component.dart - Enhanced NIP-05 badge
  with chain-link icon for verified .bit identifiers
- test/services/namecoin/namecoin_name_resolver_test.dart - 24 unit tests

Modified files (6):
- lib/globals.dart - Added namecoinService and namecoinPreferences globals
- lib/initializers.dart - Initialize Namecoin service on startup, graceful
  fallback if remote cache init fails
- lib/repositories/http_functions_repository.dart - Route .bit domains to
  Namecoin verification in checkNip05Validity()
- lib/logic/metadata_cubit/metadata_cubit.dart - Route .bit identifiers to
  Namecoin resolution in getNip05Pubkey() and batch validation
- lib/logic/search_cubit/search_cubit.dart - Route .bit search queries
  through Namecoin resolver, skip relay connectivity check for .bit domains
- lib/views/settings_view/settings_view.dart - Add Namecoin settings tile

Supported identifier formats:
- NIP-05 style: [email protected]
- Bare domain: example.bit
- Domain namespace: d/example
- Identity namespace: id/alice

No new dependencies - uses crypto (already in pubspec.yaml) and dart:io
for TCP/TLS sockets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant