diff --git a/cw_core/lib/node.dart b/cw_core/lib/node.dart index 886add3cd..ff1d6b051 100644 --- a/cw_core/lib/node.dart +++ b/cw_core/lib/node.dart @@ -17,6 +17,7 @@ class Node extends HiveObject with Keyable { {this.login, this.password, this.useSSL, + this.trusted = false, String? uri, WalletType? type,}) { if (uri != null) { @@ -31,7 +32,8 @@ class Node extends HiveObject with Keyable { : uriRaw = map['uri'] as String? ?? '', login = map['login'] as String?, password = map['password'] as String?, - useSSL = map['useSSL'] as bool?; + useSSL = map['useSSL'] as bool?, + trusted = map['trusted'] as bool? ?? false; static const typeId = 1; static const boxName = 'Nodes'; @@ -51,6 +53,9 @@ class Node extends HiveObject with Keyable { @HiveField(4) bool? useSSL; + @HiveField(5) + bool trusted; + bool get isSSL => useSSL ?? false; Uri get uri { @@ -104,28 +109,28 @@ class Node extends HiveObject with Keyable { final rpcUri = isSSL ? Uri.https(uri.authority, path) : Uri.http(uri.authority, path); final realm = 'monero-rpc'; final body = { - 'jsonrpc': '2.0', - 'id': '0', + 'jsonrpc': '2.0', + 'id': '0', 'method': 'get_info' }; try { final authenticatingClient = HttpClient(); - + authenticatingClient.addCredentials( rpcUri, - realm, + realm, HttpClientDigestCredentials(login ?? '', password ?? ''), ); - + final http.Client client = ioc.IOClient(authenticatingClient); - + final response = await client.post( rpcUri, headers: {'Content-Type': 'application/json'}, body: json.encode(body), ); - + client.close(); final resBody = json.decode(response.body) as Map; diff --git a/cw_haven/ios/Classes/haven_api.cpp b/cw_haven/ios/Classes/haven_api.cpp index c1013bf87..aecaf0016 100644 --- a/cw_haven/ios/Classes/haven_api.cpp +++ b/cw_haven/ios/Classes/haven_api.cpp @@ -927,6 +927,16 @@ extern "C" return static_cast(rates.size()); } + void set_trusted_daemon(bool arg) + { + m_wallet->setTrustedDaemon(arg); + } + + bool trusted_daemon() + { + return m_wallet->trustedDaemon(); + } + #ifdef __cplusplus } #endif diff --git a/cw_haven/lib/api/signatures.dart b/cw_haven/lib/api/signatures.dart index 774a303d7..31c911edc 100644 --- a/cw_haven/lib/api/signatures.dart +++ b/cw_haven/lib/api/signatures.dart @@ -137,4 +137,8 @@ typedef get_rate = Pointer Function(); typedef size_of_rate = Int32 Function(); -typedef update_rate = Void Function(); \ No newline at end of file +typedef update_rate = Void Function(); + +typedef set_trusted_daemon = Void Function(Int8 trusted); + +typedef trusted_daemon = Int8 Function(); \ No newline at end of file diff --git a/cw_haven/lib/api/types.dart b/cw_haven/lib/api/types.dart index f1dc0e26b..de9ff74a0 100644 --- a/cw_haven/lib/api/types.dart +++ b/cw_haven/lib/api/types.dart @@ -135,4 +135,8 @@ typedef GetRate = Pointer Function(); typedef SizeOfRate = int Function(); -typedef UpdateRate = void Function(); \ No newline at end of file +typedef UpdateRate = void Function(); + +typedef SetTrustedDaemon = void Function(int); + +typedef TrustedDaemon = int Function(); \ No newline at end of file diff --git a/cw_haven/lib/api/wallet.dart b/cw_haven/lib/api/wallet.dart index 2b85f60e2..bdf6a1af7 100644 --- a/cw_haven/lib/api/wallet.dart +++ b/cw_haven/lib/api/wallet.dart @@ -116,6 +116,14 @@ final rescanBlockchainAsyncNative = havenApi .lookup>('rescan_blockchain') .asFunction(); +final setTrustedDaemonNative = havenApi + .lookup>('set_trusted_daemon') + .asFunction(); + +final trustedDaemonNative = havenApi + .lookup>('trusted_daemon') + .asFunction(); + int getSyncingHeight() => getSyncingHeightNative(); bool isNeededToRefresh() => isNeededToRefreshNative() != 0; @@ -351,3 +359,7 @@ Future isConnected() => compute(_isConnected, 0); Future getNodeHeight() => compute(_getNodeHeight, 0); void rescanBlockchainAsync() => rescanBlockchainAsyncNative(); + +Future setTrustedDaemon(bool trusted) async => setTrustedDaemonNative(_boolToInt(trusted)); + +Future trustedDaemon() async => trustedDaemonNative() != 0; diff --git a/cw_haven/lib/haven_wallet.dart b/cw_haven/lib/haven_wallet.dart index cf7c9dcdd..a4b949d8f 100644 --- a/cw_haven/lib/haven_wallet.dart +++ b/cw_haven/lib/haven_wallet.dart @@ -121,6 +121,8 @@ abstract class HavenWalletBase extends WalletBasegetSubaddressLabel(accountIndex, addressIndex).c_str()); } + void set_trusted_daemon(bool arg) + { + m_wallet->setTrustedDaemon(arg); + } + + bool trusted_daemon() + { + return m_wallet->trustedDaemon(); + } + #ifdef __cplusplus } #endif diff --git a/cw_monero/ios/Classes/monero_api.h b/cw_monero/ios/Classes/monero_api.h index 3e2ebcff2..74258ba4c 100644 --- a/cw_monero/ios/Classes/monero_api.h +++ b/cw_monero/ios/Classes/monero_api.h @@ -30,6 +30,9 @@ void set_refresh_from_block_height(uint64_t height); void set_recovering_from_seed(bool is_recovery); void store(char *path); +void set_trusted_daemon(bool arg); +bool trusted_daemon(); + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/cw_monero/lib/api/signatures.dart b/cw_monero/lib/api/signatures.dart index f9e88153e..0b14fd557 100644 --- a/cw_monero/lib/api/signatures.dart +++ b/cw_monero/lib/api/signatures.dart @@ -125,4 +125,8 @@ typedef rescan_blockchain = Void Function(); typedef get_subaddress_label = Pointer Function( Int32 accountIndex, - Int32 addressIndex); \ No newline at end of file + Int32 addressIndex); + +typedef set_trusted_daemon = Void Function(Int8 trusted); + +typedef trusted_daemon = Int8 Function(); \ No newline at end of file diff --git a/cw_monero/lib/api/types.dart b/cw_monero/lib/api/types.dart index 468ce93e2..c5918c12a 100644 --- a/cw_monero/lib/api/types.dart +++ b/cw_monero/lib/api/types.dart @@ -123,4 +123,8 @@ typedef RescanBlockchainAsync = void Function(); typedef GetSubaddressLabel = Pointer Function( int accountIndex, - int addressIndex); \ No newline at end of file + int addressIndex); + +typedef SetTrustedDaemon = void Function(int); + +typedef TrustedDaemon = int Function(); \ No newline at end of file diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index 5c2f1bd27..7ddbf29dc 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -120,6 +120,14 @@ final getSubaddressLabelNative = moneroApi .lookup>('get_subaddress_label') .asFunction(); +final setTrustedDaemonNative = moneroApi + .lookup>('set_trusted_daemon') + .asFunction(); + +final trustedDaemonNative = moneroApi + .lookup>('trusted_daemon') + .asFunction(); + int getSyncingHeight() => getSyncingHeightNative(); bool isNeededToRefresh() => isNeededToRefreshNative() != 0; @@ -359,4 +367,8 @@ void rescanBlockchainAsync() => rescanBlockchainAsyncNative(); String getSubaddressLabel(int accountIndex, int addressIndex) { return convertUTF8ToString(pointer: getSubaddressLabelNative(accountIndex, addressIndex)); -} \ No newline at end of file +} + +Future setTrustedDaemon(bool trusted) async => setTrustedDaemonNative(_boolToInt(trusted)); + +Future trustedDaemon() async => trustedDaemonNative() != 0; \ No newline at end of file diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index 69c61b83a..a9d708c05 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -136,6 +136,8 @@ abstract class MoneroWalletBase extends WalletBase StandardCheckbox( + value: nodeCreateOrEditViewModel.trusted, + onChanged: (value) => + nodeCreateOrEditViewModel.trusted = value, + caption: S.of(context).trusted, + )) + ], + )), ] ], )), diff --git a/lib/view_model/node_list/node_create_or_edit_view_model.dart b/lib/view_model/node_list/node_create_or_edit_view_model.dart index 31b83faff..e24692059 100644 --- a/lib/view_model/node_list/node_create_or_edit_view_model.dart +++ b/lib/view_model/node_list/node_create_or_edit_view_model.dart @@ -18,7 +18,8 @@ abstract class NodeCreateOrEditViewModelBase with Store { address = '', port = '', login = '', - password = ''; + password = '', + trusted = false; @observable ExecutionState state; @@ -41,6 +42,9 @@ abstract class NodeCreateOrEditViewModelBase with Store { @observable bool useSSL; + @observable + bool trusted; + @computed bool get isReady => address.isNotEmpty && port.isNotEmpty; @@ -68,6 +72,7 @@ abstract class NodeCreateOrEditViewModelBase with Store { login = ''; password = ''; useSSL = false; + trusted = false; } @action @@ -76,7 +81,7 @@ abstract class NodeCreateOrEditViewModelBase with Store { state = IsExecutingState(); final node = Node(uri: uri, type: _wallet.type, login: login, password: password, - useSSL: useSSL); + useSSL: useSSL, trusted: trusted); await _nodeSource.add(node); state = ExecutedSuccessfullyState(); } catch (e) { diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 95fd0b6ff..cab983627 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider}-Fehler", "use_ssl" : "SSL verwenden", + "trusted" : "Vertrauenswürdige", "color_theme" : "Farbthema", "light_theme" : "Hell", diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index a470ccd70..08bf8fb5f 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} error", "use_ssl" : "Use SSL", + "trusted" : "Trusted", "color_theme" : "Color theme", "light_theme" : "Light", diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index ad0476df4..c5212ea52 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} error", "use_ssl" : "Utilice SSL", + "trusted" : "de confianza", "color_theme" : "Tema de color", "light_theme" : "Ligera", diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index 9666df9cb..187265404 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -435,6 +435,7 @@ "provider_error" : "Erreur de ${provider}", "use_ssl" : "Utiliser SSL", + "trusted" : "de confiance", "color_theme" : "Thème", "light_theme" : "Clair", diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index c7144d14a..155444460 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} त्रुटि", "use_ssl" : "उपयोग SSL", + "trusted" : "भरोसा", "color_theme" : "रंग विषय", "light_theme" : "रोशनी", diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 897075ce7..27e07b448 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} greška", "use_ssl" : "Koristi SSL", + "trusted" : "vjerovao", "color_theme" : "Shema boja", "light_theme" : "Svijetla", diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index a8e30ae06..64505dfc2 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} errore", "use_ssl" : "Usa SSL", + "trusted" : "di fiducia", "color_theme" : "Colore tema", "light_theme" : "Bianco", diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index d5553ff10..a17791d0a 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} エラー", "use_ssl" : "SSLを使用する", + "trusted" : "信頼できる", "color_theme" : "カラーテーマ", "light_theme" : "光", diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index a374e18ad..b5868d25a 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} 오류", "use_ssl" : "SSL 사용", + "trusted" : "신뢰할 수 있는", "color_theme" : "색상 테마", "light_theme" : "빛", diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 286735406..66c127f12 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} fout", "use_ssl" : "Gebruik SSL", + "trusted" : "vertrouwd", "color_theme" : "Kleur thema", "light_theme" : "Licht", diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 9ec4ce591..5e2cc380a 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} pomyłka", "use_ssl" : "Użyj SSL", + "trusted" : "zaufany", "color_theme" : "Motyw kolorystyczny", "light_theme" : "Lekki", diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 6dc3df4e0..78d908dbd 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} erro", "use_ssl" : "Use SSL", + "trusted" : "confiável", "color_theme" : "Tema de cor", "light_theme" : "Luz", @@ -545,7 +546,6 @@ "create_account": "Criar conta", "privacy_policy": "Política de privacidade", "welcome_to_cakepay": "Bem-vindo ao Cake Pay!", - "create_account": "Registar-se", "forgot_password": "Esqueci a senha", "reset_password": "Redefinir senha", "gift_cards": "Cartões de presente", diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index e08cc74a3..bc3ac1840 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -437,6 +437,7 @@ "provider_error" : "${provider} ошибка", "use_ssl" : "Использовать SSL", + "trusted" : "доверенный", "color_theme" : "Цветовая тема", "light_theme" : "Светлая", diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 3c98cb126..bb41712ec 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -436,6 +436,7 @@ "provider_error" : "${provider} помилка", "use_ssl" : "Використати SSL", + "trusted" : "довіряють", "color_theme" : "Кольорова тема", "light_theme" : "Світла", diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 8434fa93c..4a08a230d 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -436,6 +436,7 @@ "provider_error" : "${provider} 错误", "use_ssl" : "使用SSL", + "trusted" : "值得信赖", "color_theme" : "主题", "light_theme" : "艳丽",