Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.22'
go-version: '1.24'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down Expand Up @@ -52,4 +52,4 @@ jobs:
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
# install-mode: "goinstall"
28 changes: 5 additions & 23 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,9 @@ jobs:

- name: Run tests and generate coverage profile
run: go test ./... -coverprofile=coverage.prof

- name: Analyze with SonarQube

# You can pin the exact commit or the version.
# uses: SonarSource/sonarqube-scan-action@master
uses: SonarSource/sonarqube-scan-action@master
env:
- name: Official SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} # Needed to get PR information
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on SonarQube, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} # add the URL of your instance to the secrets of this repo with the name SONAR_HOST_URL (Settings > Secrets > Actions > add new repository secret)
with:
# Additional arguments for the sonarcloud scanner
args:
# Unique key of your project. You can find it in SonarQube > [my project] > Project Information (top-right menu)
# mandatory
-Dsonar.projectKey=flash
# Comma-separated paths to directories containing main source files.
#-Dsonar.sources=.
# When you need the analysis to take place in a directory other than the one from which it was launched
#-Dsonar.projectBaseDir= # optional, default is .
# Comma-separated paths to directories containing test source files.
#-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/
# Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing.
#-Dsonar.verbose= # optional, default is false
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
71 changes: 2 additions & 69 deletions cmd/flash/main.go
Original file line number Diff line number Diff line change
@@ -1,74 +1,7 @@
package main

import (
"context"
"encoding/hex"
"flag"

"github.com/ardevd/flash/internal/credentials"
"github.com/ardevd/flash/internal/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/log"
"github.com/lightninglabs/lndclient"

"os"
)
import "github.com/ardevd/flash/cmd"

func main() {
logger := log.NewWithOptions(os.Stderr, log.Options{})
styles := tui.GetDefaultStyles()
// Arguments
tlsCertFile := flag.String("c", "", "TLS Certificate file")
adminMacaroon := flag.String("m", "", "Admin Macaroon")
authFile := flag.String("a", "", "Authentication file")
encKey := flag.String("k", "", "Encryption key")
rpcServerAddress := flag.String("h", "", "RPC hostname:port")
flag.Parse()

if *tlsCertFile != "" && *adminMacaroon != "" {
encryptionKey := credentials.EncryptCredentials(*tlsCertFile, *adminMacaroon)
log.Info("Encrypted credentials file 'auth.bin' saved.\nEncryption key:" +
styles.Keyword(encryptionKey) + "\n\nauth.bin with the encryption key can now be used to connect to the node")
return
}

if *rpcServerAddress == "" {
log.Fatal("No RPC hostname specified.")
}

var tlsData []byte
var macData []byte
if *authFile != "" && *encKey != "" {
tlsData, macData = credentials.DecryptCredentials(*encKey, *authFile)
} else {
logger.Fatal("Auth file and encryption key required for node connection, alternatively generate them first with -a and -c")
}

// Create a new gRPC client using the provided credentials.
config := lndclient.LndServicesConfig{
LndAddress: *rpcServerAddress,
Network: lndclient.NetworkMainnet,
CustomMacaroonHex: hex.EncodeToString(macData),
TLSData: string(tlsData),
}
client, err := lndclient.NewLndServices(&config)

if err != nil {
logger.Fatal(err)
}

ctx := context.Background()

m := tui.InitLoading(client)
p := tea.NewProgram(m)

go func() {
nodeData := tui.GetData(client, ctx)
p.Send(tui.DataLoaded(nodeData))
}()

if _, err := p.Run(); err != nil {
logger.Fatal("error running program:", err)
os.Exit(1)
}
cmd.Execute()
}
103 changes: 103 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package cmd

import (
"context"
"encoding/hex"
"os"

"github.com/ardevd/flash/internal/credentials"
"github.com/ardevd/flash/internal/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/fang"
"github.com/charmbracelet/log"
"github.com/lightninglabs/lndclient"
"github.com/spf13/cobra"
)

var (
// Used for flags.
tlsCertFile string
adminMacaroon string
authFile string
encKey string
rpcServerAddress string
rootCmd = &cobra.Command{
Use: "flash",
Short: "A TUI based Lightning node management tool",
Long: `Flash is a TUI based Bitcoin Ligthing Network management tool
written in Go.`,

Run: func(cmd *cobra.Command, args []string) {
runApp()
},
}
)

