diff --git a/assets/images/info_icon.svg b/assets/images/info_icon.svg
new file mode 100644
index 000000000..31518cd17
--- /dev/null
+++ b/assets/images/info_icon.svg
@@ -0,0 +1,21 @@
+
+
+
+
\ No newline at end of file
diff --git a/cw_bitcoin/lib/bitcoin_address_record.dart b/cw_bitcoin/lib/bitcoin_address_record.dart
index 400e325be..d6de05051 100644
--- a/cw_bitcoin/lib/bitcoin_address_record.dart
+++ b/cw_bitcoin/lib/bitcoin_address_record.dart
@@ -54,6 +54,8 @@ abstract class BaseBitcoinAddressRecord {
BitcoinAddressType type;
+ String get derivationPath;
+
String toJSON();
}
@@ -118,6 +120,31 @@ class BitcoinAddressRecord extends BaseBitcoinAddressRecord {
String? scriptHash;
+ static int _purposeForType(BitcoinAddressType type) {
+ if (type == P2pkhAddressType.p2pkh) return 44;
+ if (type == P2shAddressType.p2wpkhInP2sh) return 49;
+ if (type == SegwitAddresType.p2wsh) return 48;
+ if (type == SegwitAddresType.p2tr) return 86;
+ return 84;
+ }
+
+ int _coinTypeForNetwork() {
+ if (!(network?.isMainnet ?? true)) return 1;
+
+ switch (network) {
+ case BitcoinNetwork.mainnet:
+ return 0;
+ case LitecoinNetwork.mainnet:
+ return 2;
+ case BitcoinCashNetwork.mainnet:
+ return 145;
+ case DogecoinNetwork.mainnet:
+ return 3;
+ default:
+ return 0;
+ }
+ }
+
String getScriptHash(BasedUtxoNetwork network) {
if (scriptHash != null) return scriptHash!;
try {
@@ -127,6 +154,21 @@ class BitcoinAddressRecord extends BaseBitcoinAddressRecord {
}
return scriptHash!;
}
+ @override
+ String get derivationPath {
+ if (type == SegwitAddresType.mweb) {
+ return "m/1000'/$index";
+ }
+
+ final coinType = _coinTypeForNetwork();
+ final purpose = _purposeForType(type);
+ final accountPath = isLegacyDerivation
+ ? electrum_path
+ : "m/$purpose'/$coinType'/0'";
+
+ final chain = isHidden ? 1 : 0;
+ return "$accountPath/$chain/$index";
+ }
@override
String toJSON() => json.encode({
@@ -186,6 +228,9 @@ class BitcoinSilentPaymentAddressRecord extends BaseBitcoinAddressRecord {
final String? silentPaymentTweak;
final String spendDerivationPath;
+ @override
+ String get derivationPath => spendDerivationPath;
+
@override
String toJSON() => json.encode({
'address': address,
diff --git a/cw_bitcoin/lib/electrum.dart b/cw_bitcoin/lib/electrum.dart
index e7993d4c2..095183426 100644
--- a/cw_bitcoin/lib/electrum.dart
+++ b/cw_bitcoin/lib/electrum.dart
@@ -144,7 +144,7 @@ class ElectrumClient {
void _parseResponse(String message) {
try {
- final response = json.decode(message) as Map;
+ final response = json.decode(message);
_handleResponse(response);
} on FormatException catch (e) {
final msg = e.message.toLowerCase();
@@ -159,7 +159,7 @@ class ElectrumClient {
}
if (isJSONStringCorrect(unterminatedString)) {
- final response = json.decode(unterminatedString) as Map;
+ final response = json.decode(unterminatedString);
_handleResponse(response);
unterminatedString = '';
}
@@ -172,8 +172,7 @@ class ElectrumClient {
unterminatedString += message;
if (isJSONStringCorrect(unterminatedString)) {
- final response = json.decode(unterminatedString) as Map;
- _handleResponse(response);
+ final response = json.decode(unterminatedString);
// unterminatedString = null;
unterminatedString = '';
}
@@ -303,6 +302,137 @@ class ElectrumClient {
return '';
});
+ Future