diff options
| author | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2024-04-25 10:07:36 +0200 |
|---|---|---|
| committer | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2024-04-25 10:07:36 +0200 |
| commit | b7eab542df8e5be2cdc2180dba2dfedc66f07a14 (patch) | |
| tree | 37152f7641bdfc65e5ca3d4916d4e290a21fa31a /wownero_libwallet2_api_c | |
| parent | 35aed1976f9927facb1f611fb5a7db5936eaf1b4 (diff) | |
wownero-seed support
Diffstat (limited to 'wownero_libwallet2_api_c')
| -rw-r--r-- | wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp | 40 | ||||
| -rw-r--r-- | wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h | 4 | ||||
| -rw-r--r-- | wownero_libwallet2_api_c/wownero_libwallet2_api_c.exp | 3 |
3 files changed, 45 insertions, 2 deletions
diff --git a/wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp b/wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp index 097c321..fbc2332 100644 --- a/wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp +++ b/wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp @@ -5,7 +5,7 @@ #include <cstring> #include <thread> #include "../../../../wownero/src/wallet/api/wallet2_api.h" - +#include "../../../../external/wownero-seed/include/wownero_seed/wownero_seed.hpp" #ifdef __cplusplus extern "C" @@ -1862,6 +1862,44 @@ uint64_t WOWNERO_cw_WalletListener_height(void* cw_walletListener_ptr) { return listener->cw_isNeedToRefresh(); }; +// 14-word polyseed compat +// wow was really quick to implement polyseed support (aka wownero-seed), which +// results in this maintenance burden we have to go through. +// +// Code is borrowed from +// https://github.com/cypherstack/flutter_libmonero/blob/2c684cedba6c3d9353c7ea748cadb5a246008027/cw_wownero/ios/Classes/wownero_api.cpp#L240 +// this code slightly goes against the way of being simple +void* WOWNERO_deprecated_restore14WordSeed(char *path, char *password, char *language, int32_t networkType, char *error) { + Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); + Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager(); + + // 14 word seeds /* + time_t time = std::time(nullptr); + wownero_seed wow_seed(time, "wownero"); + + std::stringstream seed_stream; + seed_stream << wow_seed; + std::string seed = seed_stream.str(); + + std::stringstream key_stream; + key_stream << wow_seed.key(); + std::string spendKey = key_stream.str(); + + uint64_t restoreHeight = wow_seed.blockheight(); + + Monero::Wallet *wallet = walletManager->createDeterministicWalletFromSpendKey( + std::string(path), + std::string(password), + std::string(language), + static_cast<Monero::NetworkType>(_networkType), + (uint64_t)restoreHeight, + spendKey, + 1); + wallet->setCacheAttribute("cake.seed", seed); + return reinterpret_cast<void*>(wallet); +} + + #ifdef __cplusplus } #endif diff --git a/wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h b/wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h index d95ec69..1482910 100644 --- a/wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h +++ b/wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h @@ -1004,6 +1004,10 @@ extern ADDAPI bool WOWNERO_cw_WalletListener_isNewTransactionExist(void* cw_wall extern ADDAPI void WOWNERO_cw_WalletListener_resetIsNewTransactionExist(void* cw_walletListener_ptr); extern ADDAPI uint64_t WOWNERO_cw_WalletListener_height(void* cw_walletListener_ptr); +// legacy + +extern ADDAPI void* WOWNERO_deprecated_restore14WordSeed(char *path, char *password, char *language, int32_t networkType, char *error); + #ifdef __cplusplus } #endif
\ No newline at end of file diff --git a/wownero_libwallet2_api_c/wownero_libwallet2_api_c.exp b/wownero_libwallet2_api_c/wownero_libwallet2_api_c.exp index a2d362f..3609c93 100644 --- a/wownero_libwallet2_api_c/wownero_libwallet2_api_c.exp +++ b/wownero_libwallet2_api_c/wownero_libwallet2_api_c.exp @@ -269,4 +269,5 @@ _WOWNERO_Wallet_viewOnlyBalance _WOWNERO_Wallet_watchOnly _WOWNERO_WalletManager_createDeterministicWalletFromSpendKey _WOWNERO_PendingTransaction_txKey -_WOWNERO_PendingTransaction_hex
\ No newline at end of file +_WOWNERO_PendingTransaction_hex +_WOWNERO_deprecated_restore14WordSeed
\ No newline at end of file |
