Skip to content

Commit

Permalink
fixup! feat(suite-native): advanced recipient address validation
Browse files Browse the repository at this point in the history
  • Loading branch information
PeKne committed Nov 27, 2024
1 parent b37362f commit 9c98ecc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion suite-native/module-send/src/screens/SendOutputsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const SendOutputsScreen = ({
isValueInSats: isAmountInSats,
feeLevelsMaxAmount,
decimals: tokenInfo?.decimals ?? network?.decimals,
isTaprootUnavailable: !deviceUnavailableCapabilities?.taproot,
isTaprootAvailable: !deviceUnavailableCapabilities?.taproot,
},
defaultValues: getDefaultValues({ tokenContract }),
});
Expand Down
12 changes: 8 additions & 4 deletions suite-native/module-send/src/sendOutputsFormSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type SendFormFormContext = {
isTokenFlow?: boolean;
feeLevelsMaxAmount?: FeeLevelsMaxAmount;
decimals?: number;
isTaprootUnavailable?: boolean;
isTaprootAvailable?: boolean;
};

const isAmountDust = (amount: string, context?: SendFormFormContext) => {
Expand Down Expand Up @@ -99,14 +99,18 @@ export const sendOutputsFormValidationSchema = yup.object({
if (!value || !context) {
return false;
}
const { networkSymbol, isTaprootUnavailable } = context;
const { networkSymbol, isTaprootAvailable } = context;

if (!networkSymbol) return false;

const isTaprootValid =
!isTaprootAddress(value, networkSymbol) || isTaprootAvailable;

return (
G.isNotNullable(networkSymbol) &&
isAddressValid(value, networkSymbol) &&
!isAddressDeprecated(value, networkSymbol) &&
!isBech32AddressUppercase(value) && // bech32 addresses are valid as uppercase but are not accepted by Trezor
!(isTaprootAddress(value, networkSymbol) && isTaprootUnavailable) // bech32m/Taproot addresses are valid but may not be supported by older FW
isTaprootValid // bech32m/Taproot addresses are valid but may not be supported by older FW
);
},
),
Expand Down

0 comments on commit 9c98ecc

Please sign in to comment.