diff --git a/short_channel_id.go b/basetypes/short_channel_id.go similarity index 98% rename from short_channel_id.go rename to basetypes/short_channel_id.go index 8ce0b94..4b88c7a 100644 --- a/short_channel_id.go +++ b/basetypes/short_channel_id.go @@ -1,4 +1,4 @@ -package main +package basetypes import ( "fmt" diff --git a/cln_client.go b/cln_client.go index 56ac320..cc9f088 100644 --- a/cln_client.go +++ b/cln_client.go @@ -5,6 +5,7 @@ import ( "fmt" "log" + "github.com/breez/lspd/basetypes" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/niftynei/glightning/glightning" @@ -121,12 +122,12 @@ func (c *ClnClient) GetChannel(peerID []byte, channelPoint wire.OutPoint) (*GetC for _, c := range peer.Channels { log.Printf("getChannel destination: %s, Short channel id: %v, local alias: %v , FundingTxID:%v, State:%v ", pubkey, c.ShortChannelId, c.Alias.Local, c.FundingTxId, c.State) if slices.Contains(OPEN_STATUSES, c.State) && c.FundingTxId == fundingTxID { - confirmedChanID, err := NewShortChannelIDFromString(c.ShortChannelId) + confirmedChanID, err := basetypes.NewShortChannelIDFromString(c.ShortChannelId) if err != nil { fmt.Printf("NewShortChannelIDFromString %v error: %v", c.ShortChannelId, err) return nil, err } - initialChanID, err := NewShortChannelIDFromString(c.Alias.Local) + initialChanID, err := basetypes.NewShortChannelIDFromString(c.Alias.Local) if err != nil { fmt.Printf("NewShortChannelIDFromString %v error: %v", c.Alias.Local, err) return nil, err @@ -176,7 +177,7 @@ func (c *ClnClient) GetClosedChannels(nodeID string, channelPoints map[string]ui lookup := make(map[string]uint64) for _, c := range peer.Channels { if slices.Contains(CLOSING_STATUSES, c.State) { - cid, err := NewShortChannelIDFromString(c.ShortChannelId) + cid, err := basetypes.NewShortChannelIDFromString(c.ShortChannelId) if err != nil { log.Printf("CLN: GetClosedChannels NewShortChannelIDFromString(%v) error: %v", c.ShortChannelId, err) continue diff --git a/lightning_client.go b/lightning_client.go index a89a38d..7f10124 100644 --- a/lightning_client.go +++ b/lightning_client.go @@ -1,6 +1,9 @@ package main -import "github.com/btcsuite/btcd/wire" +import ( + "github.com/breez/lspd/basetypes" + "github.com/btcsuite/btcd/wire" +) type GetInfoResult struct { Alias string @@ -8,8 +11,8 @@ type GetInfoResult struct { } type GetChannelResult struct { - InitialChannelID ShortChannelID - ConfirmedChannelID ShortChannelID + InitialChannelID basetypes.ShortChannelID + ConfirmedChannelID basetypes.ShortChannelID } type OpenChannelRequest struct { diff --git a/lnd_client.go b/lnd_client.go index f0582d7..f98054c 100644 --- a/lnd_client.go +++ b/lnd_client.go @@ -9,6 +9,7 @@ import ( "os" "strings" + "github.com/breez/lspd/basetypes" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/lnrpc" @@ -140,8 +141,8 @@ func (c *LndClient) GetChannel(peerID []byte, channelPoint wire.OutPoint) (*GetC } } return &GetChannelResult{ - InitialChannelID: ShortChannelID(c.ChanId), - ConfirmedChannelID: ShortChannelID(confirmedChanId), + InitialChannelID: basetypes.ShortChannelID(c.ChanId), + ConfirmedChannelID: basetypes.ShortChannelID(confirmedChanId), }, nil } }