From 0f55af61292e1cbe8ea6ed73346c597fe5524d5f Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Thu, 11 Jan 2018 23:35:39 -0600 Subject: [PATCH] fix(payment): setTimeout for 10 seconds after sending a payment. if LND hangs while sending a payment we wont show the loading screen forever lol we'll remove it and show an error after 10 seconds --- app/reducers/payment.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/reducers/payment.js b/app/reducers/payment.js index a3907ca7..7a1fbc66 100644 --- a/app/reducers/payment.js +++ b/app/reducers/payment.js @@ -57,9 +57,18 @@ export const fetchPayments = () => (dispatch) => { // Receive IPC event for payments export const receivePayments = (event, { payments }) => dispatch => dispatch({ type: RECEIVE_PAYMENTS, payments }) -export const payInvoice = paymentRequest => (dispatch) => { +export const payInvoice = paymentRequest => (dispatch, getState) => { dispatch(sendPayment()) ipcRenderer.send('lnd', { msg: 'sendPayment', data: { paymentRequest } }) + + // if LND hangs on sending the payment we'll cut it after 10 seconds and return an error + setTimeout(() => { + const { payment } = getState() + + if (payment.sendingPayment) { + dispatch(paymentFailed(null, { error: `Shoot, we're having some trouble sending your payment.` })) + } + }, 10000) } // Receive IPC event for successful payment