Skip to content

Commit be380b9

Browse files
committed
fix p2sh address detection
1 parent 08ed0fc commit be380b9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:coinlib_flutter/coinlib_flutter.dart' as cl;
2+
import 'package:flutter/foundation.dart';
23

34
import '../../../models/isar/models/blockchain_data/address.dart';
5+
import '../../../utilities/logger.dart';
46
import '../intermediate/bip39_hd_currency.dart';
57

68
mixin ElectrumXCurrencyInterface on Bip39HDCurrency {
@@ -14,15 +16,29 @@ mixin ElectrumXCurrencyInterface on Bip39HDCurrency {
1416
try {
1517
final clAddress = cl.Address.fromString(address, networkParams);
1618

19+
Logging.instance.t(
20+
"getAddressType($address) type is ${clAddress.runtimeType}",
21+
);
22+
1723
return switch (clAddress) {
1824
cl.P2PKHAddress() => AddressType.p2pkh,
19-
cl.P2WSHAddress() => AddressType.p2sh,
25+
cl.P2SHAddress() => AddressType.p2sh,
2026
cl.P2WPKHAddress() => AddressType.p2wpkh,
2127
cl.P2TRAddress() => AddressType.p2tr,
2228
cl.MwebAddress() => AddressType.mweb,
2329
_ => null,
2430
};
25-
} catch (_) {
31+
} catch (e, s) {
32+
if (kDebugMode) {
33+
Logging.instance.e(
34+
"getAddressType($address) failed",
35+
error: e,
36+
stackTrace: s,
37+
);
38+
} else {
39+
Logging.instance.t("getAddressType($address) failed");
40+
}
41+
2642
return null;
2743
}
2844
}

0 commit comments

Comments
 (0)