Generic fixes (#1243)

* handle currency names with appended network * Fix BCH sending issue for p2sh addresses * Update app versions [skip ci]

Omar Hatem committed Dec 22, 2023 at 23:31 UTC c8856f5ca1df4d2111f50a08544778adfbccda37
9 files changed +32 -20
assets/text/Release_Notes.txt
+1 -5
@@ -1,6 +1,2 @@
1 -Add Polygon (Matic) wallet
2 -Polyseed enhancements
3 -New on-ramp provider DFX
4 -Usability enhancements
5 -Bitcoin enhancements
1 +Support multiple address types for Bitcoin Cash
2 Bug fixes
\ No newline at end of file
cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart
+21 -1
@@ -1,6 +1,7 @@
1 import 'dart:convert';
2
3 import 'package:bitbox/bitbox.dart' as bitbox;
4 +import 'package:bitcoin_base/bitcoin_base.dart';
5 import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
6 import 'package:cw_bitcoin/bitcoin_address_record.dart';
7 import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
@@ -210,9 +211,28 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
211 txb.addInput(input.hash, input.vout);
212 });
213
214 + final String bchPrefix = "bitcoincash:";
215 +
216 outputs.forEach((item) {
217 final outputAmount = hasMultiDestination ? item.formattedCryptoAmount : amount;
215 - final outputAddress = item.isParsedAddress ? item.extractedAddress! : item.address;
218 + String outputAddress = item.isParsedAddress ? item.extractedAddress! : item.address;
219 +
220 + if (!outputAddress.startsWith(bchPrefix)) {
221 + outputAddress = "$bchPrefix$outputAddress";
222 + }
223 +
224 + bool isP2sh = outputAddress.startsWith("p", bchPrefix.length);
225 +
226 + if (isP2sh) {
227 + final p2sh = P2shAddress.fromAddress(
228 + address: outputAddress,
229 + network: BitcoinCashNetwork.mainnet,
230 + );
231 +
232 + txb.addOutput(Uint8List.fromList(p2sh.toScriptPubKey().toBytes()), outputAmount!);
233 + return;
234 + }
235 +
236 txb.addOutput(outputAddress, outputAmount!);
237 });
238
cw_bitcoin_cash/pubspec.yaml
+1
@@ -29,6 +29,7 @@ dependencies:
29 git:
30 url: https://github.com/cake-tech/bitbox-flutter.git
31 ref: master
32 + bitcoin_base: ^3.0.1
33
34
35
cw_core/lib/crypto_currency.dart
+1 -1
@@ -245,7 +245,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
245 }
246
247 static CryptoCurrency fromFullName(String name) {
248 - if (CryptoCurrency._fullNameCurrencyMap[name.toLowerCase()] == null) {
248 + if (CryptoCurrency._fullNameCurrencyMap[name.split("(").first.trim().toLowerCase()] == null) {
249 final s = 'Unexpected token: $name for CryptoCurrency fromFullName';
250 throw ArgumentError.value(name, 'Fullname', s);
251 }
lib/core/address_validator.dart
+1 -1
@@ -92,7 +92,7 @@ class AddressValidator extends TextValidator {
92 case CryptoCurrency.eos:
93 return '[0-9a-zA-Z]';
94 case CryptoCurrency.bch:
95 - return '^(?!bitcoincash:)[0-9a-zA-Z]*\$|^(?!bitcoincash:)q[0-9a-zA-Z]{41}\$|^(?!bitcoincash:)q[0-9a-zA-Z]{42}\$|^bitcoincash:q[0-9a-zA-Z]{41}\$|^bitcoincash:q[0-9a-zA-Z]{42}\$';
95 + return '^(?!bitcoincash:)[0-9a-zA-Z]*\$|^(?!bitcoincash:)q|p[0-9a-zA-Z]{41}\$|^(?!bitcoincash:)q|p[0-9a-zA-Z]{42}\$|^bitcoincash:q|p[0-9a-zA-Z]{41}\$|^bitcoincash:q|p[0-9a-zA-Z]{42}\$';
96 case CryptoCurrency.bnb:
97 return '[0-9a-zA-Z]';
98 case CryptoCurrency.ltc:
macos/Podfile.lock
+1 -6
@@ -41,7 +41,6 @@ PODS:
41 - shared_preferences_foundation (0.0.1):
42 - Flutter
43 - FlutterMacOS
44 - - tor (0.0.1)
44 - url_launcher_macos (0.0.1):
45 - FlutterMacOS
46 - wakelock_plus (0.0.1):
@@ -60,7 +59,6 @@ DEPENDENCIES:
59 - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
60 - share_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/share_plus_macos/macos`)
61 - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
63 - - tor (from `Flutter/ephemeral/.symlinks/plugins/tor/macos`)
62 - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
63 - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`)
64
@@ -93,8 +91,6 @@ EXTERNAL SOURCES:
91 :path: Flutter/ephemeral/.symlinks/plugins/share_plus_macos/macos
92 shared_preferences_foundation:
93 :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
96 - tor:
97 - :path: Flutter/ephemeral/.symlinks/plugins/tor/macos
94 url_launcher_macos:
95 :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
96 wakelock_plus:
@@ -102,7 +98,7 @@ EXTERNAL SOURCES:
98
99 SPEC CHECKSUMS:
100 connectivity_plus_macos: f6e86fd000e971d361e54b5afcadc8c8fa773308
105 - cw_monero: f8b7f104508efba2591548e76b5c058d05cba3f0
101 + cw_monero: ec03de55a19c4a2b174ea687e0f4202edc716fa4
102 device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f
103 devicelocale: 9f0f36ac651cabae2c33f32dcff4f32b61c38225
104 flutter_secure_storage_macos: d56e2d218c1130b262bef8b4a7d64f88d7f9c9ea
@@ -114,7 +110,6 @@ SPEC CHECKSUMS:
110 ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
111 share_plus_macos: 853ee48e7dce06b633998ca0735d482dd671ade4
112 shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
117 - tor: 2138c48428e696b83eacdda404de6d5574932e26
113 url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
114 wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269
115
scripts/android/app_env.sh
+2 -2
@@ -22,8 +22,8 @@ MONERO_COM_PACKAGE="com.monero.app"
22 MONERO_COM_SCHEME="monero.com"
23
24 CAKEWALLET_NAME="Cake Wallet"
25 -CAKEWALLET_VERSION="4.12.0"
26 -CAKEWALLET_BUILD_NUMBER=187
25 +CAKEWALLET_VERSION="4.12.1"
26 +CAKEWALLET_BUILD_NUMBER=188
27 CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
28 CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
29 CAKEWALLET_SCHEME="cakewallet"
scripts/ios/app_env.sh
+2 -2
@@ -18,8 +18,8 @@ MONERO_COM_BUILD_NUMBER=69
18 MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
19
20 CAKEWALLET_NAME="Cake Wallet"
21 -CAKEWALLET_VERSION="4.12.0"
22 -CAKEWALLET_BUILD_NUMBER=205
21 +CAKEWALLET_VERSION="4.12.1"
22 +CAKEWALLET_BUILD_NUMBER=206
23 CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
24
25 HAVEN_NAME="Haven"
scripts/macos/app_env.sh
+2 -2
@@ -15,8 +15,8 @@ if [ -n "$1" ]; then
15 fi
16
17 CAKEWALLET_NAME="Cake Wallet"
18 -CAKEWALLET_VERSION="1.5.0"
19 -CAKEWALLET_BUILD_NUMBER=47
18 +CAKEWALLET_VERSION="1.5.1"
19 +CAKEWALLET_BUILD_NUMBER=48
20 CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
21
22 if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then