diff --git a/x/eibc/types/tx.go b/x/eibc/types/tx.go index 2416e5066..0a441a1e4 100644 --- a/x/eibc/types/tx.go +++ b/x/eibc/types/tx.go @@ -1,6 +1,8 @@ package types import ( + "encoding/hex" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -37,7 +39,7 @@ func (msg *MsgFulfillOrder) GetSignBytes() []byte { } func (m *MsgFulfillOrder) ValidateBasic() error { - if m.OrderId == "" { + if !m.isValidOrderId(m.OrderId) { return ErrInvalidOrderID } _, err := sdk.AccAddressFromBech32(m.FulfillerAddress) @@ -47,6 +49,16 @@ func (m *MsgFulfillOrder) ValidateBasic() error { return nil } +func (m *MsgFulfillOrder) isValidOrderId(orderId string) bool { + hashBytes, err := hex.DecodeString(orderId) + if err != nil { + // The string is not a valid hexadecimal string + return false + } + // SHA-256 hashes are 32 bytes long + return len(hashBytes) == 32 +} + func (m *MsgFulfillOrder) Validate() error { if err := m.ValidateBasic(); err != nil { return err