contractcourt: write confirmed CommitSet to disk before MarkChannelClosed

In this commit, we make a series of changes to ensure that we'll be able
to properly survive restarts if we crash right after we call
MarkChannelClosed. In order to ensure we can survive restarts, we'll now
long the confirmed CommitSet to disk right before we close the channel.
Upon restart, we'll read these from disk so we can pick up where we left
over.

Additionally, we also will now consult the legacy chain actions if it
turns out that the channel has been closed, but we don't have a
confCommitSet written to disk. This will only be the case for nodes that
had pending close channels before this commitment.
This commit is contained in:
Olaoluwa Osuntokun
2019-05-23 20:27:04 -07:00
parent 364c0dd9f1
commit 2011ccc571
3 changed files with 96 additions and 35 deletions

View File

@@ -463,7 +463,7 @@ func (c *ChainArbitrator) Start() error {
// We can also leave off the set of HTLC's here as since the
// channel is already in the process of being full resolved, no
// new HTLC's we be added.
// new HTLC's will be added.
c.activeChannels[chanPoint] = NewChannelArbitrator(
arbCfg, nil, chanLog,
)