From 9c34c472877a3032baba7e32eb9c39db58aa228a Mon Sep 17 00:00:00 2001 From: bruwbird Date: Tue, 30 Jan 2024 09:24:06 +0900 Subject: [PATCH] cln: added display logic for PREMIUM Add item to peerSwapPeer to display Premium Rate Ppm. Set the value retrieved from the poll so that it can be checked with the ListPeers command. --- clightning/clightning_commands.go | 22 +++++++++++++--------- swap/swap.go | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/clightning/clightning_commands.go b/clightning/clightning_commands.go index 310df04b..8fc03e74 100644 --- a/clightning/clightning_commands.go +++ b/clightning/clightning_commands.go @@ -186,8 +186,8 @@ type SwapOut struct { ShortChannelId string `json:"short_channel_id"` SatAmt uint64 `json:"amt_sat"` Asset string `json:"asset"` - Force bool `json:"force"` PremiumLimit int64 `json:"premium_limit"` + Force bool `json:"force"` cl *ClightningClient `json:"-"` } @@ -649,7 +649,9 @@ func (l *ListPeers) Call() (jrpc2.Result, error) { SatsOut: ReceiverSatsOut, SatsIn: ReceiverSatsIn, }, - PaidFee: paidFees, + PaidFee: paidFees, + SwapInPremiumRatePpm: p.SwapInPremiumRatePPM, + SwapOutPremiumRatePpm: p.SwapOutPremiumRatePPM, } peerSwapPeerChannels := []*PeerSwapPeerChannel{} @@ -1131,13 +1133,15 @@ type SwapStats struct { } type PeerSwapPeer struct { - NodeId string `json:"nodeid"` - SwapsAllowed bool `json:"swaps_allowed"` - SupportedAssets []string `json:"supported_assets"` - Channels []*PeerSwapPeerChannel `json:"channels"` - AsSender *SwapStats `json:"sent,omitempty"` - AsReceiver *SwapStats `json:"received,omitempty"` - PaidFee uint64 `json:"total_fee_paid,omitempty"` + NodeId string `json:"nodeid"` + SwapsAllowed bool `json:"swaps_allowed"` + SupportedAssets []string `json:"supported_assets"` + Channels []*PeerSwapPeerChannel `json:"channels"` + AsSender *SwapStats `json:"sent,omitempty"` + AsReceiver *SwapStats `json:"received,omitempty"` + PaidFee uint64 `json:"total_fee_paid,omitempty"` + SwapInPremiumRatePpm int64 + SwapOutPremiumRatePpm int64 } // checkFeatures checks if a node runs the peerswap Plugin diff --git a/swap/swap.go b/swap/swap.go index 04f16a61..6db28038 100644 --- a/swap/swap.go +++ b/swap/swap.go @@ -235,10 +235,10 @@ func (s *SwapData) GetAsset() string { return "" } func (s *SwapData) GetPremium() int64 { - if s.SwapInRequest != nil { + if s.SwapInAgreement != nil { return s.SwapInAgreement.Premium } - if s.SwapOutRequest != nil { + if s.SwapOutAgreement != nil { return s.SwapOutAgreement.Premium } return 0