Skip to content

Commit

Permalink
Generic fixes (#1243)
Browse files Browse the repository at this point in the history
* handle currency names with appended network

* Fix BCH sending issue for p2sh addresses

* Update app versions [skip ci]
  • Loading branch information
OmarHatem28 authored Dec 22, 2023
1 parent be285e7 commit c8856f5
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 20 deletions.
6 changes: 1 addition & 5 deletions assets/text/Release_Notes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
Add Polygon (Matic) wallet
Polyseed enhancements
New on-ramp provider DFX
Usability enhancements
Bitcoin enhancements
Support multiple address types for Bitcoin Cash
Bug fixes
22 changes: 21 additions & 1 deletion cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:bitbox/bitbox.dart' as bitbox;
import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
import 'package:cw_bitcoin/bitcoin_address_record.dart';
import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
Expand Down Expand Up @@ -210,9 +211,28 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
txb.addInput(input.hash, input.vout);
});

final String bchPrefix = "bitcoincash:";

outputs.forEach((item) {
final outputAmount = hasMultiDestination ? item.formattedCryptoAmount : amount;
final outputAddress = item.isParsedAddress ? item.extractedAddress! : item.address;
String outputAddress = item.isParsedAddress ? item.extractedAddress! : item.address;

if (!outputAddress.startsWith(bchPrefix)) {
outputAddress = "$bchPrefix$outputAddress";
}

bool isP2sh = outputAddress.startsWith("p", bchPrefix.length);

if (isP2sh) {
final p2sh = P2shAddress.fromAddress(
address: outputAddress,
network: BitcoinCashNetwork.mainnet,
);

txb.addOutput(Uint8List.fromList(p2sh.toScriptPubKey().toBytes()), outputAmount!);
return;
}

txb.addOutput(outputAddress, outputAmount!);
});

Expand Down
1 change: 1 addition & 0 deletions cw_bitcoin_cash/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies:
git:
url: https://github.com/cake-tech/bitbox-flutter.git
ref: master
bitcoin_base: ^3.0.1



Expand Down
2 changes: 1 addition & 1 deletion cw_core/lib/crypto_currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
}

static CryptoCurrency fromFullName(String name) {
if (CryptoCurrency._fullNameCurrencyMap[name.toLowerCase()] == null) {
if (CryptoCurrency._fullNameCurrencyMap[name.split("(").first.trim().toLowerCase()] == null) {
final s = 'Unexpected token: $name for CryptoCurrency fromFullName';
throw ArgumentError.value(name, 'Fullname', s);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/address_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AddressValidator extends TextValidator {
case CryptoCurrency.eos:
return '[0-9a-zA-Z]';
case CryptoCurrency.bch:
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}\$';
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}\$';
case CryptoCurrency.bnb:
return '[0-9a-zA-Z]';
case CryptoCurrency.ltc:
Expand Down
7 changes: 1 addition & 6 deletions macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ PODS:
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- tor (0.0.1)
- url_launcher_macos (0.0.1):
- FlutterMacOS
- wakelock_plus (0.0.1):
Expand All @@ -60,7 +59,6 @@ DEPENDENCIES:
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- share_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/share_plus_macos/macos`)
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
- tor (from `Flutter/ephemeral/.symlinks/plugins/tor/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
- wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`)

Expand Down Expand Up @@ -93,16 +91,14 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/share_plus_macos/macos
shared_preferences_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
tor:
:path: Flutter/ephemeral/.symlinks/plugins/tor/macos
url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
wakelock_plus:
:path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos

SPEC CHECKSUMS:
connectivity_plus_macos: f6e86fd000e971d361e54b5afcadc8c8fa773308
cw_monero: f8b7f104508efba2591548e76b5c058d05cba3f0
cw_monero: ec03de55a19c4a2b174ea687e0f4202edc716fa4
device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f
devicelocale: 9f0f36ac651cabae2c33f32dcff4f32b61c38225
flutter_secure_storage_macos: d56e2d218c1130b262bef8b4a7d64f88d7f9c9ea
Expand All @@ -114,7 +110,6 @@ SPEC CHECKSUMS:
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
share_plus_macos: 853ee48e7dce06b633998ca0735d482dd671ade4
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
tor: 2138c48428e696b83eacdda404de6d5574932e26
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269

Expand Down
4 changes: 2 additions & 2 deletions scripts/android/app_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ MONERO_COM_PACKAGE="com.monero.app"
MONERO_COM_SCHEME="monero.com"

CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.12.0"
CAKEWALLET_BUILD_NUMBER=187
CAKEWALLET_VERSION="4.12.1"
CAKEWALLET_BUILD_NUMBER=188
CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
CAKEWALLET_SCHEME="cakewallet"
Expand Down
4 changes: 2 additions & 2 deletions scripts/ios/app_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ MONERO_COM_BUILD_NUMBER=69
MONERO_COM_BUNDLE_ID="com.cakewallet.monero"

CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.12.0"
CAKEWALLET_BUILD_NUMBER=205
CAKEWALLET_VERSION="4.12.1"
CAKEWALLET_BUILD_NUMBER=206
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"

HAVEN_NAME="Haven"
Expand Down
4 changes: 2 additions & 2 deletions scripts/macos/app_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ if [ -n "$1" ]; then
fi

CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="1.5.0"
CAKEWALLET_BUILD_NUMBER=47
CAKEWALLET_VERSION="1.5.1"
CAKEWALLET_BUILD_NUMBER=48
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"

if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then
Expand Down

0 comments on commit c8856f5

Please sign in to comment.