Browse Source

feature(payment error): error handling for LN payment

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
3dedf6c522
  1. 19
      app/components/GlobalError/GlobalError.js
  2. 5
      app/lnd/methods/index.js
  3. 3
      app/reducers/ipc.js
  4. 13
      app/reducers/payment.js
  5. 1
      app/reducers/transaction.js
  6. 10
      app/routes/app/containers/AppContainer.js

19
app/components/GlobalError/GlobalError.js

@ -3,16 +3,19 @@ import PropTypes from 'prop-types'
import { MdClose } from 'react-icons/lib/md'
import styles from './GlobalError.scss'
const GlobalError = ({ error, clearError }) => (
<div className={`${styles.container} ${!error && styles.closed}`}>
<div className={styles.content}>
<div className={styles.close} onClick={clearError}>
<MdClose />
const GlobalError = ({ error, clearError }) => {
console.log('error: ', error)
return (
<div className={`${styles.container} ${!error && styles.closed}`}>
<div className={styles.content}>
<div className={styles.close} onClick={clearError}>
<MdClose />
</div>
<h2>{error}</h2>
</div>
<h2>{error}</h2>
</div>
</div>
)
)
}
GlobalError.propTypes = {

5
app/lnd/methods/index.js

@ -112,7 +112,10 @@ export default function (lnd, event, msg, data) {
// { paymentRequest } = data
paymentsController.sendPaymentSync(lnd, data)
.then(({ payment_route }) => event.sender.send('paymentSuccessful', Object.assign(data, { payment_route })))
.catch(error => console.log('payinvoice error: ', error))
.catch(error => {
console.log('payinvoice error: ', error)
event.sender.send('paymentFailed', { error: error.toString() })
})
break
case 'sendCoins':
// Transaction looks like { txid: String }

3
app/reducers/ipc.js

@ -21,7 +21,7 @@ import {
} from './channels'
import { lightningPaymentUri } from './payform'
import { receivePayments, paymentSuccessful } from './payment'
import { receivePayments, paymentSuccessful, paymentFailed } from './payment'
import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate } from './invoice'
import { receiveBalance } from './balance'
import {
@ -55,6 +55,7 @@ const ipc = createIpc({
lightningPaymentUri,
paymentSuccessful,
paymentFailed,
channelSuccessful,
pushchannelupdated,

13
app/reducers/payment.js

@ -4,6 +4,7 @@ import { fetchBalance } from './balance'
import { setFormType } from './form'
import { resetPayForm } from './payform'
import { showModal } from './modal'
import { setError } from './error'
// ------------------------------------
// Constants
@ -47,12 +48,6 @@ export function paymentSuccessfull(payment) {
}
}
export function paymentFailed() {
return {
type: PAYMENT_FAILED
}
}
// Send IPC event for payments
export const fetchPayments = () => (dispatch) => {
dispatch(getPayments())
@ -87,6 +82,12 @@ export const paymentSuccessful = () => (dispatch) => {
dispatch(fetchBalance())
}
export const paymentFailed = (event, { error }) => (dispatch) => {
dispatch({ type: PAYMENT_FAILED })
console.log('error: ', error)
dispatch(setError(error))
}
// ------------------------------------
// Action Handlers

1
app/reducers/transaction.js

@ -70,6 +70,7 @@ export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatc
export const transactionError = (event, { error }) => (dispatch) => {
dispatch({ type: TRANSACTION_FAILED })
console.log('error: ', error)
dispatch(setError(error))
}

10
app/routes/app/containers/AppContainer.js

@ -49,15 +49,9 @@ const mapDispatchToProps = {
createInvoice,
fetchInvoice,
<<<<<<< HEAD
<<<<<<< HEAD
fetchBlockHeight
=======
fetchBlockHeight,
clearError,
clearError
>>>>>>> feature(globalerror): clear error
=======
clearError
>>>>>>> 46b03abc5a79d74487165abf8656e69da020f3bc
}
const mapStateToProps = state => ({

Loading…
Cancel
Save