Merge pull request #2431 from cfromknecht/keyring-remote-delay-retribution

lnwallet: Add keyring and remote CSV delay to BreachRetribution
This commit is contained in:
Olaoluwa Osuntokun 2019-01-11 15:33:16 -08:00 committed by GitHub
commit 400a1d3282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

@ -743,13 +743,27 @@ func (c *chainWatcher) dispatchContractBreach(spendEvent *chainntnfs.SpendDetail
retribution.RemoteOutputSignDesc.DoubleTweak != nil {
retribution.RemoteOutputSignDesc.DoubleTweak.Curve = nil
}
if retribution.RemoteOutputSignDesc != nil &&
retribution.RemoteOutputSignDesc.KeyDesc.PubKey != nil {
retribution.RemoteOutputSignDesc.KeyDesc.PubKey.Curve = nil
}
if retribution.LocalOutputSignDesc != nil &&
retribution.LocalOutputSignDesc.DoubleTweak != nil {
retribution.LocalOutputSignDesc.DoubleTweak.Curve = nil
}
if retribution.LocalOutputSignDesc != nil &&
retribution.LocalOutputSignDesc.KeyDesc.PubKey != nil {
retribution.LocalOutputSignDesc.KeyDesc.PubKey.Curve = nil
}
log.Debugf("Punishment breach retribution created: %v",
newLogClosure(func() string {
retribution.KeyRing.CommitPoint.Curve = nil
retribution.KeyRing.LocalHtlcKey = nil
retribution.KeyRing.RemoteHtlcKey = nil
retribution.KeyRing.DelayKey = nil
retribution.KeyRing.NoDelayKey = nil
retribution.KeyRing.RevocationKey = nil
return spew.Sdump(retribution)
}))

@ -1891,6 +1891,15 @@ type BreachRetribution struct {
// HtlcRetributions is a slice of HTLC retributions for each output
// active HTLC output within the breached commitment transaction.
HtlcRetributions []HtlcRetribution
// KeyRing contains the derived public keys used to construct the
// breaching commitment transaction. This allows downstream clients to
// have access to the public keys used in the scripts.
KeyRing *CommitmentKeyRing
// RemoteDelay specifies the CSV delay applied to to-local scripts on
// the breaching commitment transaction.
RemoteDelay uint32
}
// NewBreachRetribution creates a new fully populated BreachRetribution for the
@ -2098,6 +2107,8 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
RemoteOutpoint: remoteOutpoint,
RemoteOutputSignDesc: remoteSignDesc,
HtlcRetributions: htlcRetributions,
KeyRing: keyRing,
RemoteDelay: remoteDelay,
}, nil
}