move short channel id to basetypes dir

This commit is contained in:
Jesse de Wit
2022-12-23 18:19:05 +01:00
parent a7631dcddf
commit 5b67c399fd
4 changed files with 14 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
package main package basetypes
import ( import (
"fmt" "fmt"

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"log" "log"
"github.com/breez/lspd/basetypes"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/niftynei/glightning/glightning" "github.com/niftynei/glightning/glightning"
@@ -121,12 +122,12 @@ func (c *ClnClient) GetChannel(peerID []byte, channelPoint wire.OutPoint) (*GetC
for _, c := range peer.Channels { 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) 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 { if slices.Contains(OPEN_STATUSES, c.State) && c.FundingTxId == fundingTxID {
confirmedChanID, err := NewShortChannelIDFromString(c.ShortChannelId) confirmedChanID, err := basetypes.NewShortChannelIDFromString(c.ShortChannelId)
if err != nil { if err != nil {
fmt.Printf("NewShortChannelIDFromString %v error: %v", c.ShortChannelId, err) fmt.Printf("NewShortChannelIDFromString %v error: %v", c.ShortChannelId, err)
return nil, err return nil, err
} }
initialChanID, err := NewShortChannelIDFromString(c.Alias.Local) initialChanID, err := basetypes.NewShortChannelIDFromString(c.Alias.Local)
if err != nil { if err != nil {
fmt.Printf("NewShortChannelIDFromString %v error: %v", c.Alias.Local, err) fmt.Printf("NewShortChannelIDFromString %v error: %v", c.Alias.Local, err)
return nil, err return nil, err
@@ -176,7 +177,7 @@ func (c *ClnClient) GetClosedChannels(nodeID string, channelPoints map[string]ui
lookup := make(map[string]uint64) lookup := make(map[string]uint64)
for _, c := range peer.Channels { for _, c := range peer.Channels {
if slices.Contains(CLOSING_STATUSES, c.State) { if slices.Contains(CLOSING_STATUSES, c.State) {
cid, err := NewShortChannelIDFromString(c.ShortChannelId) cid, err := basetypes.NewShortChannelIDFromString(c.ShortChannelId)
if err != nil { if err != nil {
log.Printf("CLN: GetClosedChannels NewShortChannelIDFromString(%v) error: %v", c.ShortChannelId, err) log.Printf("CLN: GetClosedChannels NewShortChannelIDFromString(%v) error: %v", c.ShortChannelId, err)
continue continue

View File

@@ -1,6 +1,9 @@
package main package main
import "github.com/btcsuite/btcd/wire" import (
"github.com/breez/lspd/basetypes"
"github.com/btcsuite/btcd/wire"
)
type GetInfoResult struct { type GetInfoResult struct {
Alias string Alias string
@@ -8,8 +11,8 @@ type GetInfoResult struct {
} }
type GetChannelResult struct { type GetChannelResult struct {
InitialChannelID ShortChannelID InitialChannelID basetypes.ShortChannelID
ConfirmedChannelID ShortChannelID ConfirmedChannelID basetypes.ShortChannelID
} }
type OpenChannelRequest struct { type OpenChannelRequest struct {

View File

@@ -9,6 +9,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/breez/lspd/basetypes"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
@@ -140,8 +141,8 @@ func (c *LndClient) GetChannel(peerID []byte, channelPoint wire.OutPoint) (*GetC
} }
} }
return &GetChannelResult{ return &GetChannelResult{
InitialChannelID: ShortChannelID(c.ChanId), InitialChannelID: basetypes.ShortChannelID(c.ChanId),
ConfirmedChannelID: ShortChannelID(confirmedChanId), ConfirmedChannelID: basetypes.ShortChannelID(confirmedChanId),
}, nil }, nil
} }
} }