strip prefixes for cashaddrs before generating uris

This commit is contained in:
julian 2023-06-23 15:36:33 -06:00
parent b64b5cdb9b
commit 7b160b9a55

View file

@ -126,7 +126,17 @@ class AddressUtils {
String address, String address,
Map<String, String> params, Map<String, String> 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) { if (params.isNotEmpty) {
uriString += Uri(queryParameters: params).toString(); uriString += Uri(queryParameters: params).toString();
} }