LightsparkFuturesWalletClient

Main entry point for the Lightspark SDK using the Java Futures API.

This client is meant to be used in Java codebases that do not support Kotlin coroutines.

// Initialize the client with oauth:
OAuthHelper oAuthHelper = new OAuthHelper(applicationContext);
LightsparkFuturesWalletClient lightsparkClient = new LightsparkFuturesWalletClient(new ClientConfig(
authProvider = new OAuthProvider(oAuthHelper)
));

// An example API call fetching the dashboard info for the active account:
WalletDashboard dashboard = lightsparkClient.getWalletDashboard().get(5, TimeUnit.SECONDS);

Note: This client object keeps a local cache in-memory, so a single instance should be reused throughout the lifetime of your app.

Constructors

Link copied to clipboard
constructor(config: ClientConfig)

Functions

Link copied to clipboard
fun createBitcoinFundingAddress(): <Error class: unknown class><String>

Creates an L1 Bitcoin wallet address which can be used to deposit or withdraw funds from the Lightning wallet.

Link copied to clipboard
fun createInvoice(amountMsats: Long, memo: String? = null, type: InvoiceType = InvoiceType.STANDARD): <Error class: unknown class><InvoiceData>

Creates a lightning invoice for the current wallet.

Link copied to clipboard
fun decodeInvoice(encodedInvoice: String): <Error class: unknown class><InvoiceData>

Decode a lightning invoice to get its details included payment amount, destination, etc.

Link copied to clipboard
suspend fun deployWallet(): <Error class: unknown class><Wallet>

Deploys a wallet in the Lightspark infrastructure. This is an asynchronous operation, the caller should then poll the wallet frequently (or subscribe to its modifications). When this process is over, the Wallet status will change to DEPLOYED (or FAILED).

Link copied to clipboard
fun <T> executeQuery(query: Query<T>): <Error class: unknown class><T>

Executes a raw graphql query against the server.

Link copied to clipboard
fun getBitcoinFeeEstimate(): <Error class: unknown class><FeeEstimate>

Get the L1 fee estimate for a deposit or withdrawal.

Link copied to clipboard
fun getCurrentWallet(): <Error class: unknown class><Wallet?>
Link copied to clipboard
suspend fun getLightningFeeEstimateForInvoice(encodedPaymentRequest: String, amountMsats: Long? = null): <Error class: unknown class><CurrencyAmount>

Gets an estimate of the fees that will be paid for a Lightning invoice.

Link copied to clipboard
suspend fun getLightningFeeEstimateForNode(destinationNodePublicKey: String, amountMsats: Long): <Error class: unknown class><CurrencyAmount>

Returns an estimate of the fees that will be paid to send a payment to another Lightning node.

Link copied to clipboard
fun getWalletDashboard(numTransactions: Int = 20, numPaymentRequests: Int = 20): <Error class: unknown class><WalletDashboard?>

Get the dashboard overview for a Lightning wallet. Includes balance info and the most recent transactions and payment requests.

Link copied to clipboard
suspend fun initializeWallet(keyType: KeyType, signingPublicKey: String): <Error class: unknown class><Wallet>

Initializes a wallet in the Lightspark infrastructure and syncs it to the Bitcoin network. This is an asynchronous operation, the caller should then poll the wallet frequently (or subscribe to its modifications). When this process is over, the Wallet status will change to READY (or FAILED).

Link copied to clipboard
fun isWalletUnlocked(): <Error class: unknown class><Boolean>
Link copied to clipboard
fun loadWalletSigningKey(signingKeyBytesPEM: ByteArray)

Unlocks the wallet for use with the SDK for the current application session. This function must be called before any other functions that require wallet signing keys, including payInvoice.

Link copied to clipboard
fun loginWithJWT(accountId: String, jwt: String, storage: JwtStorage): <Error class: unknown class><LoginWithJWTOutput>

Login using the Custom JWT authentication scheme described in our documentation.

Link copied to clipboard
fun payInvoice(encodedInvoice: String, maxFeesMsats: Long, amountMsats: Long? = null, timeoutSecs: Int = 60): <Error class: unknown class><OutgoingPayment>

Pay a lightning invoice from the current wallet.

Link copied to clipboard
fun requestWithdrawal(amountSats: Long, bitcoinAddress: String): <Error class: unknown class><WithdrawalRequest>

Withdraws funds from the account and sends it to the requested bitcoin address.

Link copied to clipboard
fun sendPayment(destinationPublicKey: String, amountMsats: Long, maxFeesMsats: Long, timeoutSecs: Int = 60): <Error class: unknown class><OutgoingPayment>

Sends a payment directly to a node on the Lightning Network through the public key of the node without an invoice.

Link copied to clipboard
fun setAuthProvider(authProvider: AuthProvider)

Override the auth token provider for this client to provide custom headers on all API calls.

Link copied to clipboard
suspend fun terminateWallet(): <Error class: unknown class><Wallet>

Removes the wallet from Lightspark infrastructure. It won't be connected to the Lightning network anymore and its funds won't be accessible outside of the Funds Recovery Kit process.