contractcourt: update the commitSweepResolver to be aware of tweakless commits

In this commit, we update the `commitSweepResolver` to be aware of
tweakless commitments. We'll now use the new behavior of the uni close
summary (leaving out the single tweak) to detect if we're dealing with a
new, or modern commitment. Depending on the commitment type, we'll then
set the witness type accordingly so we can generate the proper signature
within the sweeper.
This commit is contained in:
Olaoluwa Osuntokun 2019-07-31 20:21:30 -07:00
parent 0b62126067
commit fdec603279
No known key found for this signature in database
GPG Key ID: BC13F65E2DC84465

@ -89,12 +89,23 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
isLocalCommitTx := c.commitResolution.MaturityDelay != 0
if !isLocalCommitTx {
// There're two types of commitments, those that have tweaks
// for the remote key (us in this case), and those that don't.
// We'll rely on the presence of the commitment tweak to to
// discern which type of commitment this is.
var witnessType input.WitnessType
if c.commitResolution.SelfOutputSignDesc.SingleTweak == nil {
witnessType = input.CommitSpendNoDelayTweakless
} else {
witnessType = input.CommitmentNoDelay
}
// We'll craft an input with all the information required for
// the sweeper to create a fully valid sweeping transaction to
// recover these coins.
inp := input.MakeBaseInput(
&c.commitResolution.SelfOutPoint,
input.CommitmentNoDelay,
witnessType,
&c.commitResolution.SelfOutputSignDesc,
c.broadcastHeight,
)