feat: Namecoin NIP-05 identity resolution (.bit domains, d/ and id/ namespaces)#623
Open
mstrofnone wants to merge 2 commits intov0l:mainfrom
Open
feat: Namecoin NIP-05 identity resolution (.bit domains, d/ and id/ namespaces)#623mstrofnone wants to merge 2 commits intov0l:mainfrom
mstrofnone wants to merge 2 commits intov0l:mainfrom
Conversation
added 2 commits
April 12, 2026 15:13
Add decentralised NIP-05-style identity verification via the Namecoin blockchain. Users with .bit domains or d//id/ namespace names can now have their Nostr pubkeys verified without relying on HTTP servers. Architecture: - Browser -> HTTP proxy -> ElectrumX TCP/TLS -> Namecoin blockchain - Proxy handles scripthash computation, tx parsing, NAME_UPDATE extraction - LRU cache (1h TTL, 500 entries) for resolved identities Components: - packages/shared/src/namecoin.ts: Core resolver module - isNamecoinIdentifier() detection - parseNamecoinIdentifier() for all formats - resolveNamecoin/resolveNamecoinCached with LRU cache - verifyNamecoinNip05 for pubkey verification - fetchNamecoinNip05Pubkey/fetchNamecoinNostrAddress for compatibility - proxy/electrumx-client.mjs: Server-side ElectrumX TCP/TLS client - Canonical name index script construction - Electrum-style scripthash computation (SHA-256, byte-reversed) - blockchain.scripthash.get_history queries - Raw transaction parsing for NAME_UPDATE scripts - Name expiry checking (NAME_EXPIRE_DEPTH = 36000 blocks) - proxy/electrumx-proxy.mjs: Standalone HTTP proxy server - proxy/vite-plugin-namecoin.mjs: Vite dev middleware (zero-setup) - Modified packages/shared/src/utils.ts: - fetchNip05PubkeyWithThrow routes .bit to Namecoin resolver - fetchNostrAddressWithThrow routes .bit to Namecoin resolver - Modified packages/app/src/Components/User/Nip05.tsx: - Amber-colored .bit domain display - Chain-link emoji badge for Namecoin-verified identities - 'Verified via Namecoin blockchain' tooltip - packages/shared/src/namecoin.test.ts: Unit tests Supported identifier formats: - alice@example.bit -> d/example, look up 'alice' - _@example.bit / example.bit -> d/example, root entry - d/example -> direct domain lookup - id/alice -> identity namespace lookup Default ElectrumX server: nmc2.bitcoins.sk:57001
Replaces the HTTP proxy approach with direct WebSocket connections from the browser to ElectrumX servers. No backend or middleware required — works as a fully static web app. Based on the approach from hzrd149/nostrudel#352
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add decentralised NIP-05-style identity verification via the Namecoin blockchain. Users with
.bitdomains ord//id/namespace names can have their Nostr public keys verified without relying on centralised HTTP servers.What is Namecoin?
Namecoin is a decentralised naming blockchain (the first fork of Bitcoin, launched 2011). Names registered in the
d/(domain) andid/(identity) namespaces can store arbitrary JSON values, including Nostr public keys. This enables fully decentralised NIP-05 — identity verification that depends on no single server, registrar, or DNS provider.Architecture
Browsers cannot make raw TCP/TLS connections to ElectrumX servers. A lightweight HTTP proxy bridges the gap, handling all ElectrumX protocol details:
OP_NAME_UPDATE+ name + empty +OP_2DROP OP_DROP OP_RETURN)blockchain.scripthash.get_historyNAME_UPDATEscriptNAME_EXPIRE_DEPTH = 36000)Supported Identifier Formats
alice@example.bitd/examplealiceinnostr.names_@example.bitd/exampleexample.bitd/exampled/exampled/exampleid/aliceid/aliceNamecoin Value Formats
Domain (
d/) — simple:{"nostr": "hex64pubkey"}Domain (
d/) — NIP-05-like extended:{"nostr": {"names": {"alice": "hex64pubkey"}, "relays": {"hex64pubkey": ["wss://..."]}}}Identity (
id/) — simple:{"nostr": "hex64pubkey"}Identity (
id/) — with relays:{"nostr": {"pubkey": "hex64pubkey", "relays": ["wss://..."]}}Changes
New files
packages/shared/src/namecoin.ts— Core resolver module with LRU cache, identifier parsing, value extractionpackages/shared/src/namecoin.test.ts— Unit tests for parsing and value extractionproxy/electrumx-client.mjs— Server-side ElectrumX TCP/TLS clientproxy/electrumx-proxy.mjs— Standalone HTTP proxy serverproxy/vite-plugin-namecoin.mjs— Vite dev middleware for zero-setup developmentModified files
packages/shared/src/utils.ts— Routes.bitdomains to Namecoin resolver infetchNip05PubkeyWithThrowandfetchNostrAddressWithThrowpackages/shared/src/index.ts— Exports namecoin modulepackages/app/src/Components/User/Nip05.tsx— Amber.bitbadge with ⛓ chain-link icon and "Verified via Namecoin blockchain" tooltippackages/app/vite.config.ts— Registers Vite proxy plugin for devHow to Run
Development (zero setup)
The Vite plugin automatically serves
/api/namecoin/*duringbun run dev, proxying to the default ElectrumX server. No additional configuration needed.Production
Set
VITE_NAMECOIN_PROXY_URLto your hosted proxy URL:Or run the standalone proxy:
Prior Art