Skip to content

Commit 6bc0965

Browse files
committed
docs: add release notes
1 parent 7c559b2 commit 6bc0965

File tree

6 files changed

+63
-33
lines changed

6 files changed

+63
-33
lines changed

docs/release-notes/release-notes-0.20.1.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@
103103
for conservative budgeting and includes griefing protection by limiting the
104104
number of probed LSPs. It enhances the previous LSP design by being more
105105
generic and more flexible.
106+
107+
* The `listchannels` RPC now [exposes the actual
108+
spendable balance](https://github.com/lightningnetwork/lnd/pull/10624)
109+
by adding `local_spendable_balance` and `remote_spendable_balance` fields.
110+
This provides users with a precise view of their actionable liquidity by
111+
correctly accounting for channel reserves and funds currently tied up in
112+
in-flight HTLCs.
106113

107114
## lncli Updates
108115

htlcswitch/mock.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ type mockServer struct {
167167

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

170-
func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error) {
170+
func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (
171+
*Switch, error) {
172+
171173
signAliasUpdate := func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
172174
error) {
173175

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

378-
if err := binary.Write(w, binary.BigEndian, f.OutgoingCTLV); err != nil {
380+
if err := binary.Write(
381+
w, binary.BigEndian, f.OutgoingCTLV); err != nil {
379382
return err
380383
}
381384

@@ -438,10 +441,11 @@ func (o *mockObfuscator) IntermediateEncrypt(reason lnwire.OpaqueReason) lnwire.
438441
return reason
439442
}
440443

441-
func (o *mockObfuscator) EncryptMalformedError(reason lnwire.OpaqueReason) lnwire.OpaqueReason {
444+
func (o *mockObfuscator) EncryptMalformedError(
445+
reason lnwire.OpaqueReason) lnwire.OpaqueReason {
446+
442447
var b bytes.Buffer
443448
b.Write(fakeHmac)
444-
445449
b.Write(reason)
446450

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

510514
var nextHopBytes [8]byte
511-
binary.BigEndian.PutUint64(nextHopBytes[:], f.NextHop.ToUint64())
515+
binary.BigEndian.PutUint64(
516+
nextHopBytes[:], f.NextHop.ToUint64(),
517+
)
512518

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

572-
if err := binary.Read(r, binary.BigEndian, &f.OutgoingCTLV); err != nil {
578+
if err := binary.Read(
579+
r, binary.BigEndian, &f.OutgoingCTLV); err != nil {
573580
return err
574581
}
575582

@@ -917,7 +924,8 @@ func (f *mockChannelLink) Bandwidth() lnwire.MilliSatoshi {
917924
return 99999999
918925
}
919926

920-
// RemoteBandwidth returns a hardcoded amount of milli-satoshis for the mock link.
927+
// RemoteBandwidth returns a hardcoded amount of milli-satoshis for
928+
// the mock link.
921929
//
922930
// NOTE: Part of the ChannelLink interface.
923931
func (f *mockChannelLink) RemoteBandwidth() lnwire.MilliSatoshi {

lnwallet/channel.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,9 +3789,8 @@ func (b BufferType) String() string {
37893789
// the adjusted balance, the buffer (less the commit fee), and the commit fee.
37903790
func (lc *LightningChannel) applyCommitFee(
37913791
balance lnwire.MilliSatoshi, commitWeight lntypes.WeightUnit,
3792-
feePerKw chainfee.SatPerKWeight,
3793-
buffer BufferType, isInitiator bool) (lnwire.MilliSatoshi, lnwire.MilliSatoshi,
3794-
lnwire.MilliSatoshi, error) {
3792+
feePerKw chainfee.SatPerKWeight, buffer BufferType, isInitiator bool) (
3793+
lnwire.MilliSatoshi, lnwire.MilliSatoshi, lnwire.MilliSatoshi, error) {
37953794

37963795
commitFee := feePerKw.FeeForWeight(commitWeight)
37973796
commitFeeMsat := lnwire.NewMSatFromSatoshis(commitFee)
@@ -9081,6 +9080,7 @@ func (lc *LightningChannel) RemoteAvailableBalance() lnwire.MilliSatoshi {
90819080
defer lc.RUnlock()
90829081

90839082
bal, _ := lc.remoteAvailableBalance(FeeBuffer)
9083+
90849084
return bal
90859085
}
90869086

@@ -9105,7 +9105,8 @@ func (lc *LightningChannel) remoteAvailableBalance(
91059105
// calculate the available balance for either the local or remote party,
91069106
// depending on the isRemote flag.
91079107
func (lc *LightningChannel) availableBalanceGeneric(
9108-
buffer BufferType, isRemote bool) (lnwire.MilliSatoshi, lntypes.WeightUnit) {
9108+
buffer BufferType, isRemote bool) (
9109+
lnwire.MilliSatoshi, lntypes.WeightUnit) {
91099110

91109111
htlcView := lc.fetchHTLCView(
91119112
lc.updateLogs.Remote.logIndex, lc.updateLogs.Local.logIndex,
@@ -9219,7 +9220,11 @@ func (lc *LightningChannel) availableCommitmentBalance(view *HtlcView,
92199220
// declare bufferAmt beforehand.
92209221
var bufferAmt lnwire.MilliSatoshi
92219222
balance, bufferAmt, commitFee, err = lc.applyCommitFee(
9222-
balance, futureCommitWeight, feePerKw, buffer, initiator,
9223+
balance,
9224+
futureCommitWeight,
9225+
feePerKw,
9226+
buffer,
9227+
initiator,
92239228
)
92249229
if err != nil {
92259230
lc.log.Debugf("No available balance after "+

lnwallet/channel_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5549,20 +5549,22 @@ func TestChanRemoteAvailableBalance(t *testing.T) {
55495549

55505550
// Query the RemoteAvailableBalance from Alice's PoV.
55515551
// This should be what Bob can send.
5552-
aliceRemoteAvailableBalance := aliceChannel.RemoteAvailableBalance()
5552+
aliceRemoteBalance := aliceChannel.RemoteAvailableBalance()
55535553

55545554
// Query the AvailableBalance from Bob's PoV.
55555555
bobAvailableBalance := bobChannel.AvailableBalance()
55565556

5557-
require.Equal(t, bobAvailableBalance, aliceRemoteAvailableBalance,
5558-
"Alice's view of Bob's balance should match Bob's own view")
5557+
require.Equal(t, bobAvailableBalance, aliceRemoteBalance,
5558+
"Alice's view of Bob's balance should match "+
5559+
"Bob's own view")
55595560

55605561
// Also check from Bob's PoV.
5561-
bobRemoteAvailableBalance := bobChannel.RemoteAvailableBalance()
5562+
bobRemoteBalance := bobChannel.RemoteAvailableBalance()
55625563
aliceAvailableBalance := aliceChannel.AvailableBalance()
55635564

5564-
require.Equal(t, aliceAvailableBalance, bobRemoteAvailableBalance,
5565-
"Bob's view of Alice's balance should match Alice's own view")
5565+
require.Equal(t, aliceAvailableBalance, bobRemoteBalance,
5566+
"Bob's view of Alice's balance should match "+
5567+
"Alice's own view")
55665568
}
55675569

55685570
// Initially, both should be correct.

peer/brontide_test.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
267267
msg: closingSigned,
268268
}
269269

270-
// Alice should accept Bob's fee, broadcast the cooperative close tx, and
271-
// send a ClosingSigned message back to Bob.
270+
// Alice should accept Bob's fee, broadcast the cooperative close tx,
271+
// and send a ClosingSigned message back to Bob.
272272

273273
// Alice should now broadcast the closing transaction.
274274
select {
@@ -295,7 +295,8 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
295295
bobFee, closingSignedMsg.FeeSatoshis)
296296
}
297297

298-
// Alice should be waiting on a single confirmation for the coop close tx.
298+
// Alice should be waiting on a single confirmation
299+
// for the coop close tx.
299300
notifier.ConfChan <- &chainntnfs.TxConfirmation{}
300301
}
301302

@@ -378,10 +379,10 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
378379
msg: closingSigned,
379380
}
380381

381-
// Alice will now see the new fee we propose, but with current settings it
382-
// won't accept it immediately as it differs too much by its ideal fee. We
383-
// should get a new proposal back, which should have the average fee rate
384-
// proposed.
382+
// Alice will now see the new fee we propose, but with current settings
383+
// it won't accept it immediately as it differs too much by its ideal
384+
// fee. We should get a new proposal back, which should have the average
385+
// fee rate proposed.
385386
select {
386387
case outMsg := <-alicePeer.outgoingQueue:
387388
msg = outMsg.msg
@@ -479,7 +480,8 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
479480
t.Fatalf("expected to receive closing signed message, got %T", msg)
480481
}
481482

482-
// Alice should be waiting on a single confirmation for the coop close tx.
483+
// Alice should be waiting on a single confirmation
484+
// for the coop close tx.
483485
notifier.ConfChan <- &chainntnfs.TxConfirmation{}
484486
}
485487

@@ -675,7 +677,8 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
675677
t.Fatalf("expected to receive closing signed message, got %T", msg)
676678
}
677679

678-
// Alice should be waiting on a single confirmation for the coop close tx.
680+
// Alice should be waiting on a single confirmation
681+
// for the coop close tx.
679682
notifier.ConfChan <- &chainntnfs.TxConfirmation{}
680683
}
681684

@@ -773,8 +776,9 @@ func TestCustomShutdownScript(t *testing.T) {
773776
tests := []struct {
774777
name string
775778

776-
// update is a function used to set values on the channel set up for the
777-
// test. It is used to set values for upfront shutdown addresses.
779+
// update is a function used to set values on the channel set up
780+
// for the test. It is used to set values for upfront shutdown
781+
// addresses.
778782
update func(a, b *channeldb.OpenChannel)
779783

780784
// userCloseScript is the address specified by the user.

peer/test_utils.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ func (m *mockUpdateHandler) ChanID() lnwire.ChannelID { return m.cid }
406406
// Bandwidth currently returns a dummy value.
407407
func (m *mockUpdateHandler) Bandwidth() lnwire.MilliSatoshi { return 0 }
408408

409+
// RemoteBandwidth currently returns a dummy value.
410+
func (m *mockUpdateHandler) RemoteBandwidth() lnwire.MilliSatoshi { return 0 }
411+
409412
// EligibleToForward currently returns a dummy value.
410413
func (m *mockUpdateHandler) EligibleToForward() bool { return false }
411414

@@ -415,12 +418,13 @@ func (m *mockUpdateHandler) MayAddOutgoingHtlc(lnwire.MilliSatoshi) error { retu
415418
type mockMessageConn struct {
416419
t *testing.T
417420

418-
// MessageConn embeds our interface so that the mock does not need to
419-
// implement every function. The mock will panic if an unspecified function
420-
// is called.
421+
// MessageConn embeds our interface so that
422+
// the mock does not need to implement every function.
423+
// The mock will panic if an unspecifiedfunction is called.
421424
MessageConn
422425

423-
// writtenMessages is a channel that our mock pushes written messages into.
426+
// writtenMessages is a channel that our mock pushes written messages
427+
// into.
424428
writtenMessages chan []byte
425429

426430
readMessages chan []byte

0 commit comments

Comments
 (0)