public abstract class BaseLNDLightningHandler extends java.lang.Object implements LightningHandler
Created by Philip Vendil on 2018-11-24.
Modifier and Type | Field and Description |
---|---|
protected java.util.List<LightningEventListener> |
listeners |
protected static java.util.logging.Logger |
log |
Constructor and Description |
---|
BaseLNDLightningHandler() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkConnection() |
protected void |
clearCache()
Method to clear all cached objects, should be called when reconnecting to LND node.
|
Invoice |
generateInvoice(PreImageData preImageData,
ConvertedOrder paymentData)
Method to create an invoice in the underlying LND node.
|
protected abstract org.lightningj.lnd.wrapper.AsynchronousLndAPI |
getAsyncAPI()
Method to get the asynchronous lnd api from lightningj.
|
protected LNDHelper |
getLndHelper() |
NodeInfo |
getNodeInfo()
Method to fetch the related lightning node's information to include in invoices.
|
protected abstract NodeInfo |
getNodeInfoFromConfiguration()
Method to retrieve node information from configuration or null if not configured.
|
protected abstract java.lang.String |
getSupportedCurrencyCode()
Method to retrieve configured supported currency code.
|
protected abstract org.lightningj.lnd.wrapper.SynchronousLndAPI |
getSyncAPI()
Method to get the synchronous lnd api from lightningj.
|
protected void |
listenToInvoices(LightningHandlerContext context)
Help method that setup invoice subscription with underlying LND node.
|
Invoice |
lookupInvoice(byte[] preImageHash)
Method to lookup an invoice in LND given the invoice's pre-image hash.
|
void |
registerListener(LightningEventListener listener)
Method to register a listener to recieve notification about updated invoices and settled invoices.
|
void |
unregisterListener(LightningEventListener listener)
Method to remove a listener from the list of event listeners of events related to adding or settling
invoices.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, connect, isConnected
protected static java.util.logging.Logger log
protected java.util.List<LightningEventListener> listeners
public Invoice generateInvoice(PreImageData preImageData, ConvertedOrder paymentData) throws java.io.IOException, InternalErrorException
generateInvoice
in interface LightningHandler
preImageData
- the generated pre image and hash to use in invoice.paymentData
- the payment data to generate invoice for.java.io.IOException
- if communication problems occurred with underlying node.InternalErrorException
- if problems occurred generating the invoice.public Invoice lookupInvoice(byte[] preImageHash) throws java.io.IOException, InternalErrorException
lookupInvoice
in interface LightningHandler
preImageHash
- the pre image hash of the invoice to lookup.java.io.IOException
- if communication problems occurred with underlying node.InternalErrorException
- if internal problems occurred communication or parsing invoice with LND node.public void registerListener(LightningEventListener listener) throws InternalErrorException
registerListener
in interface LightningHandler
listener
- the event listener to add to list receiving notifications.InternalErrorException
- if problems occurred registering from listeners.public void unregisterListener(LightningEventListener listener) throws InternalErrorException
unregisterListener
in interface LightningHandler
listener
- the listener to remove from list of listeners.InternalErrorException
- if problems occurred un-registering from listeners.protected void listenToInvoices(LightningHandlerContext context) throws java.io.IOException, InternalErrorException
context
- the related LND context with latest indicies.java.io.IOException
- if communication problems occurred with underlying node.InternalErrorException
- if internal problems occurred with subscribing to LND node.protected void checkConnection() throws java.io.IOException, InternalErrorException
java.io.IOException
InternalErrorException
protected void clearCache()
public NodeInfo getNodeInfo() throws java.io.IOException, InternalErrorException
getNodeInfo
in interface LightningHandler
java.io.IOException
- if communication problems occurred with underlying node.InternalErrorException
- if internal problems occurred closing the connections with lightning node.protected LNDHelper getLndHelper() throws java.io.IOException, InternalErrorException
java.io.IOException
InternalErrorException
protected abstract org.lightningj.lnd.wrapper.AsynchronousLndAPI getAsyncAPI() throws java.io.IOException, InternalErrorException
java.io.IOException
- if communication problems occurred with underlying node.InternalErrorException
- if internal problems occurred with LND node.protected abstract org.lightningj.lnd.wrapper.SynchronousLndAPI getSyncAPI() throws java.io.IOException, InternalErrorException
java.io.IOException
- if communication problems occurred with underlying node.InternalErrorException
- if internal problems occurred with LND node.protected abstract NodeInfo getNodeInfoFromConfiguration() throws InternalErrorException
Used when the LND macaroon doesn't have access rights to retrieve LND Node information.
InternalErrorException
- if problems occurred parsing the configuration.protected abstract java.lang.String getSupportedCurrencyCode() throws InternalErrorException
InternalErrorException
- if currency code configuration was unparsable.