2020-09-03 08:36:41 +00:00
|
|
|
package liquidity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/btcsuite/btcutil"
|
2020-09-03 08:36:43 +00:00
|
|
|
"github.com/lightninglabs/lndclient"
|
2020-09-03 08:36:42 +00:00
|
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
2021-02-16 11:31:49 +00:00
|
|
|
"github.com/lightningnetwork/lnd/routing/route"
|
2020-09-03 08:36:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
2020-09-03 08:36:42 +00:00
|
|
|
|
|
|
|
// channelID is the channel that has these balances.
|
|
|
|
channelID lnwire.ShortChannelID
|
2021-02-16 11:31:49 +00:00
|
|
|
|
|
|
|
// pubkey is the public key of the peer we have this balances set with.
|
|
|
|
pubkey route.Vertex
|
2020-09-03 08:36:41 +00:00
|
|
|
}
|
2020-09-03 08:36:43 +00:00
|
|
|
|
|
|
|
// 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,
|
|
|
|
channelID: lnwire.NewShortChanIDFromInt(info.ChannelID),
|
2021-02-16 11:31:49 +00:00
|
|
|
pubkey: info.PubKeyBytes,
|
2020-09-03 08:36:43 +00:00
|
|
|
}
|
|
|
|
}
|