Nwc class
Main entry point for the NWC (Nostr Wallet Connect - NIP47 ) usecase
Multiple Relay Support
NWC now supports multiple relays for improved reliability and redundancy.
URI Formats:
- Single relay:
nostr+walletconnect://pubkey?relay=wss://relay.com&secret=secret - Multiple relays:
nostr+walletconnect://pubkey?relays=wss://relay1.com,wss://relay2.com&secret=secret - Mixed format:
nostr+walletconnect://pubkey?relay=wss://relay1.com&relays=wss://relay2.com,wss://relay3.com&secret=secret
When connecting to an NWC wallet with multiple relays, the client will:
- Query all relays for the wallet info (kind 13194)
- Subscribe to notifications and responses on all relays
- Broadcast requests to all relays for redundancy
This provides better reliability in case some relays are offline or unreachable.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancelHoldInvoice(
NwcConnection connection, {required String paymentHash}) → Future< NwcResponse> -
Does a
cancel_hold_invoicerequest -
connect(
String uri, {bool doGetInfoMethod = false, bool useETagForEachRequest = false, bool ignoreCapabilitiesCheck = false, dynamic onError(String?)?, Duration? timeout}) → Future< NwcConnection> -
Connects to a given nostr+walletconnect:// uri,
checking for 13194 event info,
and optionally doing a
get_inforequest (default false). It subscribes for notifications -
disconnect(
NwcConnection connection) → Future< void> - Disconnects everything related to this connection, i.e.: closes response & notification subscription and streams
-
disconnectAll(
) → Future< void> - Disconnects all NWC connections
-
getBalance(
NwcConnection connection, {Duration? timeout}) → Future< GetBalanceResponse> -
Does a
get_balancerequest -
getBudget(
NwcConnection connection) → Future< GetBudgetResponse> -
Does a
get_balancerequest -
getInfo(
NwcConnection connection, {Duration? timeout}) → Future< GetInfoResponse> -
Does a
get_inforequest for returning node detailed info -
listTransactions(
NwcConnection connection, {int? from, int? until, int? limit, int? offset, required bool unpaid, TransactionType? type}) → Future< ListTransactionsResponse> -
Does a
list_transactionsrequest -
lookupInvoice(
NwcConnection connection, {String? paymentHash, String? invoice}) → Future< LookupInvoiceResponse> -
Does a
lookup_invoicerequest -
makeHoldInvoice(
NwcConnection connection, {required int amountSats, String? description, String? descriptionHash, int? expiry, required String paymentHash}) → Future< MakeInvoiceResponse> -
Does a
make_hold_invoicerequest -
makeInvoice(
NwcConnection connection, {required int amountSats, String? description, String? descriptionHash, int? expiry}) → Future< MakeInvoiceResponse> -
Does a
make_invoicerequest -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
payInvoice(
NwcConnection connection, {required String invoice, Duration? timeout}) → Future< PayInvoiceResponse> -
Does a
pay_invoicerequest -
settleHoldInvoice(
NwcConnection connection, {required String preimage}) → Future< NwcResponse> -
Does a
settle_hold_invoicerequest -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- kNWCProtocolPrefix → const String