mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopout: add unit test for the MuSig2 sweep case
This commit is contained in:
parent
82b58e5c0e
commit
5d7b0abdf5
6 changed files with 244 additions and 37 deletions
11
loopout.go
11
loopout.go
|
|
@ -10,7 +10,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
|
|
@ -96,6 +96,7 @@ type executeConfig struct {
|
|||
totalPaymentTimout time.Duration
|
||||
maxPaymentRetries int
|
||||
cancelSwap func(context.Context, *outCancelDetails) error
|
||||
verifySchnorrSig func(pubKey *btcec.PublicKey, hash, sig []byte) error
|
||||
}
|
||||
|
||||
// loopOutInitResult contains information about a just-initiated loop out swap.
|
||||
|
|
@ -1437,15 +1438,13 @@ func (s *loopOutSwap) createMuSig2SweepTxn(
|
|||
|
||||
// To be sure that we're good, parse and validate that the combined
|
||||
// signature is indeed valid for the sig hash and the internal pubkey.
|
||||
sig, err := schnorr.ParseSignature(finalSig)
|
||||
err = s.executeConfig.verifySchnorrSig(
|
||||
htlc.TaprootKey, sigHash, finalSig,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !sig.Verify(sigHash, htlc.TaprootKey) {
|
||||
return nil, fmt.Errorf("invalid combined signature")
|
||||
}
|
||||
|
||||
// Now that we know the signature is correct, we can fill it in to our
|
||||
// witness.
|
||||
sweepTx.TxIn[0].Witness = wire.TxWitness{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue