lnwallet/channel: make NewUnilateralCloseSummary take commitPoint

This commit is contained in:
Johan T. Halseth 2018-07-12 11:02:52 +02:00
parent f8751350bc
commit 06ceba429f
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -4850,24 +4850,16 @@ type UnilateralCloseSummary struct {
// NewUnilateralCloseSummary creates a new summary that provides the caller // NewUnilateralCloseSummary creates a new summary that provides the caller
// with all the information required to claim all funds on chain in the event // with all the information required to claim all funds on chain in the event
// that the remote party broadcasts their commitment. If the // that the remote party broadcasts their commitment. The commitPoint argument
// remotePendingCommit value is set to true, then we'll use the next (second) // should be set to the per_commitment_point corresponding to the spending
// unrevoked commitment point to construct the summary. Otherwise, we assume // commitment.
// that the remote party broadcast the lower of their two possible commits.
func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, signer Signer, func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, signer Signer,
pCache PreimageCache, commitSpend *chainntnfs.SpendDetail, pCache PreimageCache, commitSpend *chainntnfs.SpendDetail,
remoteCommit channeldb.ChannelCommitment, remoteCommit channeldb.ChannelCommitment,
remotePendingCommit bool) (*UnilateralCloseSummary, error) { commitPoint *btcec.PublicKey) (*UnilateralCloseSummary, error) {
// First, we'll generate the commitment point and the revocation point // First, we'll generate the commitment point and the revocation point
// so we can re-construct the HTLC state and also our payment key. If // so we can re-construct the HTLC state and also our payment key.
// this is the pending remote commitment, then we'll use the second
// unrevoked commit point in order to properly reconstruct the scripts
// we need to locate.
commitPoint := chanState.RemoteCurrentRevocation
if remotePendingCommit {
commitPoint = chanState.RemoteNextRevocation
}
keyRing := deriveCommitmentKeys( keyRing := deriveCommitmentKeys(
commitPoint, false, &chanState.LocalChanCfg, commitPoint, false, &chanState.LocalChanCfg,
&chanState.RemoteChanCfg, &chanState.RemoteChanCfg,