Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mj850 committed Nov 14, 2024
1 parent 2c73e2d commit 3ea53a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x/confidentialtransfers/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func makeWithdrawCmd(cmd *cobra.Command, args []string) error {
}
address := clientCtx.GetFromAddress().String()
denom := args[0]
amount, err := strconv.ParseUint(args[2], 10, 64)
amount, err := strconv.ParseUint(args[1], 10, 64)
if err != nil {
return err
}
Expand Down Expand Up @@ -352,7 +352,7 @@ func makeDepositCmd(cmd *cobra.Command, args []string) error {

address := clientCtx.GetFromAddress().String()
denom := args[0]
amount, err := strconv.ParseUint(args[2], 10, 64)
amount, err := strconv.ParseUint(args[1], 10, 64)
if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions x/confidentialtransfers/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ func (m msgServer) Transfer(goCtx context.Context, req *types.MsgTransfer) (*typ
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid msg")
}

if instruction.FromAddress == instruction.ToAddress {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "sender and recipient addresses must be different")
}

// Check that sender and recipient accounts exist.
senderAccount, exists := m.Keeper.GetAccount(ctx, req.FromAddress, req.Denom)
if !exists {
Expand Down
5 changes: 5 additions & 0 deletions x/confidentialtransfers/types/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func NewTransfer(
amount uint64,
recipientPubkey *curves.Point,
auditors []AuditorInput) (*Transfer, error) {

if senderAddr == recipientAddr {
return &Transfer{}, errors.New("sender and recipient addresses cannot be the same")
}

Check failure on line 71 in x/confidentialtransfers/types/transfer.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofmt`-ed with `-s` (gofmt)
// Get the current balance of the account from the decryptableBalance
aesKey, err := encryption.GetAESKey(*privateKey, denom)
if err != nil {
Expand Down

0 comments on commit 3ea53a6

Please sign in to comment.