mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
refactor wallet constructors and add wownero shell
This commit is contained in:
parent
fa4fa60532
commit
e6556de97e
15 changed files with 102 additions and 37 deletions
|
@ -3,8 +3,8 @@ import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/bip39_hd_currency.dart';
|
|
||||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart';
|
||||||
|
|
||||||
class Bitcoin extends Bip39HDCurrency {
|
class Bitcoin extends Bip39HDCurrency {
|
||||||
Bitcoin(super.network) {
|
Bitcoin(super.network) {
|
||||||
|
|
|
@ -8,8 +8,8 @@ import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/bip39_hd_currency.dart';
|
|
||||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart';
|
||||||
|
|
||||||
class Bitcoincash extends Bip39HDCurrency {
|
class Bitcoincash extends Bip39HDCurrency {
|
||||||
Bitcoincash(super.network) {
|
Bitcoincash(super.network) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:flutter_libepiccash/lib.dart' as epic;
|
import 'package:flutter_libepiccash/lib.dart' as epic;
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/bip39_currency.dart';
|
|
||||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart';
|
||||||
|
|
||||||
class Epiccash extends Bip39Currency {
|
class Epiccash extends Bip39Currency {
|
||||||
Epiccash(super.network) {
|
Epiccash(super.network) {
|
||||||
|
|
19
lib/wallets/crypto_currency/coins/wownero.dart
Normal file
19
lib/wallets/crypto_currency/coins/wownero.dart
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart';
|
||||||
|
|
||||||
|
class Wownero extends CryptonoteCurrency {
|
||||||
|
Wownero(super.network);
|
||||||
|
|
||||||
|
@override
|
||||||
|
// TODO: implement genesisHash
|
||||||
|
String get genesisHash => throw UnimplementedError();
|
||||||
|
|
||||||
|
@override
|
||||||
|
// TODO: implement minConfirms
|
||||||
|
int get minConfirms => throw UnimplementedError();
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool validateAddress(String address) {
|
||||||
|
// TODO: implement validateAddress
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/bip39_currency.dart';
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart';
|
||||||
|
|
||||||
abstract class Bip39HDCurrency extends Bip39Currency {
|
abstract class Bip39HDCurrency extends Bip39Currency {
|
||||||
Bip39HDCurrency(super.network);
|
Bip39HDCurrency(super.network);
|
|
@ -0,0 +1,5 @@
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||||
|
|
||||||
|
abstract class CryptonoteCurrency extends CryptoCurrency {
|
||||||
|
CryptonoteCurrency(super.network);
|
||||||
|
}
|
|
@ -15,12 +15,9 @@ class BitcoinWallet extends Bip39HDWallet with ElectrumXMixin {
|
||||||
int get isarTransactionVersion => 2;
|
int get isarTransactionVersion => 2;
|
||||||
|
|
||||||
BitcoinWallet(
|
BitcoinWallet(
|
||||||
super.cryptoCurrency, {
|
Bitcoin cryptoCurrency, {
|
||||||
required NodeService nodeService,
|
required NodeService nodeService,
|
||||||
}) {
|
}) : super(cryptoCurrency) {
|
||||||
// TODO: [prio=low] ensure this hack isn't needed
|
|
||||||
assert(cryptoCurrency is Bitcoin);
|
|
||||||
|
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,9 @@ class BitcoincashWallet extends Bip39HDWallet with ElectrumXMixin {
|
||||||
int get isarTransactionVersion => 2;
|
int get isarTransactionVersion => 2;
|
||||||
|
|
||||||
BitcoincashWallet(
|
BitcoincashWallet(
|
||||||
super.cryptoCurrency, {
|
Bitcoincash cryptoCurrency, {
|
||||||
required NodeService nodeService,
|
required NodeService nodeService,
|
||||||
}) {
|
}) : super(cryptoCurrency) {
|
||||||
// TODO: [prio=low] ensure this hack isn't needed
|
|
||||||
assert(cryptoCurrency is Bitcoincash);
|
|
||||||
|
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,17 @@ import 'package:stackwallet/services/node_service.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
|
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart';
|
||||||
import 'package:stackwallet/wallets/models/tx_data.dart';
|
import 'package:stackwallet/wallets/models/tx_data.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart';
|
import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart';
|
||||||
|
|
||||||
class EpiccashWallet extends Bip39Wallet {
|
class EpiccashWallet extends Bip39Wallet {
|
||||||
final NodeService nodeService;
|
late final NodeService nodeService;
|
||||||
|
|
||||||
EpiccashWallet(super.cryptoCurrency, {required this.nodeService});
|
EpiccashWallet(
|
||||||
|
Epiccash cryptoCurrency, {
|
||||||
|
required this.nodeService,
|
||||||
|
}) : super(cryptoCurrency);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<TxData> confirmSend({required TxData txData}) {
|
Future<TxData> confirmSend({required TxData txData}) {
|
||||||
|
|
54
lib/wallets/wallet/impl/wownero_wallet.dart
Normal file
54
lib/wallets/wallet/impl/wownero_wallet.dart
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import 'package:stackwallet/models/paymint/fee_object_model.dart';
|
||||||
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart';
|
||||||
|
import 'package:stackwallet/wallets/wallet/intermediate/cryptonote_wallet.dart';
|
||||||
|
|
||||||
|
class WowneroWallet extends CryptonoteWallet {
|
||||||
|
WowneroWallet(Wownero wownero) : super(wownero);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Amount> estimateFeeFor(Amount amount, int feeRate) {
|
||||||
|
// TODO: implement estimateFeeFor
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
// TODO: implement fees
|
||||||
|
Future<FeeObject> get fees => throw UnimplementedError();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> pingCheck() {
|
||||||
|
// TODO: implement pingCheck
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateBalance() {
|
||||||
|
// TODO: implement updateBalance
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateChainHeight() {
|
||||||
|
// TODO: implement updateChainHeight
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateNode() {
|
||||||
|
// TODO: implement updateNode
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateTransactions() {
|
||||||
|
// TODO: implement updateTransactions
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateUTXOs() {
|
||||||
|
// TODO: implement updateUTXOs
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,12 +5,12 @@ import 'package:stackwallet/models/balance.dart';
|
||||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/bip39_hd_currency.dart';
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart';
|
||||||
import 'package:stackwallet/wallets/models/tx_data.dart';
|
import 'package:stackwallet/wallets/models/tx_data.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart';
|
import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart';
|
||||||
|
|
||||||
abstract class Bip39HDWallet<T extends Bip39HDCurrency> extends Bip39Wallet<T> {
|
abstract class Bip39HDWallet<T extends Bip39HDCurrency> extends Bip39Wallet<T> {
|
||||||
Bip39HDWallet(super.cryptoCurrency);
|
Bip39HDWallet(T cryptoCurrency) : super(cryptoCurrency);
|
||||||
|
|
||||||
/// Generates a receiving address of [info.mainAddressType]. If none
|
/// Generates a receiving address of [info.mainAddressType]. If none
|
||||||
/// are in the current wallet db it will generate at index 0, otherwise the
|
/// are in the current wallet db it will generate at index 0, otherwise the
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:stackwallet/wallets/crypto_currency/bip39_currency.dart';
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/mixins/mnemonic_based_wallet.dart';
|
import 'package:stackwallet/wallets/wallet/mixins/mnemonic_based_wallet.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
||||||
|
|
||||||
abstract class Bip39Wallet<T extends Bip39Currency> extends Wallet<T>
|
abstract class Bip39Wallet<T extends Bip39Currency> extends Wallet<T>
|
||||||
with MnemonicBasedWallet {
|
with MnemonicBasedWallet {
|
||||||
Bip39Wallet(super.cryptoCurrency);
|
Bip39Wallet(T currency) : super(currency);
|
||||||
|
|
||||||
// ========== Private ========================================================
|
// ========== Private ========================================================
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,11 @@
|
||||||
import 'package:stackwallet/exceptions/sw_exception.dart';
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart';
|
||||||
import 'package:stackwallet/wallets/models/tx_data.dart';
|
import 'package:stackwallet/wallets/models/tx_data.dart';
|
||||||
|
import 'package:stackwallet/wallets/wallet/mixins/mnemonic_based_wallet.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
||||||
|
|
||||||
abstract class CryptonoteWallet extends Wallet {
|
abstract class CryptonoteWallet<T extends CryptonoteCurrency> extends Wallet<T>
|
||||||
CryptonoteWallet(super.cryptoCurrency);
|
with MnemonicBasedWallet<T> {
|
||||||
|
CryptonoteWallet(T currency) : super(currency);
|
||||||
Future<String> getMnemonic() async {
|
|
||||||
final mnemonic = await secureStorageInterface.read(
|
|
||||||
key: Wallet.mnemonicKey(walletId: info.walletId),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (mnemonic == null) {
|
|
||||||
throw SWException("mnemonic has not been set");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mnemonic;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== Overrides ======================================================
|
// ========== Overrides ======================================================
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import 'package:stackwallet/exceptions/sw_exception.dart';
|
import 'package:stackwallet/exceptions/sw_exception.dart';
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
||||||
|
|
||||||
import '../../crypto_currency/crypto_currency.dart';
|
|
||||||
|
|
||||||
mixin MnemonicBasedWallet<T extends CryptoCurrency> on Wallet<T> {
|
mixin MnemonicBasedWallet<T extends CryptoCurrency> on Wallet<T> {
|
||||||
Future<String> getMnemonic() async {
|
Future<String> getMnemonic() async {
|
||||||
final mnemonic = await secureStorageInterface.read(
|
final mnemonic = await secureStorageInterface.read(
|
||||||
|
|
Loading…
Reference in a new issue