From baeb3687035914f555e2c4e2c49c938866e5a37f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 16:44:03 +0000 Subject: [PATCH 1/3] build(deps): bump github.com/go-viper/mapstructure/v2 --- updated-dependencies: - dependency-name: github.com/go-viper/mapstructure/v2 dependency-version: 2.3.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 44d0587..1ac2424 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/go-errors/errors v1.0.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-viper/mapstructure/v2 v2.2.1 // indirect + github.com/go-viper/mapstructure/v2 v2.3.0 // indirect github.com/gofrs/uuid v4.2.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.2 // indirect diff --git a/go.sum b/go.sum index d835826..099194e 100644 --- a/go.sum +++ b/go.sum @@ -165,8 +165,8 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= -github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk= +github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= From 543ff97c49a5a272b89c34448d860aa15d3ba1e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 07:57:57 +0000 Subject: [PATCH 2/3] build(deps): bump github.com/go-viper/mapstructure/v2 in /tools Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.2.1 to 2.3.0. - [Release notes](https://github.com/go-viper/mapstructure/releases) - [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md) - [Commits](https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.3.0) --- updated-dependencies: - dependency-name: github.com/go-viper/mapstructure/v2 dependency-version: 2.3.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- tools/go.mod | 2 +- tools/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/go.mod b/tools/go.mod index 4b0e23b..530bcae 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -61,7 +61,7 @@ require ( github.com/go-toolsmith/astp v1.1.0 // indirect github.com/go-toolsmith/strparse v1.1.0 // indirect github.com/go-toolsmith/typep v1.1.0 // indirect - github.com/go-viper/mapstructure/v2 v2.2.1 // indirect + github.com/go-viper/mapstructure/v2 v2.3.0 // indirect github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/gofrs/flock v0.12.1 // indirect diff --git a/tools/go.sum b/tools/go.sum index 491f84e..e5364d8 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -191,8 +191,8 @@ github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQi github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ= github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUNHus= github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig= -github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= -github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk= +github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUWY= github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= From 3e14d695c320fc3c8b22b905f88348297f709b72 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 28 Jun 2025 18:25:11 -0300 Subject: [PATCH 3/3] GetInfo: add more fields to response Add fields: CommitHash, BestBlockHash, Color, NumPeers. --- lightning_client.go | 37 +++++++++++++++++++++++++++++++++---- lnd_services_test.go | 1 + 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lightning_client.go b/lightning_client.go index 95c6e71..534f123 100644 --- a/lightning_client.go +++ b/lightning_client.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "errors" "fmt" + "image/color" "io" "sync" "time" @@ -16,6 +17,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" invpkg "github.com/lightningnetwork/lnd/invoices" + "github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" "github.com/lightningnetwork/lnd/lntypes" @@ -316,15 +318,27 @@ type Info struct { // Version is the version that lnd is running. Version string + // CommitHash is the SHA1 commit hash that the daemon is compiled with. + CommitHash string + // BlockHeight is the best block height that lnd has knowledge of. BlockHeight uint32 + // BestHeaderTimeStamp is the best block timestamp known to the wallet. + BestHeaderTimeStamp time.Time + + // BestBlockHash is the node's view of the hash of the best block. + BestBlockHash chainhash.Hash + // IdentityPubkey is our node's pubkey. IdentityPubkey [33]byte // Alias is our node's alias. Alias string + // Color is the color of the current node in RGB format. + Color color.RGBA + // Network is the network we are currently operating on. Network string @@ -339,9 +353,6 @@ type Info struct { // public channel graph. SyncedToGraph bool - // BestHeaderTimeStamp is the best block timestamp known to the wallet. - BestHeaderTimeStamp time.Time - // ActiveChannels is the number of active channels we have. ActiveChannels uint32 @@ -350,6 +361,9 @@ type Info struct { // PendingChannels is the number of pending channels we have. PendingChannels uint32 + + // NumPeers is the number of peers we connect to. + NumPeers uint32 } // ChannelInfo stores unpacked per-channel info. @@ -1419,19 +1433,34 @@ func newInfo(resp *lnrpc.GetInfoResponse) (*Info, error) { var pubKeyArray [33]byte copy(pubKeyArray[:], pubKey) + bestBlockHash, err := chainhash.NewHashFromStr(resp.BlockHash) + if err != nil { + return nil, fmt.Errorf("failed to parse BlockHash: %w", err) + } + + color, err := lncfg.ParseHexColor(resp.Color) + if err != nil { + return nil, fmt.Errorf("failed to parse color hex %q: %w", + resp.Color, err) + } + return &Info{ Version: resp.Version, + CommitHash: resp.CommitHash, BlockHeight: resp.BlockHeight, + BestHeaderTimeStamp: time.Unix(resp.BestHeaderTimestamp, 0), + BestBlockHash: *bestBlockHash, IdentityPubkey: pubKeyArray, Alias: resp.Alias, + Color: color, Network: resp.Chains[0].Network, Uris: resp.Uris, SyncedToChain: resp.SyncedToChain, SyncedToGraph: resp.SyncedToGraph, - BestHeaderTimeStamp: time.Unix(resp.BestHeaderTimestamp, 0), ActiveChannels: resp.NumActiveChannels, InactiveChannels: resp.NumInactiveChannels, PendingChannels: resp.NumPendingChannels, + NumPeers: resp.NumPeers, }, nil } diff --git a/lnd_services_test.go b/lnd_services_test.go index 401501b..708bbfc 100644 --- a/lnd_services_test.go +++ b/lnd_services_test.go @@ -197,6 +197,7 @@ func (l *lockLNDMock) GetInfo(ctx context.Context, _ *lnrpc.GetInfoRequest, return &lnrpc.GetInfoResponse{ Chains: []*lnrpc.Chain{{}}, + Color: "#112233", }, err }