From fdec6032798a2cb72a4d94c42584f74fa2dfce42 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 31 Jul 2019 20:21:30 -0700 Subject: [PATCH] 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. --- contractcourt/commit_sweep_resolver.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contractcourt/commit_sweep_resolver.go b/contractcourt/commit_sweep_resolver.go index 1ef7e966..4e571272 100644 --- a/contractcourt/commit_sweep_resolver.go +++ b/contractcourt/commit_sweep_resolver.go @@ -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, )