mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: channel open states for deposit and fsm
This commit is contained in:
parent
81012de948
commit
d12663ea7c
2 changed files with 34 additions and 1 deletions
|
|
@ -70,7 +70,8 @@ func (d *Deposit) IsInFinalState() bool {
|
|||
defer d.Unlock()
|
||||
|
||||
return d.state == Expired || d.state == Withdrawn ||
|
||||
d.state == LoopedIn || d.state == HtlcTimeoutSwept
|
||||
d.state == LoopedIn || d.state == HtlcTimeoutSwept ||
|
||||
d.state == ChannelPublished
|
||||
}
|
||||
|
||||
func (d *Deposit) IsExpired(currentHeight, expiry uint32) bool {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ var (
|
|||
fsm.OnError: {},
|
||||
OnWithdrawInitiated: {},
|
||||
OnWithdrawn: {},
|
||||
OnOpeningChannel: {},
|
||||
OnChannelPublished: {},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -51,6 +53,15 @@ var (
|
|||
// Withdrawn signals that the withdrawal transaction has been confirmed.
|
||||
Withdrawn = fsm.StateType("Withdrawn")
|
||||
|
||||
// OpeningChannel signals that the open channel transaction has been
|
||||
// broadcast.
|
||||
OpeningChannel = fsm.StateType("OpeningChannel")
|
||||
|
||||
// ChannelPublished signals that the open channel transaction has been
|
||||
// published and that the channel should be managed from lnd from now
|
||||
// on.
|
||||
ChannelPublished = fsm.StateType("ChannelPublished")
|
||||
|
||||
// LoopingIn signals that the deposit is locked for a loop in swap.
|
||||
LoopingIn = fsm.StateType("LoopingIn")
|
||||
|
||||
|
|
@ -93,6 +104,15 @@ var (
|
|||
// OnWithdrawn is sent to the fsm when a withdrawal has been confirmed.
|
||||
OnWithdrawn = fsm.EventType("OnWithdrawn")
|
||||
|
||||
// OnOpeningChannel is sent to the fsm when a channel open has been
|
||||
// initiated.
|
||||
OnOpeningChannel = fsm.EventType("OnOpeningChannel")
|
||||
|
||||
// OnChannelPublished is sent to the fsm when a channel open has been
|
||||
// published. Loop has done its work here and the channel should now be
|
||||
// managed from lnd.
|
||||
OnChannelPublished = fsm.EventType("OnChannelPublished")
|
||||
|
||||
// OnLoopInInitiated is sent to the fsm when a loop in has been
|
||||
// initiated.
|
||||
OnLoopInInitiated = fsm.EventType("OnLoopInInitiated")
|
||||
|
|
@ -253,6 +273,7 @@ func (f *FSM) DepositStatesV0() fsm.States {
|
|||
OnExpiry: PublishExpirySweep,
|
||||
OnWithdrawInitiated: Withdrawing,
|
||||
OnLoopInInitiated: LoopingIn,
|
||||
OnOpeningChannel: OpeningChannel,
|
||||
// We encounter OnSweepingHtlcTimeout if the
|
||||
// server published the htlc tx without paying
|
||||
// us. We then need to monitor for the timeout
|
||||
|
|
@ -366,6 +387,17 @@ func (f *FSM) DepositStatesV0() fsm.States {
|
|||
},
|
||||
Action: f.FinalizeDepositAction,
|
||||
},
|
||||
OpeningChannel: fsm.State{
|
||||
Transitions: fsm.Transitions{
|
||||
fsm.OnError: Deposited,
|
||||
OnChannelPublished: ChannelPublished,
|
||||
OnRecover: OpeningChannel,
|
||||
},
|
||||
Action: fsm.NoOpAction,
|
||||
},
|
||||
ChannelPublished: fsm.State{
|
||||
Action: f.FinalizeDepositAction,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue