diff --git a/src/DotNetLightning.Core/Channel/Channel.fs b/src/DotNetLightning.Core/Channel/Channel.fs index a793338d0..8da364c26 100644 --- a/src/DotNetLightning.Core/Channel/Channel.fs +++ b/src/DotNetLightning.Core/Channel/Channel.fs @@ -882,7 +882,8 @@ module Channel = | WeAcceptedOperationUpdateFee(_msg, newCommitments), ChannelState.Normal d -> { c with State = ChannelState.Normal({ d with Commitments = newCommitments }) } - | WeAcceptedUpdateFee(_msg), ChannelState.Normal _d -> c + | WeAcceptedUpdateFee(_msg, newCommitments), ChannelState.Normal normalData -> + { c with State = ChannelState.Normal({ normalData with Commitments = newCommitments }) } | WeAcceptedOperationSign(_msg, newCommitments), ChannelState.Normal d -> { c with State = ChannelState.Normal({ d with Commitments = newCommitments }) } diff --git a/src/DotNetLightning.Core/Channel/ChannelTypes.fs b/src/DotNetLightning.Core/Channel/ChannelTypes.fs index a66ddc93b..73dafd725 100644 --- a/src/DotNetLightning.Core/Channel/ChannelTypes.fs +++ b/src/DotNetLightning.Core/Channel/ChannelTypes.fs @@ -285,7 +285,7 @@ type ChannelEvent = | WeAcceptedFailMalformedHTLC of origin: HTLCSource * msg: UpdateAddHTLCMsg * newCommitments: Commitments | WeAcceptedOperationUpdateFee of msg: UpdateFeeMsg * nextCommitments: Commitments - | WeAcceptedUpdateFee of msg: UpdateFeeMsg + | WeAcceptedUpdateFee of msg: UpdateFeeMsg * newCommitments: Commitments | WeAcceptedOperationSign of msg: CommitmentSignedMsg * nextCommitments: Commitments | WeAcceptedCommitmentSigned of msg: RevokeAndACKMsg * nextCommitments: Commitments diff --git a/src/DotNetLightning.Core/Channel/CommitmentsModule.fs b/src/DotNetLightning.Core/Channel/CommitmentsModule.fs index 405d7bf2c..391f4e3df 100644 --- a/src/DotNetLightning.Core/Channel/CommitmentsModule.fs +++ b/src/DotNetLightning.Core/Channel/CommitmentsModule.fs @@ -251,19 +251,22 @@ module internal Commitments = else result { do! Helpers.checkUpdateFee (config) (msg) (localFeerate) - let c1 = cm.AddRemoteProposal(msg) + let nextCommitments = cm.AddRemoteProposal(msg) let! reduced = - c1.LocalCommit.Spec.Reduce(c1.LocalChanges.ACKed, c1.RemoteChanges.Proposed) |> expectTransactionError + nextCommitments.LocalCommit.Spec.Reduce( + nextCommitments.LocalChanges.ACKed, + nextCommitments.RemoteChanges.Proposed + ) |> expectTransactionError - let fees = Transactions.commitTxFee(c1.RemoteParams.DustLimitSatoshis) reduced - let missing = reduced.ToRemote.ToMoney() - c1.RemoteParams.ChannelReserveSatoshis - fees + let fees = Transactions.commitTxFee(nextCommitments.RemoteParams.DustLimitSatoshis) reduced + let missing = reduced.ToRemote.ToMoney() - nextCommitments.RemoteParams.ChannelReserveSatoshis - fees if (missing < Money.Zero) then return! - (c1.LocalParams.ChannelReserveSatoshis, fees, (-1 * missing)) + (nextCommitments.LocalParams.ChannelReserveSatoshis, fees, (-1 * missing)) |> cannotAffordFee else return - [ WeAcceptedUpdateFee msg ] + [ WeAcceptedUpdateFee(msg, nextCommitments) ] } let sendCommit (channelPrivKeys: ChannelPrivKeys) (n: Network) (cm: Commitments) =