From 6759be05de6fcb5235426bad626e5c09cb51a84e Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Thu, 12 Mar 2020 00:16:58 -0700 Subject: [PATCH] fix(ui): add zero amount payment request error (#3385) address #1510 --- renderer/components/Form/LightningInvoiceInput.js | 6 +++++- renderer/components/Form/messages.js | 2 ++ translations/af-ZA.json | 1 + translations/ar-SA.json | 1 + translations/bg-BG.json | 1 + translations/ca-ES.json | 1 + translations/cs-CZ.json | 1 + translations/da-DK.json | 1 + translations/de-DE.json | 1 + translations/el-GR.json | 1 + translations/en.json | 1 + translations/es-ES.json | 1 + translations/fi-FI.json | 1 + translations/fr-FR.json | 1 + translations/ga-IE.json | 1 + translations/he-IL.json | 1 + translations/hi-IN.json | 1 + translations/hr-HR.json | 1 + translations/hu-HU.json | 1 + translations/it-IT.json | 1 + translations/ja-JP.json | 1 + translations/ko-KR.json | 1 + translations/nl-NL.json | 1 + translations/no-NO.json | 1 + translations/pl-PL.json | 1 + translations/pt-BR.json | 1 + translations/pt-PT.json | 1 + translations/ro-RO.json | 1 + translations/ru-RU.json | 1 + translations/sr-SP.json | 1 + translations/sv-SE.json | 1 + translations/tr-TR.json | 1 + translations/uk-UA.json | 1 + translations/vi-VN.json | 1 + translations/zh-CN.json | 1 + translations/zh-TW.json | 1 + 36 files changed, 41 insertions(+), 1 deletion(-) diff --git a/renderer/components/Form/LightningInvoiceInput.js b/renderer/components/Form/LightningInvoiceInput.js index fcfe7efee3d..35b30474595 100644 --- a/renderer/components/Form/LightningInvoiceInput.js +++ b/renderer/components/Form/LightningInvoiceInput.js @@ -23,9 +23,13 @@ const validate = (intl, network, chain, value) => { if (isLn(value, chain, network)) { try { const invoice = decodePayReq(value) - if (!invoice || (!invoice.satoshis && !invoice.millisatoshis)) { + if (!invoice) { throw new Error('Invalid invoice') } + + if (!invoice.satoshis && !invoice.millisatoshis) { + return intl.formatMessage({ ...messages.zero_amount_request }) + } } catch (e) { return invalidRequestMessage } diff --git a/renderer/components/Form/messages.js b/renderer/components/Form/messages.js index a7f4a44d437..ac4d79d8b7e 100644 --- a/renderer/components/Form/messages.js +++ b/renderer/components/Form/messages.js @@ -24,4 +24,6 @@ export default defineMessages({ transaction_speed_description_medium: 'less than 3 hours', transaction_speed_description_slow: 'up to 24 hours', transaction_speed_description_slowest: 'more than 24 hours', + zero_amount_request: + 'Unsupported lightning payment request: payment requests must include a non-zero amount.', }) diff --git a/translations/af-ZA.json b/translations/af-ZA.json index f57133982b4..720187d6444 100644 --- a/translations/af-ZA.json +++ b/translations/af-ZA.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/ar-SA.json b/translations/ar-SA.json index b108066eced..787a46b27fa 100644 --- a/translations/ar-SA.json +++ b/translations/ar-SA.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/bg-BG.json b/translations/bg-BG.json index 8fc9b3d257c..a7d7b60b87c 100644 --- a/translations/bg-BG.json +++ b/translations/bg-BG.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/ca-ES.json b/translations/ca-ES.json index f57133982b4..720187d6444 100644 --- a/translations/ca-ES.json +++ b/translations/ca-ES.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/cs-CZ.json b/translations/cs-CZ.json index 48ce7cda651..584255f4137 100644 --- a/translations/cs-CZ.json +++ b/translations/cs-CZ.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "Pomalu", "components.Form.valid_pubkey": "Validní PubKey", "components.Form.valid_request": "Validní {chain} požadavek", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "Zrušit", "components.Home.button_save": "Uložit", "components.Home.cert_description": "Cesta k lnd tls certifikátu.", diff --git a/translations/da-DK.json b/translations/da-DK.json index a09b626637c..42bae4e2e35 100644 --- a/translations/da-DK.json +++ b/translations/da-DK.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "Gyldig {chain} anmodning", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/de-DE.json b/translations/de-DE.json index c2da55dacb8..e9136748f94 100644 --- a/translations/de-DE.json +++ b/translations/de-DE.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "Langsam", "components.Form.valid_pubkey": "Gültiger PubKey", "components.Form.valid_request": "Gültige {chain} -Anfrage", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "Abbrechen", "components.Home.button_save": "Speichern", "components.Home.cert_description": "Pfad zum Lnd TLS-Zertifikat.", diff --git a/translations/el-GR.json b/translations/el-GR.json index 27d24b9b3e7..8a01fb2d115 100644 --- a/translations/el-GR.json +++ b/translations/el-GR.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/en.json b/translations/en.json index 63e857c97cf..7fd4ecb04db 100644 --- a/translations/en.json +++ b/translations/en.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "Slow", "components.Form.valid_pubkey": "Valid PubKey", "components.Form.valid_request": "Valid {chain} request", + "components.Form.zero_amount_request": "Unsupported lightning payment request: payment requests must include a non-zero amount.", "components.Home.button_cancel": "Cancel", "components.Home.button_save": "Save", "components.Home.cert_description": "Path to the lnd tls cert.", diff --git a/translations/es-ES.json b/translations/es-ES.json index b8ceb6b104f..2c9685c508d 100644 --- a/translations/es-ES.json +++ b/translations/es-ES.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "Lento", "components.Form.valid_pubkey": "Pubkey Valida", "components.Form.valid_request": "Solicitud valida de {chain}", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "Cancelar", "components.Home.button_save": "Guardar", "components.Home.cert_description": "La ruta al certificado tls de lnd.", diff --git a/translations/fi-FI.json b/translations/fi-FI.json index f57133982b4..720187d6444 100644 --- a/translations/fi-FI.json +++ b/translations/fi-FI.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/fr-FR.json b/translations/fr-FR.json index cb67289f329..0564ed7c162 100644 --- a/translations/fr-FR.json +++ b/translations/fr-FR.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "Lente", "components.Form.valid_pubkey": "PubKey valide", "components.Form.valid_request": "Requête {chain} valide", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "Annuler", "components.Home.button_save": "Enregistrer", "components.Home.cert_description": "Le chemin d'accès au certificat TLS de lnd.", diff --git a/translations/ga-IE.json b/translations/ga-IE.json index 8b08096df3d..e7eba6f2ba7 100644 --- a/translations/ga-IE.json +++ b/translations/ga-IE.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "Iarratas bailí {chain}", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/he-IL.json b/translations/he-IL.json index e90001a3fa6..595a2a4e5b6 100644 --- a/translations/he-IL.json +++ b/translations/he-IL.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/hi-IN.json b/translations/hi-IN.json index fbee16e2bae..36a7621b7cc 100644 --- a/translations/hi-IN.json +++ b/translations/hi-IN.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/hr-HR.json b/translations/hr-HR.json index b7a5f2de30a..96f75719ef1 100644 --- a/translations/hr-HR.json +++ b/translations/hr-HR.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "Sporo", "components.Form.valid_pubkey": "Valjan PubKey", "components.Form.valid_request": "Valjan {chain} zahtijev", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "Odustani", "components.Home.button_save": "Spremi", "components.Home.cert_description": "Staza do lnd tls cert.", diff --git a/translations/hu-HU.json b/translations/hu-HU.json index f57133982b4..720187d6444 100644 --- a/translations/hu-HU.json +++ b/translations/hu-HU.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/it-IT.json b/translations/it-IT.json index 519d64359a3..a51ca6f1795 100644 --- a/translations/it-IT.json +++ b/translations/it-IT.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/ja-JP.json b/translations/ja-JP.json index 518e0bdbe15..8fee615461d 100644 --- a/translations/ja-JP.json +++ b/translations/ja-JP.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/ko-KR.json b/translations/ko-KR.json index f57133982b4..720187d6444 100644 --- a/translations/ko-KR.json +++ b/translations/ko-KR.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/nl-NL.json b/translations/nl-NL.json index cbae963ad8b..3180b69edc1 100644 --- a/translations/nl-NL.json +++ b/translations/nl-NL.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/no-NO.json b/translations/no-NO.json index 2db72b3c8f0..1f2ce86e6c6 100644 --- a/translations/no-NO.json +++ b/translations/no-NO.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "Sakte", "components.Form.valid_pubkey": "Gyldig PubKey", "components.Form.valid_request": "Gyldig {chain} forespørsel", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "Avbryt", "components.Home.button_save": "Lagre", "components.Home.cert_description": "", diff --git a/translations/pl-PL.json b/translations/pl-PL.json index edd9bc93f43..6a88db38491 100644 --- a/translations/pl-PL.json +++ b/translations/pl-PL.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/pt-BR.json b/translations/pt-BR.json index 6f675a00190..1e46ce37644 100644 --- a/translations/pt-BR.json +++ b/translations/pt-BR.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/pt-PT.json b/translations/pt-PT.json index 593c57cc721..9f10a7781d3 100644 --- a/translations/pt-PT.json +++ b/translations/pt-PT.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/ro-RO.json b/translations/ro-RO.json index 94cc7329ca9..afde41b988b 100644 --- a/translations/ro-RO.json +++ b/translations/ro-RO.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/ru-RU.json b/translations/ru-RU.json index f0de69dc6e9..69b2870aa93 100644 --- a/translations/ru-RU.json +++ b/translations/ru-RU.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "Отмена", "components.Home.button_save": "Сохранить", "components.Home.cert_description": "", diff --git a/translations/sr-SP.json b/translations/sr-SP.json index f57133982b4..720187d6444 100644 --- a/translations/sr-SP.json +++ b/translations/sr-SP.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/sv-SE.json b/translations/sv-SE.json index 1e20a81fc3d..15ed6c2dae6 100644 --- a/translations/sv-SE.json +++ b/translations/sv-SE.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/tr-TR.json b/translations/tr-TR.json index 144445895c2..0919b01e98f 100644 --- a/translations/tr-TR.json +++ b/translations/tr-TR.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/uk-UA.json b/translations/uk-UA.json index 39e6eb17d6e..2a180329b2d 100644 --- a/translations/uk-UA.json +++ b/translations/uk-UA.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "Скасувати", "components.Home.button_save": "Зберегти", "components.Home.cert_description": "", diff --git a/translations/vi-VN.json b/translations/vi-VN.json index f57133982b4..720187d6444 100644 --- a/translations/vi-VN.json +++ b/translations/vi-VN.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/zh-CN.json b/translations/zh-CN.json index a6716d31fb7..f9dc6df439e 100644 --- a/translations/zh-CN.json +++ b/translations/zh-CN.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "", diff --git a/translations/zh-TW.json b/translations/zh-TW.json index 4f0facb32d0..47a035db083 100644 --- a/translations/zh-TW.json +++ b/translations/zh-TW.json @@ -248,6 +248,7 @@ "components.Form.transaction_speed_slow": "", "components.Form.valid_pubkey": "", "components.Form.valid_request": "", + "components.Form.zero_amount_request": "", "components.Home.button_cancel": "", "components.Home.button_save": "", "components.Home.cert_description": "",