Merge pull request #529 from cake-tech/CW-182-allow-trusted-nodes

Cw 182 allow trusted nodes
This commit is contained in:
Omar Hatem 2022-12-04 02:17:35 +02:00 committed by GitHub
commit dc60123f79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 123 additions and 17 deletions

View file

@ -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 {

View file

@ -927,6 +927,16 @@ extern "C"
return static_cast<int32_t>(rates.size());
}
void set_trusted_daemon(bool arg)
{
m_wallet->setTrustedDaemon(arg);
}
bool trusted_daemon()
{
return m_wallet->trustedDaemon();
}
#ifdef __cplusplus
}
#endif

View file

@ -138,3 +138,7 @@ typedef get_rate = Pointer<Int64> Function();
typedef size_of_rate = Int32 Function();
typedef update_rate = Void Function();
typedef set_trusted_daemon = Void Function(Int8 trusted);
typedef trusted_daemon = Int8 Function();

View file

@ -136,3 +136,7 @@ typedef GetRate = Pointer<Int64> Function();
typedef SizeOfRate = int Function();
typedef UpdateRate = void Function();
typedef SetTrustedDaemon = void Function(int);
typedef TrustedDaemon = int Function();

View file

@ -116,6 +116,14 @@ final rescanBlockchainAsyncNative = havenApi
.lookup<NativeFunction<rescan_blockchain>>('rescan_blockchain')
.asFunction<RescanBlockchainAsync>();
final setTrustedDaemonNative = havenApi
.lookup<NativeFunction<set_trusted_daemon>>('set_trusted_daemon')
.asFunction<SetTrustedDaemon>();
final trustedDaemonNative = havenApi
.lookup<NativeFunction<trusted_daemon>>('trusted_daemon')
.asFunction<TrustedDaemon>();
int getSyncingHeight() => getSyncingHeightNative();
bool isNeededToRefresh() => isNeededToRefreshNative() != 0;
@ -351,3 +359,7 @@ Future<bool> isConnected() => compute(_isConnected, 0);
Future<int> getNodeHeight() => compute(_getNodeHeight, 0);
void rescanBlockchainAsync() => rescanBlockchainAsyncNative();
Future setTrustedDaemon(bool trusted) async => setTrustedDaemonNative(_boolToInt(trusted));
Future<bool> trustedDaemon() async => trustedDaemonNative() != 0;

View file

@ -121,6 +121,8 @@ abstract class HavenWalletBase extends WalletBase<MoneroBalance,
password: node.password,
useSSL: node.useSSL ?? false,
isLightWallet: false); // FIXME: hardcoded value
haven_wallet.setTrustedDaemon(node.trusted);
syncStatus = ConnectedSyncStatus();
} catch (e) {
syncStatus = FailedSyncStatus();

View file

@ -783,6 +783,16 @@ extern "C"
return strdup(get_current_wallet()->getSubaddressLabel(accountIndex, addressIndex).c_str());
}
void set_trusted_daemon(bool arg)
{
m_wallet->setTrustedDaemon(arg);
}
bool trusted_daemon()
{
return m_wallet->trustedDaemon();
}
#ifdef __cplusplus
}
#endif

View file

@ -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

View file

@ -126,3 +126,7 @@ typedef rescan_blockchain = Void Function();
typedef get_subaddress_label = Pointer<Utf8> Function(
Int32 accountIndex,
Int32 addressIndex);
typedef set_trusted_daemon = Void Function(Int8 trusted);
typedef trusted_daemon = Int8 Function();

View file

@ -124,3 +124,7 @@ typedef RescanBlockchainAsync = void Function();
typedef GetSubaddressLabel = Pointer<Utf8> Function(
int accountIndex,
int addressIndex);
typedef SetTrustedDaemon = void Function(int);
typedef TrustedDaemon = int Function();

View file

