mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 09:17:35 +00:00
Add Native setTrustedDaemon and trustedDaemon functions and integrate them with their wallets
This commit is contained in:
parent
d748f12e44
commit
cb9f690745
12 changed files with 83 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -137,4 +137,8 @@ typedef get_rate = Pointer<Int64> Function();
|
|||
|
||||
typedef size_of_rate = Int32 Function();
|
||||
|
||||
typedef update_rate = Void Function();
|
||||
typedef update_rate = Void Function();
|
||||
|
||||
typedef set_trusted_daemon = Void Function(Int8 trusted);
|
||||
|
||||
typedef trusted_daemon = Int8 Function();
|
|
@ -135,4 +135,8 @@ typedef GetRate = Pointer<Int64> Function();
|
|||
|
||||
typedef SizeOfRate = int Function();
|
||||
|
||||
typedef UpdateRate = void Function();
|
||||
typedef UpdateRate = void Function();
|
||||
|
||||
typedef SetTrustedDaemon = void Function(int);
|
||||
|
||||
typedef TrustedDaemon = int Function();
|
|
@ -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;
|
||||
|
@ -346,3 +354,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;
|
||||
|
|
|
@ -390,4 +390,8 @@ abstract class HavenWalletBase extends WalletBase<MoneroBalance,
|
|||
print(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void setTrustedDaemon(bool arg) => haven_wallet.setTrustedDaemon(arg);
|
||||
|
||||
Future<bool> trustedDaemon() async => haven_wallet.trustedDaemon();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -125,4 +125,8 @@ typedef rescan_blockchain = Void Function();
|
|||
|
||||
typedef get_subaddress_label = Pointer<Utf8> Function(
|
||||
Int32 accountIndex,
|
||||
Int32 addressIndex);
|
||||
Int32 addressIndex);
|
||||
|
||||
typedef set_trusted_daemon = Void Function(Int8 trusted);
|
||||
|
||||
typedef trusted_daemon = Int8 Function();
|
|
@ -123,4 +123,8 @@ typedef RescanBlockchainAsync = void Function();
|
|||
|
||||
typedef GetSubaddressLabel = Pointer<Utf8> Function(
|
||||
int accountIndex,
|
||||
int addressIndex);
|
||||
int addressIndex);
|
||||
|
||||
typedef SetTrustedDaemon = void Function(int);
|
||||
|
||||
typedef TrustedDaemon = int Function();
|
|
@ -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;
|
||||
|
@ -353,4 +361,8 @@ 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;
|
|
@ -427,4 +427,8 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
|
|||
print(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void setTrustedDaemon(bool arg) => monero_wallet.setTrustedDaemon(arg);
|
||||
|
||||
Future<bool> trustedDaemon() async => monero_wallet.trustedDaemon();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cw_haven/haven_wallet.dart';
|
||||
import 'package:cw_monero/monero_wallet.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
|
@ -78,6 +80,11 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
|||
final node =
|
||||
Node(uri: uri, type: _wallet.type, login: login, password: password,
|
||||
useSSL: useSSL, trusted: trusted);
|
||||
if (_wallet.type == WalletType.monero) {
|
||||
(_wallet as MoneroWallet).setTrustedDaemon(trusted);
|
||||
} else if (_wallet.type == WalletType.haven) {
|
||||
(_wallet as HavenWallet).setTrustedDaemon(trusted);
|
||||
}
|
||||
await _nodeSource.add(node);
|
||||
state = ExecutedSuccessfullyState();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in a new issue