From 483dc3f96a73f9e719ba92e8a5bc5697f50b9c80 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 27 Nov 2017 12:24:00 -0800 Subject: [PATCH] lnwallet: only the initiator needs to validate new fee updates In this commit, we fix an existing bug, as only the initiator needs to validate any new fee updates. If the initiator sends an invalid fee, then it will be rejected by the responder as it may put them below their required reserve. --- lnwallet/channel.go | 7 ++----- lnwallet/channel_test.go | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 4d2faf56..e8f93a4c 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1695,7 +1695,7 @@ func (lc *LightningChannel) restoreStateLogs( } // HtlcRetribution contains all the items necessary to seep a revoked HTLC -// transaction from a revoked commitment transaction broadcast by the remot +// transaction from a revoked commitment transaction broadcast by the remote // party. type HtlcRetribution struct { // SignDesc is a design descriptor capable of generating the necessary @@ -4937,10 +4937,7 @@ func (lc *LightningChannel) ReceiveUpdateFee(feePerKw btcutil.Amount) error { return fmt.Errorf("received fee update as initiator") } - // Ensure that the passed fee rate meets our current requirements. - if err := lc.validateFeeRate(feePerKw); err != nil { - return err - } + // TODO(roasbeef): or just modify to use the other balance? lc.pendingFeeUpdate = &feePerKw diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index 80de9d88..0a44c212 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -3385,7 +3385,7 @@ func TestFeeUpdateRejectInsaneFee(t *testing.T) { // Create a test channel which will be used for the duration of this // unittest. The channel will be funded evenly with Alice having 5 BTC, // and Bob having 5 BTC. - aliceChannel, bobChannel, cleanUp, err := createTestChannels(1) + aliceChannel, _, cleanUp, err := createTestChannels(1) if err != nil { t.Fatalf("unable to create test channels: %v", err) } @@ -3401,9 +3401,6 @@ func TestFeeUpdateRejectInsaneFee(t *testing.T) { if err := aliceChannel.UpdateFee(newFeeRate); err == nil { t.Fatalf("alice should've rejected fee update") } - if err := bobChannel.ReceiveUpdateFee(newFeeRate); err == nil { - t.Fatalf("bob should've rejected fee update") - } } // TestChannelRetransmissionFeeUpdate tests that the initiator will include any