Browse Source
Merge pull request #185 from LN-Zap/fix/payment-timeout
fix(payment): dont let sending a payment hang foevaaa
renovate/lint-staged-8.x
JimmyMow
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
14 additions and
5 deletions
-
app/reducers/payment.js
|
|
@ -57,11 +57,6 @@ 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) => { |
|
|
|
dispatch(sendPayment()) |
|
|
|
ipcRenderer.send('lnd', { msg: 'sendPayment', data: { paymentRequest } }) |
|
|
|
} |
|
|
|
|
|
|
|
// Receive IPC event for successful payment
|
|
|
|
// TODO: Add payment to state, not a total re-fetch
|
|
|
|
export const paymentSuccessful = () => (dispatch) => { |
|
|
@ -87,6 +82,20 @@ export const paymentFailed = (event, { error }) => (dispatch) => { |
|
|
|
dispatch(setError(error)) |
|
|
|
} |
|
|
|
|
|
|
|
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) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------
|
|
|
|
// Action Handlers
|
|
|
|