Skip to content

Commit

Permalink
fix: check for invoice expiry before navigating to send
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Dec 16, 2024
1 parent 4c5db75 commit 821ba28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/screens/wallet/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function Send() {
}

const invoice = new Invoice({ pr: recipient });

navigate(`/wallet/send/confirm-payment`, {
state: {
args: { paymentRequest: invoice },
Expand Down
8 changes: 8 additions & 0 deletions transactions/transactions_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ func (svc *transactionsService) SendPaymentSync(ctx context.Context, payReq stri
return nil, err
}

if time.Now().After(time.Unix(int64(paymentRequest.CreatedAt+paymentRequest.Expiry), 0)) {
logger.Logger.WithFields(logrus.Fields{
"bolt11": payReq,
}).Errorf("Failed to decode bolt11 invoice: %v", err)

return nil, errors.New("this invoice has expired")
}

selfPayment := paymentRequest.Payee != "" && paymentRequest.Payee == lnClient.GetPubkey()

var dbTransaction db.Transaction
Expand Down

0 comments on commit 821ba28

Please sign in to comment.