Browse Source

feature(sendcoins): hook up error handling backend -> frontend for sendcoins

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
934b7e6f57
  1. 2
      app/lnd/methods/index.js
  2. 3
      app/reducers/ipc.js
  3. 9
      app/reducers/payment.js

2
app/lnd/methods/index.js

@ -97,7 +97,7 @@ export default function (lnd, event, msg, data) {
// { amount, addr } = data
walletController.sendCoins(lnd, data)
.then(({ txid }) => event.sender.send('sendSuccessful', { amount: data.amount, addr: data.addr, txid }))
.catch(error => console.log('sendcoins error: ', error))
.catch(error => event.sender.send('sendCoinsError', { error }))
break
case 'openChannel':
// Response is empty. Streaming updates on channel status and updates

3
app/reducers/ipc.js

@ -19,7 +19,7 @@ import {
pushclosechannelstatus
} from './channels'
import { receivePayments, paymentSuccessful, sendSuccessful } from './payment'
import { receivePayments, paymentSuccessful, sendSuccessful, sendCoinsError } from './payment'
import { receiveInvoices, createdInvoice, receiveFormInvoice } from './invoice'
import { receiveBalance } from './balance'
@ -41,6 +41,7 @@ const ipc = createIpc({
paymentSuccessful,
sendSuccessful,
sendCoinsError,
channelSuccessful,
pushchannelupdated,

9
app/reducers/payment.js

@ -2,7 +2,7 @@ import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { btc, usd } from '../utils'
import { setForm, resetForm } from './form'
import { showModal } from './modal'
import { showModal, hideModal } from './modal'
// ------------------------------------
// Constants
@ -88,6 +88,10 @@ export const sendSuccessful = (event, { amount, addr, txid }) => (dispatch) => {
dispatch(resetForm())
}
export const sendCoinsError = (event, { error }) => (dispatch) => {
dispatch({ type: PAYMENT_FAILED })
}
// ------------------------------------
// Action Handlers
@ -97,7 +101,8 @@ const ACTION_HANDLERS = {
[GET_PAYMENTS]: state => ({ ...state, paymentLoading: true }),
[SEND_PAYMENT]: state => ({ ...state, sendingPayment: true }),
[RECEIVE_PAYMENTS]: (state, { payments }) => ({ ...state, paymentLoading: false, payments }),
[PAYMENT_SUCCESSFULL]: state => ({ ...state, sendingPayment: false })
[PAYMENT_SUCCESSFULL]: state => ({ ...state, sendingPayment: false }),
[PAYMENT_FAILED]: state => ({ ...state, sendingPayment: false })
}
const paymentSelectors = {}

Loading…
Cancel
Save