Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/ldk-payment-se…
Browse files Browse the repository at this point in the history
…nt-duration
  • Loading branch information
rolznz committed Jun 24, 2024
2 parents 73dbc76 + 30474da commit 793dc12
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
30 changes: 16 additions & 14 deletions api/lsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,9 @@ func (api *api) NewInstantChannelInvoice(ctx context.Context, request *NewInstan

func (api *api) getLSPS1LSPInfo(url string) (*lspInfo, error) {

type lsps1LSPInfoOptions struct {
MaxChannelExpiryBlocks uint64 `json:"max_channel_expiry_blocks"`
}
type lsps1LSPInfo struct {
Options lsps1LSPInfoOptions `json:"options"`
URIs []string `json:"uris"`
MaxChannelExpiryBlocks uint64 `json:"max_channel_expiry_blocks"`
URIs []string `json:"uris"`
}
var lsps1LspInfo lsps1LSPInfo
client := http.Client{
Expand Down Expand Up @@ -223,7 +220,7 @@ func (api *api) getLSPS1LSPInfo(url string) (*lspInfo, error) {
Pubkey: parts[1],
Address: parts[2],
Port: uint16(port),
MaxChannelExpiryBlocks: lsps1LspInfo.Options.MaxChannelExpiryBlocks,
MaxChannelExpiryBlocks: lsps1LspInfo.MaxChannelExpiryBlocks,
}, nil
}
func (api *api) getFlowLSPInfo(url string) (*lspInfo, error) {
Expand Down Expand Up @@ -627,15 +624,20 @@ func (api *api) requestLSPS1Invoice(ctx context.Context, selectedLsp *lsp.LSP, a
return "", 0, fmt.Errorf("create_order endpoint returned non-success code: %s", string(body))
}

type NewLSPS1ChannelPayment struct {
Bolt11Invoice string `json:"bolt11_invoice"`
FeeTotalSat string `json:"fee_total_sat"`
type newLSPS1ChannelPaymentBolt11 struct {
Invoice string `json:"invoice"`
FeeTotalSat string `json:"fee_total_sat"`
}

type newLSPS1ChannelPayment struct {
Bolt11 newLSPS1ChannelPaymentBolt11 `json:"bolt11"`
// TODO: add onchain
}
type NewLSPS1ChannelResponse struct {
Payment NewLSPS1ChannelPayment `json:"payment"`
type newLSPS1ChannelResponse struct {
Payment newLSPS1ChannelPayment `json:"payment"`
}

var newChannelResponse NewLSPS1ChannelResponse
var newChannelResponse newLSPS1ChannelResponse

err = json.Unmarshal(body, &newChannelResponse)
if err != nil {
Expand All @@ -645,8 +647,8 @@ func (api *api) requestLSPS1Invoice(ctx context.Context, selectedLsp *lsp.LSP, a
return "", 0, fmt.Errorf("failed to deserialize json %s %s", selectedLsp.Url, string(body))
}

invoice = newChannelResponse.Payment.Bolt11Invoice
fee, err = strconv.ParseUint(newChannelResponse.Payment.FeeTotalSat, 10, 64)
invoice = newChannelResponse.Payment.Bolt11.Invoice
fee, err = strconv.ParseUint(newChannelResponse.Payment.Bolt11.FeeTotalSat, 10, 64)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"url": selectedLsp.Url,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/davrux/echo-logrus/v4 v4.0.3
github.com/elnosh/gonuts v0.1.1-0.20240602162005-49da741613e4
github.com/getAlby/glalby-go v0.0.0-20240616134525-322750d01f8d
github.com/getAlby/ldk-node-go v0.0.0-20240623072352-6f823b4fa9c7
github.com/getAlby/ldk-node-go v0.0.0-20240624050304-d2810786ce55
github.com/go-gormigrate/gormigrate/v2 v2.1.1
github.com/gorilla/sessions v1.2.2
github.com/labstack/echo-contrib v0.14.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/getAlby/glalby-go v0.0.0-20240616134525-322750d01f8d h1:ouIUrgIJXgf+foCDfOU67oNSraBeED15vCoPvaanU1I=
github.com/getAlby/glalby-go v0.0.0-20240616134525-322750d01f8d/go.mod h1:ViyJvjlvv0GCesTJ7mb3fBo4G+/qsujDAFN90xZ7a9U=
github.com/getAlby/ldk-node-go v0.0.0-20240623072352-6f823b4fa9c7 h1:ETuDVXtImG84yIa8hMZPHS4cDC908NjtX0v70eagNv8=
github.com/getAlby/ldk-node-go v0.0.0-20240623072352-6f823b4fa9c7/go.mod h1:8BRjtKcz8E0RyYTPEbMS8VIdgredcGSLne8vHDtcRLg=
github.com/getAlby/ldk-node-go v0.0.0-20240624050304-d2810786ce55 h1:hDsk9Yn2FvxZ0fz/0+7Dv+Xdfha73krDuL8MhG70I6c=
github.com/getAlby/ldk-node-go v0.0.0-20240624050304-d2810786ce55/go.mod h1:8BRjtKcz8E0RyYTPEbMS8VIdgredcGSLne8vHDtcRLg=
github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
Expand Down
9 changes: 7 additions & 2 deletions lnclient/ldk/ldk.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,13 @@ func (ls *LDKService) CloseChannel(ctx context.Context, closeChannelRequest *lnc
logger.Logger.WithFields(logrus.Fields{
"request": closeChannelRequest,
}).Info("Closing Channel")
// TODO: support passing force option
err := ls.node.CloseChannel(closeChannelRequest.ChannelId, closeChannelRequest.NodeId, closeChannelRequest.Force)

var err error
if closeChannelRequest.Force {
err = ls.node.ForceCloseChannel(closeChannelRequest.ChannelId, closeChannelRequest.NodeId)
} else {
err = ls.node.CloseChannel(closeChannelRequest.ChannelId, closeChannelRequest.NodeId)
}
if err != nil {
logger.Logger.WithError(err).Error("CloseChannel failed")
return nil, err
Expand Down

0 comments on commit 793dc12

Please sign in to comment.