mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-18 13:08:28 +02:00
instantout: guard MuSig peer slice lengths
Peer MuSig data was indexed by reservation position before validating counts. Short server responses could panic loopd instead of returning an error.
This commit is contained in:
parent
60d43898f0
commit
add29cf2d0
1 changed files with 12 additions and 0 deletions
|
|
@ -263,6 +263,12 @@ func (i *InstantOut) signMusig2Tx(ctx context.Context,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(musig2sessions) != len(inputs) {
|
||||
return nil, fmt.Errorf("invalid number of MuSig2 sessions")
|
||||
}
|
||||
if len(counterPartyNonces) != len(inputs) {
|
||||
return nil, fmt.Errorf("invalid number of peer nonces")
|
||||
}
|
||||
|
||||
prevOutFetcher := inputs.GetPrevoutFetcher()
|
||||
sigHashes := txscript.NewTxSigHashes(tx, prevOutFetcher)
|
||||
|
|
@ -329,6 +335,12 @@ func (i *InstantOut) finalizeMusig2Transaction(ctx context.Context,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(musig2Sessions) != len(inputs) {
|
||||
return nil, fmt.Errorf("invalid number of MuSig2 sessions")
|
||||
}
|
||||
if len(serverSigs) != len(inputs) {
|
||||
return nil, fmt.Errorf("invalid number of peer signatures")
|
||||
}
|
||||
|
||||
for idx := range inputs {
|
||||
haveAllSigs, finalSig, err := signer.MuSig2CombineSig(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue