From 8b0a351f52b8fe251ee0a84528ce649c063fb75a Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sat, 9 Nov 2019 10:12:53 +0100 Subject: [PATCH] fix(wallet): present correct fee when no route Ensure fee rate is displayed as `unknown` if no routes are found. Fix #3154 --- renderer/components/Pay/PaySummary.js | 29 +++---------------- .../components/Pay/PaySummaryLightning.js | 2 +- renderer/reducers/pay.js | 4 +-- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/renderer/components/Pay/PaySummary.js b/renderer/components/Pay/PaySummary.js index e28bc4c7ce5..c28fedcc1fa 100644 --- a/renderer/components/Pay/PaySummary.js +++ b/renderer/components/Pay/PaySummary.js @@ -8,29 +8,16 @@ import { PAY_FORM_STEPS } from './constants' import { getFeeRate } from './utils' const PaySummary = props => { - const { amountInSats, formApi, isOnchain, lndTargetConfirmations } = props + const { amountInSats, formApi, isOnchain, lndTargetConfirmations, onchainFees, routes } = props const formState = formApi.getState() const { speed, payReq, isCoinSweep } = formState.values - /** - * getFee - Get the current per byte fee based on the form values. - * - * @returns {number} Fee rate for currently selected conf speed - */ - const getFee = () => { - const { formApi, onchainFees } = props - const formState = formApi.getState() - const { speed } = formState.values - - return getFeeRate(onchainFees, speed) - } - if (isOnchain) { return ( { ) } - const { routes } = props - let minFee = 0 - let maxFeeInclusive = 0 - if (routes.length) { - minFee = getMinFee(routes) - maxFeeInclusive = getMaxFeeInclusive(routes) - } - return ( diff --git a/renderer/components/Pay/PaySummaryLightning.js b/renderer/components/Pay/PaySummaryLightning.js index 75e2a062f7d..e514caceaec 100644 --- a/renderer/components/Pay/PaySummaryLightning.js +++ b/renderer/components/Pay/PaySummaryLightning.js @@ -76,7 +76,7 @@ class PaySummaryLightning extends React.Component { let feeMessage = messages.fee_unknown // If thex max fee is 0 or 1 then show a message like "less than 1". - if (maxFee === 0 || maxFee === 1) { + if (maxFee >= 0 && maxFee < 1) { feeMessage = messages.fee_less_than_1 } // Otherwise, if we have both a min and max fee that are different, present the fee range. diff --git a/renderer/reducers/pay.js b/renderer/reducers/pay.js index ebcb0e505c7..eaffe04f1b7 100644 --- a/renderer/reducers/pay.js +++ b/renderer/reducers/pay.js @@ -203,7 +203,7 @@ export const queryFees = (address, amountInSats) => async (dispatch, getState) = dispatch({ type: QUERY_FEES_SUCCESS, onchainFees }) } catch (e) { - const error = get(e, 'response.statusText', e) + const error = get(e, 'response.statusText', e.message) dispatch({ type: QUERY_FEES_FAILURE, error }) } } @@ -225,7 +225,7 @@ export const queryRoutes = (pubKey, amount) => async dispatch => { }) dispatch({ type: QUERY_ROUTES_SUCCESS, routes }) } catch (e) { - dispatch({ type: QUERY_ROUTES_FAILURE }) + dispatch({ type: QUERY_ROUTES_FAILURE, error: e.message }) } }