@@ -334,12 +334,21 @@ func (m msgServer) Close(goCtx context.Context, msg *types.MsgClose) (*types.Msg
334
334
return nil , types .ErrInvalidRepayment
335
335
}
336
336
337
- repay := m .GetRepayment (ctx , msg .LoanId )
337
+ repayment := m .GetRepayment (ctx , msg .LoanId )
338
+ if len (repayment .DcaAdaptorSignature ) == 0 {
339
+ return nil , types .ErrRepaymentAdaptorSigDoesNotExist
340
+ }
341
+
342
+ sigBytes , _ := hex .DecodeString (msg .Signature )
343
+ adaptorSigBytes , _ := hex .DecodeString (repayment .DcaAdaptorSignature )
338
344
339
345
// extract secret from signature
340
- secret := msg .Signature + repay .RepayAdaptorPoint // fix it later.
346
+ secret := adaptor .Extract (sigBytes , adaptorSigBytes )
347
+ if len (secret ) == 0 {
348
+ return nil , types .ErrInvalidSignature
349
+ }
341
350
342
- if types .AdaptorPoint (secret ) != repay .RepayAdaptorPoint {
351
+ if types .AdaptorPoint (secret ) != repayment .RepayAdaptorPoint {
343
352
return nil , types .ErrInvalidRepaymentSecret
344
353
}
345
354
@@ -355,7 +364,7 @@ func (m msgServer) Close(goCtx context.Context, msg *types.MsgClose) (*types.Msg
355
364
356
365
m .EmitEvent (ctx , msg .Relayer ,
357
366
sdk .NewAttribute ("loan_id" , loan .VaultAddress ),
358
- sdk .NewAttribute ("payment_secret" , secret ),
367
+ sdk .NewAttribute ("payment_secret" , hex . EncodeToString ( secret ) ),
359
368
)
360
369
361
370
return & types.MsgCloseResponse {}, nil
0 commit comments