|
Nostrduino
|
#include <NWC.h>
A class to interact with the Nostr Wallet Connect services without dealing with the underlying transport
| NWC::~NWC | ( | ) |
| NWC::NWC | ( | Transport * | transport, |
| NostrString | nwcUrl, | ||
| const NostrLimits & | limits = NostrLimits(), |
||
| NWCEncryptionPolicy | encryptionPolicy = NWCEncryptionPolicy::RequireNip44 |
||
| ) |
Initialize a standalone NWC service
| transport | A transport object, you can get one for the esp32 platform using nostr::esp32::ESP32Platform::getTransport() , for other platforms you need to implement the Transport interface |
| nwcUrl | The NWC connection URL |
| limits | Resource and protocol limits |
| encryptionPolicy | Encryption policy used after the verified NIP-47 info event has been processed |
The default NWCEncryptionPolicy::RequireNip44 requires nip44_v2. A legacy wallet can be enabled explicitly:
| void NWC::getBalance | ( | std::function< void(GetBalanceResponse)> | onRes = nullptr, |
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Get the balance
| onRes | A callback that will be called when the balance is retrieved (optional) |
| onErr | A callback that will be called when the balance retrieval fails (optional) |
|
inline |
The encryption selected from the wallet info event.
| void NWC::getInfo | ( | std::function< void(GetInfoResponse)> | onRes = nullptr, |
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Get the info
| onRes | A callback that will be called when the info is retrieved (optional) |
| onErr | A callback that will be called when the info retrieval fails (optional) |
|
inline |
Whether the wallet info event has been processed and requests can be sent.
| void NWC::listTransactions | ( | unsigned long | from = 0, |
| unsigned long | until = 0, |
||
| int | limit = 0, |
||
| int | offset = 0, |
||
| bool | unpaid = false, |
||
| NostrString | type = "", |
||
| std::function< void(ListTransactionsResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
List transactions
| from | The start time of the transactions to list (optional) |
| until | The end time of the transactions to list (optional) |
| limit | The maximum number of transactions to list (optional) |
| offset | The offset of the transactions to list (optional) |
| unpaid | Whether to list only unpaid transactions (optional) |
| type | The type of transactions to list (optional) |
| onRes | A callback that will be called when the transactions are listed (optional) |
| onErr | A callback that will be called when the transactions listing fails (optional) |
| void NWC::lookUpInvoice | ( | NostrString | invoice, |
| std::function< void(LookUpInvoiceResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Look up an invoice
| invoice | The invoice to look up |
| onRes | A callback that will be called when the invoice is found (optional) |
| onErr | A callback that will be called when the invoice is not found (optional) |
| void NWC::lookUpPaymentHash | ( | NostrString | paymentHash, |
| std::function< void(LookUpInvoiceResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Look up a payment hash
| paymentHash | The payment hash to look up |
| onRes | A callback that will be called when the payment is found (optional) |
| onErr | A callback that will be called when the payment is not found (optional) |
| void NWC::makeInvoice | ( | MilliSats | amount, |
| NostrString | description = "", |
||
| NostrString | descriptionHash = "", |
||
| unsigned long | expiry = 0, |
||
| std::function< void(MakeInvoiceResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Create a lightning invoice
| amount | The amount to invoice |
| description | A description of the invoice (optional) |
| descriptionHash | A hash of the description (optional) |
| expiry | The expiry time of the invoice in seconds (optional) |
| onRes | A callback that will be called when the invoice is created (optional) |
| onErr | A callback that will be called when the invoice creation fails (optional) |
| void NWC::multiPayInvoice | ( | const std::vector< Invoice > & | invoices, |
| std::function< void(MultiPayInvoiceResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
| void NWC::multiPayInvoice | ( | std::initializer_list< Invoice > | invoices, |
| std::function< void(MultiPayInvoiceResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Pay multiple lightning invoices
| invoices | A list of invoices to pay |
| onRes | A callback that will be called when the payment is successful (nb. it will be called once for each invoice) (optional) |
| onErr | A callback that will be called when the payment fails (optional) |
| void NWC::multiPayKeySend | ( | const std::vector< KeySend > & | keySends, |
| std::function< void(MultiPayKeySendResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
| void NWC::multiPayKeySend | ( | std::initializer_list< KeySend > | keySends, |
| std::function< void(MultiPayKeySendResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Send multiple keysend payments
| keySends | A list of keysend payments to send |
| onRes | A callback that will be called when the payment is successful (nb. it will be called once for each keysend) (optional) |
| onErr | A callback that will be called when the payment fails (optional) |
| void NWC::payInvoice | ( | NostrString | invoice, |
| MilliSats | amount = MILLISATS_UNSPECIFIED, |
||
| std::function< void(PayInvoiceResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Pay a lightning invoice
| invoice | The invoice to pay |
| amount | The amount to pay, if not specified the full amount will be paid (optional) |
| onRes | A callback that will be called when the payment is successful (optional) |
| onErr | A callback that will be called when the payment fails (optional) |
| void NWC::payKeySend | ( | NostrString | pubkey, |
| MilliSats | amount, | ||
| NostrString | preimage, | ||
| const std::vector< TLVRecords > & | tlv, | ||
| std::function< void(PayKeySendResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
| void NWC::payKeySend | ( | NostrString | pubkey, |
| MilliSats | amount, | ||
| NostrString | preimage = "", |
||
| std::initializer_list< TLVRecords > | tlv = {}, |
||
| std::function< void(PayKeySendResponse)> | onRes = nullptr, |
||
| std::function< void(NostrString, NostrString)> | onErr = nullptr |
||
| ) |
Send a keysend payment
| pubkey | The pubkey to send to |
| amount | The amount to send |
| preimage | The preimage to use (optional) |
| tlv | A list of TLV records to include (optional) |
| onRes | A callback that will be called when the payment is successful (optional) |
| onErr | A callback that will be called when the payment fails (optional) |
|
inline |
Set the event tracking policy used by the managed pool.
| void NWC::subscribeNotifications | ( | std::function< void(NotificationResponse)> | onRes, |
| std::function< void(NostrString, NostrString)> | onErr | ||
| ) |
Subscribe to payment notifications
| onRes | A callback that will be called when a payment notification is received |
| onErr | A callback that will be called when an error is received (optional) |