From 7b160b9a55ee716aa42bad345d2196f758e9093f Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 23 Jun 2023 15:36:33 -0600 Subject: [PATCH] strip prefixes for cashaddrs before generating uris --- lib/utilities/address_utils.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/utilities/address_utils.dart b/lib/utilities/address_utils.dart index 93f776d98..454391f56 100644 --- a/lib/utilities/address_utils.dart +++ b/lib/utilities/address_utils.dart @@ -126,7 +126,17 @@ class AddressUtils { String address, Map params, ) { - String uriString = "${coin.uriScheme}:$address"; + // TODO: other sanitation as well ? + String sanitizedAddress = address; + if (coin == Coin.bitcoincash || + coin == Coin.bitcoincashTestnet || + coin == Coin.eCash) { + final prefix = "${coin.uriScheme}:"; + if (address.startsWith(prefix)) { + sanitizedAddress = address.replaceFirst(prefix, ""); + } + } + String uriString = "${coin.uriScheme}:$sanitizedAddress"; if (params.isNotEmpty) { uriString += Uri(queryParameters: params).toString(); }