mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
wownero mostly ready for testing
This commit is contained in:
parent
e6556de97e
commit
daa9ccd099
8 changed files with 1024 additions and 1404 deletions
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as btc;
|
||||
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'
|
||||
as bch;
|
||||
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'
|
||||
|
@ -29,7 +28,6 @@ import 'package:stackwallet/services/coins/particl/particl_wallet.dart'
|
|||
as particl;
|
||||
import 'package:stackwallet/services/coins/stellar/stellar_wallet.dart' as xlm;
|
||||
import 'package:stackwallet/services/coins/tezos/tezos_wallet.dart' as tezos;
|
||||
import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart' as wow;
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
||||
enum Coin {
|
||||
|
@ -379,7 +377,7 @@ extension CoinExt on Coin {
|
|||
switch (this) {
|
||||
case Coin.bitcoin:
|
||||
case Coin.bitcoinTestNet:
|
||||
return btc.MINIMUM_CONFIRMATIONS;
|
||||
throw UnimplementedError("moved");
|
||||
|
||||
case Coin.litecoin:
|
||||
case Coin.litecoinTestNet:
|
||||
|
@ -420,7 +418,7 @@ extension CoinExt on Coin {
|
|||
return tezos.MINIMUM_CONFIRMATIONS;
|
||||
|
||||
case Coin.wownero:
|
||||
return wow.MINIMUM_CONFIRMATIONS;
|
||||
throw UnimplementedError("moved");
|
||||
|
||||
case Coin.namecoin:
|
||||
return nmc.MINIMUM_CONFIRMATIONS;
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
import 'package:cw_wownero/api/wallet.dart' as wownero_wallet;
|
||||
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();
|
||||
int get minConfirms => 15;
|
||||
|
||||
@override
|
||||
bool validateAddress(String address) {
|
||||
// TODO: implement validateAddress
|
||||
throw UnimplementedError();
|
||||
return wownero_wallet.validateAddress(address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,4 +2,9 @@ import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
|||
|
||||
abstract class CryptonoteCurrency extends CryptoCurrency {
|
||||
CryptonoteCurrency(super.network);
|
||||
|
||||
@override
|
||||
String get genesisHash {
|
||||
return "not used in stack's cryptonote coins";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cw_wownero/pending_wownero_transaction.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart';
|
||||
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
|
@ -38,6 +39,9 @@ class TxData {
|
|||
final BigInt? chainId;
|
||||
final BigInt? feeInWei;
|
||||
|
||||
// wownero specific
|
||||
final PendingWowneroTransaction? pendingWowneroTransaction;
|
||||
|
||||
TxData({
|
||||
this.feeRateType,
|
||||
this.feeRateAmount,
|
||||
|
@ -59,6 +63,7 @@ class TxData {
|
|||
this.nonce,
|
||||
this.chainId,
|
||||
this.feeInWei,
|
||||
this.pendingWowneroTransaction,
|
||||
});
|
||||
|
||||
Amount? get amount => recipients != null && recipients!.isNotEmpty
|
||||
|
@ -92,6 +97,7 @@ class TxData {
|
|||
int? nonce,
|
||||
BigInt? chainId,
|
||||
BigInt? feeInWei,
|
||||
PendingWowneroTransaction? pendingWowneroTransaction,
|
||||
}) {
|
||||
return TxData(
|
||||
feeRateType: feeRateType ?? this.feeRateType,
|
||||
|
@ -114,6 +120,8 @@ class TxData {
|
|||
nonce: nonce ?? this.nonce,
|
||||
chainId: chainId ?? this.chainId,
|
||||
feeInWei: feeInWei ?? this.feeInWei,
|
||||
pendingWowneroTransaction:
|
||||
pendingWowneroTransaction ?? this.pendingWowneroTransaction,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -139,5 +147,6 @@ class TxData {
|
|||
'nonce: $nonce, '
|
||||
'chainId: $chainId, '
|
||||
'feeInWei: $feeInWei, '
|
||||
'pendingWowneroTransaction: $pendingWowneroTransaction, '
|
||||
'}';
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,4 +26,9 @@ abstract class CryptonoteWallet<T extends CryptonoteCurrency> extends Wallet<T>
|
|||
// TODO: implement recover
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateUTXOs() async {
|
||||
// do nothing for now
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:meta/meta.dart';
|
|||
import 'package:mutex/mutex.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||
import 'package:stackwallet/models/node_model.dart';
|
||||
import 'package:stackwallet/models/paymint/fee_object_model.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart';
|
||||
|
@ -13,6 +14,7 @@ import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
|||
import 'package:stackwallet/services/node_service.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/default_nodes.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
@ -20,13 +22,16 @@ import 'package:stackwallet/utilities/prefs.dart';
|
|||
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
import 'package:stackwallet/wallets/models/tx_data.dart';
|
||||
import 'package:stackwallet/wallets/wallet/impl/bitcoin_wallet.dart';
|
||||
import 'package:stackwallet/wallets/wallet/impl/bitcoincash_wallet.dart';
|
||||
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
|
||||
import 'package:stackwallet/wallets/wallet/impl/wownero_wallet.dart';
|
||||
import 'package:stackwallet/wallets/wallet/mixins/electrumx_mixin.dart';
|
||||
import 'package:stackwallet/wallets/wallet/mixins/multi_address.dart';
|
||||
|
||||
abstract class Wallet<T extends CryptoCurrency> {
|
||||
// default to Transaction class. For TransactionV2 set to 2
|
||||
|
@ -41,6 +46,7 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
|
||||
late final MainDB mainDB;
|
||||
late final SecureStorageInterface secureStorageInterface;
|
||||
late final NodeService nodeService;
|
||||
late final Prefs prefs;
|
||||
|
||||
final refreshMutex = Mutex();
|
||||
|
@ -75,6 +81,11 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
|
||||
bool _isConnected = false;
|
||||
|
||||
void xmrAndWowSyncSpecificFunctionThatShouldBeGottenRidOfInTheFuture(
|
||||
bool flag) {
|
||||
_isConnected = flag;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// ========== Wallet Info Convenience Getters ================================
|
||||
|
||||
|
@ -207,10 +218,10 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
}) async {
|
||||
final Wallet wallet = _loadWallet(
|
||||
walletInfo: walletInfo,
|
||||
nodeService: nodeService,
|
||||
);
|
||||
|
||||
wallet.prefs = prefs;
|
||||
wallet.nodeService = nodeService;
|
||||
|
||||
if (wallet is ElectrumXMixin) {
|
||||
// initialize electrumx instance
|
||||
|
@ -226,37 +237,36 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
|
||||
static Wallet _loadWallet({
|
||||
required WalletInfo walletInfo,
|
||||
required NodeService nodeService,
|
||||
}) {
|
||||
switch (walletInfo.coin) {
|
||||
case Coin.bitcoin:
|
||||
return BitcoinWallet(
|
||||
Bitcoin(CryptoCurrencyNetwork.main),
|
||||
nodeService: nodeService,
|
||||
);
|
||||
|
||||
case Coin.bitcoinTestNet:
|
||||
return BitcoinWallet(
|
||||
Bitcoin(CryptoCurrencyNetwork.test),
|
||||
nodeService: nodeService,
|
||||
);
|
||||
|
||||
case Coin.bitcoincash:
|
||||
return BitcoincashWallet(
|
||||
Bitcoincash(CryptoCurrencyNetwork.main),
|
||||
nodeService: nodeService,
|
||||
);
|
||||
|
||||
case Coin.bitcoincashTestnet:
|
||||
return BitcoincashWallet(
|
||||
Bitcoincash(CryptoCurrencyNetwork.test),
|
||||
nodeService: nodeService,
|
||||
);
|
||||
|
||||
case Coin.epicCash:
|
||||
return EpiccashWallet(
|
||||
Epiccash(CryptoCurrencyNetwork.main),
|
||||
nodeService: nodeService,
|
||||
);
|
||||
|
||||
case Coin.wownero:
|
||||
return WowneroWallet(
|
||||
Wownero(CryptoCurrencyNetwork.main),
|
||||
);
|
||||
|
||||
default:
|
||||
|
@ -348,6 +358,13 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
|
||||
//===========================================
|
||||
|
||||
NodeModel getCurrentNode() {
|
||||
final node = nodeService.getPrimaryNodeFor(coin: cryptoCurrency.coin) ??
|
||||
DefaultNodes.getNodeFor(cryptoCurrency.coin);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
// Should fire events
|
||||
Future<void> refresh() async {
|
||||
// Awaiting this lock could be dangerous.
|
||||
|
@ -388,13 +405,16 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
// final feeObj = _getFees();
|
||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.60, walletId));
|
||||
|
||||
await utxosRefreshFuture;
|
||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.70, walletId));
|
||||
// _feeObject = Future(() => feeObj);
|
||||
|
||||
await utxosRefreshFuture;
|
||||
await fetchFuture;
|
||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.80, walletId));
|
||||
|
||||
await fetchFuture;
|
||||
if (this is MultiAddress) {
|
||||
await (this as MultiAddress).checkReceivingAddressForTransactions();
|
||||
}
|
||||
// await getAllTxsToWatch();
|
||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.90, walletId));
|
||||
|
||||
|
@ -458,6 +478,7 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
newAddress: address!.value,
|
||||
isar: mainDB.isar,
|
||||
);
|
||||
|
||||
// TODO: make sure subclasses override this if they require some set up
|
||||
// especially xmr/wow/epiccash
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue