Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

19 Commits

Repository files navigation

go eclair

what?

A simple API client for Acinq's Eclairlightning node JSON API

Examples

Some helpful examples are available in the examples folder

Create Invoice

client=client.WithBaseURL("http://localhost:8282")
invoice, err:= client.CreateInvoice({
Description: "Groceries"
Amount: 100000,
})
iferr!=nil {
panic(err)
}
fmt.Println(invoice.Serialized)

Pay Invoice

resp, err:=client.PayInvoice(eclair.PayInvoiceRequest{
Invoice: resp.Serialized,
})
fmt.Println(resp.Message)

Watching Events

It is possible to listen for a handful of events that the node emits. This is done over websocket. Events that be subscribed to:

Event TypeDescription
payment-receivedA payment has been received
payment-relayedA payment has been successfully relayed
payment-sentA payment has been successfully sent
payment-settling-onchainA payment wasn't fulfilled and its HTLC is being redeemed on-chain
payment-failedA payment failed
channel-createdA channel opening flow has started
channel-openedA channel opening flow has completed
channel-state-changedA channel state changed (e.g. going from offline to connected)
channel-closedA channel has been closed
onion-message-receivedAn onion message was received

To open a channel and watch for events

client=client.WithBaseURL("http://localhost:8282") // if you are using polar for a local setupchannel, err:=client.Subscribe()
iferr!=nil {
panic(err)
return
}
// example fo handling eventsformessage:=rangechannel {
switchmessage.Type {
caseeclair.ChannelOpenedEvent:
// handle channel opened eventcaseeclair.ChannelClosedEvent:
// handle channel closed eventcase eclair.PaymentReceivedEvent// handle channel closed event//...etc for all/any message type
}
}

About

go JSON API client for interacting with an Acinq Elcair Lightning node

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages