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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
37 changes: 33 additions & 4 deletions lightning_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"image/color"
"io"
"sync"
"time"
Expand All @@ -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"
Expand Down Expand Up @@ -325,15 +327,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

Expand All @@ -348,9 +362,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

Expand All @@ -359,6 +370,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.
Expand Down Expand Up @@ -1430,19 +1444,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
}

Expand Down
1 change: 1 addition & 0 deletions lnd_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (l *lockLNDMock) GetInfo(ctx context.Context, _ *lnrpc.GetInfoRequest,

return &lnrpc.GetInfoResponse{
Chains: []*lnrpc.Chain{{}},
Color: "#112233",
}, err
}

Expand Down
2 changes: 1 addition & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down