lnwallet: when signing a new commitment state, store a CommitDiff
This commit is contained in:
1 file changed
+13
-14
+13
-14
@@ -2842,6 +2842,7 @@ func (lc *LightningChannel) SignNextCommitment() (*btcec.Signature, []*btcec.Sig
|
|||||||
|
|
||||||
// Determine the last update on the remote log that has been locked in.
|
// Determine the last update on the remote log that has been locked in.
|
||||||
remoteACKedIndex := lc.localCommitChain.tail().theirMessageIndex
|
remoteACKedIndex := lc.localCommitChain.tail().theirMessageIndex
|
||||||
|
remoteHtlcIndex := lc.localCommitChain.tail().theirHtlcIndex
|
||||||
|
|
||||||
// Before we extend this new commitment to the remote commitment chain,
|
// Before we extend this new commitment to the remote commitment chain,
|
||||||
// ensure that we aren't violating any of the constraints the remote
|
// ensure that we aren't violating any of the constraints the remote
|
||||||
@@ -2939,26 +2940,24 @@ func (lc *LightningChannel) SignNextCommitment() (*btcec.Signature, []*btcec.Sig
|
|||||||
htlcSigs = append(htlcSigs, jobResp.sig)
|
htlcSigs = append(htlcSigs, jobResp.sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend the remote commitment chain by one with the addition of our
|
// As we're about to proposer a new commitment state for the remote
|
||||||
// latest commitment update.
|
// party, we'll write this pending state to disk before we exit, so we
|
||||||
lc.remoteCommitChain.addCommitment(newCommitView)
|
// can retransmit it if necessary.
|
||||||
|
commitDiff, err := lc.createCommitDiff(newCommitView, sig, htlcSigs)
|
||||||
// ...
|
|
||||||
commitDiff, err := lc.createCommitDiff(newCommitView)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
if lc.channelState.AppendRemoteCommitChain(commitDiff); err != nil {
|
||||||
// ...
|
|
||||||
if err := channeldb.AddCommitDiff(lc.channelState.Db,
|
|
||||||
&lc.channelState.FundingOutpoint,
|
|
||||||
commitDiff); err != nil {
|
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := lc.channelState.UpdateHTLCs(newCommitView.htlcs(false)); err != nil {
|
// TODO(roasbeef): check that one eclair bug
|
||||||
return nil, nil, err
|
// * need to retransmit on first state still?
|
||||||
}
|
// * after initial reconnect
|
||||||
|
|
||||||
|
// Extend the remote commitment chain by one with the addition of our
|
||||||
|
// latest commitment update.
|
||||||
|
lc.remoteCommitChain.addCommitment(newCommitView)
|
||||||
|
|
||||||
// If we are the channel initiator then we would have signed any sent
|
// If we are the channel initiator then we would have signed any sent
|
||||||
// fee update at this point, so mark this update as pending ACK, and
|
// fee update at this point, so mark this update as pending ACK, and
|
||||||
|
|||||||
Reference in new issue
Block a user