diff options
| author | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2024-06-30 11:53:21 +0000 |
|---|---|---|
| committer | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2024-06-30 11:53:21 +0000 |
| commit | 8af6b773b71e3121c7faeadd30763531556103a3 (patch) | |
| tree | 337eccdac9a4f8547d01dcaffd7202c9683866da /wownero_libwallet2_api_c/src/main | |
| parent | eaa7bdb8be3479418445ddb18bf33d453f64afcf (diff) | |
fix: wownero seed giving incorrect
add: pr-comment.yaml
Diffstat (limited to 'wownero_libwallet2_api_c/src/main')
| -rw-r--r-- | wownero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp | 63 |
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) { |
