mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-05-15 11:44:39 +00:00
Add Payjoin Setting
This commit is contained in:
parent
11f87a5b16
commit
4c4fd8e645
5 changed files with 43 additions and 18 deletions
lib
entities
src/screens/settings
store
view_model/settings
tool
|
@ -77,6 +77,7 @@ class PreferencesKey {
|
|||
static const lookupsOpenAlias = 'looks_up_open_alias';
|
||||
static const lookupsENS = 'looks_up_ens';
|
||||
static const lookupsWellKnown = 'looks_up_well_known';
|
||||
static const usePayjoin = 'use_payjoin';
|
||||
static const showCameraConsent = 'show_camera_consent';
|
||||
|
||||
static String moneroWalletUpdateV1Key(String name) =>
|
||||
|
|
|
@ -49,6 +49,14 @@ class PrivacyPage extends BasePage {
|
|||
_privacySettingsViewModel.setExchangeApiMode(mode),
|
||||
),
|
||||
),
|
||||
if (_privacySettingsViewModel.canUsePayjoin)
|
||||
SettingsSwitcherCell(
|
||||
title: 'Use Payjoin', // ToDo: localize
|
||||
value: _privacySettingsViewModel.usePayjoin,
|
||||
onValueChange: (BuildContext _, bool value) {
|
||||
_privacySettingsViewModel.setUsePayjoin(value);
|
||||
},
|
||||
),
|
||||
SettingsSwitcherCell(
|
||||
title: S.current.settings_save_recipient_address,
|
||||
value: _privacySettingsViewModel.shouldSaveRecipientAddress,
|
||||
|
|
|
@ -16,7 +16,6 @@ import 'package:cake_wallet/entities/fiat_currency.dart';
|
|||
import 'package:cake_wallet/entities/language_service.dart';
|
||||
import 'package:cake_wallet/entities/pin_code_required_duration.dart';
|
||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:cake_wallet/entities/provider_types.dart';
|
||||
import 'package:cake_wallet/entities/secret_store_key.dart';
|
||||
import 'package:cake_wallet/entities/seed_phrase_length.dart';
|
||||
import 'package:cake_wallet/entities/seed_type.dart';
|
||||
|
@ -116,6 +115,7 @@ abstract class SettingsStoreBase with Store {
|
|||
required this.lookupsOpenAlias,
|
||||
required this.lookupsENS,
|
||||
required this.lookupsWellKnown,
|
||||
required this.usePayjoin,
|
||||
required this.customBitcoinFeeRate,
|
||||
required this.silentPaymentsCardDisplay,
|
||||
required this.silentPaymentsAlwaysScan,
|
||||
|
@ -465,6 +465,11 @@ abstract class SettingsStoreBase with Store {
|
|||
(bool looksUpWellKnown) =>
|
||||
_sharedPreferences.setBool(PreferencesKey.lookupsWellKnown, looksUpWellKnown));
|
||||
|
||||
reaction(
|
||||
(_) => usePayjoin,
|
||||
(bool usePayjoin) =>
|
||||
_sharedPreferences.setBool(PreferencesKey.usePayjoin, usePayjoin));
|
||||
|
||||
// secure storage keys:
|
||||
reaction(
|
||||
(_) => allowBiometricalAuthentication,
|
||||
|
@ -780,6 +785,10 @@ abstract class SettingsStoreBase with Store {
|
|||
|
||||
@observable
|
||||
bool lookupsWellKnown;
|
||||
|
||||
@observable
|
||||
bool usePayjoin;
|
||||
|
||||
@observable
|
||||
SyncMode currentSyncMode;
|
||||
|
||||
|
@ -976,6 +985,7 @@ abstract class SettingsStoreBase with Store {
|
|||
final lookupsOpenAlias = sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias) ?? true;
|
||||
final lookupsENS = sharedPreferences.getBool(PreferencesKey.lookupsENS) ?? true;
|
||||
final lookupsWellKnown = sharedPreferences.getBool(PreferencesKey.lookupsWellKnown) ?? true;
|
||||
final usePayjoin = sharedPreferences.getBool(PreferencesKey.usePayjoin) ?? true;
|
||||
final customBitcoinFeeRate = sharedPreferences.getInt(PreferencesKey.customBitcoinFeeRate) ?? 1;
|
||||
final silentPaymentsCardDisplay =
|
||||
sharedPreferences.getBool(PreferencesKey.silentPaymentsCardDisplay) ?? true;
|
||||
|
@ -1255,6 +1265,7 @@ abstract class SettingsStoreBase with Store {
|
|||
lookupsOpenAlias: lookupsOpenAlias,
|
||||
lookupsENS: lookupsENS,
|
||||
lookupsWellKnown: lookupsWellKnown,
|
||||
usePayjoin: usePayjoin,
|
||||
customBitcoinFeeRate: customBitcoinFeeRate,
|
||||
silentPaymentsCardDisplay: silentPaymentsCardDisplay,
|
||||
silentPaymentsAlwaysScan: silentPaymentsAlwaysScan,
|
||||
|
|
|
@ -33,19 +33,18 @@ abstract class PrivacySettingsViewModelBase with Store {
|
|||
@action
|
||||
void setAutoGenerateSubaddresses(bool value) {
|
||||
_wallet.isEnabledAutoGenerateSubaddress = value;
|
||||
if (value) {
|
||||
_settingsStore.autoGenerateSubaddressStatus = AutoGenerateSubaddressStatus.enabled;
|
||||
} else {
|
||||
_settingsStore.autoGenerateSubaddressStatus = AutoGenerateSubaddressStatus.disabled;
|
||||
}
|
||||
_settingsStore.autoGenerateSubaddressStatus = value
|
||||
? AutoGenerateSubaddressStatus.enabled
|
||||
: AutoGenerateSubaddressStatus.disabled;
|
||||
}
|
||||
|
||||
bool get isAutoGenerateSubaddressesVisible =>
|
||||
_wallet.type == WalletType.monero ||
|
||||
_wallet.type == WalletType.wownero ||
|
||||
_wallet.type == WalletType.bitcoin ||
|
||||
_wallet.type == WalletType.litecoin ||
|
||||
_wallet.type == WalletType.bitcoinCash;
|
||||
bool get isAutoGenerateSubaddressesVisible => [
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
WalletType.bitcoin,
|
||||
WalletType.litecoin,
|
||||
WalletType.bitcoinCash
|
||||
].contains(_wallet.type);
|
||||
|
||||
bool get isMoneroWallet => _wallet.type == WalletType.monero;
|
||||
|
||||
|
@ -97,6 +96,9 @@ abstract class PrivacySettingsViewModelBase with Store {
|
|||
@computed
|
||||
bool get looksUpWellKnown => _settingsStore.lookupsWellKnown;
|
||||
|
||||
@computed
|
||||
bool get usePayjoin => _settingsStore.usePayjoin;
|
||||
|
||||
bool get canUseEtherscan => _wallet.type == WalletType.ethereum;
|
||||
|
||||
bool get canUsePolygonScan => _wallet.type == WalletType.polygon;
|
||||
|
@ -105,6 +107,8 @@ abstract class PrivacySettingsViewModelBase with Store {
|
|||
|
||||
bool get canUseMempoolFeeAPI => _wallet.type == WalletType.bitcoin;
|
||||
|
||||
bool get canUsePayjoin => _wallet.type == WalletType.bitcoin;
|
||||
|
||||
@action
|
||||
void setShouldSaveRecipientAddress(bool value) =>
|
||||
_settingsStore.shouldSaveRecipientAddress = value;
|
||||
|
@ -164,7 +168,9 @@ abstract class PrivacySettingsViewModelBase with Store {
|
|||
}
|
||||
|
||||
@action
|
||||
void setUseMempoolFeeAPI(bool value) {
|
||||
_settingsStore.useMempoolFeeAPI = value;
|
||||
}
|
||||
void setUseMempoolFeeAPI(bool value) =>
|
||||
_settingsStore.useMempoolFeeAPI = value;
|
||||
|
||||
@action
|
||||
void setUsePayjoin(bool value) => _settingsStore.usePayjoin = value;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,8 @@ import 'package:cw_bitcoin/bitcoin_wallet_service.dart';
|
|||
import 'package:cw_bitcoin/bitcoin_wallet_creation_credentials.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_wallet.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_wallet_addresses.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
|
||||
import 'package:cw_bitcoin/litecoin_wallet_service.dart';
|
||||
import 'package:cw_bitcoin/litecoin_wallet.dart';
|
||||
|
@ -239,9 +241,6 @@ abstract class Bitcoin {
|
|||
String? getUnusedSegwitAddress(Object wallet);
|
||||
|
||||
String buildV2PjStr({required Object receiverWallet});
|
||||
Future<String> extractOriginalTransaction(UncheckedProposal proposal);
|
||||
Future<PayjoinProposal> processProposal({required UncheckedProposal proposal, required Object receiverWallet});
|
||||
Future<String> sendFinalProposal(PayjoinProposal finalProposal);
|
||||
Future<Sender> buildPayjoinRequest(String originalPsbt, dynamic pjUri, int fee);
|
||||
Future<String> buildOriginalPsbt(Object wallet, int fee, double amount, Object credentials);
|
||||
Future<String> requestAndPollV2Proposal(Sender sender);
|
||||
|
|
Loading…
Reference in a new issue