2024-04-24 19:37:22 +00:00
|
|
|
import 'package:monero/monero.dart' as monero;
|
2024-01-08 19:40:07 +00:00
|
|
|
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../../../models/node_model.dart';
|
|
|
|
import '../../../utilities/default_nodes.dart';
|
|
|
|
import '../../../utilities/enums/derive_path_type_enum.dart';
|
|
|
|
import '../crypto_currency.dart';
|
|
|
|
import '../intermediate/cryptonote_currency.dart';
|
2024-01-08 19:40:07 +00:00
|
|
|
|
|
|
|
class Monero extends CryptonoteCurrency {
|
|
|
|
Monero(super.network) {
|
2024-05-15 21:20:45 +00:00
|
|
|
_idMain = "monero";
|
|
|
|
_uriScheme = "monero";
|
2024-01-08 19:40:07 +00:00
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
2024-05-15 21:20:45 +00:00
|
|
|
_id = _idMain;
|
|
|
|
_name = "Monero";
|
|
|
|
_ticker = "XMR";
|
2024-01-08 19:40:07 +00:00
|
|
|
default:
|
|
|
|
throw Exception("Unsupported network: $network");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-15 21:20:45 +00:00
|
|
|
late final String _id;
|
|
|
|
@override
|
|
|
|
String get identifier => _id;
|
|
|
|
|
|
|
|
late final String _idMain;
|
|
|
|
@override
|
|
|
|
String get mainNetId => _idMain;
|
|
|
|
|
|
|
|
late final String _name;
|
|
|
|
@override
|
|
|
|
String get prettyName => _name;
|
|
|
|
|
|
|
|
late final String _uriScheme;
|
|
|
|
@override
|
|
|
|
String get uriScheme => _uriScheme;
|
|
|
|
|
|
|
|
late final String _ticker;
|
|
|
|
@override
|
|
|
|
String get ticker => _ticker;
|
|
|
|
|
2024-01-08 19:40:07 +00:00
|
|
|
@override
|
|
|
|
int get minConfirms => 10;
|
|
|
|
|
2024-06-12 21:20:53 +00:00
|
|
|
@override
|
|
|
|
bool get torSupport => true;
|
|
|
|
|
2024-01-08 19:40:07 +00:00
|
|
|
@override
|
|
|
|
bool validateAddress(String address) {
|
2024-05-27 19:40:42 +00:00
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
|
|
|
return monero.Wallet_addressValid(address, 0);
|
|
|
|
default:
|
|
|
|
throw Exception("Unsupported network: $network");
|
|
|
|
}
|
2024-01-08 19:40:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
NodeModel get defaultNode {
|
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
|
|
|
return NodeModel(
|
|
|
|
host: "https://monero.stackwallet.com",
|
|
|
|
port: 18081,
|
|
|
|
name: DefaultNodes.defaultName,
|
2024-05-15 21:20:45 +00:00
|
|
|
id: DefaultNodes.buildId(this),
|
2024-01-08 19:40:07 +00:00
|
|
|
useSSL: true,
|
|
|
|
enabled: true,
|
2024-05-15 21:20:45 +00:00
|
|
|
coinName: identifier,
|
2024-01-08 19:40:07 +00:00
|
|
|
isFailover: true,
|
|
|
|
isDown: false,
|
|
|
|
trusted: true,
|
|
|
|
);
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw UnimplementedError();
|
|
|
|
}
|
|
|
|
}
|
2024-04-17 18:04:10 +00:00
|
|
|
|
|
|
|
@override
|
2024-05-15 21:20:45 +00:00
|
|
|
int get defaultSeedPhraseLength => 25;
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get fractionDigits => 12;
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool get hasBuySupport => false;
|
2024-04-17 18:04:10 +00:00
|
|
|
|
|
|
|
@override
|
2024-05-15 21:20:45 +00:00
|
|
|
bool get hasMnemonicPassphraseSupport => false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<int> get possibleMnemonicLengths => [defaultSeedPhraseLength];
|
|
|
|
|
|
|
|
@override
|
|
|
|
BigInt get satsPerCoin => BigInt.from(1000000000000);
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get targetBlockTimeSeconds => 120;
|
|
|
|
|
|
|
|
@override
|
|
|
|
DerivePathType get primaryDerivePathType => throw UnsupportedError(
|
|
|
|
"$runtimeType does not use bitcoin style derivation paths",
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Uri defaultBlockExplorer(String txid) {
|
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
|
|
|
return Uri.parse("https://xmrchain.net/tx/$txid");
|
|
|
|
default:
|
|
|
|
throw Exception(
|
|
|
|
"Unsupported network for defaultBlockExplorer(): $network",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-01-08 19:40:07 +00:00
|
|
|
}
|