// Execute executes the root command.
func Execute() {
if err := fang.Execute(context.Background(), rootCmd); err != nil {
os.Exit(1)
}
}

func runApp() {

logger := log.NewWithOptions(os.Stderr, log.Options{})
styles := tui.GetDefaultStyles()
if tlsCertFile != "" && adminMacaroon != "" {
encryptionKey := credentials.EncryptCredentials(tlsCertFile, adminMacaroon)
logger.Info("Encrypted credentials file 'auth.bin' saved.\nEncryption key:" +
styles.Keyword(encryptionKey) + "\n\nauth.bin with the encryption key can now be used to connect to the node")
return
}

if rpcServerAddress == "" {
log.Fatal("No RPC hostname specified.")
}

var tlsData []byte
var macData []byte
if authFile != "" && encKey != "" {
tlsData, macData = credentials.DecryptCredentials(encKey, authFile)
} else {
logger.Fatal("Auth file and encryption key required for node connection, alternatively generate them first with -a and -c")
}

// Create a new gRPC client using the provided credentials.
config := lndclient.LndServicesConfig{
LndAddress: rpcServerAddress,
Network: lndclient.NetworkMainnet,
CustomMacaroonHex: hex.EncodeToString(macData),
TLSData: string(tlsData),
}
client, err := lndclient.NewLndServices(&config)

if err != nil {
logger.Fatal(err)
}

ctx := context.Background()

m := tui.InitLoading(client)
p := tea.NewProgram(m)

go func() {
nodeData := tui.GetData(client, ctx)
p.Send(tui.DataLoaded(nodeData))
}()

if _, err := p.Run(); err != nil {
logger.Fatal("error running program:", err)
os.Exit(1)
}
}

func init() {

rootCmd.PersistentFlags().StringVarP(&tlsCertFile, "tlscert", "c", "", "TLS Certificate file")
rootCmd.PersistentFlags().StringVarP(&adminMacaroon, "macaroon", "m", "", "Admin Macaroon")
rootCmd.PersistentFlags().StringVarP(&authFile, "auth", "a", "", "Authentication file")
rootCmd.PersistentFlags().StringVarP(&encKey, "enckey", "k", "", "Encryption key")
rootCmd.PersistentFlags().StringVar(&rpcServerAddress, "host", "", "RPC hostname:port")

}
44 changes: 30 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/ardevd/flash

go 1.22
go 1.24.0

toolchain go1.24.5

require (
github.com/btcsuite/btcd/btcutil v1.1.5
Expand All @@ -14,7 +16,8 @@ require (
github.com/lightningnetwork/lnd v0.17.4-beta.rc1
github.com/muesli/termenv v0.15.2
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/stretchr/testify v1.8.4
github.com/spf13/cobra v1.9.1
github.com/stretchr/testify v1.10.0
)

require (
Expand Down Expand Up @@ -43,8 +46,15 @@ require (
github.com/catppuccin/go v0.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/charmbracelet/colorprofile v0.3.1 // indirect
github.com/charmbracelet/fang v0.3.0 // indirect
github.com/charmbracelet/glamour v0.6.0 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.2 // indirect
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
github.com/charmbracelet/x/exp/charmtone v0.0.0-20250603201427-c31516f43444 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
Expand Down Expand Up @@ -73,6 +83,7 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.0 // indirect
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa // indirect
Expand Down Expand Up @@ -107,7 +118,7 @@ require (
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mholt/archiver/v3 v3.5.0 // indirect
github.com/microcosm-cc/bluemonday v1.0.25 // indirect
Expand All @@ -116,7 +127,11 @@ require (
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/mango v0.1.0 // indirect
github.com/muesli/mango-cobra v1.2.0 // indirect
github.com/muesli/mango-pflag v0.1.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/roff v0.1.0 // indirect
github.com/nwaples/rardecode v1.1.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pierrec/lz4/v4 v4.1.8 // indirect
Expand All @@ -126,19 +141,20 @@ require (
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/fastuuid v1.2.0 // indirect
github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/spf13/pflag v1.0.7 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.6.0 // indirect
github.com/yuin/goldmark-emoji v1.0.2 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
Expand All @@ -160,16 +176,16 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
Expand Down
Loading
Loading