Skip to content

Commit b8debde

Browse files
feat(suite): remove RBF option from the SendForm, make all Transactions with RBF enabled by default
1 parent 510ba01 commit b8debde

File tree

18 files changed

+56
-159
lines changed

18 files changed

+56
-159
lines changed

packages/suite-analytics/src/types/events.ts

-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ export type SuiteAnalyticsEvent =
188188
tokens: string;
189189
outputsCount: number;
190190
broadcast: boolean;
191-
bitcoinRbf: boolean;
192191
bitcoinLockTime: boolean;
193192
ethereumData: boolean;
194193
ethereumNonce: boolean;

packages/suite/src/actions/wallet/stakeActions.ts

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ export const signTransaction =
151151

152152
const enhancedTxInfo: PrecomposedTransactionFinal = {
153153
...transactionInfo,
154-
rbf: false,
155154
};
156155

157156
// store formValues and transactionInfo in send reducer to be used by TransactionReviewModal

packages/suite/src/components/suite/modals/ReduxModal/TransactionReviewModal/TransactionReviewOutputList/TransactionReviewOutputList.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ export const TransactionReviewOutputList = ({
141141
.join(','),
142142
outputsCount: precomposedForm.outputs.length,
143143
broadcast: broadcastEnabled,
144-
bitcoinRbf: !!options.includes('bitcoinRBF'),
145144
bitcoinLockTime: !!options.includes('bitcoinLockTime'),
146145
ethereumData: !!options.includes('ethereumData'),
147146
rippleDestinationTag: !!options.includes('rippleDestinationTag'),

packages/suite/src/components/suite/modals/ReduxModal/TransactionReviewModal/TransactionReviewSummary.tsx

+19-36
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import styled, { useTheme } from 'styled-components';
22
import { BigNumber } from '@trezor/utils/src/bigNumber';
33
import { getFeeUnits, formatNetworkAmount, formatAmount, getFee } from '@suite-common/wallet-utils';
44
import { Icon, CoinLogo, variables } from '@trezor/components';
5-
import { formatDuration, isFeatureFlagEnabled } from '@suite-common/suite-utils';
5+
import { formatDuration } from '@suite-common/suite-utils';
66
import { borders, spacingsPx, typography } from '@trezor/theme';
77
import { TranslationKey } from '@suite-common/intl-types';
88
import { Translation, FormattedCryptoAmount, AccountLabel } from 'src/components/suite';
@@ -164,7 +164,7 @@ const LeftDetailsBottom = styled.div`
164164
flex: 1;
165165
`;
166166

167-
const ReviewRbfLeftDetailsLineLeft = styled.div`
167+
const ReviewLeftDetailsLineLeft = styled.div`
168168
display: flex;
169169
align-items: center;
170170
margin: 0 5% 0 0;
@@ -177,7 +177,7 @@ const ReviewRbfLeftDetailsLineLeft = styled.div`
177177
}
178178
`;
179179

180-
const ReviewRbfLeftDetailsLineRight = styled.div<{ $color: string; $uppercase?: boolean }>`
180+
const ReviewLeftDetailsLineRight = styled.div<{ $color: string; $uppercase?: boolean }>`
181181
width: 45%;
182182
text-align: left;
183183
color: ${props => props.$color};
@@ -268,40 +268,40 @@ export const TransactionReviewSummary = ({
268268
<LeftDetails>
269269
{estimateTime !== undefined && (
270270
<LeftDetailsRow>
271-
<ReviewRbfLeftDetailsLineLeft>
271+
<ReviewLeftDetailsLineLeft>
272272
<Icon size={12} color={theme.iconSubdued} icon="CALENDAR" />
273273
<Translation id="TR_DELIVERY" />
274-
</ReviewRbfLeftDetailsLineLeft>
274+
</ReviewLeftDetailsLineLeft>
275275

276-
<ReviewRbfLeftDetailsLineRight $color={theme.textSubdued}>
276+
<ReviewLeftDetailsLineRight $color={theme.textSubdued}>
277277
{formatDuration(estimateTime)}
278-
</ReviewRbfLeftDetailsLineRight>
278+
</ReviewLeftDetailsLineRight>
279279
</LeftDetailsRow>
280280
)}
281281
{!!tx.feeLimit && network.networkType !== 'solana' && (
282282
<LeftDetailsRow>
283-
<ReviewRbfLeftDetailsLineLeft>
283+
<ReviewLeftDetailsLineLeft>
284284
<Icon size={12} color={theme.iconSubdued} icon="GAS" />
285285
<Translation id="TR_GAS_LIMIT" />
286-
</ReviewRbfLeftDetailsLineLeft>
286+
</ReviewLeftDetailsLineLeft>
287287

288-
<ReviewRbfLeftDetailsLineRight $color={theme.textSubdued}>
288+
<ReviewLeftDetailsLineRight $color={theme.textSubdued}>
289289
{tx.feeLimit}
290-
</ReviewRbfLeftDetailsLineRight>
290+
</ReviewLeftDetailsLineRight>
291291
</LeftDetailsRow>
292292
)}
293293
<LeftDetailsRow>
294-
<ReviewRbfLeftDetailsLineLeft>
294+
<ReviewLeftDetailsLineLeft>
295295
<Icon size={12} color={theme.iconSubdued} icon="GAS" />
296296
{network.networkType === 'bitcoin' && <Translation id="TR_FEE_RATE" />}
297297
{network.networkType === 'ethereum' && <Translation id="TR_GAS_PRICE" />}
298298
{network.networkType === 'ripple' && <Translation id="TR_TX_FEE" />}
299299
{network.networkType === 'solana' && <Translation id="TR_TX_FEE" />}
300-
</ReviewRbfLeftDetailsLineLeft>
300+
</ReviewLeftDetailsLineLeft>
301301

302-
<ReviewRbfLeftDetailsLineRight $color={theme.textSubdued}>
302+
<ReviewLeftDetailsLineRight $color={theme.textSubdued}>
303303
{fee} {getFeeUnits(network.networkType)}
304-
</ReviewRbfLeftDetailsLineRight>
304+
</ReviewLeftDetailsLineRight>
305305
</LeftDetailsRow>
306306

307307
{isComposedFeeRateDifferent && network.networkType === 'bitcoin' && (
@@ -313,35 +313,18 @@ export const TransactionReviewSummary = ({
313313
)}
314314

315315
<LeftDetailsRow>
316-
<ReviewRbfLeftDetailsLineLeft>
316+
<ReviewLeftDetailsLineLeft>
317317
<Icon size={12} color={theme.iconSubdued} icon="BROADCAST" />
318318
<Translation id="BROADCAST" />
319-
</ReviewRbfLeftDetailsLineLeft>
319+
</ReviewLeftDetailsLineLeft>
320320

321-
<ReviewRbfLeftDetailsLineRight
321+
<ReviewLeftDetailsLineRight
322322
$color={broadcast ? theme.textPrimaryDefault : theme.textAlertYellow}
323323
$uppercase
324324
>
325325
<Translation id={broadcast ? 'TR_ON' : 'TR_OFF'} />
326-
</ReviewRbfLeftDetailsLineRight>
326+
</ReviewLeftDetailsLineRight>
327327
</LeftDetailsRow>
328-
{isFeatureFlagEnabled('RBF') &&
329-
network.features?.includes('rbf') &&
330-
network.networkType !== 'ethereum' && (
331-
<LeftDetailsRow>
332-
<ReviewRbfLeftDetailsLineLeft>
333-
<Icon size={12} color={theme.textSubdued} icon="RBF" />
334-
<Translation id="RBF" />
335-
</ReviewRbfLeftDetailsLineLeft>
336-
337-
<ReviewRbfLeftDetailsLineRight
338-
$color={tx.rbf ? theme.textPrimaryDefault : theme.textAlertYellow}
339-
$uppercase
340-
>
341-
<Translation id={tx.rbf ? 'TR_ON' : 'TR_OFF'} />
342-
</ReviewRbfLeftDetailsLineRight>
343-
</LeftDetailsRow>
344-
)}
345328
{tx.inputs.length !== 0 && (
346329
<LeftDetailsBottom>
347330
<Separator />

packages/suite/src/hooks/wallet/useCoinmarketExchangeOffers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export const useOffers = ({ selectedAccount }: UseCoinmarketExchangeFormProps) =
303303
undefined,
304304
undefined,
305305
undefined,
306-
['broadcast', 'bitcoinRBF'],
306+
['broadcast'],
307307
);
308308
// in case of not success, recomposeAndSign shows notification
309309
if (result?.success) {

packages/suite/src/hooks/wallet/useRbfForm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const useRbfState = ({ selectedAccount, rbfParams, chainedTxs }: UseRbfProps) =>
166166
outputs,
167167
selectedFee: undefined,
168168
setMaxOutputId,
169-
options: ['bitcoinRBF', 'broadcast'],
169+
options: ['broadcast'],
170170
ethereumDataHex: rbfParams.ethereumData,
171171
rbfParams,
172172
baseFee,

packages/suite/src/hooks/wallet/useSendForm.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ export const useSendForm = (props: UseSendFormProps): SendContextValues => {
138138
}
139139

140140
return {
141-
...getDefaultValues(localCurrencyOption, state.network),
141+
...getDefaultValues(localCurrencyOption),
142142
...loadedState,
143143
...feeEnhancement,
144144
};
145145
},
146-
[dispatch, localCurrencyOption, state.network],
146+
[dispatch, localCurrencyOption],
147147
);
148148

149149
// update custom values

packages/suite/src/hooks/wallet/useSendFormFields.ts

-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useCallback } from 'react';
22
import { FieldPath, UseFormReturn } from 'react-hook-form';
33
import { formatNetworkAmount, toFiatCurrency } from '@suite-common/wallet-utils';
44
import { FormState, FormOptions } from '@suite-common/wallet-types';
5-
import { isFeatureFlagEnabled } from '@suite-common/suite-utils';
65
import { useBitcoinAmountUnit } from './useBitcoinAmountUnit';
76
import { Rate } from '@suite-common/wallet-types';
87
import { SendContextValues, UseSendFormState } from 'src/types/wallet/sendForm';
@@ -113,13 +112,6 @@ export const useSendFormFields = ({
113112
};
114113

115114
const toggleOption = (option: FormOptions) => {
116-
if (
117-
option === 'bitcoinRBF' &&
118-
(!isFeatureFlagEnabled('RBF') || !network.features?.includes('rbf'))
119-
) {
120-
// do not use RBF if disabled
121-
return;
122-
}
123115
const enabledOptions = getValues('options') || [];
124116
const isEnabled = enabledOptions.includes(option);
125117
if (isEnabled) {

packages/suite/src/views/wallet/send/components/Options/BitcoinOptions/BitcoinOptions.tsx

-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useWatch } from 'react-hook-form';
22
import styled from 'styled-components';
33

4-
import { isFeatureFlagEnabled } from '@suite-common/suite-utils';
54
import { Button, Tooltip, variables } from '@trezor/components';
65
import { spacingsPx } from '@trezor/theme';
76
import { Translation } from 'src/components/suite';
@@ -55,7 +54,6 @@ const Inline = styled.span`
5554

5655
export const BitcoinOptions = () => {
5756
const {
58-
network,
5957
addOutput,
6058
control,
6159
utxoSelection: { isCoinControlEnabled },
@@ -74,7 +72,6 @@ export const BitcoinOptions = () => {
7472
});
7573

7674
const locktimeEnabled = options.includes('bitcoinLockTime');
77-
const rbfEnabled = options.includes('bitcoinRBF');
7875
const utxoSelectionEnabled = options.includes('utxoSelection');
7976
const broadcastEnabled = options.includes('broadcast');
8077

@@ -115,33 +112,6 @@ export const BitcoinOptions = () => {
115112
</StyledButton>
116113
</Tooltip>
117114
)}
118-
119-
{isFeatureFlagEnabled('RBF') &&
120-
network.features?.includes('rbf') &&
121-
!locktimeEnabled && (
122-
<Tooltip
123-
addon={
124-
<OpenGuideFromTooltip id="/3_send-and-receive/5_replace-by-fee-rbf.md" />
125-
}
126-
content={<Translation id="RBF_TOOLTIP" />}
127-
cursor="pointer"
128-
>
129-
<StyledButton
130-
variant="tertiary"
131-
size="small"
132-
icon="RBF"
133-
onClick={() => {
134-
toggleOption('bitcoinRBF');
135-
composeTransaction();
136-
}}
137-
>
138-
<Inline>
139-
<Translation id="RBF" />
140-
<OnOffSwitcher isOn={rbfEnabled} />
141-
</Inline>
142-
</StyledButton>
143-
</Tooltip>
144-
)}
145115
<Tooltip content={<Translation id="BROADCAST_TOOLTIP" />} cursor="pointer">
146116
<StyledButton
147117
variant="tertiary"
@@ -203,7 +173,6 @@ export const BitcoinOptions = () => {
203173
close={() => {
204174
resetDefaultValue('bitcoinLockTime');
205175
// close additional form
206-
if (!rbfEnabled) toggleOption('bitcoinRBF');
207176
if (!broadcastEnabled) toggleOption('broadcast');
208177
toggleOption('bitcoinLockTime');
209178
composeTransaction();

packages/suite/src/views/wallet/send/components/Options/BitcoinOptions/Locktime.tsx

+1-54
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,25 @@ import { BigNumber } from '@trezor/utils/src/bigNumber';
22
import styled from 'styled-components';
33
import { NumberInput, Translation } from 'src/components/suite';
44
import { useSendFormContext } from 'src/hooks/wallet';
5-
import { Card, Icon, IconButton, Paragraph, Switch } from '@trezor/components';
5+
import { Card, Icon, IconButton } from '@trezor/components';
66
import { getInputState, isInteger } from '@suite-common/wallet-utils';
7-
import { isFeatureFlagEnabled } from '@suite-common/suite-utils';
87
import { useTranslation } from 'src/hooks/suite';
98
import { spacingsPx } from '@trezor/theme';
109

11-
const RbfIcon = styled(Icon)`
12-
padding-top: ${spacingsPx.xs};
13-
`;
14-
1510
const Label = styled.div`
1611
display: flex;
1712
align-items: center;
1813
gap: ${spacingsPx.xs};
1914
`;
2015

21-
const RbfMessage = styled.div`
22-
display: flex;
23-
flex: 1;
24-
margin-top: ${spacingsPx.xs};
25-
gap: ${spacingsPx.xs};
26-
`;
27-
28-
const Center = styled.div`
29-
display: flex;
30-
flex: 1;
31-
flex-direction: column;
32-
`;
33-
34-
const Description = styled(Paragraph)`
35-
color: ${({ theme }) => theme.textSubdued};
36-
`;
37-
3816
interface LocktimeProps {
3917
close: () => void;
4018
}
4119

4220
export const Locktime = ({ close }: LocktimeProps) => {
4321
const {
44-
network,
4522
control,
4623
getDefaultValue,
47-
setValue,
4824
toggleOption,
4925
formState: { errors },
5026
composeTransaction,
@@ -53,15 +29,13 @@ export const Locktime = ({ close }: LocktimeProps) => {
5329
const { translationString } = useTranslation();
5430

5531
const options = getDefaultValue('options', []);
56-
const rbfEnabled = options.includes('bitcoinRBF');
5732
const broadcastEnabled = options.includes('broadcast');
5833
const inputName = 'bitcoinLockTime';
5934
const inputValue = getDefaultValue(inputName) || '';
6035
const error = errors[inputName];
6136

6237
const handleLocktimeChange = () => {
6338
if (!error) {
64-
if (rbfEnabled) toggleOption('bitcoinRBF');
6539
if (broadcastEnabled) toggleOption('broadcast');
6640
}
6741
composeTransaction(inputName);
@@ -85,15 +59,6 @@ export const Locktime = ({ close }: LocktimeProps) => {
8559
},
8660
};
8761

88-
const handleRbfSwitch = () => {
89-
if (inputValue.length > 0) {
90-
setValue(inputName, '');
91-
}
92-
93-
toggleOption('bitcoinRBF');
94-
composeTransaction(inputName);
95-
};
96-
9762
return (
9863
<Card>
9964
<NumberInput
@@ -115,24 +80,6 @@ export const Locktime = ({ close }: LocktimeProps) => {
11580
bottomText={error?.message || null}
11681
data-test="locktime-input"
11782
/>
118-
119-
{isFeatureFlagEnabled('RBF') && network.features?.includes('rbf') && (
120-
<RbfMessage>
121-
<RbfIcon size={16} icon="RBF" />
122-
123-
<Center>
124-
<Paragraph typographyStyle="highlight">
125-
<Translation id={rbfEnabled ? 'RBF_ON' : 'RBF_OFF'} />
126-
</Paragraph>
127-
128-
<Description typographyStyle="hint">
129-
<Translation id="RBF_DESCRIPTION" />
130-
</Description>
131-
</Center>
132-
133-
<Switch isChecked={rbfEnabled} onChange={handleRbfSwitch} />
134-
</RbfMessage>
135-
)}
13683
</Card>
13784
);
13885
};

suite-common/suite-config/src/features.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// General flags
77
export const FLAGS = {
88
GOOGLE_DRIVE_SYNC: true, // Google Drive sync (used for labeling)
9-
RBF: true, // replace by fee feature in the send form
109
FILE_SYSTEM_SYNC: false, // File system sync (used for labeling)
1110
ONION_LOCATION_META: true, // Show TOR onion-location meta tag in page head
1211
DESKTOP_AUTO_UPDATER: true, // Runs auto updater code on desktop

suite-common/wallet-constants/src/sendForm.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
export const CUSTOM_FEE = 'custom' as const;
22
export const FIRST_OUTPUT_ID = 0;
3+
4+
// A popular choice is to use 0xFFFFFFFD for your sequence fields,
5+
// as this enables both the locktime field (in case you want to use it)
6+
// and also replace-by-fee (which is generally useful).
7+
export const BTC_RBF_SEQUENCE = 0xffffffff - 2;
8+
9+
// Locktime enabled, but RBF disabled
310
export const BTC_LOCKTIME_SEQUENCE = 0xffffffff - 1;
11+
412
export const BTC_LOCKTIME_VALUE = 500000000; // if locktime is equal/greater than this then it's a timestamp
5-
export const BTC_RBF_SEQUENCE = 0xffffffff - 2;
613
export const XRP_FLAG = 0x80000000;
714
export const U_INT_32 = 0xffffffff;
815
export const ETH_BACKUP_GAS_LIMIT = '21000';

0 commit comments

Comments
 (0)