diff options
| author | Konstantin Ullrich <konstantinullrich12@gmail.com> | 2024-10-07 12:26:48 +0200 |
|---|---|---|
| committer | Konstantin Ullrich <konstantinullrich12@gmail.com> | 2024-10-07 12:26:48 +0200 |
| commit | 04b29d84a2c368c677cf5ec946269203622ca170 (patch) | |
| tree | fd135b090bd5d93c89f71df6934a3a8d2c857563 | |
| parent | 817787df2e40677325bc3c5531bbd0bc6ec94567 (diff) | |
Implement monero queryWalletDevice
| -rw-r--r-- | impls/monero.dart/lib/monero.dart | 18 | ||||
| -rw-r--r-- | impls/monero.dart/lib/src/generated_bindings_monero.g.dart | 14 | ||||
| -rw-r--r-- | monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp | 11 | ||||
| -rw-r--r-- | monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h | 4 |
4 files changed, 35 insertions, 12 deletions
diff --git a/impls/monero.dart/lib/monero.dart b/impls/monero.dart/lib/monero.dart index b30bd3f..8a0eea4 100644 --- a/impls/monero.dart/lib/monero.dart +++ b/impls/monero.dart/lib/monero.dart @@ -3585,6 +3585,24 @@ bool WalletManager_verifyWalletPassword( return s; } +int WalletManager_queryWalletDevice( + WalletManager wm_ptr, { + required String keysFileName, + required String password, + required int kdfRounds, +}) { + debugStart?.call('MONERO_WalletManager_queryWalletDevice'); + lib ??= MoneroC(DynamicLibrary.open(libPath)); + final keysFileName_ = keysFileName.toNativeUtf8().cast<Char>(); + final password_ = password.toNativeUtf8().cast<Char>(); + final s = lib!.MONERO_WalletManager_queryWalletDevice( + wm_ptr, keysFileName_, password_, kdfRounds); + calloc.free(keysFileName_); + calloc.free(password_); + debugEnd?.call('MONERO_WalletManager_queryWalletDevice'); + return s; +} + String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) { debugStart?.call('MONERO_WalletManager_findWallets'); lib ??= MoneroC(DynamicLibrary.open(libPath)); diff --git a/impls/monero.dart/lib/src/generated_bindings_monero.g.dart b/impls/monero.dart/lib/src/generated_bindings_monero.g.dart index 039fbf9..cd2124b 100644 --- a/impls/monero.dart/lib/src/generated_bindings_monero.g.dart +++ b/impls/monero.dart/lib/src/generated_bindings_monero.g.dart @@ -4911,14 +4911,14 @@ class MoneroC { bool Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, bool, int)>(); - bool MONERO_WalletManager_queryWalletDevice( - int device_type, + int MONERO_WalletManager_queryWalletDevice( + ffi.Pointer<ffi.Void> wm_ptr, ffi.Pointer<ffi.Char> keys_file_name, ffi.Pointer<ffi.Char> password, int kdf_rounds, ) { return _MONERO_WalletManager_queryWalletDevice( - device_type, + wm_ptr, keys_file_name, password, kdf_rounds, @@ -4927,15 +4927,15 @@ class MoneroC { late final _MONERO_WalletManager_queryWalletDevicePtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ffi.Int, + ffi.Int Function( + ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, ffi.Uint64)>>('MONERO_WalletManager_queryWalletDevice'); late final _MONERO_WalletManager_queryWalletDevice = _MONERO_WalletManager_queryWalletDevicePtr.asFunction< - bool Function( - int, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int)>(); + int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, + ffi.Pointer<ffi.Char>, int)>(); ffi.Pointer<ffi.Char> MONERO_WalletManager_findWallets( ffi.Pointer<ffi.Void> wm_ptr, diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp index 13f99d5..f577f57 100644 --- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp +++ b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp @@ -1768,10 +1768,15 @@ bool MONERO_WalletManager_verifyWalletPassword(void* wm_ptr, const char* keys_fi Monero::WalletManager *wm = reinterpret_cast<Monero::WalletManager*>(wm_ptr); return wm->verifyWalletPassword(std::string(keys_file_name), std::string(password), no_spend_key, kdf_rounds); } + // virtual bool queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds = 1) const = 0; -// bool MONERO_WalletManager_queryWalletDevice(int device_type, const char* keys_file_name, const char* password, uint64_t kdf_rounds) { -// return Monero::WalletManagerFactory::getWalletManager()->queryWalletDevice(device_type, std::string(keys_file_name), std::string(password), kdf_rounds); -//} +int MONERO_WalletManager_queryWalletDevice(void* wm_ptr, const char* keys_file_name, const char* password, uint64_t kdf_rounds) { + Monero::WalletManager *wm = reinterpret_cast<Monero::WalletManager*>(wm_ptr); + Monero::Wallet::Device device_type; + wm->queryWalletDevice(device_type, std::string(keys_file_name), std::string(password), kdf_rounds); + return device_type; +} + // virtual std::vector<std::string> findWallets(const std::string &path) = 0; const char* MONERO_WalletManager_findWallets(void* wm_ptr, const char* path, const char* separator) { Monero::WalletManager *wm = reinterpret_cast<Monero::WalletManager*>(wm_ptr); diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h index 6e691c8..143da40 100644 --- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h +++ b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h @@ -948,7 +948,7 @@ extern ADDAPI bool MONERO_WalletManager_walletExists(void* wm_ptr, const char* p // virtual bool verifyWalletPassword(const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds = 1) const = 0; extern ADDAPI bool MONERO_WalletManager_verifyWalletPassword(void* wm_ptr, const char* keys_file_name, const char* password, bool no_spend_key, uint64_t kdf_rounds); // virtual bool queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds = 1) const = 0; -extern ADDAPI bool MONERO_WalletManager_queryWalletDevice(int device_type, const char* keys_file_name, const char* password, uint64_t kdf_rounds); +extern ADDAPI int MONERO_WalletManager_queryWalletDevice(void* wm_ptr, const char* keys_file_name, const char* password, uint64_t kdf_rounds); // virtual std::vector<std::string> findWallets(const std::string &path) = 0; extern ADDAPI const char* MONERO_WalletManager_findWallets(void* wm_ptr, const char* path, const char* separator); // virtual std::string errorString() const = 0; @@ -1039,4 +1039,4 @@ extern ADDAPI const char* MONERO_checksum_wallet2_api_c_exp(); #ifdef __cplusplus } -#endif
\ No newline at end of file +#endif |
