Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/hooks/useWeatherWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -107,6 +108,7 @@ const calculateCondition = (
};

const useWeatherWidget = (): TWidgetState => {
const { fiatTicker } = useCurrency();
const [state, setState] = useState<TWidgetState>(() => {
const cached = getCachedData();
return cached
Expand Down Expand Up @@ -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 };

Expand All @@ -170,7 +172,7 @@ const useWeatherWidget = (): TWidgetState => {
clearInterval(interval);
abortController.abort();
};
}, []);
}, [fiatTicker]);

return state;
};
Expand Down
10 changes: 5 additions & 5 deletions src/screens/Settings/AddressViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ const AddressViewer = (): ReactElement => {
);
// The private key of the currently selected address to display qrcode data for.
const [privateKey, setPrivateKey] = useState<string | undefined>(undefined);
// Available array of UTXO's after checking for a balance.
// Available array of UTXOs after checking for a balance.
const [utxos, setUtxos] = useState<IUtxo[] | undefined>();
// 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<IUtxo[]>([]);
const [searchTxt, setSearchTxt] = useState('');
// Addresses filtered from a search query in onSearch.
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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<void> => {
setIsCheckingBalances(true);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Settings/DevSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const DevSettings = ({
onPress: widgetsCache.clear,
},
{
title: "Clear UTXO's",
title: 'Clear UTXOs',
type: EItemType.button,
onPress: clearUtxos,
},
Expand Down
11 changes: 5 additions & 6 deletions src/screens/Wallets/Send/CoinSelection.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
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';
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';
Expand All @@ -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
Expand Down Expand Up @@ -65,9 +64,9 @@ const UtxoRow = ({

{tags && (
<ScrollView
style={styles.coinTagsScroll}
horizontal={true}
centerContent={true}
style={styles.coinTagsScroll}>
centerContent={true}>
{tags.map((t) => (
<Tag style={styles.tag} key={t} value={t} />
))}
Expand All @@ -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];

Expand Down
9 changes: 8 additions & 1 deletion src/store/utils/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ export const showSheet = <Id extends keyof SheetsParamList>(
): 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<void> => {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/i18n/locales/en/wallet.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
19 changes: 19 additions & 0 deletions src/utils/lightning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,23 @@ export const waitForLdk = async (): Promise<void> => {
});
};

export const waitForLdkChannels = async (): Promise<void> => {
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<Result<string>>}
Expand Down Expand Up @@ -1579,6 +1596,8 @@ export const payLightningInvoice = async ({
amount?: number;
}): Promise<Result<string>> => {
try {
await waitForLdkChannels();

const addPeersResponse = await addPeers();
if (addPeersResponse.isErr()) {
return err(addPeersResponse.error.message);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/wallet/electrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const isConnectedElectrum = async (): Promise<boolean> => {
};

/**
* 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<Result<IGetUtxosResponse>>}
*/
Expand All @@ -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 ({
Expand Down
2 changes: 1 addition & 1 deletion src/utils/wallet/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading