@@ -37,6 +37,7 @@ import '../../../utilities/stack_file_system.dart';
3737import '../../../wl_gen/interfaces/cs_monero_interface.dart' ;
3838import '../../../wl_gen/interfaces/cs_salvium_interface.dart'
3939 show WrappedWallet;
40+ import '../../crypto_currency/crypto_currency.dart' ;
4041import '../../crypto_currency/intermediate/cryptonote_currency.dart' ;
4142import '../../isar/models/wallet_info.dart' ;
4243import '../../models/tx_data.dart' ;
@@ -110,6 +111,20 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
110111
111112 final lib_monero_compat.WalletType compatType;
112113
114+ /// Maps CryptoCurrencyNetwork to monero_c network type integer.
115+ int getNetworkType () {
116+ switch (cryptoCurrency.network) {
117+ case CryptoCurrencyNetwork .main:
118+ return 0 ;
119+ case CryptoCurrencyNetwork .test:
120+ return 1 ;
121+ case CryptoCurrencyNetwork .stage:
122+ return 2 ;
123+ default :
124+ throw Exception ("Unsupported network: ${cryptoCurrency .network }" );
125+ }
126+ }
127+
113128 lib_monero_compat.SyncStatus ? get syncStatus => _syncStatus;
114129 lib_monero_compat.SyncStatus ? _syncStatus;
115130 int _syncedCount = 0 ;
@@ -138,20 +153,23 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
138153 Future <WrappedWallet > loadWallet ({
139154 required String path,
140155 required String password,
156+ int network = 0 ,
141157 });
142158
143159 Future <WrappedWallet > getCreatedWallet ({
144160 required String path,
145161 required String password,
146162 required int wordCount,
147163 required String seedOffset,
164+ int network = 0 ,
148165 });
149166
150167 Future <WrappedWallet > getRestoredWallet ({
151168 required String path,
152169 required String password,
153170 required String mnemonic,
154171 required String seedOffset,
172+ int network = 0 ,
155173 int height = 0 ,
156174 });
157175
@@ -160,6 +178,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
160178 required String password,
161179 required String address,
162180 required String privateViewKey,
181+ int network = 0 ,
163182 int height = 0 ,
164183 });
165184
@@ -209,7 +228,11 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
209228 throw Exception ("Password not found $e , $s " );
210229 }
211230
212- wallet = await loadWallet (path: path, password: password);
231+ wallet = await loadWallet (
232+ path: path,
233+ password: password,
234+ network: getNetworkType (),
235+ );
213236
214237 _setListener ();
215238
@@ -329,7 +352,11 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
329352 } catch (e, s) {
330353 throw Exception ("Password not found $e , $s " );
331354 }
332- wallet = await loadWallet (path: path, password: password);
355+ wallet = await loadWallet (
356+ path: path,
357+ password: password,
358+ network: getNetworkType (),
359+ );
333360 return (
334361 await csMonero.getAddress (wallet! ),
335362 await csMonero.getPrivateViewKey (wallet! ),
@@ -355,6 +382,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
355382 password: password,
356383 wordCount: wordCount,
357384 seedOffset: "" , // default for non restored wallets for now
385+ network: getNetworkType (),
358386 );
359387
360388 await info.updateRestoreHeight (
@@ -438,6 +466,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
438466 mnemonic: mnemonic,
439467 height: height,
440468 seedOffset: seedOffset,
469+ network: getNetworkType (),
441470 );
442471
443472 if (this .wallet != null ) {
@@ -1575,6 +1604,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
15751604 address: data.address,
15761605 privateViewKey: data.privateViewKey,
15771606 height: height,
1607+ network: getNetworkType (),
15781608 );
15791609
15801610 if (this .wallet == null ) {
0 commit comments