@ -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