Class NWCWallet

java.lang.Object
org.ngengine.wallets.nip47.NWCWallet
All Implemented Interfaces:
Wallet

public class NWCWallet extends Object implements Wallet
  • Field Details

    • INFO_KIND

      public static final int INFO_KIND
      See Also:
    • REQUEST_KIND

      public static final int REQUEST_KIND
      See Also:
    • RESPONSE_KIND

      public static final int RESPONSE_KIND
      See Also:
    • NOTIFICATION_KIND

      public static final int NOTIFICATION_KIND
      See Also:
    • pool

      protected final NostrPool pool
    • uri

      protected final NWCUri uri
    • supportedMethods

      protected volatile org.ngengine.platform.AsyncTask<List<String>> supportedMethods
    • tempPool

      protected boolean tempPool
    • closer

      protected Runnable closer
  • Constructor Details

  • Method Details

    • close

      public void close()
      Description copied from interface: Wallet
      Close the wallet and release any resources.
      Specified by:
      close in interface Wallet
    • getSupportedMethods

      public org.ngengine.platform.AsyncTask<List<String>> getSupportedMethods()
    • payInvoice

      public org.ngengine.platform.AsyncTask<PayResponse> payInvoice(@Nonnull String invoice, @Nullable Long amountMsats, @Nullable Instant expireRequestAt)
      Description copied from interface: Wallet
      Pay a lightning invoice
      Specified by:
      payInvoice in interface Wallet
      Parameters:
      invoice - the lightning invoice to pay
      amountMsats - the amount in millisatoshis to pay, or null to use the invoice amount
      expireRequestAt - an optional Instant to expire the request at, or null for no expiration
      Returns:
      an AsyncTask that resolves to a PayResponse containing the payment result
    • keySend

      public org.ngengine.platform.AsyncTask<NWCKeysendResponse> keySend(@Nullable String id, long amountMsats, @Nonnull String pubkey, @Nullable String preimage, @Nullable List<NWCTLVRecord> tlvRecords, @Nullable Instant expireRequestAt)
    • makeInvoice

      public org.ngengine.platform.AsyncTask<InvoiceData> makeInvoice(InvoiceProperties req, @Nullable Instant expireRequestAt)
      Description copied from interface: Wallet
      Create a lightning invoice
      Specified by:
      makeInvoice in interface Wallet
      Parameters:
      req - the properties for the invoice to create
      expireRequestAt - an optional Instant to expire the request at, or null for no expiration
      Returns:
    • lookupInvoice

      public org.ngengine.platform.AsyncTask<InvoiceData> lookupInvoice(@Nullable String paymentHash, @Nullable String invoice, @Nullable Instant expireRequestAt)
      Description copied from interface: Wallet
      Lookup an invoice by payment hash or invoice string.
      Specified by:
      lookupInvoice in interface Wallet
      Parameters:
      paymentHash - the payment hash to lookup, or null if not available
      invoice - the invoice string to lookup, or null if not available
      expireRequestAt - an optional Instant to expire the request at, or null for no expiration
      Returns:
      an AsyncTask that resolves to an InvoiceData containing the invoice details
    • listTransactions

      public org.ngengine.platform.AsyncTask<List<TransactionInfo>> listTransactions(@Nullable Instant from, @Nullable Instant until, @Nullable Integer limit, @Nullable Integer offset, boolean includeUnpaid, @Nullable TransactionType type, @Nullable Instant expireRequestAt)
      Description copied from interface: Wallet
      List transactions in the wallet.
      Specified by:
      listTransactions in interface Wallet
      Parameters:
      from - the start time to filter transactions from, or null for no start time
      until - the end time to filter transactions until, or null for no end time
      limit - the maximum number of transactions to return, or null for no limit
      offset - the offset to start returning transactions from, or null for no offset
      includeUnpaid - whether to include unpaid transactions, or false to exclude them
      type - the type of transactions to filter by, or null for all types
      expireRequestAt - an optional Instant to expire the request at, or null for no expiration
      Returns:
      an AsyncTask that resolves to a List of TransactionInfo containing the transactions
    • getBalance

      public org.ngengine.platform.AsyncTask<Long> getBalance(@Nullable Instant expireRequestAt)
      Description copied from interface: Wallet
      Get the msats balance of the wallet.
      Specified by:
      getBalance in interface Wallet
      Parameters:
      expireRequestAt - an optional Instant to expire the request at, or null for no expiration
      Returns:
      an AsyncTask that resolves to the balance in millisatoshis
    • getInfo

      public org.ngengine.platform.AsyncTask<WalletInfo> getInfo(@Nullable Instant expireRequestAt)
      Description copied from interface: Wallet
      Get information about the wallet.
      Specified by:
      getInfo in interface Wallet
      Parameters:
      expireRequestAt - an optional Instant to expire the request at, or null for no expiration
      Returns:
      an AsyncTask that resolves to a WalletInfo containing the wallet details
    • isReady

      public boolean isReady()
      Description copied from interface: Wallet
      Check if the wallet is ready to use.
      Specified by:
      isReady in interface Wallet
      Returns:
      true if the wallet is ready, false otherwise
    • waitForReady

      public org.ngengine.platform.AsyncTask<Boolean> waitForReady()
      Description copied from interface: Wallet
      Wait for the wallet to be ready.
      Specified by:
      waitForReady in interface Wallet
      Returns:
      an AsyncTask that resolves to true if the wallet is ready, false if it failed to become ready
    • isMethodSupported

      public org.ngengine.platform.AsyncTask<Boolean> isMethodSupported(Wallet.Methods method)
      Description copied from interface: Wallet
      Check if a specific method is supported by the wallet.
      Specified by:
      isMethodSupported in interface Wallet
      Parameters:
      method - the method to check support for
      Returns:
      an AsyncTask that resolves to true if the method is supported, false otherwise