diff options
Diffstat (limited to 'wownero_libwallet2_api_c/src/main/cpp')
| -rw-r--r-- | wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp | 36 | ||||
| -rw-r--r-- | wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h | 5 |
2 files changed, 37 insertions, 4 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 fbc2332..e5035ef 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 @@ -1869,7 +1869,40 @@ uint64_t WOWNERO_cw_WalletListener_height(void* cw_walletListener_ptr) { // 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) { +void* WOWNERO_deprecated_restore14WordSeed(char *path, char *password, char *seed, int32_t networkType) { + Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); + Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager(); + + // 14 word seeds /* + wownero_seed wow_seed(seed, "wownero"); + + std::stringstream seed_stream; + seed_stream << wow_seed; + std::string seed_str = 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), + "English", + static_cast<Monero::NetworkType>(_networkType), + (uint64_t)restoreHeight, + spendKey, + 1); + wallet->setCacheAttribute("cake.seed", seed_str); +} + +uint64_t WOWNERO_deprecated_14WordSeedHeight(char *seed) { + wownero_seed wow_seed(seed, "wownero"); + return wow_seed.blockheight(); +} + +void* WOWNERO_deprecated_create14WordSeed(char *path, char *password, char *language, int32_t networkType) { Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType); Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager(); @@ -1899,7 +1932,6 @@ void* WOWNERO_deprecated_restore14WordSeed(char *path, char *password, char *lan 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 1482910..b028105 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 @@ -1006,8 +1006,9 @@ extern ADDAPI uint64_t WOWNERO_cw_WalletListener_height(void* cw_walletListener_ // legacy -extern ADDAPI void* WOWNERO_deprecated_restore14WordSeed(char *path, char *password, char *language, int32_t networkType, char *error); - +extern ADDAPI void* WOWNERO_deprecated_restore14WordSeed(char *path, char *password, char *language, int32_t networkType); +extern ADDAPI void* WOWNERO_deprecated_create14WordSeed(char *path, char *password, char *language, int32_t networkType); +extern ADDAPI uint64_t WOWNERO_deprecated_14WordSeedHeight(char *seed); #ifdef __cplusplus } #endif
\ No newline at end of file |
