From deba55f3549a46c7f94bcc71b2c4c03f47671437 Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Mon, 24 Mar 2025 17:32:28 +0100 Subject: [PATCH 1/5] fix(widgets): update weather fee on currency change --- src/hooks/useWeatherWidget.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hooks/useWeatherWidget.ts b/src/hooks/useWeatherWidget.ts index 828459b3b..012778779 100644 --- a/src/hooks/useWeatherWidget.ts +++ b/src/hooks/useWeatherWidget.ts @@ -3,6 +3,7 @@ import { __E2E__ } from '../constants/env'; import { widgetsCache } from '../storage/widgets-cache'; import { refreshOnchainFeeEstimates } from '../store/utils/fees'; import { getDisplayValues, getFiatDisplayValues } from '../utils/displayValues'; +import { useCurrency } from './displayValues'; type TBlockFeeRates = { avgHeight: number; @@ -107,6 +108,7 @@ const calculateCondition = ( }; const useWeatherWidget = (): TWidgetState => { + const { fiatTicker } = useCurrency(); const [state, setState] = useState(() => { const cached = getCachedData(); return cached @@ -145,7 +147,7 @@ const useWeatherWidget = (): TWidgetState => { // Total fee based on average native segwit transaction of 140 vBytes const avgFee = fees.normal * VBYTES_SIZE; - const dv = getDisplayValues({ satoshis: avgFee }); + const dv = getDisplayValues({ satoshis: avgFee, currency: fiatTicker }); const currentFee = `${dv.fiatSymbol} ${dv.fiatFormatted}`; const data = { condition, currentFee, nextBlockFee: fees.fast }; @@ -170,7 +172,7 @@ const useWeatherWidget = (): TWidgetState => { clearInterval(interval); abortController.abort(); }; - }, []); + }, [fiatTicker]); return state; }; From d62bdfce9e19ca704c4725d8a975c1fa12b15dcf Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Mon, 24 Mar 2025 18:13:50 +0100 Subject: [PATCH 2/5] fix: UTXO's -> UTXOs --- src/screens/Settings/AddressViewer/index.tsx | 10 +++++----- src/screens/Settings/DevSettings/index.tsx | 2 +- src/utils/i18n/locales/en/settings.json | 10 +++++----- src/utils/i18n/locales/en/wallet.json | 2 +- src/utils/wallet/electrum.ts | 4 ++-- src/utils/wallet/transactions.ts | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/screens/Settings/AddressViewer/index.tsx b/src/screens/Settings/AddressViewer/index.tsx index 7c39f9cdf..094fadd8b 100644 --- a/src/screens/Settings/AddressViewer/index.tsx +++ b/src/screens/Settings/AddressViewer/index.tsx @@ -257,11 +257,11 @@ const AddressViewer = (): ReactElement => { ); // The private key of the currently selected address to display qrcode data for. const [privateKey, setPrivateKey] = useState(undefined); - // Available array of UTXO's after checking for a balance. + // Available array of UTXOs after checking for a balance. const [utxos, setUtxos] = useState(); - // Total balance of available UTXO's after checking for a balance. + // Total balance of available UTXOs after checking for a balance. const [totalBalance, setTotalBalance] = useState(0); - // An array of UTXO's that are currently selected for spending. + // An array of UTXOs that are currently selected for spending. const [selectedUtxos, setSelectedUtxos] = useState([]); const [searchTxt, setSearchTxt] = useState(''); // Addresses filtered from a search query in onSearch. @@ -615,7 +615,7 @@ const AddressViewer = (): ReactElement => { ); /** - * This method will gather all selected UTXO's and setup an on-chain transaction. + * This method will gather all selected UTXOs and setup an on-chain transaction. * The on-chain transaction will retrieve and include the app's receiving address by default. * Finally, this method will prompt the sendNavigation modal to appear for the user to finalize and confirm the transaction. */ @@ -735,7 +735,7 @@ const AddressViewer = (): ReactElement => { }, [getMoreAddresses]); /** - * Retrieves the balance and UTXO's associated with all addresses of each type. + * Retrieves the balance and UTXOs associated with all addresses of each type. */ const onCheckBalance = useCallback(async (): Promise => { setIsCheckingBalances(true); diff --git a/src/screens/Settings/DevSettings/index.tsx b/src/screens/Settings/DevSettings/index.tsx index 22675c443..cac8aaff8 100644 --- a/src/screens/Settings/DevSettings/index.tsx +++ b/src/screens/Settings/DevSettings/index.tsx @@ -178,7 +178,7 @@ const DevSettings = ({ onPress: widgetsCache.clear, }, { - title: "Clear UTXO's", + title: 'Clear UTXOs', type: EItemType.button, onPress: clearUtxos, }, diff --git a/src/utils/i18n/locales/en/settings.json b/src/utils/i18n/locales/en/settings.json index 18a89ced4..58f28cbb5 100644 --- a/src/utils/i18n/locales/en/settings.json +++ b/src/utils/i18n/locales/en/settings.json @@ -430,31 +430,31 @@ "string": "Smallest First" }, "cs_max_description": { - "string": "Sort by and use smallest UTXO first. Potentially higher fee, but hides your largest UTXO's." + "string": "Sort by and use smallest UTXO first. Potentially higher fee, but hides your largest UTXOs." }, "cs_min": { "string": "Largest First" }, "cs_min_description": { - "string": "Sort by and use largest UTXO first. Potentially lower fee, but reveals your largest UTXO's." + "string": "Sort by and use largest UTXO first. Potentially lower fee, but reveals your largest UTXOs." }, "cs_consolidate": { "string": "Consolidate" }, "cs_consolidate_description": { - "string": "Use all available UTXO's regardless of the amount being sent. Use this method when fees are low in order to reduce fees in future transactions." + "string": "Use all available UTXOs regardless of the amount being sent. Use this method when fees are low in order to reduce fees in future transactions." }, "cs_first_in_first_out": { "string": "First-In First-Out" }, "cs_first_in_first_out_description": { - "string": "Use older UTXO's first (by block height)." + "string": "Use older UTXOs first (by block height)." }, "cs_last_in_last_out": { "string": "Last-In Last-Out" }, "cs_last_in_last_out_description": { - "string": "Use newer UTXO's first (by block height)." + "string": "Use newer UTXOs first (by block height)." }, "payment_preference": { "string": "Payment Preference" diff --git a/src/utils/i18n/locales/en/wallet.json b/src/utils/i18n/locales/en/wallet.json index d177623c0..e4f2b4703 100644 --- a/src/utils/i18n/locales/en/wallet.json +++ b/src/utils/i18n/locales/en/wallet.json @@ -228,7 +228,7 @@ "string": "Please increase your send amount to proceed." }, "send_coin_selection_output_to_small_description": { - "string": "Please remove UTXO's or increase your send amount to proceed." + "string": "Please remove UTXOs or increase your send amount to proceed." }, "send_fee_error_min": { "string": "Unable to decrease the fee any further." diff --git a/src/utils/wallet/electrum.ts b/src/utils/wallet/electrum.ts index 488d10e38..45aa47b21 100644 --- a/src/utils/wallet/electrum.ts +++ b/src/utils/wallet/electrum.ts @@ -41,7 +41,7 @@ export const isConnectedElectrum = async (): Promise => { }; /** - * Formats a provided array of addresses a returns their UTXO's & balances. + * Formats a provided array of addresses a returns their UTXOs & balances. * @param {IAddress[]} allAddresses * @returns {Promise>} */ @@ -58,7 +58,7 @@ export const getAddressUtxos = async ({ }; /** - * Queries Electrum to return the available UTXO's and balance of the provided addresses. + * Queries Electrum to return the available UTXOs and balance of the provided addresses. * @param {TUnspentAddressScriptHashData} addresses */ export const listUnspentAddressScriptHashes = async ({ diff --git a/src/utils/wallet/transactions.ts b/src/utils/wallet/transactions.ts index d3f754379..267189bbb 100644 --- a/src/utils/wallet/transactions.ts +++ b/src/utils/wallet/transactions.ts @@ -40,7 +40,7 @@ import { } from './index'; /* - * Attempt to estimate the current fee for a given wallet and its UTXO's + * Attempt to estimate the current fee for a given wallet and its UTXOs */ export const getTotalFee = ({ satsPerByte, From 2452cf73f14fa2ec519599fdc24444b9a9133ac8 Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Tue, 25 Mar 2025 14:51:27 +0100 Subject: [PATCH 3/5] fix(send): #2528 coin selection row background color --- src/screens/Wallets/Send/CoinSelection.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/screens/Wallets/Send/CoinSelection.tsx b/src/screens/Wallets/Send/CoinSelection.tsx index e57773f1f..060dd2a53 100644 --- a/src/screens/Wallets/Send/CoinSelection.tsx +++ b/src/screens/Wallets/Send/CoinSelection.tsx @@ -1,7 +1,7 @@ import { BottomSheetScrollView } from '@gorhom/bottom-sheet'; import React, { ReactElement, memo, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { StyleSheet, View } from 'react-native'; +import { ScrollView, StyleSheet, View } from 'react-native'; import BottomSheetNavigationHeader from '../../../components/BottomSheetNavigationHeader'; import GradientView from '../../../components/GradientView'; @@ -9,7 +9,6 @@ import SafeAreaInset from '../../../components/SafeAreaInset'; import Switch from '../../../components/Switch'; import Tag from '../../../components/Tag'; import Button from '../../../components/buttons/Button'; -import { ScrollView } from '../../../styles/components'; import { BodyMSB, BodySSB, Caption13Up, Subtitle } from '../../../styles/text'; import { IUtxo } from 'beignet'; @@ -34,7 +33,7 @@ import { } from '../../../utils/wallet/transactions'; /** - * Some UTXO's may contain the same tx_hash. + * Some UTXOs may contain the same tx_hash. * So we include the tx_pos to ensure we can quickly distinguish. * @param {IUtxo} utxo * @return string @@ -65,9 +64,9 @@ const UtxoRow = ({ {tags && ( + centerContent={true}> {tags.map((t) => ( ))} @@ -94,7 +93,7 @@ const CoinSelection = ({ return transaction.inputs; }, [transaction.inputs]); - //Combine known utxo's with current transaction inputs in the event we're using utxo's from the address viewer. + //Combine known UTXOs with current transaction inputs in the event we're using UTXOs from the address viewer. const combinedUtxos = useMemo(() => { const combined: IUtxo[] = [...utxos, ...inputs]; From e31f1007dd02e7e98ac7d3ba15bc9cd85a4b315d Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Tue, 25 Mar 2025 14:52:04 +0100 Subject: [PATCH 4/5] fix(ui): handle sheet reference readiness in showSheet function --- src/store/utils/ui.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/store/utils/ui.ts b/src/store/utils/ui.ts index 9ced50477..b79c4488a 100644 --- a/src/store/utils/ui.ts +++ b/src/store/utils/ui.ts @@ -19,7 +19,14 @@ export const showSheet = ( ): void => { const [id, params] = args; const sheetRef = getSheetRefOutsideComponent(id); - sheetRef.current?.present(params); + + if (!sheetRef.current) { + // sheetRef not ready, try again after a short wait + // NOTE: needed for deeplinks when app is closed + setTimeout(() => showSheet(...args), 100); + } else { + sheetRef.current?.present(params); + } }; export const closeSheet = async (id: SheetId): Promise => { From cf173ff872f22255a922ba5d5126f981b7e0b06c Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Tue, 25 Mar 2025 14:53:04 +0100 Subject: [PATCH 5/5] fix(lightning): wait for channels ready when paying invoice --- src/utils/lightning/index.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/utils/lightning/index.ts b/src/utils/lightning/index.ts index dcdace8a0..aa6d49a83 100644 --- a/src/utils/lightning/index.ts +++ b/src/utils/lightning/index.ts @@ -1151,6 +1151,23 @@ export const waitForLdk = async (): Promise => { }); }; +export const waitForLdkChannels = async (): Promise => { + await tryNTimes({ + toTry: async () => { + const channelsResult = await ldk.listUsableChannels(); + if (channelsResult.isOk()) { + if (channelsResult.value.length > 0) { + return ok(channelsResult.value); + } + return err('no channels ready'); + } + return err('error getting channels'); + }, + times: 5, + interval: 1000, + }); +}; + /** * Returns the current LDK node id. * @returns {Promise>} @@ -1579,6 +1596,8 @@ export const payLightningInvoice = async ({ amount?: number; }): Promise> => { try { + await waitForLdkChannels(); + const addPeersResponse = await addPeers(); if (addPeersResponse.isErr()) { return err(addPeersResponse.error.message);