Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/wallets/crypto_currency/coins/monero.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand All @@ -80,6 +86,23 @@ class Monero extends CryptonoteCurrency {
isPrimary: isPrimary,
);

case CryptoCurrencyNetwork.stage:
return NodeModel(
host: "http://node3.monerodevs.org",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been tested working with monero-wallet-cli, but still has issues in SW. not sure that a stackwallet.com-hosted version will be any better

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(that's why this is a draft)

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();
}
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion lib/wallets/crypto_currency/crypto_currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions lib/wallets/wallet/impl/monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -92,6 +93,7 @@ class MoneroWallet extends LibMoneroWallet {
password: password,
seedType: type,
seedOffset: seedOffset,
networkType: networkType ?? getNetworkType(),
);
}

Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions lib/wallets/wallet/impl/wownero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -131,6 +132,7 @@ class WowneroWallet extends LibMoneroWallet {
seedType: type,
overrideDeprecated14WordSeedException: true,
seedOffset: seedOffset,
networkType: networkType ?? getNetworkType(),
);
}

Expand All @@ -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
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions lib/wallets/wallet/intermediate/lib_monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -108,6 +109,20 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
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;
Expand Down Expand Up @@ -142,6 +157,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
required String password,
required int wordCount,
required String seedOffset,
int? networkType,
});

Future<lib_monero.Wallet> getRestoredWallet({
Expand All @@ -150,6 +166,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
required String mnemonic,
required String seedOffset,
int height = 0,
int? networkType,
});

Future<lib_monero.Wallet> getRestoredFromViewKeyWallet({
Expand All @@ -158,6 +175,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
required String address,
required String privateViewKey,
int height = 0,
int? networkType,
});

void invalidSeedLengthCheck(int length);
Expand Down Expand Up @@ -348,6 +366,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
password: password,
wordCount: wordCount,
seedOffset: "", // default for non restored wallets for now
networkType: getNetworkType(),
);

final height = wallet.getRefreshFromBlockHeight();
Expand Down Expand Up @@ -428,6 +447,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
mnemonic: mnemonic,
height: height,
seedOffset: seedOffset,
networkType: getNetworkType(),
);

if (libMoneroWallet != null) {
Expand Down Expand Up @@ -1453,6 +1473,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
address: data.address,
privateViewKey: data.privateViewKey,
height: height,
networkType: getNetworkType(),
);

if (libMoneroWallet != null) {
Expand Down
23 changes: 11 additions & 12 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions scripts/app_config/configure_stack_duo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ final List<CryptoCurrency> _supportedCoins = List.unmodifiable([
Bitcoin(CryptoCurrencyNetwork.test4),
BitcoinFrost(CryptoCurrencyNetwork.test),
BitcoinFrost(CryptoCurrencyNetwork.test4),
Monero(CryptoCurrencyNetwork.stage),
]);

final ({String from, String fromFuzzyNet, String to, String toFuzzyNet})
Expand Down
1 change: 1 addition & 0 deletions scripts/app_config/configure_stack_wallet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ final List<CryptoCurrency> _supportedCoins = List.unmodifiable([
Peercoin(CryptoCurrencyNetwork.test),
Stellar(CryptoCurrencyNetwork.test),
Xelis(CryptoCurrencyNetwork.test),
Monero(CryptoCurrencyNetwork.stage),
]);

final ({String from, String fromFuzzyNet, String to, String toFuzzyNet})
Expand Down
Loading