mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 18:21:08 +00:00
241 lines
6.2 KiB
Dart
241 lines
6.2 KiB
Dart
import 'dart:math';
|
|
import 'package:bip39/bip39.dart' as bip39;
|
|
import 'package:decimal/decimal.dart';
|
|
import 'package:stackwallet/models/paymint/fee_object_model.dart';
|
|
import 'package:stackwallet/models/paymint/transactions_model.dart';
|
|
import 'package:stackwallet/models/paymint/utxo_model.dart';
|
|
import 'package:stackwallet/services/price.dart';
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
|
import 'package:string_to_hex/string_to_hex.dart';
|
|
import 'package:web3dart/credentials.dart';
|
|
import 'package:web3dart/web3dart.dart';
|
|
import 'package:http/http.dart';
|
|
|
|
import 'package:stackwallet/hive/db.dart';
|
|
import 'package:stackwallet/utilities/logger.dart';
|
|
import 'package:stackwallet/services/coins/coin_service.dart';
|
|
|
|
const int MINIMUM_CONFIRMATIONS = 1;
|
|
const int DUST_LIMIT = 294;
|
|
|
|
const String GENESIS_HASH_MAINNET =
|
|
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
|
|
const String GENESIS_HASH_TESTNET =
|
|
"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
|
|
|
|
class EthereumWallet extends CoinServiceAPI {
|
|
@override
|
|
set isFavorite(bool markFavorite) {
|
|
DB.instance.put<dynamic>(
|
|
boxName: walletId, key: "isFavorite", value: markFavorite);
|
|
}
|
|
|
|
@override
|
|
bool get isFavorite {
|
|
try {
|
|
return DB.instance.get<dynamic>(boxName: walletId, key: "isFavorite")
|
|
as bool;
|
|
} catch (e, s) {
|
|
Logging.instance.log(
|
|
"isFavorite fetch failed (returning false by default): $e\n$s",
|
|
level: LogLevel.Error);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Coin get coin => _coin;
|
|
|
|
late SecureStorageInterface _secureStore;
|
|
|
|
late PriceAPI _priceAPI;
|
|
|
|
EthereumWallet(
|
|
{required String walletId,
|
|
required String walletName,
|
|
required Coin coin,
|
|
PriceAPI? priceAPI,
|
|
required SecureStorageInterface secureStore}) {
|
|
_walletId = walletId;
|
|
_walletName = walletName;
|
|
_coin = coin;
|
|
|
|
_priceAPI = priceAPI ?? PriceAPI(Client());
|
|
_secureStore = secureStore;
|
|
}
|
|
|
|
@override
|
|
bool shouldAutoSync = false;
|
|
|
|
@override
|
|
String get walletName => _walletName;
|
|
late String _walletName;
|
|
|
|
late Coin _coin;
|
|
|
|
@override
|
|
// TODO: implement allOwnAddresses
|
|
Future<List<String>> get allOwnAddresses => throw UnimplementedError();
|
|
|
|
@override
|
|
// TODO: implement availableBalance
|
|
Future<Decimal> get availableBalance => throw UnimplementedError();
|
|
|
|
@override
|
|
// TODO: implement balanceMinusMaxFee
|
|
Future<Decimal> get balanceMinusMaxFee => throw UnimplementedError();
|
|
|
|
@override
|
|
Future<String> confirmSend({required Map<String, dynamic> txData}) {
|
|
// TODO: implement confirmSend
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
// TODO: implement currentReceivingAddress
|
|
Future<String> get currentReceivingAddress => throw UnimplementedError();
|
|
|
|
@override
|
|
Future<int> estimateFeeFor(int satoshiAmount, int feeRate) {
|
|
// TODO: implement estimateFeeFor
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
Future<void> exit() {
|
|
// TODO: implement exit
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
// TODO: implement fees
|
|
Future<FeeObject> get fees => throw UnimplementedError();
|
|
|
|
@override
|
|
Future<void> fullRescan(
|
|
int maxUnusedAddressGap, int maxNumberOfIndexesToCheck) {
|
|
// TODO: implement fullRescan
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
Future<bool> generateNewAddress() {
|
|
// TODO: implement generateNewAddress
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
// TODO: implement hasCalledExit
|
|
bool get hasCalledExit => throw UnimplementedError();
|
|
|
|
@override
|
|
Future<void> initializeExisting() {
|
|
// TODO: implement initializeExisting
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
Future<void> initializeNew() {
|
|
// TODO: implement initializeNew
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
// TODO: implement isConnected
|
|
bool get isConnected => throw UnimplementedError();
|
|
|
|
@override
|
|
// TODO: implement isRefreshing
|
|
bool get isRefreshing => throw UnimplementedError();
|
|
|
|
@override
|
|
// TODO: implement maxFee
|
|
Future<int> get maxFee => throw UnimplementedError();
|
|
|
|
@override
|
|
// TODO: implement mnemonic
|
|
Future<List<String>> get mnemonic => throw UnimplementedError();
|
|
|
|
@override
|
|
// TODO: implement pendingBalance
|
|
Future<Decimal> get pendingBalance => throw UnimplementedError();
|
|
|
|
@override
|
|
Future<Map<String, dynamic>> prepareSend(
|
|
{required String address,
|
|
required int satoshiAmount,
|
|
Map<String, dynamic>? args}) {
|
|
// TODO: implement prepareSend
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
Future<void> recoverFromMnemonic(
|
|
{required String mnemonic,
|
|
required int maxUnusedAddressGap,
|
|
required int maxNumberOfIndexesToCheck,
|
|
required int height}) {
|
|
// TODO: implement recoverFromMnemonic
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
Future<void> refresh() {
|
|
// TODO: implement refresh
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
Future<String> send(
|
|
{required String toAddress,
|
|
required int amount,
|
|
Map<String, String> args = const {}}) {
|
|
// TODO: implement send
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
Future<bool> testNetworkConnection() {
|
|
// TODO: implement testNetworkConnection
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
// TODO: implement totalBalance
|
|
Future<Decimal> get totalBalance => throw UnimplementedError();
|
|
|
|
@override
|
|
// TODO: implement transactionData
|
|
Future<TransactionData> get transactionData => throw UnimplementedError();
|
|
|
|
@override
|
|
// TODO: implement unspentOutputs
|
|
Future<List<UtxoObject>> get unspentOutputs => throw UnimplementedError();
|
|
|
|
@override
|
|
Future<void> updateNode(bool shouldRefresh) {
|
|
// TODO: implement updateNode
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) {
|
|
// TODO: implement updateSentCachedTxData
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
bool validateAddress(String address) {
|
|
// TODO: implement validateAddress
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
@override
|
|
String get walletId => _walletId;
|
|
late String _walletId;
|
|
|
|
@override
|
|
@override
|
|
set walletName(String newName) => _walletName = newName;
|
|
}
|