mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
Reject duplicate static-address deposit outpoints before creating withdrawal, loop-in, or channel-open requests. Use the shared outpoint duplicate helper so each flow reports the same input validation failure.
21 lines
444 B
Go
21 lines
444 B
Go
package deposit
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
|
)
|
|
|
|
// CheckDuplicates returns an error if the outpoint list contains duplicates.
|
|
func CheckDuplicates(outpoints []wire.OutPoint) error {
|
|
seen := make(map[wire.OutPoint]struct{}, len(outpoints))
|
|
for _, outpoint := range outpoints {
|
|
if _, ok := seen[outpoint]; ok {
|
|
return fmt.Errorf("duplicate outpoint %v", outpoint)
|
|
}
|
|
|
|
seen[outpoint] = struct{}{}
|
|
}
|
|
|
|
return nil
|
|
}
|