mirror of
https://github.com/lightninglabs/loop
synced 2024-11-11 13:11:12 +00:00
3f46ae514b
We add 'peer-level' rules to allow assessment of liquidity on a per-peer level, rather than on an individual channel basis. No overlap is allowed with the existing set of channel rules because this could lead to contradictory rules.
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package liquidity
|
|
|
|
import (
|
|
"github.com/btcsuite/btcutil"
|
|
"github.com/lightninglabs/lndclient"
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
|
"github.com/lightningnetwork/lnd/routing/route"
|
|
)
|
|
|
|
// balances summarizes the state of the balances of a channel. Channel reserve,
|
|
// fees and pending htlc balances are not included in these balances.
|
|
type balances struct {
|
|
// capacity is the total capacity of the channel.
|
|
capacity btcutil.Amount
|
|
|
|
// incoming is the remote balance of the channel.
|
|
incoming btcutil.Amount
|
|
|
|
// outgoing is the local balance of the channel.
|
|
outgoing btcutil.Amount
|
|
|
|
// channels is the channel that has these balances represent. This may
|
|
// be more than one channel in the case where we are examining a peer's
|
|
// liquidity as a whole.
|
|
channels []lnwire.ShortChannelID
|
|
|
|
// pubkey is the public key of the peer we have this balances set with.
|
|
pubkey route.Vertex
|
|
}
|
|
|
|
// newBalances creates a balances struct from lndclient channel information.
|
|
func newBalances(info lndclient.ChannelInfo) *balances {
|
|
return &balances{
|
|
capacity: info.Capacity,
|
|
incoming: info.RemoteBalance,
|
|
outgoing: info.LocalBalance,
|
|
channels: []lnwire.ShortChannelID{
|
|
lnwire.NewShortChanIDFromInt(info.ChannelID),
|
|
},
|
|
pubkey: info.PubKeyBytes,
|
|
}
|
|
}
|