Skip to content

Commit a0dba66

Browse files
committed
Handle WeResumedDelayedFundingLocked msg in applyEvent
Sending a funding_locked message after having already received one and processing all events returned by executeCommand will now put the channel into Normal state, rather than WaitForFundingLocked.
1 parent 0e90ded commit a0dba66

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

src/DotNetLightning.Core/Channel/Channel.fs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,28 @@ module Channel =
701701
| state, cmd ->
702702
undefinedStateAndCmdPair state cmd
703703

704+
let bothFundingLocked c (msg: FundingLocked) (s: WaitForFundingLockedData): Channel =
705+
let feeBase = ChannelHelpers.getOurFeeBaseMSat c.FeeEstimator s.InitialFeeRatePerKw s.Commitments.LocalParams.IsFunder
706+
let channelUpdate = ChannelHelpers.makeChannelUpdate (c.Network.GenesisHashRev,
707+
c.LocalNodeSecret,
708+
c.RemoteNodeId,
709+
s.ShortChannelId,
710+
s.Commitments.LocalParams.ToSelfDelay,
711+
s.Commitments.RemoteParams.HTLCMinimumMSat,
712+
feeBase,
713+
c.Config.ChannelOptions.FeeProportionalMillionths,
714+
true,
715+
None)
716+
let nextState = { NormalData.Buried = false;
717+
Commitments = s.Commitments
718+
ShortChannelId = s.ShortChannelId
719+
ChannelAnnouncement = None
720+
ChannelUpdate = channelUpdate
721+
LocalShutdown = None
722+
RemoteShutdown = None
723+
ChannelId = msg.ChannelId }
724+
{ c with State = ChannelState.Normal nextState }
725+
704726
let applyEvent c (e: ChannelEvent): Channel =
705727
match e, c.State with
706728
| NewOutboundChannelStarted(_, data), WaitForInitInternal ->
@@ -727,28 +749,11 @@ module Channel =
727749
| TheySentFundingLocked msg, WaitForFundingConfirmed s ->
728750
{ c with State = WaitForFundingConfirmed({ s with Deferred = Some(msg) }) }
729751
| TheySentFundingLocked msg, WaitForFundingLocked s ->
730-
let feeBase = ChannelHelpers.getOurFeeBaseMSat c.FeeEstimator s.InitialFeeRatePerKw s.Commitments.LocalParams.IsFunder
731-
let channelUpdate = ChannelHelpers.makeChannelUpdate (c.Network.GenesisHashRev,
732-
c.LocalNodeSecret,
733-
c.RemoteNodeId,
734-
s.ShortChannelId,
735-
s.Commitments.LocalParams.ToSelfDelay,
736-
s.Commitments.RemoteParams.HTLCMinimumMSat,
737-
feeBase,
738-
c.Config.ChannelOptions.FeeProportionalMillionths,
739-
true,
740-
None)
741-
let nextState = { NormalData.Buried = false;
742-
Commitments = s.Commitments
743-
ShortChannelId = s.ShortChannelId
744-
ChannelAnnouncement = None
745-
ChannelUpdate = channelUpdate
746-
LocalShutdown = None
747-
RemoteShutdown = None
748-
ChannelId = msg.ChannelId }
749-
{ c with State = ChannelState.Normal nextState }
752+
bothFundingLocked c msg s
750753
| WeSentFundingLocked msg, WaitForFundingLocked prevState ->
751754
{ c with State = WaitForFundingLocked { prevState with OurMessage = msg; HaveWeSentFundingLocked = true } }
755+
| WeResumedDelayedFundingLocked msg, WaitForFundingLocked s ->
756+
bothFundingLocked c msg s
752757
| BothFundingLocked data, WaitForFundingSigned _s ->
753758
{ c with State = ChannelState.Normal data }
754759
| BothFundingLocked data, WaitForFundingLocked _s ->

src/DotNetLightning.Infrastructure/ActorManagers/ChannelManager.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,10 @@ type ChannelManager(log: ILogger<ChannelManager>,
163163
match e.ChannelEvent with
164164
| ChannelEvent.WeAcceptedAcceptChannel (nextMsg, _) ->
165165
this.FundingTxs.TryAdd(nextMsg.FundingTxId, (e.NodeId, None)) |> ignore
166+
(*
166167
| WeResumedDelayedFundingLocked theirFundingSigned ->
167168
do! (this.Actors.[e.NodeId] :> IActor<_>).Put(ChannelCommand.ApplyFundingLocked theirFundingSigned)
169+
*)
168170
| _ -> ()
169171
}
170172
vt.AsTask() |> Async.AwaitTask

0 commit comments

Comments
 (0)