Skip to content

Commit

Permalink
Move ShortChannelId into SavedChannelState
Browse files Browse the repository at this point in the history
  • Loading branch information
canndrew authored and knocte committed Jun 18, 2021
1 parent 8ed3c86 commit abc0476
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/DotNetLightning.Core/Channel/Channel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ type ChannelWaitingForFundingSigned = {
SavedChannelState = {
StaticChannelConfig = self.StaticChannelConfig
RemotePerCommitmentSecrets = PerCommitmentSecretStore()
ShortChannelId = None
}
ChannelOptions = self.ChannelOptions
ChannelPrivKeys = self.ChannelPrivKeys
NodeSecret = self.NodeSecret
ShortChannelId = None
RemoteNextCommitInfo = None
NegotiatingState = NegotiatingState.New()
Commitments = commitments
Expand Down Expand Up @@ -168,12 +168,12 @@ and ChannelWaitingForFundingCreated = {
SavedChannelState = {
StaticChannelConfig = staticChannelConfig
RemotePerCommitmentSecrets = PerCommitmentSecretStore()
ShortChannelId = None
}
ChannelOptions = self.ChannelOptions
ChannelPrivKeys = self.ChannelPrivKeys
NodeSecret = self.NodeSecret
RemoteNextCommitInfo = None
ShortChannelId = None
NegotiatingState = NegotiatingState.New()
Commitments = commitments
}
Expand Down Expand Up @@ -328,12 +328,10 @@ and ChannelWaitingForAcceptChannel = {
}

and Channel = {
//StaticChannelConfig: StaticChannelConfig
SavedChannelState: SavedChannelState
ChannelOptions: ChannelOptions
ChannelPrivKeys: ChannelPrivKeys
NodeSecret: NodeSecret
ShortChannelId: Option<ShortChannelId>
RemoteNextCommitInfo: Option<RemoteNextCommitInfo>
NegotiatingState: NegotiatingState
Commitments: Commitments
Expand All @@ -352,7 +350,7 @@ and Channel = {

member internal self.RemoteNextCommitInfoIfFundingLockedNormal (operation: string)
: Result<RemoteNextCommitInfo, ChannelError> =
match self.ShortChannelId with
match self.SavedChannelState.ShortChannelId with
| None ->
sprintf
"cannot perform operation %s because funding is not confirmed"
Expand Down Expand Up @@ -520,7 +518,7 @@ and Channel = {
Error <| InvalidFundingLocked { NetworkMsg = fundingLockedMsg }
else
Ok ()
match self.ShortChannelId with
match self.SavedChannelState.ShortChannelId with
| None ->
return {
self with
Expand All @@ -536,7 +534,7 @@ and Channel = {
(txindex: TxIndexInBlock)
(depth: BlockHeightOffset32)
: Result<Channel * Option<FundingLockedMsg>, ChannelError> = result {
match self.ShortChannelId with
match self.SavedChannelState.ShortChannelId with
| None ->
if self.SavedChannelState.StaticChannelConfig.FundingTxMinimumDepth > depth then
// TODO: this should probably be an error (?)
Expand Down Expand Up @@ -564,9 +562,13 @@ and Channel = {
|> uint16
|> TxOutIndex
}
let savedChannelState = {
self.SavedChannelState with
ShortChannelId = Some shortChannelId
}
let channel = {
self with
ShortChannelId = Some shortChannelId
SavedChannelState = savedChannelState
}
return channel, Some msgToSend
| Some _shortChannelId ->
Expand Down
1 change: 1 addition & 0 deletions src/DotNetLightning.Core/Channel/ChannelTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ type ClosingSignedResponse =
type SavedChannelState = {
StaticChannelConfig: StaticChannelConfig
RemotePerCommitmentSecrets: PerCommitmentSecretStore
ShortChannelId: Option<ShortChannelId>
}

0 comments on commit abc0476

Please sign in to comment.