Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/release-notes/release-notes-0.20.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@
for conservative budgeting and includes griefing protection by limiting the
number of probed LSPs. It enhances the previous LSP design by being more
generic and more flexible.

* The `listchannels` RPC now [exposes the actual
spendable balance](https://github.com/lightningnetwork/lnd/pull/10624)
by adding `local_spendable_balance` and `remote_spendable_balance` fields.
This provides users with a precise view of their actionable liquidity by
correctly accounting for channel reserves and funds currently tied up in
in-flight HTLCs.

## lncli Updates

Expand Down
12 changes: 9 additions & 3 deletions htlcswitch/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ type ChannelUpdateHandler interface {

// Bandwidth returns the amount of milli-satoshis which current link
// might pass through channel link. The value returned from this method
// represents the up to date available flow through the channel. This
// takes into account any forwarded but un-cleared HTLC's, and any
// HTLC's which have been set to the over flow queue.
// represents the up to date available flow through the channel for the
// local party. This takes into account any forwarded but un-cleared
// HTLC's, and any HTLC's which have been set to the over flow queue.
Bandwidth() lnwire.MilliSatoshi

// RemoteBandwidth returns the amount of milli-satoshis which the remote
// party can send through the channel. Similar to Bandwidth(), it takes
// into account reserves and commitment fees from the remote's
// perspective.
RemoteBandwidth() lnwire.MilliSatoshi

// EligibleToForward returns a bool indicating if the channel is able
// to actively accept requests to forward HTLC's. A channel may be
// active, but not able to forward HTLC's if it hasn't yet finalized
Expand Down
9 changes: 9 additions & 0 deletions htlcswitch/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,15 @@ func (l *channelLink) Bandwidth() lnwire.MilliSatoshi {
return l.channel.AvailableBalance()
}

// RemoteBandwidth returns the total amount that the remote party can send
// through the channel link at this given instance. The value returned is
// expressed in millisatoshi.
//
// NOTE: Part of the ChannelLink interface.
func (l *channelLink) RemoteBandwidth() lnwire.MilliSatoshi {
return l.channel.RemoteAvailableBalance()
}

// MayAddOutgoingHtlc indicates whether we can add an outgoing htlc with the
// amount provided to the link. This check does not reserve a space, since
// forwards or other payments may use the available slot, so it should be
Expand Down
30 changes: 24 additions & 6 deletions htlcswitch/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ type mockServer struct {

var _ lnpeer.Peer = (*mockServer)(nil)

func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error) {
func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (
*Switch, error) {

signAliasUpdate := func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) {

Expand Down Expand Up @@ -375,7 +377,8 @@ func encodeFwdInfo(w io.Writer, f *hop.ForwardingInfo) error {
return err
}

if err := binary.Write(w, binary.BigEndian, f.OutgoingCTLV); err != nil {
if err := binary.Write(
w, binary.BigEndian, f.OutgoingCTLV); err != nil {
return err
}

Expand Down Expand Up @@ -438,10 +441,11 @@ func (o *mockObfuscator) IntermediateEncrypt(reason lnwire.OpaqueReason) lnwire.
return reason
}

func (o *mockObfuscator) EncryptMalformedError(reason lnwire.OpaqueReason) lnwire.OpaqueReason {
func (o *mockObfuscator) EncryptMalformedError(
reason lnwire.OpaqueReason) lnwire.OpaqueReason {

var b bytes.Buffer
b.Write(fakeHmac)

b.Write(reason)

return b.Bytes()
Expand Down Expand Up @@ -508,7 +512,9 @@ func (p *mockIteratorDecoder) DecodeHopIterator(r io.Reader, rHash []byte,
}

var nextHopBytes [8]byte
binary.BigEndian.PutUint64(nextHopBytes[:], f.NextHop.ToUint64())
binary.BigEndian.PutUint64(
nextHopBytes[:], f.NextHop.ToUint64(),
)

hops[i] = hop.NewLegacyPayload(&sphinx.HopData{
Realm: [1]byte{}, // hop.BitcoinNetwork
Expand Down Expand Up @@ -569,7 +575,8 @@ func decodeFwdInfo(r io.Reader, f *hop.ForwardingInfo) error {
return err
}

if err := binary.Read(r, binary.BigEndian, &f.OutgoingCTLV); err != nil {
if err := binary.Read(
r, binary.BigEndian, &f.OutgoingCTLV); err != nil {
return err
}

Expand Down Expand Up @@ -910,10 +917,21 @@ func (f *mockChannelLink) ShortChanID() lnwire.ShortChannelID {
return f.shortChanID
}

// Bandwidth returns a hardcoded amount of milli-satoshis for the mock link.
//
// NOTE: Part of the ChannelLink interface.
func (f *mockChannelLink) Bandwidth() lnwire.MilliSatoshi {
return 99999999
}

// RemoteBandwidth returns a hardcoded amount of milli-satoshis for
// the mock link.
//
// NOTE: Part of the ChannelLink interface.
func (f *mockChannelLink) RemoteBandwidth() lnwire.MilliSatoshi {
return 99999999
}

func (f *mockChannelLink) PeerPubKey() [33]byte {
return f.peer.PubKey()
}
Expand Down
Loading
Loading