Skip to content

Commit 1c551b8

Browse files
canndrewknocte
authored andcommitted
Actually apply update fee messages
Prior to this commit, apply an update_fee message would cause DNL to validate the message but not actually apply it to its commitments. It now updates its commitments as it should. Upstream PR: joemphilips#159
1 parent 31286f1 commit 1c551b8

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/DotNetLightning.Core/Channel/Channel.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,8 @@ module Channel =
882882

883883
| WeAcceptedOperationUpdateFee(_msg, newCommitments), ChannelState.Normal d ->
884884
{ c with State = ChannelState.Normal({ d with Commitments = newCommitments }) }
885-
| WeAcceptedUpdateFee(_msg), ChannelState.Normal _d -> c
885+
| WeAcceptedUpdateFee(_msg, newCommitments), ChannelState.Normal normalData ->
886+
{ c with State = ChannelState.Normal({ normalData with Commitments = newCommitments }) }
886887

887888
| WeAcceptedOperationSign(_msg, newCommitments), ChannelState.Normal d ->
888889
{ c with State = ChannelState.Normal({ d with Commitments = newCommitments }) }

src/DotNetLightning.Core/Channel/ChannelTypes.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ type ChannelEvent =
285285
| WeAcceptedFailMalformedHTLC of origin: HTLCSource * msg: UpdateAddHTLCMsg * newCommitments: Commitments
286286

287287
| WeAcceptedOperationUpdateFee of msg: UpdateFeeMsg * nextCommitments: Commitments
288-
| WeAcceptedUpdateFee of msg: UpdateFeeMsg
288+
| WeAcceptedUpdateFee of msg: UpdateFeeMsg * newCommitments: Commitments
289289

290290
| WeAcceptedOperationSign of msg: CommitmentSignedMsg * nextCommitments: Commitments
291291
| WeAcceptedCommitmentSigned of msg: RevokeAndACKMsg * nextCommitments: Commitments

src/DotNetLightning.Core/Channel/CommitmentsModule.fs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,22 @@ module internal Commitments =
251251
else
252252
result {
253253
do! Helpers.checkUpdateFee (config) (msg) (localFeerate)
254-
let c1 = cm.AddRemoteProposal(msg)
254+
let nextCommitments = cm.AddRemoteProposal(msg)
255255
let! reduced =
256-
c1.LocalCommit.Spec.Reduce(c1.LocalChanges.ACKed, c1.RemoteChanges.Proposed) |> expectTransactionError
256+
nextCommitments.LocalCommit.Spec.Reduce(
257+
nextCommitments.LocalChanges.ACKed,
258+
nextCommitments.RemoteChanges.Proposed
259+
) |> expectTransactionError
257260

258-
let fees = Transactions.commitTxFee(c1.RemoteParams.DustLimitSatoshis) reduced
259-
let missing = reduced.ToRemote.ToMoney() - c1.RemoteParams.ChannelReserveSatoshis - fees
261+
let fees = Transactions.commitTxFee(nextCommitments.RemoteParams.DustLimitSatoshis) reduced
262+
let missing = reduced.ToRemote.ToMoney() - nextCommitments.RemoteParams.ChannelReserveSatoshis - fees
260263
if (missing < Money.Zero) then
261264
return!
262-
(c1.LocalParams.ChannelReserveSatoshis, fees, (-1 * missing))
265+
(nextCommitments.LocalParams.ChannelReserveSatoshis, fees, (-1 * missing))
263266
|> cannotAffordFee
264267
else
265268
return
266-
[ WeAcceptedUpdateFee msg ]
269+
[ WeAcceptedUpdateFee(msg, nextCommitments) ]
267270
}
268271

269272
let sendCommit (channelPrivKeys: ChannelPrivKeys) (n: Network) (cm: Commitments) =

0 commit comments

Comments
 (0)