Skip to content

Commit

Permalink
cln: added display logic for PREMIUM
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
YusukeShimizu committed Jan 30, 2024
1 parent 65dcce8 commit 9c34c47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 13 additions & 9 deletions clightning/clightning_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
}

Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions swap/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c34c47

Please sign in to comment.