NWC Client CLI Tool
A command-line interface tool for making calls to Nostr Wallet Connect (NWC) services.
Overview
This CLI tool allows you to interact with NWC wallet services using the methods defined in the NIP-47 specification. It provides a simple interface for executing wallet operations and displays the JSON response from the wallet service.
Usage
nwcclient <connection URL> <method> [parameters...]
Connection URL
The connection URL should be in the Nostr Wallet Connect format:
nostr+walletconnect://<wallet_pubkey>?relay=<relay_url>&secret=<secret>
Supported Methods
The following methods are supported by this CLI tool:
get_info- Get wallet informationget_balance- Get wallet balanceget_budget- Get wallet budgetmake_invoice- Create an invoicepay_invoice- Pay an invoicepay_keysend- Send a keysend paymentlookup_invoice- Look up an invoicelist_transactions- List transactionssign_message- Sign a message
Unsupported Methods
The following methods are defined in the NIP-47 specification but are not directly supported by this CLI tool due to limitations in the underlying nwc package:
create_connection- Create a connectionmake_hold_invoice- Create a hold invoicesettle_hold_invoice- Settle a hold invoicecancel_hold_invoice- Cancel a hold invoicemulti_pay_invoice- Pay multiple invoicesmulti_pay_keysend- Send multiple keysend payments
Method Parameters
Methods with No Parameters
get_infoget_balanceget_budget
Example:
nwcclient <connection URL> get_info
Methods with Parameters
make_invoice
nwcclient <connection URL> make_invoice <amount> <description> [description_hash] [expiry]
amount- Amount in millisatoshis (msats)description- Invoice descriptiondescription_hash(optional) - Hash of the descriptionexpiry(optional) - Expiry time in seconds
Example:
nwcclient <connection URL> make_invoice 1000000 "Test invoice" "" 3600
pay_invoice
nwcclient <connection URL> pay_invoice <invoice> [amount]
invoice- BOLT11 invoiceamount(optional) - Amount in millisatoshis (msats)
Example:
nwcclient <connection URL> pay_invoice lnbc1...
pay_keysend
nwcclient <connection URL> pay_keysend <amount> <pubkey> [preimage]
amount- Amount in millisatoshis (msats)pubkey- Recipient's public keypreimage(optional) - Payment preimage
Example:
nwcclient <connection URL> pay_keysend 1000000 03...
lookup_invoice
nwcclient <connection URL> lookup_invoice <payment_hash_or_invoice>
payment_hash_or_invoice- Payment hash or BOLT11 invoice
Example:
nwcclient <connection URL> lookup_invoice 3d...
list_transactions
nwcclient <connection URL> list_transactions [from <timestamp>] [until <timestamp>] [limit <count>] [offset <count>] [unpaid <true|false>] [type <incoming|outgoing>]
Parameters are specified as name-value pairs:
from- Start timestampuntil- End timestamplimit- Maximum number of transactions to returnoffset- Number of transactions to skipunpaid- Whether to include unpaid transactionstype- Transaction type (incoming or outgoing)
Example:
nwcclient <connection URL> list_transactions limit 10 type incoming
sign_message
nwcclient <connection URL> sign_message <message>
message- Message to sign
Example:
nwcclient <connection URL> sign_message "Hello, world!"
Output
The tool prints the JSON response from the wallet service to stdout. If an error occurs, an error message is printed to stderr.
Limitations
- The tool only supports methods that have direct client methods in the nwc package.
- Complex parameters like metadata are not supported.
- The tool does not support interactive authentication or authorization.