mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-04 04:13:49 +01:00
commit
20d7f9181f
4 changed files with 174 additions and 89 deletions
|
@ -3,7 +3,7 @@ import React, { lazy, Suspense } from 'react';
|
||||||
import { LazyLoadingIndicator } from './LazyLoadingIndicator';
|
import { LazyLoadingIndicator } from './LazyLoadingIndicator';
|
||||||
|
|
||||||
const SendDetails = lazy(() => import('../screen/send/details'));
|
const SendDetails = lazy(() => import('../screen/send/details'));
|
||||||
const Confirm = lazy(() => import('../screen/send/confirm'));
|
const Confirm = lazy(() => import('../screen/send/Confirm'));
|
||||||
const PsbtWithHardwareWallet = lazy(() => import('../screen/send/psbtWithHardwareWallet'));
|
const PsbtWithHardwareWallet = lazy(() => import('../screen/send/psbtWithHardwareWallet'));
|
||||||
const CreateTransaction = lazy(() => import('../screen/send/create'));
|
const CreateTransaction = lazy(() => import('../screen/send/create'));
|
||||||
const PsbtMultisig = lazy(() => import('../screen/send/psbtMultisig'));
|
const PsbtMultisig = lazy(() => import('../screen/send/psbtMultisig'));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
|
||||||
import navigationStyle, { navigationStyleTx } from '../components/navigationStyle';
|
import navigationStyle, { navigationStyleTx } from '../components/navigationStyle';
|
||||||
import { useTheme } from '../components/themes';
|
import { useTheme } from '../components/themes';
|
||||||
|
@ -16,11 +16,13 @@ import {
|
||||||
SuccessComponent,
|
SuccessComponent,
|
||||||
} from './LazyLoadSendDetailsStack';
|
} from './LazyLoadSendDetailsStack';
|
||||||
import { SendDetailsStackParamList } from './SendDetailsStackParamList';
|
import { SendDetailsStackParamList } from './SendDetailsStackParamList';
|
||||||
|
import HeaderRightButton from '../components/HeaderRightButton';
|
||||||
|
|
||||||
const Stack = createNativeStackNavigator<SendDetailsStackParamList>();
|
const Stack = createNativeStackNavigator<SendDetailsStackParamList>();
|
||||||
|
|
||||||
const SendDetailsStack = () => {
|
const SendDetailsStack = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const DetailsButton = useMemo(() => <HeaderRightButton testID="Save" disabled={true} title={loc.wallets.create_details} />, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack.Navigator initialRouteName="SendDetails" screenOptions={{ headerShadowVisible: false }}>
|
<Stack.Navigator initialRouteName="SendDetails" screenOptions={{ headerShadowVisible: false }}>
|
||||||
|
@ -34,7 +36,11 @@ const SendDetailsStack = () => {
|
||||||
}))(theme)}
|
}))(theme)}
|
||||||
initialParams={{ isEditable: true }} // Correctly typed now
|
initialParams={{ isEditable: true }} // Correctly typed now
|
||||||
/>
|
/>
|
||||||
<Stack.Screen name="Confirm" component={ConfirmComponent} options={navigationStyle({ title: loc.send.confirm_header })(theme)} />
|
<Stack.Screen
|
||||||
|
name="Confirm"
|
||||||
|
component={ConfirmComponent}
|
||||||
|
options={navigationStyle({ title: loc.send.confirm_header, headerRight: () => DetailsButton })(theme)}
|
||||||
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="PsbtWithHardwareWallet"
|
name="PsbtWithHardwareWallet"
|
||||||
component={PsbtWithHardwareWalletComponent}
|
component={PsbtWithHardwareWalletComponent}
|
||||||
|
|
|
@ -45,7 +45,10 @@ export type SendDetailsStackParamList = {
|
||||||
fromWallet: string;
|
fromWallet: string;
|
||||||
launchedBy?: string;
|
launchedBy?: string;
|
||||||
};
|
};
|
||||||
Success: undefined;
|
Success: {
|
||||||
|
fee: number;
|
||||||
|
amount: number;
|
||||||
|
};
|
||||||
SelectWallet: {
|
SelectWallet: {
|
||||||
onWalletSelect: (wallet: TWallet) => void;
|
onWalletSelect: (wallet: TWallet) => void;
|
||||||
chainType: Chain;
|
chainType: Chain;
|
||||||
|
|
|
@ -1,39 +1,88 @@
|
||||||
import { useNavigation, useRoute } from '@react-navigation/native';
|
import React, { useContext, useEffect, useMemo, useReducer } from 'react';
|
||||||
|
import { ActivityIndicator, FlatList, TouchableOpacity, StyleSheet, Switch, View } from 'react-native';
|
||||||
|
import { Text } from 'react-native-elements';
|
||||||
|
import { PayjoinClient } from 'payjoin-client';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import * as bitcoin from 'bitcoinjs-lib';
|
import * as bitcoin from 'bitcoinjs-lib';
|
||||||
import { PayjoinClient } from 'payjoin-client';
|
import { BlueText, BlueCard } from '../../BlueComponents';
|
||||||
import PropTypes from 'prop-types';
|
import { BitcoinUnit } from '../../models/bitcoinUnits';
|
||||||
import React, { useContext, useEffect, useState } from 'react';
|
import loc, { formatBalance, formatBalanceWithoutSuffix } from '../../loc';
|
||||||
import { ActivityIndicator, FlatList, StyleSheet, Switch, TouchableOpacity, View } from 'react-native';
|
|
||||||
import { Text } from 'react-native-elements';
|
|
||||||
|
|
||||||
import * as BlueElectrum from '../../blue_modules/BlueElectrum';
|
|
||||||
import { satoshiToBTC, satoshiToLocalCurrency } from '../../blue_modules/currency';
|
|
||||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
|
||||||
import Notifications from '../../blue_modules/notifications';
|
import Notifications from '../../blue_modules/notifications';
|
||||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||||
import { BlueCard, BlueText } from '../../BlueComponents';
|
import { useRoute, RouteProp } from '@react-navigation/native';
|
||||||
import PayjoinTransaction from '../../class/payjoin-transaction';
|
|
||||||
import presentAlert from '../../components/Alert';
|
import presentAlert from '../../components/Alert';
|
||||||
import Button from '../../components/Button';
|
|
||||||
import SafeArea from '../../components/SafeArea';
|
|
||||||
import { useTheme } from '../../components/themes';
|
import { useTheme } from '../../components/themes';
|
||||||
|
import Button from '../../components/Button';
|
||||||
|
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||||
|
import SafeArea from '../../components/SafeArea';
|
||||||
|
import { satoshiToBTC, satoshiToLocalCurrency } from '../../blue_modules/currency';
|
||||||
|
import * as BlueElectrum from '../../blue_modules/BlueElectrum';
|
||||||
import { useBiometrics } from '../../hooks/useBiometrics';
|
import { useBiometrics } from '../../hooks/useBiometrics';
|
||||||
import loc, { formatBalance, formatBalanceWithoutSuffix } from '../../loc';
|
import { TWallet, CreateTransactionTarget } from '../../class/wallets/types';
|
||||||
import { BitcoinUnit } from '../../models/bitcoinUnits';
|
import PayjoinTransaction from '../../class/payjoin-transaction';
|
||||||
|
import debounce from '../../blue_modules/debounce';
|
||||||
|
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||||
|
import { SendDetailsStackParamList } from '../../navigation/SendDetailsStackParamList';
|
||||||
|
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||||
|
|
||||||
const Confirm = () => {
|
enum ActionType {
|
||||||
|
SET_LOADING = 'SET_LOADING',
|
||||||
|
SET_PAYJOIN_ENABLED = 'SET_PAYJOIN_ENABLED',
|
||||||
|
SET_BUTTON_DISABLED = 'SET_BUTTON_DISABLED',
|
||||||
|
}
|
||||||
|
|
||||||
|
type Action =
|
||||||
|
| { type: ActionType.SET_LOADING; payload: boolean }
|
||||||
|
| { type: ActionType.SET_PAYJOIN_ENABLED; payload: boolean }
|
||||||
|
| { type: ActionType.SET_BUTTON_DISABLED; payload: boolean };
|
||||||
|
|
||||||
|
interface State {
|
||||||
|
isLoading: boolean;
|
||||||
|
isPayjoinEnabled: boolean;
|
||||||
|
isButtonDisabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialState: State = {
|
||||||
|
isLoading: false,
|
||||||
|
isPayjoinEnabled: false,
|
||||||
|
isButtonDisabled: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const reducer = (state: State, action: Action): State => {
|
||||||
|
switch (action.type) {
|
||||||
|
case ActionType.SET_LOADING:
|
||||||
|
return { ...state, isLoading: action.payload };
|
||||||
|
case ActionType.SET_PAYJOIN_ENABLED:
|
||||||
|
return { ...state, isPayjoinEnabled: action.payload };
|
||||||
|
case ActionType.SET_BUTTON_DISABLED:
|
||||||
|
return { ...state, isButtonDisabled: action.payload };
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
type ConfirmRouteProp = RouteProp<SendDetailsStackParamList, 'Confirm'>;
|
||||||
|
type ConfirmNavigationProp = NativeStackNavigationProp<SendDetailsStackParamList, 'Confirm'>;
|
||||||
|
|
||||||
|
const Confirm: React.FC = () => {
|
||||||
const { wallets, fetchAndSaveWalletTransactions, isElectrumDisabled } = useContext(BlueStorageContext);
|
const { wallets, fetchAndSaveWalletTransactions, isElectrumDisabled } = useContext(BlueStorageContext);
|
||||||
const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics();
|
const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics();
|
||||||
const { params } = useRoute();
|
const navigation = useExtendedNavigation<ConfirmNavigationProp>();
|
||||||
const { recipients = [], walletID, fee, memo, tx, satoshiPerByte, psbt } = params;
|
const route = useRoute<ConfirmRouteProp>(); // Get the route and its params
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const { recipients, walletID, fee, memo, tx, satoshiPerByte, psbt, payjoinUrl } = route.params; // Destructure params
|
||||||
const [isPayjoinEnabled, setIsPayjoinEnabled] = useState(false);
|
|
||||||
const wallet = wallets.find(w => w.getID() === walletID);
|
const [state, dispatch] = useReducer(reducer, initialState);
|
||||||
const payjoinUrl = wallet.allowPayJoin() ? params.payjoinUrl : false;
|
const { navigate, setOptions, goBack } = navigation;
|
||||||
|
const wallet = wallets.find((w: TWallet) => w.getID() === walletID) as TWallet;
|
||||||
const feeSatoshi = new BigNumber(fee).multipliedBy(100000000).toNumber();
|
const feeSatoshi = new BigNumber(fee).multipliedBy(100000000).toNumber();
|
||||||
const { navigate, setOptions } = useNavigation();
|
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!wallet) {
|
||||||
|
goBack();
|
||||||
|
}
|
||||||
|
}, [wallet, goBack]);
|
||||||
|
|
||||||
const stylesHook = StyleSheet.create({
|
const stylesHook = StyleSheet.create({
|
||||||
transactionDetailsTitle: {
|
transactionDetailsTitle: {
|
||||||
color: colors.foregroundColor,
|
color: colors.foregroundColor,
|
||||||
|
@ -61,68 +110,83 @@ const Confirm = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const HeaderRightButton = useMemo(
|
||||||
|
() => (
|
||||||
|
<TouchableOpacity
|
||||||
|
accessibilityRole="button"
|
||||||
|
testID="TransactionDetailsButton"
|
||||||
|
style={[styles.txDetails, stylesHook.txDetails]}
|
||||||
|
onPress={async () => {
|
||||||
|
if (await isBiometricUseCapableAndEnabled()) {
|
||||||
|
if (!(await unlockWithBiometrics())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navigate('CreateTransaction', {
|
||||||
|
fee,
|
||||||
|
recipients,
|
||||||
|
memo,
|
||||||
|
tx,
|
||||||
|
satoshiPerByte,
|
||||||
|
wallet,
|
||||||
|
feeSatoshi,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={[styles.txText, stylesHook.valueUnit]}>{loc.send.create_details}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
),
|
||||||
|
[
|
||||||
|
stylesHook.txDetails,
|
||||||
|
stylesHook.valueUnit,
|
||||||
|
isBiometricUseCapableAndEnabled,
|
||||||
|
navigate,
|
||||||
|
fee,
|
||||||
|
recipients,
|
||||||
|
memo,
|
||||||
|
tx,
|
||||||
|
satoshiPerByte,
|
||||||
|
wallet,
|
||||||
|
feeSatoshi,
|
||||||
|
unlockWithBiometrics,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('send/confirm - useEffect');
|
console.log('send/confirm - useEffect');
|
||||||
console.log('address = ', recipients);
|
console.log('address = ', recipients);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [recipients]);
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setOptions({
|
setOptions({
|
||||||
// eslint-disable-next-line react/no-unstable-nested-components
|
headerRight: () => HeaderRightButton,
|
||||||
headerRight: () => (
|
|
||||||
<TouchableOpacity
|
|
||||||
accessibilityRole="button"
|
|
||||||
testID="TransactionDetailsButton"
|
|
||||||
style={[styles.txDetails, stylesHook.txDetails]}
|
|
||||||
onPress={async () => {
|
|
||||||
if (await isBiometricUseCapableAndEnabled()) {
|
|
||||||
if (!(await unlockWithBiometrics())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
navigate('CreateTransaction', {
|
|
||||||
fee,
|
|
||||||
recipients,
|
|
||||||
memo,
|
|
||||||
tx,
|
|
||||||
satoshiPerByte,
|
|
||||||
wallet,
|
|
||||||
feeSatoshi,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={[styles.txText, stylesHook.valueUnit]}>{loc.send.create_details}</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [HeaderRightButton, colors, fee, feeSatoshi, memo, recipients, satoshiPerByte, setOptions, tx, wallet]);
|
||||||
}, [colors, fee, feeSatoshi, memo, recipients, satoshiPerByte, tx, wallet]);
|
|
||||||
|
|
||||||
/**
|
const getPaymentScript = (): Buffer | undefined => {
|
||||||
* we need to look into `recipients`, find destination address and return its outputScript
|
if (!(recipients.length > 0) || !recipients[0].address) {
|
||||||
* (needed for payjoin)
|
return undefined;
|
||||||
*
|
}
|
||||||
* @return {string}
|
return bitcoin.address.toOutputScript(recipients[0].address, bitcoin.networks.bitcoin);
|
||||||
*/
|
|
||||||
const getPaymentScript = () => {
|
|
||||||
return bitcoin.address.toOutputScript(recipients[0].address);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const send = async () => {
|
const send = async () => {
|
||||||
setIsLoading(true);
|
dispatch({ type: ActionType.SET_BUTTON_DISABLED, payload: true });
|
||||||
|
dispatch({ type: ActionType.SET_LOADING, payload: true });
|
||||||
try {
|
try {
|
||||||
const txids2watch = [];
|
const txids2watch = [];
|
||||||
if (!isPayjoinEnabled) {
|
if (!state.isPayjoinEnabled) {
|
||||||
await broadcast(tx);
|
await broadcast(tx);
|
||||||
} else {
|
} else {
|
||||||
const payJoinWallet = new PayjoinTransaction(psbt, txHex => broadcast(txHex), wallet);
|
const payJoinWallet = new PayjoinTransaction(psbt, (txHex: string) => broadcast(txHex), wallet);
|
||||||
const paymentScript = getPaymentScript();
|
const paymentScript = getPaymentScript();
|
||||||
|
if (!paymentScript) {
|
||||||
|
throw new Error('Invalid payment script');
|
||||||
|
}
|
||||||
const payjoinClient = new PayjoinClient({
|
const payjoinClient = new PayjoinClient({
|
||||||
paymentScript,
|
paymentScript,
|
||||||
wallet: payJoinWallet,
|
wallet: payJoinWallet.getPayjoinPsbt(),
|
||||||
payjoinUrl,
|
payjoinUrl: payjoinUrl as string,
|
||||||
});
|
});
|
||||||
await payjoinClient.run();
|
await payjoinClient.run();
|
||||||
const payjoinPsbt = payJoinWallet.getPayjoinPsbt();
|
const payjoinPsbt = payJoinWallet.getPayjoinPsbt();
|
||||||
|
@ -134,31 +198,37 @@ const Confirm = () => {
|
||||||
|
|
||||||
const txid = bitcoin.Transaction.fromHex(tx).getId();
|
const txid = bitcoin.Transaction.fromHex(tx).getId();
|
||||||
txids2watch.push(txid);
|
txids2watch.push(txid);
|
||||||
|
// @ts-ignore: Notifications has to be TSed
|
||||||
Notifications.majorTomToGroundControl([], [], txids2watch);
|
Notifications.majorTomToGroundControl([], [], txids2watch);
|
||||||
let amount = 0;
|
let amount = 0;
|
||||||
for (const recipient of recipients) {
|
for (const recipient of recipients) {
|
||||||
amount += recipient.value;
|
if (recipient.value) {
|
||||||
|
amount += recipient.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
amount = formatBalanceWithoutSuffix(amount, BitcoinUnit.BTC, false);
|
amount = Number(formatBalanceWithoutSuffix(amount, BitcoinUnit.BTC, false));
|
||||||
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
|
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
|
||||||
navigate('Success', {
|
navigate('Success', {
|
||||||
fee: Number(fee),
|
fee: Number(fee),
|
||||||
amount,
|
amount,
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsLoading(false);
|
dispatch({ type: ActionType.SET_LOADING, payload: false });
|
||||||
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 3000)); // sleep to make sure network propagates
|
await new Promise(resolve => setTimeout(resolve, 3000)); // sleep to make sure network propagates
|
||||||
fetchAndSaveWalletTransactions(walletID);
|
fetchAndSaveWalletTransactions(walletID);
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
|
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
|
||||||
setIsLoading(false);
|
dispatch({ type: ActionType.SET_LOADING, payload: false });
|
||||||
|
dispatch({ type: ActionType.SET_BUTTON_DISABLED, payload: false });
|
||||||
presentAlert({ message: error.message });
|
presentAlert({ message: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const broadcast = async transaction => {
|
const debouncedSend = debounce(send, 3000);
|
||||||
|
|
||||||
|
const broadcast = async (transaction: string) => {
|
||||||
await BlueElectrum.ping();
|
await BlueElectrum.ping();
|
||||||
await BlueElectrum.waitTillConnected();
|
await BlueElectrum.waitTillConnected();
|
||||||
|
|
||||||
|
@ -176,16 +246,18 @@ const Confirm = () => {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const _renderItem = ({ index, item }) => {
|
const renderItem = ({ index, item }: { index: number; item: CreateTransactionTarget }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View style={styles.valueWrap}>
|
<View style={styles.valueWrap}>
|
||||||
<Text testID="TransactionValue" style={[styles.valueValue, stylesHook.valueValue]}>
|
<Text testID="TransactionValue" style={[styles.valueValue, stylesHook.valueValue]}>
|
||||||
{satoshiToBTC(item.value)}
|
{item.value && satoshiToBTC(item.value)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={[styles.valueUnit, stylesHook.valueValue]}>{' ' + loc.units[BitcoinUnit.BTC]}</Text>
|
<Text style={[styles.valueUnit, stylesHook.valueValue]}>{' ' + loc.units[BitcoinUnit.BTC]}</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={[styles.transactionAmountFiat, stylesHook.transactionAmountFiat]}>{satoshiToLocalCurrency(item.value)}</Text>
|
<Text style={[styles.transactionAmountFiat, stylesHook.transactionAmountFiat]}>
|
||||||
|
{item.value && satoshiToLocalCurrency(item.value)}
|
||||||
|
</Text>
|
||||||
<BlueCard>
|
<BlueCard>
|
||||||
<Text style={[styles.transactionDetailsTitle, stylesHook.transactionDetailsTitle]}>{loc.send.create_to}</Text>
|
<Text style={[styles.transactionDetailsTitle, stylesHook.transactionDetailsTitle]}>{loc.send.create_to}</Text>
|
||||||
<Text testID="TransactionAddress" style={[styles.transactionDetailsSubtitle, stylesHook.transactionDetailsSubtitle]}>
|
<Text testID="TransactionAddress" style={[styles.transactionDetailsSubtitle, stylesHook.transactionDetailsSubtitle]}>
|
||||||
|
@ -198,10 +270,6 @@ const Confirm = () => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
_renderItem.propTypes = {
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
item: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderSeparator = () => {
|
const renderSeparator = () => {
|
||||||
return <View style={styles.separator} />;
|
return <View style={styles.separator} />;
|
||||||
|
@ -210,11 +278,11 @@ const Confirm = () => {
|
||||||
return (
|
return (
|
||||||
<SafeArea style={[styles.root, stylesHook.root]}>
|
<SafeArea style={[styles.root, stylesHook.root]}>
|
||||||
<View style={styles.cardTop}>
|
<View style={styles.cardTop}>
|
||||||
<FlatList
|
<FlatList<CreateTransactionTarget>
|
||||||
scrollEnabled={recipients.length > 1}
|
scrollEnabled={recipients.length > 1}
|
||||||
extraData={recipients}
|
extraData={recipients}
|
||||||
data={recipients}
|
data={recipients}
|
||||||
renderItem={_renderItem}
|
renderItem={renderItem}
|
||||||
keyExtractor={(_item, index) => `${index}`}
|
keyExtractor={(_item, index) => `${index}`}
|
||||||
ItemSeparatorComponent={renderSeparator}
|
ItemSeparatorComponent={renderSeparator}
|
||||||
/>
|
/>
|
||||||
|
@ -223,7 +291,11 @@ const Confirm = () => {
|
||||||
<BlueCard>
|
<BlueCard>
|
||||||
<View style={[styles.payjoinWrapper, stylesHook.payjoinWrapper]}>
|
<View style={[styles.payjoinWrapper, stylesHook.payjoinWrapper]}>
|
||||||
<Text style={styles.payjoinText}>Payjoin</Text>
|
<Text style={styles.payjoinText}>Payjoin</Text>
|
||||||
<Switch testID="PayjoinSwitch" value={isPayjoinEnabled} onValueChange={setIsPayjoinEnabled} />
|
<Switch
|
||||||
|
testID="PayjoinSwitch"
|
||||||
|
value={state.isPayjoinEnabled}
|
||||||
|
onValueChange={value => dispatch({ type: ActionType.SET_PAYJOIN_ENABLED, payload: value })}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</BlueCard>
|
</BlueCard>
|
||||||
</View>
|
</View>
|
||||||
|
@ -234,7 +306,11 @@ const Confirm = () => {
|
||||||
<Text style={styles.cardText} testID="TransactionFee">
|
<Text style={styles.cardText} testID="TransactionFee">
|
||||||
{loc.send.create_fee}: {formatBalance(feeSatoshi, BitcoinUnit.BTC)} ({satoshiToLocalCurrency(feeSatoshi)})
|
{loc.send.create_fee}: {formatBalance(feeSatoshi, BitcoinUnit.BTC)} ({satoshiToLocalCurrency(feeSatoshi)})
|
||||||
</Text>
|
</Text>
|
||||||
{isLoading ? <ActivityIndicator /> : <Button disabled={isElectrumDisabled} onPress={send} title={loc.send.confirm_sendNow} />}
|
{state.isLoading ? (
|
||||||
|
<ActivityIndicator />
|
||||||
|
) : (
|
||||||
|
<Button disabled={isElectrumDisabled || state.isButtonDisabled} onPress={debouncedSend} title={loc.send.confirm_sendNow} />
|
||||||
|
)}
|
||||||
</BlueCard>
|
</BlueCard>
|
||||||
</View>
|
</View>
|
||||||
</SafeArea>
|
</SafeArea>
|
Loading…
Add table
Reference in a new issue