do not allow taproot address as a simplex receiving address

This commit is contained in:
sneurlax 2024-09-02 13:49:54 -05:00 committed by julian-CStack
parent 87ca5b909d
commit 0e0f9803cb

View file

@ -154,6 +154,8 @@ class _BuyFormState extends ConsumerState<BuyForm> {
} }
} }
String _receivingAddressValidationErrorString = "";
void selectCrypto() async { void selectCrypto() async {
if (ref.read(simplexProvider).supportedCryptos.isEmpty) { if (ref.read(simplexProvider).supportedCryptos.isEmpty) {
bool shouldPop = false; bool shouldPop = false;
@ -1218,6 +1220,15 @@ class _BuyFormState extends ConsumerState<BuyForm> {
_address = newValue; _address = newValue;
setState(() { setState(() {
_addressToggleFlag = newValue.isNotEmpty; _addressToggleFlag = newValue.isNotEmpty;
// TODO [prio=low]: Validate address.
if (newValue.startsWith("bc1p")) {
// Display an error message or handle invalid address
_receivingAddressValidationErrorString =
"Taproot addresses are not allowed.";
} else {
_receivingAddressValidationErrorString = "";
}
}); });
}, },
focusNode: _receiveAddressFocusNode, focusNode: _receiveAddressFocusNode,
@ -1430,6 +1441,14 @@ class _BuyFormState extends ConsumerState<BuyForm> {
), ),
), ),
), ),
SizedBox(
height: isDesktop ? 10 : 4,
),
if (_receivingAddressValidationErrorString.isNotEmpty)
Text(
_receivingAddressValidationErrorString,
style: STextStyles.errorSmall(context),
),
SizedBox( SizedBox(
height: isDesktop ? 20 : 12, height: isDesktop ? 20 : 12,
), ),