loopout: attempt cooperative musig2 sweep

This commit adds optional cooperative musig2 sweep by calling the server
to create a partial signature for the sweep if we'd otherwise be allowed
to spend the htlc. If the cooperative musig2 spend fails, we always fall
back to use the scriptpath spend.
This commit is contained in:
Andras Banki-Horvath 2022-05-05 11:59:31 +02:00
parent 32557a57ea
commit 82b58e5c0e
No known key found for this signature in database
GPG key ID: 80E5375C094198D8
5 changed files with 553 additions and 108 deletions

View file

@ -866,7 +866,9 @@ func (h *HtlcScriptV3) GenTimeoutWitness(
// IsSuccessWitness checks whether the given stack is valid for
// redeeming the htlc.
func (h *HtlcScriptV3) IsSuccessWitness(witness wire.TxWitness) bool {
return len(witness) == 4
// The witness has four elements if this is a script spend or one
// element if this is a keyspend.
return len(witness) == 4 || len(witness) == 1
}
// TimeoutScript returns the redeem script required to unlock the htlc after