From 7fba63712d82259a81f628ca0a73aaef9895eee1 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Fri, 13 Jun 2025 13:02:10 +0200 Subject: [PATCH] fix(ui): remove SP from UI in view only wallet --- cw_bitcoin/lib/bitcoin_receive_page_option.dart | 8 ++++++++ cw_bitcoin/pubspec.lock | 8 -------- lib/bitcoin/cw_bitcoin.dart | 9 ++++++++- lib/view_model/dashboard/receive_option_view_model.dart | 2 +- tool/configure.dart | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cw_bitcoin/lib/bitcoin_receive_page_option.dart b/cw_bitcoin/lib/bitcoin_receive_page_option.dart index 07083e111..c4b175590 100644 --- a/cw_bitcoin/lib/bitcoin_receive_page_option.dart +++ b/cw_bitcoin/lib/bitcoin_receive_page_option.dart @@ -28,6 +28,14 @@ class BitcoinReceivePageOption implements ReceivePageOption { BitcoinReceivePageOption.p2pkh ]; + static const allViewOnly = [ + BitcoinReceivePageOption.p2wpkh, + BitcoinReceivePageOption.p2tr, + BitcoinReceivePageOption.p2wsh, + BitcoinReceivePageOption.p2sh, + BitcoinReceivePageOption.p2pkh + ]; + static const allLitecoin = [ BitcoinReceivePageOption.p2wpkh, BitcoinReceivePageOption.mweb, diff --git a/cw_bitcoin/pubspec.lock b/cw_bitcoin/pubspec.lock index fe3f87e17..4a77b31ca 100644 --- a/cw_bitcoin/pubspec.lock +++ b/cw_bitcoin/pubspec.lock @@ -1110,14 +1110,6 @@ packages: url: "https://github.com/bukata-sa/bc-ur-dart" source: git version: "0.1.0" - uuid: - dependency: transitive - description: - name: uuid - sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff - url: "https://pub.dev" - source: hosted - version: "4.5.1" vector_math: dependency: transitive description: diff --git a/lib/bitcoin/cw_bitcoin.dart b/lib/bitcoin/cw_bitcoin.dart index 263fe7e84..ae285ab36 100644 --- a/lib/bitcoin/cw_bitcoin.dart +++ b/lib/bitcoin/cw_bitcoin.dart @@ -280,7 +280,14 @@ class CWBitcoin extends Bitcoin { } @override - List getBitcoinReceivePageOptions() => BitcoinReceivePageOption.all; + List getBitcoinReceivePageOptions(Object wallet) { + final bitcoinWallet = wallet as ElectrumWallet; + final keys = bitcoinWallet.keys; + if (keys.privateKey.isEmpty) { + return BitcoinReceivePageOption.allViewOnly; + } + return BitcoinReceivePageOption.all; + } @override List getLitecoinReceivePageOptions() { diff --git a/lib/view_model/dashboard/receive_option_view_model.dart b/lib/view_model/dashboard/receive_option_view_model.dart index f15d7dad6..1ae6851a0 100644 --- a/lib/view_model/dashboard/receive_option_view_model.dart +++ b/lib/view_model/dashboard/receive_option_view_model.dart @@ -22,7 +22,7 @@ abstract class ReceiveOptionViewModelBase with Store { switch (walletType) { case WalletType.bitcoin: _options = [ - ...bitcoin!.getBitcoinReceivePageOptions(), + ...bitcoin!.getBitcoinReceivePageOptions(_wallet), ...ReceivePageOptions.where((element) => element != ReceivePageOption.mainnet) ]; break; diff --git a/tool/configure.dart b/tool/configure.dart index 05568e146..45d7cbba3 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -207,7 +207,7 @@ abstract class Bitcoin { Map> getElectrumDerivations(); Future setAddressType(Object wallet, dynamic option); ReceivePageOption getSelectedAddressType(Object wallet); - List getBitcoinReceivePageOptions(); + List getBitcoinReceivePageOptions(Object wallet); List getLitecoinReceivePageOptions(); BitcoinAddressType getBitcoinAddressType(ReceivePageOption option); bool isPayjoinAvailable(Object wallet);