Skip to content
Permalink
Browse files

fix(wallet): handle case when payment path is missing

  • Loading branch information...
mrfelton committed Jun 3, 2019
1 parent 5999b60 commit a94d091269ae947fae73d3439a4e352c55e27de6
@@ -1,18 +1,34 @@
import React from 'react'
import PropTypes from 'prop-types'
import { FormattedMessage, FormattedTime, injectIntl, intlShape } from 'react-intl'
import { decodePayReq } from '@zap/utils/crypto'
import { Box, Flex } from 'rebass'
import { Message, Text } from 'components/UI'
import { CryptoValue, FiatValue } from 'containers/UI'
import messages from './messages'

const Payment = ({ payment, showActivityModal, nodes, currencyName, intl }) => {
const displayNodeName = pubkey => {
const node = nodes.find(n => pubkey === n.pub_key)
if (node && node.alias.length) {
return node.alias
const displayNodeName = payment => {
// First try to get the pubkey from payment.path
let pubkey = payment.path && payment.path[payment.path.length - 1]

// If we don't have a pubkey, try to get it from the payment request.
if (!pubkey && payment.payment_request) {
const paymentRequest = decodePayReq(payment.payment_request)
pubkey = paymentRequest.payeeNodeKey
}

// If we know the pubkey, try to lookup its alias.
if (pubkey) {
const node = nodes.find(n => pubkey === n.pub_key)
if (node && node.alias.length) {
return node.alias
}
return pubkey.substring(0, 10)
}
return pubkey.substring(0, 10)

// If all else fails, return the string 'unknown'.
return intl.formatMessage({ ...messages.unknown })
}

return (
@@ -27,7 +43,7 @@ const Payment = ({ payment, showActivityModal, nodes, currencyName, intl }) => {
data-hint={intl.formatMessage({ ...messages.type })}
width={3 / 4}
>
<Text mb={1}>{displayNodeName(payment.path[payment.path.length - 1])}</Text>
<Text mb={1}>{displayNodeName(payment)}</Text>
{payment.sending ? (
<>
{payment.status === 'sending' && (
@@ -8,4 +8,5 @@ export default defineMessages({
status_processing: 'Processing your payment...',
status_success: 'Your payment was successful.',
status_error: 'There was a problem sending your payment.',
unknown: 'Unknown',
})
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "Lightning плащане",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "Zap behandler din betaling. Dette kan tage op til 01:00 min.",
"components.Activity.Payment.status_success": "Din betaling var succesfuld.",
"components.Activity.Payment.type": "Lightning betaling",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "Beløb",
"components.Activity.PaymentModal.current_value": "Nuværende værdi",
"components.Activity.PaymentModal.date_sent": "Dato sendt",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "Deine Zahlung wird bearbeitet...",
"components.Activity.Payment.status_success": "Zahlung wurde erfolgreich ausgeführt.",
"components.Activity.Payment.type": "Lightning Zahlung",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "Betrag",
"components.Activity.PaymentModal.current_value": "Aktueller Wert",
"components.Activity.PaymentModal.date_sent": "Sendedatum",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "Processing your payment...",
"components.Activity.Payment.status_success": "Your payment was successful.",
"components.Activity.Payment.type": "Lightning payment",
"components.Activity.Payment.unknown": "Unknown",
"components.Activity.PaymentModal.amount": "Amount",
"components.Activity.PaymentModal.current_value": "Current value",
"components.Activity.PaymentModal.date_sent": "Date sent",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "Procesando su pago...",
"components.Activity.Payment.status_success": "Su pago ha sido exitoso",
"components.Activity.Payment.type": "Pago de Lightning",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "Cantidad",
"components.Activity.PaymentModal.current_value": "Valor actual",
"components.Activity.PaymentModal.date_sent": "Fecha enviado",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "Paiements Lightning",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "Date d'envoi",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "Tá Zap ag próiseáil d'íocaíochta. Is féidir é seo a dhéanamh go dtí 01:00 nóiméad.",
"components.Activity.Payment.status_success": "D'éirigh le d'íocaíocht.",
"components.Activity.Payment.type": "Íocaíocht lightning",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "Méid",
"components.Activity.PaymentModal.current_value": "Luach reatha",
"components.Activity.PaymentModal.date_sent": "Dáta a seoladh",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "Zap procesuira vaše plaćanje. Ovo može potrajati do jedne minute.",
"components.Activity.Payment.status_success": "Vaše plaćanje je bilo uspješno.",
"components.Activity.Payment.type": "LN plaćanje",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "Iznos",
"components.Activity.PaymentModal.current_value": "Trenutna vrijednost",
"components.Activity.PaymentModal.date_sent": "Datum slanja",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "Stiamo processando il tuo pagamento...",
"components.Activity.Payment.status_success": "Pagamento effettuato con successo.",
"components.Activity.Payment.type": "Pagamento Lightning",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "Importo",
"components.Activity.PaymentModal.current_value": "Valore attuale",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "お支払い処理中・・・",
"components.Activity.Payment.status_success": "お支払いは成功した !",
"components.Activity.Payment.type": "ライトニングペイメンツ",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "数量",
"components.Activity.PaymentModal.current_value": "現在値",
"components.Activity.PaymentModal.date_sent": "送信日",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "Zap 正在处理您的付款。这可能需要01:00 分钟。",
"components.Activity.Payment.status_success": "您的付款已成功",
"components.Activity.Payment.type": "闪电网络支付",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "数量",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "发送日期",
@@ -29,6 +29,7 @@
"components.Activity.Payment.status_processing": "",
"components.Activity.Payment.status_success": "",
"components.Activity.Payment.type": "",
"components.Activity.Payment.unknown": "",
"components.Activity.PaymentModal.amount": "",
"components.Activity.PaymentModal.current_value": "",
"components.Activity.PaymentModal.date_sent": "",

0 comments on commit a94d091

Please sign in to comment.
You can’t perform that action at this time.