The ./create-nwc-wallet.sh
script creates Lightning wallets using the NIP-90 DVM (Data Vending Machine) protocol combined with NWC (Nostr Wallet Connect) standards.
sequenceDiagram
participant User as π€ User
participant Script as π create-nwc-wallet.sh
participant Python as π dvm-create-wallet.py
participant NostrKeys as π NostrKeys
participant Relay as π‘ Nostr Relay<br/>(ws://localhost:7000)
participant Bridge as π NWC-Deposits Bridge<br/>(Docker Container)
participant LND as β‘ LND Deposits Vault
participant WalletFile as π Wallet File
User->>Script: ./create-nwc-wallet.sh "My Wallet" 100000
Note over Script: π Step 1: Environment Check
Script->>Bridge: docker ps | grep deposits-nwc-deposits-bridge
Bridge-->>Script: β
Bridge Running
Script->>Bridge: docker logs (get bridge pubkey)
Bridge-->>Script: π Bridge Pubkey: abc123...
Note over Script: π Step 2: Python Environment Setup
Script->>Script: Check/Create Python venv
Script->>Script: source ../common/nwc-env/bin/activate
Script->>Script: pip install requirements-nwc.txt
Note over Script: π Step 3: DVM Wallet Creation
Script->>Python: python3 ../common/dvm-create-wallet.py<br/>--bridge-pubkey abc123...<br/>--spending-limit 100000<br/>--wallet-name "My Wallet"
Note over Python: π Key Generation
Python->>NostrKeys: NostrKeys() # Generate client keys
NostrKeys-->>Python: π Client Private/Public Key Pair
Note over Python: π‘ Connect to Relay
Python->>Relay: websockets.connect(ws://localhost:7000)
Relay-->>Python: β
WebSocket Connection
Python->>Relay: ["REQ", "dvm-client-abc", {"kinds": [6050-6059], "#p": [client_pubkey]}]
Relay-->>Python: β
Subscribed to DVM Responses
Note over Python: π Create DVM Request
Python->>Python: create_event(kind=5050,<br/>content={"wallet_name": "My Wallet", "spending_limit": 100000},<br/>tags=[["p", bridge_pubkey], ["t", "wallet-creation"]])
Python->>NostrKeys: sign_event() # Schnorr signature
NostrKeys-->>Python: β
Signed DVM Event
Python->>Relay: ["EVENT", dvm_event]
Note over Relay,Bridge: π DVM Processing
Relay->>Bridge: Forward DVM Event (kind 5050)
Note over Bridge: ποΈ Wallet Creation Logic
Bridge->>Bridge: Parse DVM request
Bridge->>Bridge: Generate deposit keypair
Bridge->>Bridge: Create spending limits config
Bridge->>LND: Create new deposit account
LND-->>Bridge: β
Deposit ID: d-xyz789
Bridge->>Bridge: Generate NWC connection string<br/>nostrwalletconnect://bridge_pubkey?relay=ws://localhost:7000&secret=...
Note over Bridge: π€ DVM Response
Bridge->>Bridge: create_event(kind=6050,<br/>content={"status": "success", "deposit_id": "d-xyz789", ...})
Bridge->>Relay: ["EVENT", dvm_response]
Relay->>Python: Forward DVM Response (kind 6050)
Note over Python: β
Process Response
Python->>Python: Parse DVM response
Python->>WalletFile: Save wallet-d-xyz789.txt<br/>NWC_CONNECTION=nostrwalletconnect://...<br/>DEPOSIT_ID=d-xyz789<br/>DEPOSIT_PUBKEY=03abc...<br/>SPENDING_LIMIT=100000
Python-->>Script: β
Wallet creation success<br/>πΎ Connection saved to: wallet-d-xyz789.txt
Note over Script: π Result Processing
Script->>WalletFile: Extract NWC_CONNECTION, DEPOSIT_ID, DEPOSIT_PUBKEY
Script->>Script: Fix relay URL (nostr-relay:8080 β localhost:7000)
Script->>WalletFile: Create clean wallet file with usage instructions
Script-->>User: π Wallet Created!<br/>π Next Steps:<br/>./nwc-client.sh --connection "..." --quick-test<br/>π± Or copy to wallet app (Alby, Zeus, Mutiny)
Note over User,LND: π Ready for Operations
Note over User: User can now:<br/>π³ Fund wallet via Lightning invoice<br/>β‘ Send payments via NWC<br/>π± Connect to mobile apps<br/>π Check balance and info
-
Nostr Keys (Client)
- Type: Schnorr signatures (BIP-340)
- Purpose: Sign DVM requests to Nostr relay
- Format: x-only public keys (32 bytes)
-
Deposit Keys (Backend)
- Type: ECDSA signatures
- Purpose: Authenticate with LND Deposits API
- Format: Compressed public keys (33 bytes)
-
Bridge Keys
- Type: Schnorr signatures
- Purpose: Bridge identity and DVM responses
- Format: x-only public keys (32 bytes)
Layer | Protocol | Purpose |
---|---|---|
Application | Shell Script | User interface and orchestration |
DVM Client | NIP-90 | Wallet creation requests (kinds 5050-5059) |
NWC Operations | NIP-47 | Wallet operations (kinds 23194-23195) |
Transport | WebSocket | Real-time communication with relay |
Backend | LND Deposits API | Actual Lightning wallet functionality |
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β NWC Client βββββΆβ DVM+NWC Bridge βββββΆβ LND Deposits β
β β β β β Vault β
β β’ Nostr Events β β β’ DVM Processing β β β’ Real Lightningβ
β β’ NWC Requests β β β’ Protocol Trans β β β’ Deposit Mgmt β
β β’ Wallet Apps β β β’ Key Management β β β’ Balance Track β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
- π€ Automated: Single command creates complete Lightning wallet
- π Secure: Multi-layer cryptographic authentication
- π± Compatible: Works with all NWC-supporting wallet apps
- β‘ Zero-UTXO: No on-chain setup required
- π Decentralized: Uses Nostr relay for communication
- π§ͺ Testable: Includes built-in testing tools
The script creates multiple files for different use cases:
-
Original DVM File:
wallet-{timestamp}.txt
- Raw output from DVM protocol
- Docker-internal relay URLs
-
Clean Wallet File:
wallet_dvm_{timestamp}.txt
- Host-accessible relay URLs
- Usage instructions included
- Ready for production use
-
Connection String: For direct wallet app integration
nostrwalletconnect://bridge_pubkey?relay=ws://localhost:7000&secret=...
- π§ͺ Quick Test:
./nwc-client.sh --connection "..." --quick-test
- π± Mobile Apps: Copy connection string to Alby, Zeus, or Mutiny
- π³ Fund Wallet: Create invoice and receive Lightning payments
- β‘ Send Payments: Pay Lightning invoices via NWC protocol
- π Interactive Mode:
./nwc-client.sh --connection "..." --interactive
This architecture enables instant Lightning wallet creation with zero on-chain setup, combining the best of Nostr's decentralized communication with Lightning's payment capabilities.