mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-30 12:14:26 +01:00
@@ -151,14 +151,14 @@ func (c *ClnClient) OpenChannel(req *lightning.OpenChannelRequest) (*wire.OutPoi
|
||||
|
||||
func (c *ClnClient) GetChannel(peerID []byte, channelPoint wire.OutPoint) (*lightning.GetChannelResult, error) {
|
||||
pubkey := hex.EncodeToString(peerID)
|
||||
peer, err := c.client.GetPeer(pubkey)
|
||||
channels, err := c.client.GetPeerChannels(pubkey)
|
||||
if err != nil {
|
||||
log.Printf("CLN: client.GetPeer(%s) error: %v", pubkey, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fundingTxID := channelPoint.Hash.String()
|
||||
for _, c := range peer.Channels {
|
||||
for _, c := range 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 := lightning.NewShortChannelIDFromString(c.ShortChannelId)
|
||||
@@ -174,7 +174,7 @@ func (c *ClnClient) GetChannel(peerID []byte, channelPoint wire.OutPoint) (*ligh
|
||||
return &lightning.GetChannelResult{
|
||||
InitialChannelID: *initialChanID,
|
||||
ConfirmedChannelID: *confirmedChanID,
|
||||
HtlcMinimumMsat: c.HtlcMinMilliSatoshi,
|
||||
HtlcMinimumMsat: c.MinimumHtlcOutMsat.MSat(),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ func (c *ClnClient) GetChannel(peerID []byte, channelPoint wire.OutPoint) (*ligh
|
||||
|
||||
func (c *ClnClient) GetNodeChannelCount(nodeID []byte) (int, error) {
|
||||
pubkey := hex.EncodeToString(nodeID)
|
||||
peer, err := c.client.GetPeer(pubkey)
|
||||
channels, err := c.client.GetPeerChannels(pubkey)
|
||||
if err != nil {
|
||||
log.Printf("CLN: client.GetPeer(%s) error: %v", pubkey, err)
|
||||
return 0, err
|
||||
@@ -193,7 +193,7 @@ func (c *ClnClient) GetNodeChannelCount(nodeID []byte) (int, error) {
|
||||
|
||||
count := 0
|
||||
openPendingStatuses := append(OPEN_STATUSES, PENDING_STATUSES...)
|
||||
for _, c := range peer.Channels {
|
||||
for _, c := range channels {
|
||||
if slices.Contains(openPendingStatuses, c.State) {
|
||||
count++
|
||||
}
|
||||
@@ -208,14 +208,14 @@ func (c *ClnClient) GetClosedChannels(nodeID string, channelPoints map[string]ui
|
||||
return r, nil
|
||||
}
|
||||
|
||||
peer, err := c.client.GetPeer(nodeID)
|
||||
channels, err := c.client.GetPeerChannels(nodeID)
|
||||
if err != nil {
|
||||
log.Printf("CLN: client.GetPeer(%s) error: %v", nodeID, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lookup := make(map[string]uint64)
|
||||
for _, c := range peer.Channels {
|
||||
for _, c := range channels {
|
||||
if slices.Contains(CLOSING_STATUSES, c.State) {
|
||||
cid, err := lightning.NewShortChannelIDFromString(c.ShortChannelId)
|
||||
if err != nil {
|
||||
@@ -240,20 +240,18 @@ func (c *ClnClient) GetClosedChannels(nodeID string, channelPoints map[string]ui
|
||||
|
||||
func (c *ClnClient) GetPeerId(scid *lightning.ShortChannelID) ([]byte, error) {
|
||||
scidStr := scid.ToString()
|
||||
peers, err := c.client.ListPeers()
|
||||
channels, err := c.client.ListPeerChannels()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var dest *string
|
||||
for _, p := range peers {
|
||||
for _, ch := range p.Channels {
|
||||
if ch.Alias.Local == scidStr ||
|
||||
ch.Alias.Remote == scidStr ||
|
||||
ch.ShortChannelId == scidStr {
|
||||
dest = &p.Id
|
||||
break
|
||||
}
|
||||
for _, ch := range channels {
|
||||
if ch.Alias.Local == scidStr ||
|
||||
ch.Alias.Remote == scidStr ||
|
||||
ch.ShortChannelId == scidStr {
|
||||
dest = &ch.PeerId
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
4
go.mod
4
go.mod
@@ -5,7 +5,7 @@ go 1.19
|
||||
require (
|
||||
github.com/GoWebProd/uuid7 v0.0.0-20230623091058-5f5954faed6a
|
||||
github.com/aws/aws-sdk-go v1.34.0
|
||||
github.com/breez/lntest v0.0.28
|
||||
github.com/breez/lntest v0.0.29-0.20231206103840-666bd5078c5e
|
||||
github.com/btcsuite/btcd v0.23.5-0.20230228185050-38331963bddd
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2
|
||||
@@ -196,4 +196,4 @@ require (
|
||||
|
||||
replace github.com/lightningnetwork/lnd v0.16.2-beta => github.com/breez/lnd v0.15.0-beta.rc6.0.20230501134702-cebcdf1b17fd
|
||||
|
||||
replace github.com/elementsproject/glightning => github.com/breez/glightning v0.0.1-breez
|
||||
replace github.com/elementsproject/glightning => github.com/breez/glightning v0.0.1-breez.0.20231123140102-d50d43e22138
|
||||
|
||||
@@ -93,6 +93,7 @@ func newClnBreezClient(h *lntest.TestHarness, m *lntest.Miner, name string) Bree
|
||||
// https://github.com/ElementsProject/lightning/blob/774d16a72e125e4ae4e312b9e3307261983bec0e/openingd/openingd.c#L481-L520
|
||||
"--max-concurrent-htlcs=30",
|
||||
"--experimental-anchors",
|
||||
"--developer",
|
||||
)
|
||||
|
||||
return &clnBreezClient{
|
||||
|
||||
@@ -63,6 +63,7 @@ func NewClnLspdNode(h *lntest.TestHarness, m *lntest.Miner, mem *mempoolApi, nam
|
||||
"--dev-allowdustreserve=true",
|
||||
"--allow-deprecated-apis=true",
|
||||
"--experimental-anchors",
|
||||
"--developer",
|
||||
}
|
||||
lightningNode := lntest.NewClnNode(h, m, name, args...)
|
||||
cln := &config.ClnConfig{
|
||||
|
||||
Reference in New Issue
Block a user