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.
This commit is contained in:
Olaoluwa Osuntokun 2017-11-27 12:24:00 -08:00
parent 3e90000e2a
commit 483dc3f96a
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 3 additions and 9 deletions

View File

@ -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

View File

@ -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