From 93d3582e8e54c6425b81ac66ae14aef3c55b137b Mon Sep 17 00:00:00 2001 From: Konstantin Ullrich Date: Fri, 25 Jul 2025 14:07:17 +0200 Subject: [PATCH] Cw 1106 enable ledger for desktop through ble (#2410) * fix: remove redundant mobile check for hardware wallet support and add macOS BLE permission handling * fix: update connect_device_page platform check and add macOS Bluetooth entitlements * fix: Ledger Monero on Windows --- cw_monero/lib/ledger.dart | 3 ++- cw_monero/pubspec.yaml | 2 +- cw_wownero/pubspec.yaml | 2 +- cw_zano/pubspec.yaml | 2 +- lib/src/screens/connect_device/connect_device_page.dart | 6 +++--- lib/src/screens/restore/restore_options_page.dart | 4 ---- lib/view_model/hardware_wallet/ledger_view_model.dart | 7 ++----- macos/Runner/DebugProfileBase.entitlements | 2 ++ macos/Runner/ReleaseBase.entitlements | 2 ++ macos/Runner/RunnerBase.entitlements | 4 +++- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cw_monero/lib/ledger.dart b/cw_monero/lib/ledger.dart index 6e32d4d68..7a3c95a27 100644 --- a/cw_monero/lib/ledger.dart +++ b/cw_monero/lib/ledger.dart @@ -34,7 +34,8 @@ void enableLedgerExchange(LedgerConnection connection) { api.MoneroWallet.setDeviceReceivedData( result.cast(), response.length); - api.MoneroFree().free(result.cast()); + malloc.free(result); + // api.MoneroFree().free(result.cast()); } callable = NativeCallable.listener(callback); diff --git a/cw_monero/pubspec.yaml b/cw_monero/pubspec.yaml index a11e85b6c..98a4045ec 100644 --- a/cw_monero/pubspec.yaml +++ b/cw_monero/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: monero: git: url: https://github.com/mrcyjanek/monero_c - ref: a27fbcb24d91143715ed930a05aaa4d853fba1f2 + ref: b576312e4d466569cd03482b61c597b39a9f4dc3 path: impls/monero.dart mutex: ^3.1.0 ledger_flutter_plus: ^1.4.1 diff --git a/cw_wownero/pubspec.yaml b/cw_wownero/pubspec.yaml index 4fda054b5..63f6251a3 100644 --- a/cw_wownero/pubspec.yaml +++ b/cw_wownero/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: monero: git: url: https://github.com/mrcyjanek/monero_c - ref: a27fbcb24d91143715ed930a05aaa4d853fba1f2 # monero_c hash + ref: b576312e4d466569cd03482b61c597b39a9f4dc3 # monero_c hash path: impls/monero.dart mutex: ^3.1.0 diff --git a/cw_zano/pubspec.yaml b/cw_zano/pubspec.yaml index 529fe04eb..c57c72a24 100644 --- a/cw_zano/pubspec.yaml +++ b/cw_zano/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: monero: git: url: https://github.com/mrcyjanek/monero_c - ref: a27fbcb24d91143715ed930a05aaa4d853fba1f2 # monero_c hash + ref: b576312e4d466569cd03482b61c597b39a9f4dc3 # monero_c hash path: impls/monero.dart dev_dependencies: flutter_test: diff --git a/lib/src/screens/connect_device/connect_device_page.dart b/lib/src/screens/connect_device/connect_device_page.dart index 9e332369e..ffa9e5470 100644 --- a/lib/src/screens/connect_device/connect_device_page.dart +++ b/lib/src/screens/connect_device/connect_device_page.dart @@ -197,9 +197,9 @@ class ConnectDevicePageBodyState extends State { Padding( padding: EdgeInsets.only(left: 20, right: 20, bottom: 20), child: Text( - Platform.isIOS - ? S.of(context).connect_your_hardware_wallet_ios - : S.of(context).connect_your_hardware_wallet, + Platform.isAndroid + ? S.of(context).connect_your_hardware_wallet + : S.of(context).connect_your_hardware_wallet_ios, style: Theme.of(context) .textTheme.titleMedium, textAlign: TextAlign.center, diff --git a/lib/src/screens/restore/restore_options_page.dart b/lib/src/screens/restore/restore_options_page.dart index ee8347f25..7f6e1f814 100644 --- a/lib/src/screens/restore/restore_options_page.dart +++ b/lib/src/screens/restore/restore_options_page.dart @@ -45,10 +45,6 @@ class _RestoreOptionsBodyState extends State<_RestoreOptionsBody> { bool isRestoring = false; bool get _doesSupportHardwareWallets { - if (!DeviceInfo.instance.isMobile) { - return false; - } - if (isMoneroOnly) { return DeviceConnectionType.supportedConnectionTypes(WalletType.monero, Platform.isIOS) .isNotEmpty; diff --git a/lib/view_model/hardware_wallet/ledger_view_model.dart b/lib/view_model/hardware_wallet/ledger_view_model.dart index 132a5deb9..1bc00fb02 100644 --- a/lib/view_model/hardware_wallet/ledger_view_model.dart +++ b/lib/view_model/hardware_wallet/ledger_view_model.dart @@ -9,7 +9,6 @@ import 'package:cake_wallet/monero/monero.dart'; import 'package:cake_wallet/polygon/polygon.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/connect_device/connect_device_page.dart'; -import 'package:cake_wallet/utils/device_info.dart'; import 'package:cake_wallet/wallet_type_utils.dart'; import 'package:cw_core/hardware/device_connection_type.dart'; import 'package:cw_core/utils/print_verbose.dart'; @@ -30,10 +29,6 @@ abstract class LedgerViewModelBase with Store { late final sdk.LedgerInterface ledgerPlusUSB; bool get _doesSupportHardwareWallets { - if (!DeviceInfo.instance.isMobile) { - return false; - } - if (isMoneroOnly) { return DeviceConnectionType.supportedConnectionTypes( WalletType.monero, Platform.isIOS) @@ -65,6 +60,8 @@ abstract class LedgerViewModelBase with Store { if (bleIsEnabled && !_bleIsInitialized) { ledgerPlusBLE = sdk.LedgerInterface.ble( onPermissionRequest: (_) async { + if (Platform.isMacOS) return true; + Map statuses = await [ Permission.bluetoothScan, Permission.bluetoothConnect, diff --git a/macos/Runner/DebugProfileBase.entitlements b/macos/Runner/DebugProfileBase.entitlements index c1b4345fe..d6b74b4aa 100644 --- a/macos/Runner/DebugProfileBase.entitlements +++ b/macos/Runner/DebugProfileBase.entitlements @@ -8,6 +8,8 @@ com.apple.security.network.server + com.apple.security.device.bluetooth + keychain-access-groups $(AppIdentifierPrefix)${BUNDLE_ID} diff --git a/macos/Runner/ReleaseBase.entitlements b/macos/Runner/ReleaseBase.entitlements index aef6ac342..c942c3aa9 100644 --- a/macos/Runner/ReleaseBase.entitlements +++ b/macos/Runner/ReleaseBase.entitlements @@ -4,6 +4,8 @@ com.apple.security.app-sandbox + com.apple.security.device.bluetooth + keychain-access-groups $(AppIdentifierPrefix)${BUNDLE_ID} diff --git a/macos/Runner/RunnerBase.entitlements b/macos/Runner/RunnerBase.entitlements index 22be818c6..5e6cc995d 100644 --- a/macos/Runner/RunnerBase.entitlements +++ b/macos/Runner/RunnerBase.entitlements @@ -6,9 +6,11 @@ com.apple.security.network.client + com.apple.security.device.bluetooth + keychain-access-groups $(AppIdentifierPrefix)${BUNDLE_ID} - \ No newline at end of file +