@ -120,6 +120,14 @@ final getSubaddressLabelNative = moneroApi
.lookup<NativeFunction<get_subaddress_label>>('get_subaddress_label')
.asFunction<GetSubaddressLabel>();
final setTrustedDaemonNative = moneroApi
.lookup<NativeFunction<set_trusted_daemon>>('set_trusted_daemon')
.asFunction<SetTrustedDaemon>();
final trustedDaemonNative = moneroApi
.lookup<NativeFunction<trusted_daemon>>('trusted_daemon')
.asFunction<TrustedDaemon>();
int getSyncingHeight() => getSyncingHeightNative();
bool isNeededToRefresh() => isNeededToRefreshNative() != 0;
@ -360,3 +368,7 @@ void rescanBlockchainAsync() => rescanBlockchainAsyncNative();
String getSubaddressLabel(int accountIndex, int addressIndex) {
return convertUTF8ToString(pointer: getSubaddressLabelNative(accountIndex, addressIndex));
}
Future setTrustedDaemon(bool trusted) async => setTrustedDaemonNative(_boolToInt(trusted));
Future<bool> trustedDaemon() async => trustedDaemonNative() != 0;

View file

@ -136,6 +136,8 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
password: node.password,
useSSL: node.isSSL,
isLightWallet: false); // FIXME: hardcoded value
monero_wallet.setTrustedDaemon(node.trusted);
syncStatus = ConnectedSyncStatus();
} catch (e) {
syncStatus = FailedSyncStatus();

View file

@ -174,7 +174,22 @@ class NodeCreateOrEditPage extends BasePage {
caption: S.of(context).use_ssl,
))
],
)),
Padding(
padding: EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Observer(
builder: (_) => StandardCheckbox(
value: nodeCreateOrEditViewModel.trusted,
onChanged: (value) =>
nodeCreateOrEditViewModel.trusted = value,
caption: S.of(context).trusted,
))
],
)),
]
],
)),

View file

@ -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) {

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider}-Fehler",
"use_ssl" : "SSL verwenden",
"trusted" : "Vertrauenswürdige",
"color_theme" : "Farbthema",
"light_theme" : "Hell",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} error",
"use_ssl" : "Use SSL",
"trusted" : "Trusted",
"color_theme" : "Color theme",
"light_theme" : "Light",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} error",
"use_ssl" : "Utilice SSL",
"trusted" : "de confianza",
"color_theme" : "Tema de color",
"light_theme" : "Ligera",

View file

@ -435,6 +435,7 @@
"provider_error" : "Erreur de ${provider}",
"use_ssl" : "Utiliser SSL",
"trusted" : "de confiance",
"color_theme" : "Thème",
"light_theme" : "Clair",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} त्रुटि",
"use_ssl" : "उपयोग SSL",
"trusted" : "भरोसा",
"color_theme" : "रंग विषय",
"light_theme" : "रोशनी",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} greška",
"use_ssl" : "Koristi SSL",
"trusted" : "vjerovao",
"color_theme" : "Shema boja",
"light_theme" : "Svijetla",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} errore",
"use_ssl" : "Usa SSL",
"trusted" : "di fiducia",
"color_theme" : "Colore tema",
"light_theme" : "Bianco",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} エラー",
"use_ssl" : "SSLを使用する",
"trusted" : "信頼できる",
"color_theme" : "カラーテーマ",
"light_theme" : "光",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} 오류",
"use_ssl" : "SSL 사용",
"trusted" : "신뢰할 수 있는",
"color_theme" : "색상 테마",
"light_theme" : "빛",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} fout",
"use_ssl" : "Gebruik SSL",
"trusted" : "vertrouwd",
"color_theme" : "Kleur thema",
"light_theme" : "Licht",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} pomyłka",
"use_ssl" : "Użyj SSL",
"trusted" : "zaufany",
"color_theme" : "Motyw kolorystyczny",
"light_theme" : "Lekki",

View file

@ -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",

View file

@ -437,6 +437,7 @@
"provider_error" : "${provider} ошибка",
"use_ssl" : "Использовать SSL",
"trusted" : "доверенный",
"color_theme" : "Цветовая тема",
"light_theme" : "Светлая",

View file

@ -436,6 +436,7 @@
"provider_error" : "${provider} помилка",
"use_ssl" : "Використати SSL",
"trusted" : "довіряють",
"color_theme" : "Кольорова тема",
"light_theme" : "Світла",

View file

@ -436,6 +436,7 @@
"provider_error" : "${provider} 错误",
"use_ssl" : "使用SSL",
"trusted" : "值得信赖",
"color_theme" : "主题",
"light_theme" : "艳丽",