Documentation
¶
Overview ¶
Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
Index ¶
- type LightsparkClient
- func (client *LightsparkClient) CreateApiToken(name string, transact bool, testMode bool) (*scripts.CreateApiTokenOutput, error)
- func (client *LightsparkClient) CreateInvoice(nodeId string, amountMsats int64, memo *string, ...) (*objects.Invoice, error)
- func (client *LightsparkClient) CreateLnurlInvoice(nodeId string, amountMsats int64, metadata string, expirySecs *int32) (*objects.Invoice, error)
- func (client *LightsparkClient) CreateNodeWalletAddress(nodeId string) (string, error)
- func (client *LightsparkClient) CreateTestModeInvoice(localNodeId string, amountMsats int64, memo *string, ...) (*string, error)
- func (client *LightsparkClient) CreateTestModePayment(localNodeId string, encodedInvoice string, amountMsats *int64) (*objects.IncomingPayment, error)
- func (client *LightsparkClient) CreateUmaInvoice(nodeId string, amountMsats int64, metadata string, expirySecs *int32) (*objects.Invoice, error)
- func (client *LightsparkClient) DecodePaymentRequest(encodedPaymentRequest string) (*objects.PaymentRequestData, error)
- func (client *LightsparkClient) DeleteApiToken(apiTokenId string) error
- func (client *LightsparkClient) ExecuteGraphqlRequest(document string, variables map[string]interface{}) (map[string]interface{}, error)
- func (client *LightsparkClient) FundNode(nodeId string, amountSats int64) (*objects.CurrencyAmount, error)
- func (client *LightsparkClient) GetBitcoinFeeEstimate(bitcoinNetwork objects.BitcoinNetwork) (*objects.FeeEstimate, error)
- func (client *LightsparkClient) GetCurrentAccount() (*objects.Account, error)
- func (client *LightsparkClient) GetEntity(id string) (*objects.Entity, error)
- func (client *LightsparkClient) GetLightningFeeEstimateForInvoice(nodeId string, encodedInvoice string, amountMsats *int64) (*objects.LightningFeeEstimateOutput, error)
- func (client *LightsparkClient) GetLightningFeeEstimateForNode(nodeId string, destinationNodePublicKey string, amountMsats int64) (*objects.LightningFeeEstimateOutput, error)
- func (client *LightsparkClient) GetNodeChannelUtxos(nodeId string) ([]string, error)
- func (client *LightsparkClient) LoadNodeSigningKey(nodeId string, loader SigningKeyLoader)
- func (client *LightsparkClient) PayInvoice(nodeId string, encodedInvoice string, timeoutSecs int, maximumFeesMsats int64, ...) (*objects.OutgoingPayment, error)
- func (client *LightsparkClient) PayUmaInvoice(nodeId string, encodedInvoice string, timeoutSecs int, maximumFeesMsats int64, ...) (*objects.OutgoingPayment, error)
- func (client *LightsparkClient) RegisterPayment(provider objects.ComplianceProvider, paymentId string, nodePubkey string, ...) error
- func (client *LightsparkClient) RequestWithdrawal(nodeId string, amountSats int64, bitcoinAddress string, ...) (*objects.WithdrawalRequest, error)
- func (client *LightsparkClient) ScreenNode(provider objects.ComplianceProvider, nodePubkey string) (*objects.RiskRating, error)
- func (client *LightsparkClient) SendPayment(nodeId string, destinationPublicKey string, amountMsats int64, timeoutSecs int, ...) (*objects.OutgoingPayment, error)
- type SigningKeyLoader
- func NewSigningKeyLoaderFromNodeIdAndPassword(nodeId string, password string) *SigningKeyLoader
- func NewSigningKeyLoaderFromRsaPrivateKey(rsaPrivateKeyBytes []byte) *SigningKeyLoader
- func NewSigningKeyLoaderFromSignerMasterSeed(masterSeedBytes []byte, network objects.BitcoinNetwork) *SigningKeyLoader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LightsparkClient ¶
type LightsparkClient struct { Requester *requester.Requester // contains filtered or unexported fields }
func NewLightsparkClient ¶
func NewLightsparkClient(apiTokenClientId string, apiTokenClientSecret string, baseUrl *string) *LightsparkClient
NewLightsparkClient creates a new LightsparkClient instance
Args:
apiTokenClientId: the client id of the API token apiTokenClientSecret: the client secret of the API token baseUrl: the base url of the Lightspark API
func (*LightsparkClient) CreateApiToken ¶
func (client *LightsparkClient) CreateApiToken(name string, transact bool, testMode bool) (*scripts.CreateApiTokenOutput, error)
CreateApiToken creates a new API token that can be used to authenticate requests for this account when using the Lightspark APIs and SDKs.
Args:
name: the name of the API token transact: whether the API token should be able to used to initiate transactions testMode: whether the API token should be created for test mode or Mainnet mode
func (*LightsparkClient) CreateInvoice ¶
func (client *LightsparkClient) CreateInvoice(nodeId string, amountMsats int64, memo *string, invoiceType *objects.InvoiceType, expirySecs *int32) (*objects.Invoice, error)
CreateInvoice generates a Lightning Invoice (follows the Bolt 11 specification) to request a payment from another Lightning Node.
Args:
nodeId: the id of the node that should be paid amountMsats: the amount of the invoice in millisatoshis memo: the memo of the invoice invoiceType: the type of the invoice expirySecs: the expiry of the invoice in seconds. Default value is 86400 (1 day).
func (*LightsparkClient) CreateLnurlInvoice ¶
func (client *LightsparkClient) CreateLnurlInvoice(nodeId string, amountMsats int64, metadata string, expirySecs *int32) (*objects.Invoice, error)
CreateLnurlInvoice creates a new LNURL invoice. The metadata is hashed and included in the invoice. This API generates a Lightning Invoice (follows the Bolt 11 specification) to request a payment from another Lightning Node. This should only be used for generating invoices for LNURLs, with `create_invoice` preferred in the general case.
Args:
nodeId: the id of the node that should be paid amountMsats: the amount of the invoice in millisatoshis metadata: the metadata to include with the invoice expirySecs: the expiry of the invoice in seconds. Default value is 86400 (1 day)
func (*LightsparkClient) CreateNodeWalletAddress ¶
func (client *LightsparkClient) CreateNodeWalletAddress(nodeId string) (string, error)
CreateNodeWalletAddress creates a Bitcoin address for the wallet associated with your Lightning Node. You can use this address to send funds to your node. It is a best practice to generate a new wallet address every time you need to send money. You can generate as many wallet addresses as you want.
func (*LightsparkClient) CreateTestModeInvoice ¶
func (client *LightsparkClient) CreateTestModeInvoice(localNodeId string, amountMsats int64, memo *string, invoiceType *objects.InvoiceType) (*string, error)
CreateTestModeInvoice In test mode, generates a Lightning Invoice which can be paid by a local node. This is useful for testing your integration with Lightspark.
Args:
localNodeId: the id of the node that will pay the invoice amountMsats: the amount of the invoice in millisatoshis memo: the memo of the invoice invoiceType: the type of the invoice
func (*LightsparkClient) CreateTestModePayment ¶
func (client *LightsparkClient) CreateTestModePayment(localNodeId string, encodedInvoice string, amountMsats *int64) (*objects.IncomingPayment, error)
CreateTestModePayment In test mode, simulates a payment from other node to an invoice. This is useful for testing your integration with Lightspark.
Args:
localNodeId: The node to where you want to send the payment. encodedInvoice: The invoice you want to be paid (as defined by the BOLT11 standard). amountMsats: The amount you will be paid for this invoice, expressed in msats. It should ONLY be set when the invoice amount is zero.
func (*LightsparkClient) CreateUmaInvoice ¶
func (client *LightsparkClient) CreateUmaInvoice(nodeId string, amountMsats int64, metadata string, expirySecs *int32) (*objects.Invoice, error)
CreateUmaInvoice creates a new invoice for the UMA protocol. The metadata is hashed and included in the invoice. This API generates a Lightning Invoice (follows the Bolt 11 specification) to request a payment from another Lightning Node. This should only be used for generating invoices for UMA, with `create_invoice` preferred in the general case.
Args:
nodeId: the id of the node that should be paid amountMsats: the amount of the invoice in millisatoshis metadata: the metadata to include with the invoice expirySecs: the expiry of the invoice in seconds. Default value is 86400 (1 day)
func (*LightsparkClient) DecodePaymentRequest ¶
func (client *LightsparkClient) DecodePaymentRequest(encodedPaymentRequest string) (*objects.PaymentRequestData, error)
DecodePaymentRequest decodes the content of an encoded payment request into structured data that can be used by the client.
Args:
encodedPaymentRequest: The encoded payment request.
func (*LightsparkClient) DeleteApiToken ¶
func (client *LightsparkClient) DeleteApiToken(apiTokenId string) error
DeleteApiToken deletes an existing API token from this account.
Args:
apiTokenId: The id of the API token to delete.
func (*LightsparkClient) ExecuteGraphqlRequest ¶
func (client *LightsparkClient) ExecuteGraphqlRequest(document string, variables map[string]interface{}) (map[string]interface{}, error)
ExecuteGraphqlRequest executes a GraphQL request.
Args:
document: The GraphQL document that you want to execute. variables: The variables that you want to pass to the GraphQL document.
func (*LightsparkClient) FundNode ¶
func (client *LightsparkClient) FundNode(nodeId string, amountSats int64) ( *objects.CurrencyAmount, error)
FundNode adds funds to a Lightspark node on the REGTEST network. If the amount is not specified, 10,000,000 SATOSHI will be added. This API only functions for nodes created on the REGTEST network and will return an error when called for any non-REGTEST node.
Args:
nodeId: The id of the node to fund. amountSats: The amount of funds to add to the node, in SATOSHI.
func (*LightsparkClient) GetBitcoinFeeEstimate ¶
func (client *LightsparkClient) GetBitcoinFeeEstimate( bitcoinNetwork objects.BitcoinNetwork) (*objects.FeeEstimate, error)
GetBitcoinFeeEstimate returns an estimate of the fees of a transaction on the Bitcoin Network.
Args:
bitcoinNetwork: The Bitcoin network to use for the estimate.
func (*LightsparkClient) GetCurrentAccount ¶
func (client *LightsparkClient) GetCurrentAccount() (*objects.Account, error)
GetCurrentAccount returns the current connected account.
func (*LightsparkClient) GetEntity ¶
func (client *LightsparkClient) GetEntity(id string) (*objects.Entity, error)
GetEntity returns any `Entity`, identified by its unique ID.
Args:
id: The unique ID of the entity.
func (*LightsparkClient) GetLightningFeeEstimateForInvoice ¶
func (client *LightsparkClient) GetLightningFeeEstimateForInvoice(nodeId string, encodedInvoice string, amountMsats *int64) (*objects.LightningFeeEstimateOutput, error)
GetLightningFeeEstimateForInvoice returns an estimate of the fees that will be paid for a Lightning invoice.
Args:
nodeId: The node from where you want to send the payment encodedInvoice: The invoice you want to pay (as defined by the BOLT11 standard). amountMsats: If the invoice does not specify a payment amount, then the amount that you wish to pay, expressed in msats.
func (*LightsparkClient) GetLightningFeeEstimateForNode ¶
func (client *LightsparkClient) GetLightningFeeEstimateForNode(nodeId string, destinationNodePublicKey string, amountMsats int64) (*objects.LightningFeeEstimateOutput, error)
GetLightningFeeEstimateForNode returns an estimate of the fees that will be paid to send a payment to another Lightning node.
Args:
nodeId: The node from where you want to send the payment. destinationNodePublicKey: The public key of the node that you want to pay. amountMsats: The amount that you wish to pay, expressed in msats.
func (*LightsparkClient) GetNodeChannelUtxos ¶
func (client *LightsparkClient) GetNodeChannelUtxos(nodeId string) ([]string, error)
GetNodeChannelUtxos returns the utxos of all channels of a node.
Args: nodeId: The id of the node whose utxos will be fetched.
func (*LightsparkClient) LoadNodeSigningKey ¶
func (client *LightsparkClient) LoadNodeSigningKey(nodeId string, loader SigningKeyLoader)
LoadNodeSigningKey loads the signing key of a node into the client.
Args:
nodeId: The ID of the node. loader: The SigningKeyLoader that can load the node's key.
func (*LightsparkClient) PayInvoice ¶
func (client *LightsparkClient) PayInvoice(nodeId string, encodedInvoice string, timeoutSecs int, maximumFeesMsats int64, amountMsats *int64) (*objects.OutgoingPayment, error)
PayInvoice sends a payment to a node on the Lightning Network, based on the invoice (as defined by the BOLT11 specification) that you provide. If you are in test mode, the invoice has to be generated by create_test_mode_invoice mutation.
Args:
nodeId: The node from where you want to send the payment. encodedInvoice: The invoice you want to pay (as defined by the BOLT11 standard). timeoutSecs: The number of seconds that you are willing to wait for the payment to complete. maximumFeesMsats: The maximum amount of fees that you are willing to pay for this payment, expressed in mSATs. amountMsats: The amount you will pay for this invoice, expressed in msats. It should ONLY be set when the invoice amount is zero.
func (*LightsparkClient) PayUmaInvoice ¶
func (client *LightsparkClient) PayUmaInvoice(nodeId string, encodedInvoice string, timeoutSecs int, maximumFeesMsats int64, amountMsats *int64) (*objects.OutgoingPayment, error)
PayUmaInvoice sends an UMA payment to a node on the Lightning Network, based on the invoice (as defined by the BOLT11 specification) that you provide. This should only be used for paying UMA invoices, with `pay_invoice` preferred in the general case.
Args:
nodeId: The node from where you want to send the payment. encodedInvoice: The invoice you want to pay (as defined by the BOLT11 standard). timeoutSecs: The number of seconds that you are willing to wait for the payment to complete. maximumFeesMsats: The maximum amount of fees that you are willing to pay for this payment, expressed in mSATs. amountMsats: The amount you will pay for this invoice, expressed in msats. It should ONLY be set when the invoice amount is zero.
func (*LightsparkClient) RegisterPayment ¶
func (client *LightsparkClient) RegisterPayment(provider objects.ComplianceProvider, paymentId string, nodePubkey string, direction objects.PaymentDirection) error
RegisterPayment registers a succeeded payment with a compliance provider. It should only be called if you have a Chainalysis API Key in settings.
Args:
provider: The provider that you want to use to register the payment. paymentId: The unique id of the payment. nodePubkey: The public key of the counterparty node which is the recipient node if the payment is an outgoing payment and the sender node if the payment is an incoming payment.
func (*LightsparkClient) RequestWithdrawal ¶
func (client *LightsparkClient) RequestWithdrawal(nodeId string, amountSats int64, bitcoinAddress string, withdrawalMode objects.WithdrawalMode) (*objects.WithdrawalRequest, error)
RequestWithdrawal withdraws funds from the account and sends it to the requested bitcoin address. Depending on the chosen mode, it will first take the funds from the wallet, and if applicable, close channels appropriately to recover enough funds. The process is asynchronous and may take up to a few minutes. You can check the progress by polling the `WithdrawalRequest` that is created, or by subscribing to a webhook.
Args:
nodeId: The node from which you'd like to make the withdrawal. amountSats: The amount you want to withdraw from this node in Satoshis. Use the special value -1 to withdrawal all funds from this node. bitcoinAddress: The bitcoin address where you want to receive the funds. withdrawalMode: The mode that will be used to withdraw the funds.
func (*LightsparkClient) ScreenNode ¶
func (client *LightsparkClient) ScreenNode( provider objects.ComplianceProvider, nodePubkey string) (*objects.RiskRating, error)
ScreenNode performs sanction screening on a lightning node against a given provider. It should only be called if you have a Chainalysis API Key in settings.
Args:
provider: The provider that you want to use to perform the screening. nodePubkey: The public key of the node that needs to be screened.
func (*LightsparkClient) SendPayment ¶
func (client *LightsparkClient) SendPayment(nodeId string, destinationPublicKey string, amountMsats int64, timeoutSecs int, maximumFeesMsats int64) (*objects.OutgoingPayment, error)
SendPayment sends a payment directly to a node on the Lightning Network through the public key of the node without an invoice.
Args:
nodeId: The node from where you want to send the payment. destinationPublicKey: The public key of the node that will receive the payment. amountMsats: The amount you will pay for this invoice, expressed in msats. timeoutSecs: The number of seconds that you are willing to wait for the payment to complete. maximumFeesMsats: The maximum amount of fees that you are willing to pay for this payment, expressed in mSATs.
type SigningKeyLoader ¶
type SigningKeyLoader struct {
// contains filtered or unexported fields
}
func NewSigningKeyLoaderFromNodeIdAndPassword ¶
func NewSigningKeyLoaderFromNodeIdAndPassword(nodeId string, password string) *SigningKeyLoader
NewSigningKeyLoaderFromNodeIdAndPassword creates a new SigningKeyLoader from a node ID and password. This cannot be used if you are using remote signing. It is used to recover an RSA operation signing key using the password you chose when setting up your node. For REGTEST nodes, the password is "1234!@#$".
func NewSigningKeyLoaderFromRsaPrivateKey ¶
func NewSigningKeyLoaderFromRsaPrivateKey(rsaPrivateKeyBytes []byte) *SigningKeyLoader
NewSigningKeyLoaderFromRsaPrivateKey creates a new SigningKeyLoader from a raw RSA private key.
func NewSigningKeyLoaderFromSignerMasterSeed ¶
func NewSigningKeyLoaderFromSignerMasterSeed(masterSeedBytes []byte, network objects.BitcoinNetwork) *SigningKeyLoader
NewSigningKeyLoaderFromSignerMasterSeed creates a new SigningKeyLoader from a master seed and network. This should be used if you are using remote signing, rather than an RSA operation signing key.
func (*SigningKeyLoader) LoadSigningKey ¶
func (s *SigningKeyLoader) LoadSigningKey(req requester.Requester) (requester.SigningKey, error)