contractcourt: fix witness type bug for taproot chans

We checked for OP_DROP, but both of the local+remote scripts end in `N
OP_CSV OP_DROP`.

So for now, we'll check for the maturity delay, with the assumption that
this won't be 1 for regular taproot chans. Either way, everything else
is correct as the witness is the same, but this may lead to display
issues down the line.
This commit is contained in:
Olaoluwa Osuntokun 2024-06-12 18:06:28 -07:00
parent 739f82e43a
commit c6e4d621d2

View File

@ -261,9 +261,7 @@ func (c *commitSweepResolver) Resolve(_ bool) (ContractResolver, error) {
// * otherwise need to base off the key in script or the CSV value
// (script num encode)
case c.chanType.IsTaproot():
scriptLen := len(signDesc.WitnessScript)
isLocalCommitTx = signDesc.WitnessScript[scriptLen-1] ==
txscript.OP_DROP
isLocalCommitTx = c.commitResolution.MaturityDelay != 1
// The output is on our local commitment if the script starts with
// OP_IF for the revocation clause. On the remote commitment it will
@ -271,10 +269,8 @@ func (c *commitSweepResolver) Resolve(_ bool) (ContractResolver, error) {
default:
isLocalCommitTx = signDesc.WitnessScript[0] == txscript.OP_IF
}
isDelayedOutput := c.commitResolution.MaturityDelay != 0
c.log.Debugf("isDelayedOutput=%v, isLocalCommitTx=%v", isDelayedOutput,
isLocalCommitTx)
isDelayedOutput := c.commitResolution.MaturityDelay != 0
// There're three types of commitments, those that have tweaks for the
// remote key (us in this case), those that don't, and a third where