2024-01-18 23:47:06 +00:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
import 'package:stackwallet/models/node_model.dart';
|
2024-01-19 21:42:38 +00:00
|
|
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
2024-01-18 23:47:06 +00:00
|
|
|
import 'package:stackwallet/utilities/default_nodes.dart';
|
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
|
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
|
|
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart';
|
2024-04-25 17:44:59 +00:00
|
|
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart';
|
2024-01-18 23:47:06 +00:00
|
|
|
|
|
|
|
class BitcoinFrost extends FrostCurrency {
|
|
|
|
BitcoinFrost(super.network) {
|
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
2024-04-25 21:54:40 +00:00
|
|
|
coin = Coin.bitcoinFrost;
|
2024-01-18 23:47:06 +00:00
|
|
|
case CryptoCurrencyNetwork.test:
|
2024-04-25 21:54:40 +00:00
|
|
|
coin = Coin.bitcoinFrostTestNet;
|
2024-01-18 23:47:06 +00:00
|
|
|
default:
|
|
|
|
throw Exception("Unsupported network: $network");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get minConfirms => 1;
|
|
|
|
|
2024-04-16 22:42:51 +00:00
|
|
|
@override
|
|
|
|
bool get torSupport => true;
|
|
|
|
|
2024-01-18 23:47:06 +00:00
|
|
|
@override
|
|
|
|
NodeModel get defaultNode {
|
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
|
|
|
return DefaultNodes.bitcoin;
|
|
|
|
|
|
|
|
case CryptoCurrencyNetwork.test:
|
|
|
|
return DefaultNodes.bitcoinTestnet;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw UnimplementedError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get genesisHash {
|
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
|
|
|
return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
|
|
|
|
case CryptoCurrencyNetwork.test:
|
|
|
|
return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
|
|
|
|
default:
|
|
|
|
throw Exception("Unsupported network: $network");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-19 21:42:38 +00:00
|
|
|
@override
|
|
|
|
Amount get dustLimit => Amount(
|
|
|
|
rawValue: BigInt.from(294),
|
|
|
|
fractionDigits: fractionDigits,
|
|
|
|
);
|
|
|
|
|
2024-01-18 23:47:06 +00:00
|
|
|
@override
|
|
|
|
String pubKeyToScriptHash({required Uint8List pubKey}) {
|
|
|
|
try {
|
|
|
|
return Bip39HDCurrency.convertBytesToScriptHash(pubKey);
|
|
|
|
} catch (e) {
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool validateAddress(String address) {
|
|
|
|
// TODO: implement validateAddress for frost addresses
|
|
|
|
return true;
|
|
|
|
}
|
2024-04-17 18:04:10 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(Object other) {
|
|
|
|
return other is BitcoinFrost && other.network == network;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode => Object.hash(BitcoinFrost, network);
|
2024-01-18 23:47:06 +00:00
|
|
|
}
|