Skip to content

Commit afa021e

Browse files
committed
add duplicate check for dkg participants
1 parent faa93c0 commit afa021e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

x/btcbridge/types/msg_initiate_dkg.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ func (m *MsgInitiateDKG) ValidateBasic() error {
1818
return ErrInvalidDKGParams
1919
}
2020

21+
participants := make(map[string]bool)
22+
2123
for _, p := range m.Participants {
2224
if len(p.Moniker) > stakingtypes.MaxMonikerLength {
2325
return ErrInvalidDKGParams
@@ -30,6 +32,12 @@ func (m *MsgInitiateDKG) ValidateBasic() error {
3032
if _, err := sdk.ConsAddressFromHex(p.ConsensusAddress); err != nil {
3133
return errorsmod.Wrap(err, "invalid consensus address")
3234
}
35+
36+
if participants[p.ConsensusAddress] {
37+
return errorsmod.Wrap(ErrInvalidDKGParams, "duplicate participant")
38+
}
39+
40+
participants[p.ConsensusAddress] = true
3341
}
3442

3543
if len(m.VaultTypes) == 0 {

0 commit comments

Comments
 (0)