Skip to main content

Nostr Wallet Connect (NIP-47) SDK for OpenClaw AI entities — pay invoices, check balance, create invoices

Project description

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nostrwalletconnect-0.1.4.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nostrwalletconnect-0.1.4-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file nostrwalletconnect-0.1.4.tar.gz.

File metadata

  • Download URL: nostrwalletconnect-0.1.4.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for nostrwalletconnect-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0fc6c8fe52cfaab0037212817788a2557de8dc39bce7c8df93c16c55d53e1c7b
MD5 5bc8dcff621c6eee305d4132be267f7e
BLAKE2b-256 aa5e503093bb3546298d525b33566b19a4f97545568c84e956e28a12349b1c87

See more details on using hashes here.

File details

Details for the file nostrwalletconnect-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for nostrwalletconnect-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b3ce1fa390fa9d57a7af0f3d24ed4d1228ab0169bb2ccb985428bfd548bac0d0
MD5 4aa4ba7b9c99888225be266c9be12cb8
BLAKE2b-256 1efc5cba05ea7b7227d2b629d937804d41e0c1531d4599188033e5ff9ba6a234

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page