Skip to content

Commit d6bc8be

Browse files
committed
hack in check for addresses that can contain colon in the uri parsing logic
1 parent 7d28ed8 commit d6bc8be

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/utilities/address_utils.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ class AddressUtils {
134134
///
135135
/// Returns null on failure to parse
136136
static PaymentUriData? parsePaymentUri(String uri, {Logging? logging}) {
137+
// hacky check its not just a bcash, ecash, or xel address
138+
final parts = uri.split(":");
139+
if (parts.length == 2) {
140+
if ([
141+
"xel",
142+
"bitcoincash",
143+
"bchtest",
144+
"ecash",
145+
"ectest",
146+
].contains(parts.first.toLowerCase())) {
147+
return null;
148+
}
149+
}
150+
137151
try {
138152
final Map<String, String> parsedData = _parseUri(uri);
139153

test/address_utils_test.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ void main() {
5757
expect(AddressUtils.parsePaymentUri(uri), isNull);
5858
});
5959

60+
test("parse double prefix type address", () {
61+
const uri =
62+
"bitcoin:xel:$firoAddress?amount=50.1&message=eggs%20are%20good%21";
63+
final result = AddressUtils.parsePaymentUri(uri);
64+
expect(result, isNotNull);
65+
expect(result!.scheme, "bitcoin");
66+
expect(result.address, "xel:$firoAddress");
67+
expect(result.amount, "50.1");
68+
expect(result.message, "eggs are good!");
69+
});
70+
6071
test("encode a list of (mnemonic) words/strings as a json object", () {
6172
final List<String> list = [
6273
"hello",
@@ -92,7 +103,10 @@ void main() {
92103
test("build a uri string with empty params", () {
93104
expect(
94105
AddressUtils.buildUriString(
95-
Firo(CryptoCurrencyNetwork.main).uriScheme, firoAddress, {}),
106+
Firo(CryptoCurrencyNetwork.main).uriScheme,
107+
firoAddress,
108+
{},
109+
),
96110
"firo:$firoAddress",
97111
);
98112
});

0 commit comments

Comments
 (0)