Skip to content
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

CLN support, first draft #125

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .env.mint.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ MINTING_MAX_AMOUNT=50000
# max melt amount (in sats)
MELTING_MAX_AMOUNT=50000

# Lightning Backend - Lnd, FakeBackend (FOR TESTING ONLY)
# Lightning Backend - Lnd, CLN, FakeBackend (FOR TESTING ONLY)
LIGHTNING_BACKEND="Lnd"

# LND
LND_GRPC_HOST="127.0.0.1:10001"
LND_CERT_PATH="/path/to/tls/cert"
LND_MACAROON_PATH="/path/to/macaroon"

# CLN
CLN_REST_URL="http://127.0.0.1:3030"
CLN_REST_RUNE="cln_rune_here" #change to path to rune later

# enable MPP/NUT-15 (disabled by default)
# ENABLE_MPP=TRUE
25 changes: 24 additions & 1 deletion cmd/mint/mint.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func configFromEnv() (*mint.Config, error) {
var lightningClient lightning.Client
switch os.Getenv("LIGHTNING_BACKEND") {
case "Lnd":
// read values for setting up LND
// Existing LND setup code remains unchanged
host := os.Getenv("LND_GRPC_HOST")
if host == "" {
return nil, errors.New("LND_GRPC_HOST cannot be empty")
Expand Down Expand Up @@ -167,8 +167,31 @@ func configFromEnv() (*mint.Config, error) {
if err != nil {
return nil, fmt.Errorf("error setting LND client: %v", err)
}

case "CLN":
// CLN setup
restURL := os.Getenv("CLN_REST_URL")
if restURL == "" {
return nil, errors.New("CLN_REST_URL cannot be empty")
}
runeToken := os.Getenv("CLN_REST_RUNE")
if runeToken == "" {
return nil, errors.New("CLN_REST_RUNE cannot be empty")
}

clnConfig := lightning.CLNConfig{
RestURL: restURL,
Rune: runeToken,
}

lightningClient, err = lightning.SetupCLNClient(clnConfig)
if err != nil {
return nil, fmt.Errorf("error setting up CLN client: %v", err)
}

case "FakeBackend":
lightningClient = &lightning.FakeBackend{}

default:
return nil, errors.New("invalid lightning backend")
}
Expand Down
Loading