Skip to main content

NostrWalletConnect for OpenClaw

Give your AI access to a Lightning wallet.

A Python SDK for OpenClaw AI entities to connect to any NWC-compatible wallet and send payments, check balance, create invoices, and list transactions — all over the Nostr protocol via NIP-47.

Why?

AI agents that can pay for things — API calls, compute, storage, services from other agents — need wallet access. NWC (Nostr Wallet Connect) gives them that without holding custody of funds. The wallet stays under the human's control. The agent gets a scoped connection string that authorizes specific operations.

What your bot can do with NWC:

  • Pay Lightning invoices — your bot can pay for services, APIs, or other agents' work.
  • Create invoices to receive payment — your bot can charge for its own services.
  • Check wallet balance — know what's available before committing to a payment.
  • Verify payments — look up whether an invoice was paid and get the preimage.
  • View transaction history — audit trail of all payments sent and received.

All communication is NIP-44 encrypted over Nostr relays. The relay operator sees nothing but ciphertext.

Install

pip install nostrwalletconnect

v0.2.0 — part of the coordinated 2026-07 correctness release (staged, pending PyPI publish). The whole Nostr library family was audited together and every package is now verified against a shared spine of known-answer test vectors (NIP-44 v2, NIP-49, NIP-19 TLV, BIP-340) so encode/decode bugs can't hide inside self-round-trip tests. This release brings NIP-47 encryption negotiation to spec, verifies wallet responses (kind/author/tag/signature) before trusting them, and fixes lookup_invoice paid detection. See CHANGELOG.md.

This also installs nostrkey as a dependency (for Nostr identity, signing, and encryption).

Quick Start

import asyncio
from nostrwalletconnect import NWCClient

# Paste your NWC connection string from your wallet
NWC_URI = "nostr+walletconnect://<wallet_pubkey>?relay=wss://...&secret=<hex_secret>"

async def main():
    async with NWCClient(NWC_URI) as nwc:
        balance = await nwc.get_balance()
        print(f"Balance: {balance.balance // 1000} sats")

asyncio.run(main())

Pay an Invoice

async with NWCClient(NWC_URI) as nwc:
    result = await nwc.pay_invoice("lnbc10u1p...")
    print(f"Paid! Preimage: {result.preimage}")

Create an Invoice

async with NWCClient(NWC_URI) as nwc:
    invoice = await nwc.make_invoice(
        amount=50_000,  # millisatoshis
        description="Payment for AI service"
    )
    print(f"Invoice: {invoice.invoice}")

Look Up an Invoice

async with NWCClient(NWC_URI) as nwc:
    status = await nwc.lookup_invoice(payment_hash="abc123...")
    print(f"Paid: {status.paid}")

List Transactions

async with NWCClient(NWC_URI) as nwc:
    history = await nwc.list_transactions(limit=10)
    for tx in history.transactions:
        direction = "received" if tx.type == "incoming" else "sent"
        print(f"  {direction} {tx.amount // 1000} sats")

NIP Implemented

NIP What Status
NIP-47 Nostr Wallet Connect Implemented

Built on top of nostrkey which implements NIP-01, NIP-19, NIP-44.

OpenClaw Skill (ClawHub)

This repo includes an OpenClaw skill in clawhub/ so AI agents can discover and use NostrWalletConnect directly from the ClawHub registry.

clawhub install nostrwalletconnect

License

MIT

Metadata

Release files for nostrwalletconnect 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nostrwalletconnect 0.2.1
File Size Uploaded Provenance Actions
nostrwalletconnect-0.2.1.tar.gz 20.8 kB Without provenance Details for nostrwalletconnect-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nostrwalletconnect 0.2.1
File Interpreter ABI Platform Actions
nostrwalletconnect-0.2.1-py3-none-any.whl Python 3 none any Details for nostrwalletconnect-0.2.1-py3-none-any.whl

Total release size: 32.8 kB

Release files / nostrwalletconnect-0.2.1.tar.gz

Download URL nostrwalletconnect-0.2.1.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
26b909899026084819d1ce555e436e5722ae128604d6e011150d79dea9a2940e
BLAKE2b-256 checksum
How to use checksums
90e40ce6db7552cdee9df020be1c23a4f23f8247764eb71b2130a7df70bc0ca1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / nostrwalletconnect-0.2.1-py3-none-any.whl

Download URL nostrwalletconnect-0.2.1-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20fde6888fa3f3d5ee4f48a9961547d2ea1edcd9af9aec9cfa0c2e2b56d120b2
BLAKE2b-256 checksum
How to use checksums
d47b2c1f250c8c46ffdd3c5a579cccd2728e10ae827937a04a3b3eb08c7a8fb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for nostrwalletconnect 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page