Package org.ngengine.wallets.nip47
Class NWCWallet
- java.lang.Object
-
- org.ngengine.wallets.nip47.NWCWallet
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ngengine.wallets.Wallet
Wallet.Methods
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Runnable
closer
static int
INFO_KIND
static int
NOTIFICATION_KIND
protected NostrPool
pool
static int
REQUEST_KIND
static int
RESPONSE_KIND
protected org.ngengine.platform.AsyncTask<java.util.List<java.lang.String>>
supportedMethods
protected boolean
tempPool
protected NWCUri
uri
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the wallet and release any resources.org.ngengine.platform.AsyncTask<java.lang.Long>
getBalance(java.time.Instant expireRequestAt)
Get the msats balance of the wallet.org.ngengine.platform.AsyncTask<WalletInfo>
getInfo(java.time.Instant expireRequestAt)
Get information about the wallet.org.ngengine.platform.AsyncTask<java.util.List<java.lang.String>>
getSupportedMethods()
org.ngengine.platform.AsyncTask<java.lang.Boolean>
isMethodSupported(Wallet.Methods method)
Check if a specific method is supported by the wallet.boolean
isReady()
Check if the wallet is ready to use.org.ngengine.platform.AsyncTask<NWCKeysendResponse>
keySend(java.lang.String id, long amountMsats, java.lang.String pubkey, java.lang.String preimage, java.util.List<NWCTLVRecord> tlvRecords, java.time.Instant expireRequestAt)
org.ngengine.platform.AsyncTask<java.util.List<TransactionInfo>>
listTransactions(java.time.Instant from, java.time.Instant until, java.lang.Integer limit, java.lang.Integer offset, boolean includeUnpaid, TransactionType type, java.time.Instant expireRequestAt)
List transactions in the wallet.org.ngengine.platform.AsyncTask<InvoiceData>
lookupInvoice(java.lang.String paymentHash, java.lang.String invoice, java.time.Instant expireRequestAt)
Lookup an invoice by payment hash or invoice string.org.ngengine.platform.AsyncTask<InvoiceData>
makeInvoice(InvoiceProperties req, java.time.Instant expireRequestAt)
Create a lightning invoiceorg.ngengine.platform.AsyncTask<PayResponse>
payInvoice(java.lang.String invoice, java.lang.Long amountMsats, java.time.Instant expireRequestAt)
Pay a lightning invoiceorg.ngengine.platform.AsyncTask<java.lang.Boolean>
waitForReady()
Wait for the wallet to be ready.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ngengine.wallets.Wallet
getBalance, getInfo, listTransactions, lookupInvoice, makeInvoice, payInvoice
-
-
-
-
Field Detail
-
INFO_KIND
public static final int INFO_KIND
- See Also:
- Constant Field Values
-
REQUEST_KIND
public static final int REQUEST_KIND
- See Also:
- Constant Field Values
-
RESPONSE_KIND
public static final int RESPONSE_KIND
- See Also:
- Constant Field Values
-
NOTIFICATION_KIND
public static final int NOTIFICATION_KIND
- See Also:
- Constant Field Values
-
pool
protected final NostrPool pool
-
uri
protected final NWCUri uri
-
supportedMethods
protected org.ngengine.platform.AsyncTask<java.util.List<java.lang.String>> supportedMethods
-
tempPool
protected boolean tempPool
-
closer
protected java.lang.Runnable closer
-
-
Method Detail
-
close
public void close()
Description copied from interface:Wallet
Close the wallet and release any resources.
-
getSupportedMethods
public org.ngengine.platform.AsyncTask<java.util.List<java.lang.String>> getSupportedMethods()
-
payInvoice
public org.ngengine.platform.AsyncTask<PayResponse> payInvoice(@Nonnull java.lang.String invoice, @Nullable java.lang.Long amountMsats, @Nullable java.time.Instant expireRequestAt)
Description copied from interface:Wallet
Pay a lightning invoice- Specified by:
payInvoice
in interfaceWallet
- Parameters:
invoice
- the lightning invoice to payamountMsats
- the amount in millisatoshis to pay, or null to use the invoice amountexpireRequestAt
- 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 java.lang.String id, long amountMsats, @Nonnull java.lang.String pubkey, @Nullable java.lang.String preimage, @Nullable java.util.List<NWCTLVRecord> tlvRecords, @Nullable java.time.Instant expireRequestAt)
-
makeInvoice
public org.ngengine.platform.AsyncTask<InvoiceData> makeInvoice(InvoiceProperties req, @Nullable java.time.Instant expireRequestAt)
Description copied from interface:Wallet
Create a lightning invoice- Specified by:
makeInvoice
in interfaceWallet
- Parameters:
req
- the properties for the invoice to createexpireRequestAt
- an optional Instant to expire the request at, or null for no expiration- Returns:
-
lookupInvoice
public org.ngengine.platform.AsyncTask<InvoiceData> lookupInvoice(@Nullable java.lang.String paymentHash, @Nullable java.lang.String invoice, @Nullable java.time.Instant expireRequestAt)
Description copied from interface:Wallet
Lookup an invoice by payment hash or invoice string.- Specified by:
lookupInvoice
in interfaceWallet
- Parameters:
paymentHash
- the payment hash to lookup, or null if not availableinvoice
- the invoice string to lookup, or null if not availableexpireRequestAt
- 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<java.util.List<TransactionInfo>> listTransactions(@Nullable java.time.Instant from, @Nullable java.time.Instant until, @Nullable java.lang.Integer limit, @Nullable java.lang.Integer offset, boolean includeUnpaid, @Nullable TransactionType type, @Nullable java.time.Instant expireRequestAt)
Description copied from interface:Wallet
List transactions in the wallet.- Specified by:
listTransactions
in interfaceWallet
- Parameters:
from
- the start time to filter transactions from, or null for no start timeuntil
- the end time to filter transactions until, or null for no end timelimit
- the maximum number of transactions to return, or null for no limitoffset
- the offset to start returning transactions from, or null for no offsetincludeUnpaid
- whether to include unpaid transactions, or false to exclude themtype
- the type of transactions to filter by, or null for all typesexpireRequestAt
- 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<java.lang.Long> getBalance(@Nullable java.time.Instant expireRequestAt)
Description copied from interface:Wallet
Get the msats balance of the wallet.- Specified by:
getBalance
in interfaceWallet
- 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 java.time.Instant expireRequestAt)
Description copied from interface:Wallet
Get information about the wallet.
-
isReady
public boolean isReady()
Description copied from interface:Wallet
Check if the wallet is ready to use.
-
waitForReady
public org.ngengine.platform.AsyncTask<java.lang.Boolean> waitForReady()
Description copied from interface:Wallet
Wait for the wallet to be ready.- Specified by:
waitForReady
in interfaceWallet
- 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<java.lang.Boolean> isMethodSupported(Wallet.Methods method)
Description copied from interface:Wallet
Check if a specific method is supported by the wallet.- Specified by:
isMethodSupported
in interfaceWallet
- Parameters:
method
- the method to check support for- Returns:
- an AsyncTask that resolves to true if the method is supported, false otherwise
-
-