diff --git a/lib/wallets/crypto_currency/coins/monero.dart b/lib/wallets/crypto_currency/coins/monero.dart index 4d1535179..47ffde707 100644 --- a/lib/wallets/crypto_currency/coins/monero.dart +++ b/lib/wallets/crypto_currency/coins/monero.dart @@ -16,6 +16,10 @@ class Monero extends CryptonoteCurrency { _id = _idMain; _name = "Monero"; _ticker = "XMR"; + case CryptoCurrencyNetwork.stage: + _id = "${_idMain}Stagenet"; + _name = "sMonero"; + _ticker = "sXMR"; default: throw Exception("Unsupported network: $network"); } @@ -55,6 +59,8 @@ class Monero extends CryptonoteCurrency { switch (network) { case CryptoCurrencyNetwork.main: return xmr_wallet_ffi.validateAddress(address, 0); + case CryptoCurrencyNetwork.stage: + return xmr_wallet_ffi.validateAddress(address, 2); // NetworkType_STAGENET. default: throw Exception("Unsupported network: $network"); } @@ -80,6 +86,23 @@ class Monero extends CryptonoteCurrency { isPrimary: isPrimary, ); + case CryptoCurrencyNetwork.stage: + return NodeModel( + host: "http://node3.monerodevs.org", + port: 38089, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: false, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + trusted: true, + torEnabled: true, + clearnetEnabled: true, + isPrimary: isPrimary, + ); + default: throw UnimplementedError(); } @@ -117,6 +140,8 @@ class Monero extends CryptonoteCurrency { switch (network) { case CryptoCurrencyNetwork.main: return Uri.parse("https://xmrchain.net/tx/$txid"); + case CryptoCurrencyNetwork.stage: + return Uri.parse("https://stagenet.xmrchain.net/tx/$txid"); default: throw Exception( "Unsupported network for defaultBlockExplorer(): $network", diff --git a/lib/wallets/crypto_currency/crypto_currency.dart b/lib/wallets/crypto_currency/crypto_currency.dart index 0c2f2cb83..dbb5e9f75 100644 --- a/lib/wallets/crypto_currency/crypto_currency.dart +++ b/lib/wallets/crypto_currency/crypto_currency.dart @@ -34,7 +34,9 @@ enum CryptoCurrencyNetwork { test4; bool get isTestNet => - this == CryptoCurrencyNetwork.test || this == CryptoCurrencyNetwork.test4; + this == CryptoCurrencyNetwork.test || + this == CryptoCurrencyNetwork.test4 || + this == CryptoCurrencyNetwork.stage; } abstract class CryptoCurrency { diff --git a/lib/wallets/wallet/impl/monero_wallet.dart b/lib/wallets/wallet/impl/monero_wallet.dart index 03bbfd5c3..11c57f966 100644 --- a/lib/wallets/wallet/impl/monero_wallet.dart +++ b/lib/wallets/wallet/impl/monero_wallet.dart @@ -72,6 +72,7 @@ class MoneroWallet extends LibMoneroWallet { required String password, required int wordCount, required String seedOffset, + int? networkType, }) async { final lib_monero.MoneroSeedType type; switch (wordCount) { @@ -92,6 +93,7 @@ class MoneroWallet extends LibMoneroWallet { password: password, seedType: type, seedOffset: seedOffset, + networkType: networkType ?? getNetworkType(), ); } @@ -102,12 +104,14 @@ class MoneroWallet extends LibMoneroWallet { required String mnemonic, required String seedOffset, int height = 0, + int? networkType, }) async => await lib_monero.MoneroWallet.restoreWalletFromSeed( path: path, password: password, seed: mnemonic, restoreHeight: height, seedOffset: seedOffset, + networkType: networkType ?? getNetworkType(), ); @override @@ -117,12 +121,14 @@ class MoneroWallet extends LibMoneroWallet { required String address, required String privateViewKey, int height = 0, + int? networkType, }) async => lib_monero.MoneroWallet.createViewOnlyWallet( path: path, password: password, address: address, viewKey: privateViewKey, restoreHeight: height, + networkType: networkType ?? getNetworkType(), ); @override diff --git a/lib/wallets/wallet/impl/wownero_wallet.dart b/lib/wallets/wallet/impl/wownero_wallet.dart index a8d5e1c65..b95334451 100644 --- a/lib/wallets/wallet/impl/wownero_wallet.dart +++ b/lib/wallets/wallet/impl/wownero_wallet.dart @@ -110,6 +110,7 @@ class WowneroWallet extends LibMoneroWallet { required String password, required int wordCount, required String seedOffset, + int? networkType, }) async { final lib_monero.WowneroSeedType type; switch (wordCount) { @@ -131,6 +132,7 @@ class WowneroWallet extends LibMoneroWallet { seedType: type, overrideDeprecated14WordSeedException: true, seedOffset: seedOffset, + networkType: networkType ?? getNetworkType(), ); } @@ -141,12 +143,14 @@ class WowneroWallet extends LibMoneroWallet { required String mnemonic, required String seedOffset, int height = 0, + int? networkType, }) async => await lib_monero.WowneroWallet.restoreWalletFromSeed( path: path, password: password, seed: mnemonic, restoreHeight: height, seedOffset: seedOffset, + networkType: networkType ?? getNetworkType(), ); @override @@ -156,12 +160,14 @@ class WowneroWallet extends LibMoneroWallet { required String address, required String privateViewKey, int height = 0, + int? networkType, }) async => lib_monero.WowneroWallet.createViewOnlyWallet( path: path, password: password, address: address, viewKey: privateViewKey, restoreHeight: height, + networkType: networkType ?? getNetworkType(), ); @override diff --git a/lib/wallets/wallet/intermediate/lib_monero_wallet.dart b/lib/wallets/wallet/intermediate/lib_monero_wallet.dart index d29e97976..66822d8cb 100644 --- a/lib/wallets/wallet/intermediate/lib_monero_wallet.dart +++ b/lib/wallets/wallet/intermediate/lib_monero_wallet.dart @@ -34,6 +34,7 @@ import '../../../utilities/amount/amount.dart'; import '../../../utilities/enums/fee_rate_type_enum.dart'; import '../../../utilities/logger.dart'; import '../../../utilities/stack_file_system.dart'; +import '../../crypto_currency/crypto_currency.dart'; import '../../crypto_currency/intermediate/cryptonote_currency.dart'; import '../../isar/models/wallet_info.dart'; import '../../models/tx_data.dart'; @@ -108,6 +109,20 @@ abstract class LibMoneroWallet final lib_monero_compat.WalletType compatType; lib_monero.Wallet? libMoneroWallet; + /// Maps CryptoCurrencyNetwork to monero_c network type integer. + int getNetworkType() { + switch (cryptoCurrency.network) { + case CryptoCurrencyNetwork.main: + return 0; // NetworkType_MAINNET. + case CryptoCurrencyNetwork.test: + return 1; // NetworkType_TESTNET. + case CryptoCurrencyNetwork.stage: + return 2; // NetworkType_STAGENET. + default: + throw Exception("Unsupported network: ${cryptoCurrency.network}"); + } + } + lib_monero_compat.SyncStatus? get syncStatus => _syncStatus; lib_monero_compat.SyncStatus? _syncStatus; int _syncedCount = 0; @@ -142,6 +157,7 @@ abstract class LibMoneroWallet required String password, required int wordCount, required String seedOffset, + int? networkType, }); Future getRestoredWallet({ @@ -150,6 +166,7 @@ abstract class LibMoneroWallet required String mnemonic, required String seedOffset, int height = 0, + int? networkType, }); Future getRestoredFromViewKeyWallet({ @@ -158,6 +175,7 @@ abstract class LibMoneroWallet required String address, required String privateViewKey, int height = 0, + int? networkType, }); void invalidSeedLengthCheck(int length); @@ -348,6 +366,7 @@ abstract class LibMoneroWallet password: password, wordCount: wordCount, seedOffset: "", // default for non restored wallets for now + networkType: getNetworkType(), ); final height = wallet.getRefreshFromBlockHeight(); @@ -428,6 +447,7 @@ abstract class LibMoneroWallet mnemonic: mnemonic, height: height, seedOffset: seedOffset, + networkType: getNetworkType(), ); if (libMoneroWallet != null) { @@ -1453,6 +1473,7 @@ abstract class LibMoneroWallet address: data.address, privateViewKey: data.privateViewKey, height: height, + networkType: getNetworkType(), ); if (libMoneroWallet != null) { diff --git a/pubspec.lock b/pubspec.lock index 4ef194c2b..a1f02743c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -813,11 +813,11 @@ packages: dependency: "direct main" description: path: "." - ref: f0b1300140d45c13e7722f8f8d20308efeba8449 - resolved-ref: f0b1300140d45c13e7722f8f8d20308efeba8449 + ref: "794ab2d7b88b34d64a89518f9b9f41dcc235aca1" + resolved-ref: "794ab2d7b88b34d64a89518f9b9f41dcc235aca1" url: "https://github.com/cypherstack/electrum_adapter.git" source: git - version: "3.0.0" + version: "3.0.2" emojis: dependency: "direct main" description: @@ -1119,8 +1119,8 @@ packages: dependency: "direct main" description: path: "." - ref: afaad488f5215a9c2c211e5e2f8460237eef60f1 - resolved-ref: afaad488f5215a9c2c211e5e2f8460237eef60f1 + ref: "540d0bc7dc27a97d45d63f412f26818a7f3b8b51" + resolved-ref: "540d0bc7dc27a97d45d63f412f26818a7f3b8b51" url: "https://github.com/cypherstack/fusiondart.git" source: git version: "1.0.0" @@ -1963,11 +1963,10 @@ packages: socks_socket: dependency: transitive description: - path: "." - ref: master - resolved-ref: e6232c53c1595469931ababa878759a067c02e94 - url: "https://github.com/cypherstack/socks_socket.git" - source: git + name: socks_socket + sha256: "53bc7eae40a3aa16ea810b0e9de3bb23ba7beb0b40d09357b89190f2f44374cc" + url: "https://pub.dev" + source: hosted version: "1.1.1" solana: dependency: "direct main" @@ -2200,8 +2199,8 @@ packages: dependency: "direct main" description: path: "." - ref: "752f054b65c500adb9cad578bf183a978e012502" - resolved-ref: "752f054b65c500adb9cad578bf183a978e012502" + ref: "16c9e709e984ec89e8715ce378b038c93ad7add3" + resolved-ref: "16c9e709e984ec89e8715ce378b038c93ad7add3" url: "https://github.com/cypherstack/tor.git" source: git version: "0.0.1" diff --git a/scripts/app_config/configure_stack_duo.sh b/scripts/app_config/configure_stack_duo.sh index 4c871fff3..852742440 100755 --- a/scripts/app_config/configure_stack_duo.sh +++ b/scripts/app_config/configure_stack_duo.sh @@ -62,6 +62,7 @@ final List _supportedCoins = List.unmodifiable([ Bitcoin(CryptoCurrencyNetwork.test4), BitcoinFrost(CryptoCurrencyNetwork.test), BitcoinFrost(CryptoCurrencyNetwork.test4), + Monero(CryptoCurrencyNetwork.stage), ]); final ({String from, String fromFuzzyNet, String to, String toFuzzyNet}) diff --git a/scripts/app_config/configure_stack_wallet.sh b/scripts/app_config/configure_stack_wallet.sh index 5aa170a98..69a630d55 100755 --- a/scripts/app_config/configure_stack_wallet.sh +++ b/scripts/app_config/configure_stack_wallet.sh @@ -87,6 +87,7 @@ final List _supportedCoins = List.unmodifiable([ Peercoin(CryptoCurrencyNetwork.test), Stellar(CryptoCurrencyNetwork.test), Xelis(CryptoCurrencyNetwork.test), + Monero(CryptoCurrencyNetwork.stage), ]); final ({String from, String fromFuzzyNet, String to, String toFuzzyNet})