Skip to content

Commit

Permalink
ensure borrower matched when redeeming
Browse files Browse the repository at this point in the history
  • Loading branch information
keithsue committed Jan 14, 2025
1 parent dc5acd8 commit b779be6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions x/lending/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ func (m msgServer) Redeem(goCtx context.Context, msg *types.MsgRedeem) (*types.M

loan := m.GetLoan(ctx, msg.LoanId)

if msg.Borrower != loan.Borrower {
return nil, types.ErrMismatchedBorrower
}

if types.HashLoanSecret(msg.LoanSecret) != loan.HashLoanSecret {
return nil, types.ErrMismatchLoanSecret
}
Expand Down
5 changes: 3 additions & 2 deletions x/lending/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ var (
ErrInvalidProof = errorsmod.Register(ModuleName, 4002, "invalid proof")
ErrDepositTxNotExists = errorsmod.Register(ModuleName, 4002, "deposit not exists")

ErrEmptyLoanSecret = errorsmod.Register(ModuleName, 5001, "invalid loan secret")
ErrMismatchLoanSecret = errorsmod.Register(ModuleName, 5001, "mismatch loan secret")
ErrMismatchedBorrower = errorsmod.Register(ModuleName, 5001, "mismatched borrower")
ErrEmptyLoanSecret = errorsmod.Register(ModuleName, 5002, "invalid loan secret")
ErrMismatchLoanSecret = errorsmod.Register(ModuleName, 5003, "mismatch loan secret")

ErrEmptyAdaptorPoint = errorsmod.Register(ModuleName, 6001, "invalid adaptor point")
ErrInvalidRepayment = errorsmod.Register(ModuleName, 6002, "invalid repayment")
Expand Down

0 comments on commit b779be6

Please # to comment.