summaryrefslogtreecommitdiff
path: root/wownero_libwallet2_api_c/src
diff options
context:
space:
mode:
Diffstat (limited to 'wownero_libwallet2_api_c/src')
-rw-r--r--wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp63
1 files changed, 38 insertions, 25 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 2ba0ef9..6afdfe4 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
@@ -1870,32 +1870,45 @@ uint64_t WOWNERO_cw_WalletListener_height(void* cw_walletListener_ptr) {
// 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 *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);
- return reinterpret_cast<void*>(wallet);
+ try {
+ Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
+
+ // 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);
+ return reinterpret_cast<void*>(wallet);
+ } catch (...) {
+ // fallback code so wallet->status() returns at least something.. eh..
+ Monero::Wallet *wallet = walletManager->recoveryWallet(
+ "/",
+ "",
+ "invalid mnemonic",
+ static_cast<Monero::NetworkType>(networkType),
+ 0,
+ 1,
+ "");
+ return reinterpret_cast<void*>(wallet);
+ }
}
uint64_t WOWNERO_deprecated_14WordSeedHeight(char *seed) {