-
Notifications
You must be signed in to change notification settings - Fork 102
feat: add CLN backend #2026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
daywalker90
wants to merge
24
commits into
getAlby:master
Choose a base branch
from
daywalker90:cln-backend
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: add CLN backend #2026
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
fe7dcb4
feat: add CLN as a lnclient backend
daywalker90 257235d
feat: add hold invoice support for CLN backend
daywalker90 bcaa738
fix: reduce CLN form to just addresses and lightning dir
daywalker90 291a710
feat: add README for CLN grpc go code generation
daywalker90 5674e99
fix: cln backend does not support keysend with given preimages
daywalker90 882dd2b
fix: hold invoice notifications in CLN backend
daywalker90 ebb81b7
fix: remove dead code in CLN backend from ListTransactions
daywalker90 1a0f8ec
fix: env example CLN_ADDRESS_HOLD with different port to show it's a …
daywalker90 3a7fea0
fix: cleanup of CLN ressources in all cases
daywalker90 b8ddad8
fix: cln backend's GetNetworkGraph only fetches specified nodeId's
daywalker90 ad22bb0
fix: cln backend: only advertise hold methods for nip47 if hold plugi…
daywalker90 6642d3b
fix: cln's Shutdown should not stop CLN itself
daywalker90 10f039a
fix: relax the LND README line regarding env configuration
daywalker90 3af02db
fix: more nil checks in clnInvoiceToTransaction
daywalker90 4aec969
fix: prevent feerate overflow in CLN's RedeemOnchainFunds
daywalker90 acf11bd
fix: don't access nil errors for empty reponses of certain CLN methods
daywalker90 43b6b2b
fix: nil instead of empty string in cln's GetNetworkGraph return types
daywalker90 efcd091
fix: nil checks for created_at in cln's clnInvoiceToTransaction
daywalker90 bae7f10
fix: set minimum tls version to 1.2 for cln backend grpc connections
daywalker90 081c687
fix: cln's subscribeOpenHoldInvoices doesn't give up as fast
daywalker90 70d007a
fix: deduplicate graph edges in cln's GetNetworkGraph
daywalker90 3956b19
fix: print the error string, not pointer address, in cln's ListChannels
daywalker90 157293c
fix: remove cln's ListTransactions completely
daywalker90 bcfc82e
fix: use ListPeers instead of ListPeerChannels in cln's ListPeers
daywalker90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import React from "react"; | ||
| import { useNavigate } from "react-router-dom"; | ||
| import Container from "src/components/Container"; | ||
| import TwoColumnLayoutHeader from "src/components/TwoColumnLayoutHeader"; | ||
| import { Button } from "src/components/ui/button"; | ||
| import { Input } from "src/components/ui/input"; | ||
| import { Label } from "src/components/ui/label"; | ||
| import useSetupStore from "src/state/SetupStore"; | ||
|
|
||
| export function CLNForm() { | ||
daywalker90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const navigate = useNavigate(); | ||
| const setupStore = useSetupStore(); | ||
| const [clnAddress, setClnAddress] = React.useState<string>( | ||
| setupStore.nodeInfo.clnAddress || "" | ||
| ); | ||
| const [clnLightningDir, setClnLightningDir] = React.useState<string>( | ||
| setupStore.nodeInfo.clnLightningDir || "" | ||
| ); | ||
| const [clnAddressHold, setClnAddressHold] = React.useState<string>( | ||
| setupStore.nodeInfo.clnAddressHold || "" | ||
| ); | ||
|
|
||
| // TODO: proper onboarding | ||
| function onSubmit(e: React.FormEvent) { | ||
| e.preventDefault(); | ||
| handleSubmit({ | ||
| clnAddress, | ||
| clnLightningDir, | ||
| clnAddressHold, | ||
| }); | ||
| } | ||
|
|
||
| async function handleSubmit(data: object) { | ||
| setupStore.updateNodeInfo({ | ||
| backendType: "CLN", | ||
| ...data, | ||
| }); | ||
| navigate("/setup/security"); | ||
| } | ||
|
|
||
| return ( | ||
| <Container> | ||
| <TwoColumnLayoutHeader | ||
| title="Configure CLN" | ||
| description="Fill out wallet details to finish setup." | ||
| /> | ||
| <form className="w-full grid gap-5 mt-6" onSubmit={onSubmit}> | ||
| <div className="grid gap-1.5"> | ||
| <Label htmlFor="cln-address">CLN Address (GRPC)</Label> | ||
| <Input | ||
| required | ||
| name="cln-address" | ||
| onChange={(e) => setClnAddress(e.target.value)} | ||
| value={clnAddress} | ||
| id="cln-address" | ||
| /> | ||
| </div> | ||
| <div className="grid gap-1.5"> | ||
| <Label htmlFor="cln-lightning-dir"> | ||
| CLN Lightning directory (full path) | ||
| </Label> | ||
| <Input | ||
| required | ||
| name="cln-lightning-dir" | ||
| onChange={(e) => setClnLightningDir(e.target.value)} | ||
| value={clnLightningDir} | ||
| type="text" | ||
| id="cln-lightning-dir" | ||
| /> | ||
| </div> | ||
| <div className="grid gap-1.5"> | ||
| <Label htmlFor="cln-address-hold"> | ||
| (optional) CLN hold plugin Address (GRPC) | ||
| </Label> | ||
| <Input | ||
| name="cln-address-hold" | ||
| onChange={(e) => setClnAddressHold(e.target.value)} | ||
| value={clnAddressHold} | ||
| id="cln-address-hold" | ||
| /> | ||
| </div> | ||
| <Button>Next</Button> | ||
| </form> | ||
| </Container> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| ## Generating Go gRPC Code | ||
|
|
||
| The Go gRPC bindings for Core Lightning (CLN) are generated from proto files that live | ||
| in the **lightning** repository (`cln-grpc`) and in the **hold** plugin repository. | ||
|
|
||
| The generated Go files are written into the **hub** repository under `lnclient/cln/clngrpc` and `lnclient/cln/clngrpc_hold`. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| Make sure the following tools are installed: | ||
|
|
||
| ```bash | ||
| # protoc (>= 3.20 recommended) | ||
| protoc --version | ||
|
|
||
| # Go plugins | ||
| go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | ||
| go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | ||
| ``` | ||
|
|
||
| Ensure `$GOPATH/bin` is in your `PATH`: | ||
|
|
||
| ```bash | ||
| export PATH="$PATH:$(go env GOPATH)/bin" | ||
| ``` | ||
|
|
||
| This guide assumes the following directory structure: | ||
|
|
||
| ``` | ||
| ~/dev/ | ||
| ├── lightning/ | ||
| │ └── cln-grpc/ | ||
| │ └── proto/ | ||
| │ ├── node.proto | ||
| │ ├── primitives.proto | ||
| │ └── ... | ||
| ├── hub/ | ||
| | └── lnclient/ | ||
| | └── cln/ | ||
| | └── clngrpc/ | ||
| | └── clngrpc_hold/ | ||
| └── hold/ | ||
| └── protos/ | ||
| └── hold.proto | ||
| ``` | ||
|
|
||
| ### Generating Go code | ||
|
|
||
| From the hub repository root, run: | ||
|
|
||
| ```bash | ||
| protoc \ | ||
| --proto_path=../lightning/cln-grpc/proto \ | ||
| --go_out=./lnclient/cln/clngrpc \ | ||
| --go_opt=paths=source_relative \ | ||
| --go_opt=Mprimitives.proto=github.com/getAlby/hub/lnclient/cln/clngrpc \ | ||
| --go_opt=Mnode.proto=github.com/getAlby/hub/lnclient/cln/clngrpc \ | ||
| --go-grpc_out=./lnclient/cln/clngrpc \ | ||
| --go-grpc_opt=paths=source_relative \ | ||
| ../lightning/cln-grpc/proto/node.proto \ | ||
| ../lightning/cln-grpc/proto/primitives.proto | ||
| ``` | ||
|
|
||
| and if you have the hold plugin repo: | ||
|
|
||
| ```bash | ||
| protoc \ | ||
| --proto_path=../hold/protos \ | ||
| --go_out=./lnclient/cln/clngrpc_hold \ | ||
| --go_opt=paths=source_relative \ | ||
| --go_opt=Mhold.proto=github.com/getAlby/hub/lnclient/cln/clngrpc_hold \ | ||
| --go-grpc_out=./lnclient/cln/clngrpc_hold \ | ||
| --go-grpc_opt=paths=source_relative \ | ||
| ../hold/protos/hold.proto | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.