mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +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'
|
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'
|
||||||
as bch;
|
as bch;
|
||||||
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'
|
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'
|
||||||
|
@ -29,7 +28,6 @@ import 'package:stackwallet/services/coins/particl/particl_wallet.dart'
|
||||||
as particl;
|
as particl;
|
||||||
import 'package:stackwallet/services/coins/stellar/stellar_wallet.dart' as xlm;
|
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/tezos/tezos_wallet.dart' as tezos;
|
||||||
import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart' as wow;
|
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
|
||||||
enum Coin {
|
enum Coin {
|
||||||
|
@ -379,7 +377,7 @@ extension CoinExt on Coin {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case Coin.bitcoin:
|
case Coin.bitcoin:
|
||||||
case Coin.bitcoinTestNet:
|
case Coin.bitcoinTestNet:
|
||||||
return btc.MINIMUM_CONFIRMATIONS;
|
throw UnimplementedError("moved");
|
||||||
|
|
||||||
case Coin.litecoin:
|
case Coin.litecoin:
|
||||||
case Coin.litecoinTestNet:
|
case Coin.litecoinTestNet:
|
||||||
|
@ -420,7 +418,7 @@ extension CoinExt on Coin {
|
||||||
return tezos.MINIMUM_CONFIRMATIONS;
|
return tezos.MINIMUM_CONFIRMATIONS;
|
||||||
|
|
||||||
case Coin.wownero:
|
case Coin.wownero:
|
||||||
return wow.MINIMUM_CONFIRMATIONS;
|
throw UnimplementedError("moved");
|
||||||
|
|
||||||
case Coin.namecoin:
|
case Coin.namecoin:
|
||||||
return nmc.MINIMUM_CONFIRMATIONS;
|
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';
|
import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart';
|
||||||
|
|
||||||
class Wownero extends CryptonoteCurrency {
|
class Wownero extends CryptonoteCurrency {
|
||||||
Wownero(super.network);
|
Wownero(super.network);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// TODO: implement genesisHash
|
int get minConfirms => 15;
|
||||||
String get genesisHash => throw UnimplementedError();
|
|
||||||
|
|
||||||
@override
|
|
||||||
// TODO: implement minConfirms
|
|
||||||
int get minConfirms => throw UnimplementedError();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool validateAddress(String address) {
|
bool validateAddress(String address) {
|
||||||
// TODO: implement validateAddress
|
return wownero_wallet.validateAddress(address);
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,9 @@ import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||||
|
|
||||||
abstract class CryptonoteCurrency extends CryptoCurrency {
|
abstract class CryptonoteCurrency extends CryptoCurrency {
|
||||||
CryptonoteCurrency(super.network);
|
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/isar/models/blockchain_data/utxo.dart';
|
||||||
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
|
@ -38,6 +39,9 @@ class TxData {
|
||||||
final BigInt? chainId;
|
final BigInt? chainId;
|
||||||
final BigInt? feeInWei;
|
final BigInt? feeInWei;
|
||||||
|
|
||||||
|
// wownero specific
|
||||||
|
final PendingWowneroTransaction? pendingWowneroTransaction;
|
||||||
|
|
||||||
TxData({
|
TxData({
|
||||||
this.feeRateType,
|
this.feeRateType,
|
||||||
this.feeRateAmount,
|
this.feeRateAmount,
|
||||||
|
@ -59,6 +63,7 @@ class TxData {
|
||||||
this.nonce,
|
this.nonce,
|
||||||
this.chainId,
|
this.chainId,
|
||||||
this.feeInWei,
|
this.feeInWei,
|
||||||
|
this.pendingWowneroTransaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
Amount? get amount => recipients != null && recipients!.isNotEmpty
|
Amount? get amount => recipients != null && recipients!.isNotEmpty
|
||||||
|
@ -92,6 +97,7 @@ class TxData {
|
||||||
int? nonce,
|
int? nonce,
|
||||||
BigInt? chainId,
|
BigInt? chainId,
|
||||||
BigInt? feeInWei,
|
BigInt? feeInWei,
|
||||||
|
PendingWowneroTransaction? pendingWowneroTransaction,
|
||||||
}) {
|
}) {
|
||||||
return TxData(
|
return TxData(
|
||||||
feeRateType: feeRateType ?? this.feeRateType,
|
feeRateType: feeRateType ?? this.feeRateType,
|
||||||
|
@ -114,6 +120,8 @@ class TxData {
|
||||||
nonce: nonce ?? this.nonce,
|
nonce: nonce ?? this.nonce,
|
||||||
chainId: chainId ?? this.chainId,
|
chainId: chainId ?? this.chainId,
|
||||||
feeInWei: feeInWei ?? this.feeInWei,
|
feeInWei: feeInWei ?? this.feeInWei,
|
||||||
|
pendingWowneroTransaction:
|
||||||
|
pendingWowneroTransaction ?? this.pendingWowneroTransaction,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,5 +147,6 @@ class TxData {
|
||||||
'nonce: $nonce, '
|
'nonce: $nonce, '
|
||||||
'chainId: $chainId, '
|
'chainId: $chainId, '
|
||||||
'feeInWei: $feeInWei, '
|
'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
|
// TODO: implement recover
|
||||||
throw UnimplementedError();
|
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:mutex/mutex.dart';
|
||||||
import 'package:stackwallet/db/isar/main_db.dart';
|
import 'package:stackwallet/db/isar/main_db.dart';
|
||||||
import 'package:stackwallet/models/isar/models/blockchain_data/address.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/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/node_connection_status_changed_event.dart';
|
||||||
import 'package:stackwallet/services/event_bus/events/global/refresh_percent_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/services/node_service.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/constants.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/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||||
import 'package:stackwallet/utilities/logger.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/bitcoin.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.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/epiccash.dart';
|
||||||
|
import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart';
|
||||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||||
import 'package:stackwallet/wallets/models/tx_data.dart';
|
import 'package:stackwallet/wallets/models/tx_data.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/impl/bitcoin_wallet.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/bitcoincash_wallet.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/impl/epiccash_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/electrumx_mixin.dart';
|
||||||
|
import 'package:stackwallet/wallets/wallet/mixins/multi_address.dart';
|
||||||
|
|
||||||
abstract class Wallet<T extends CryptoCurrency> {
|
abstract class Wallet<T extends CryptoCurrency> {
|
||||||
// default to Transaction class. For TransactionV2 set to 2
|
// 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 MainDB mainDB;
|
||||||
late final SecureStorageInterface secureStorageInterface;
|
late final SecureStorageInterface secureStorageInterface;
|
||||||
|
late final NodeService nodeService;
|
||||||
late final Prefs prefs;
|
late final Prefs prefs;
|
||||||
|
|
||||||
final refreshMutex = Mutex();
|
final refreshMutex = Mutex();
|
||||||
|
@ -75,6 +81,11 @@ abstract class Wallet<T extends CryptoCurrency> {
|
||||||
|
|
||||||
bool _isConnected = false;
|
bool _isConnected = false;
|
||||||
|
|
||||||
|
void xmrAndWowSyncSpecificFunctionThatShouldBeGottenRidOfInTheFuture(
|
||||||
|
bool flag) {
|
||||||
|
_isConnected = flag;
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
// ========== Wallet Info Convenience Getters ================================
|
// ========== Wallet Info Convenience Getters ================================
|
||||||
|
|
||||||
|
@ -207,10 +218,10 @@ abstract class Wallet<T extends CryptoCurrency> {
|
||||||
}) async {
|
}) async {
|
||||||
final Wallet wallet = _loadWallet(
|
final Wallet wallet = _loadWallet(
|
||||||
walletInfo: walletInfo,
|
walletInfo: walletInfo,
|
||||||
nodeService: nodeService,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
wallet.prefs = prefs;
|
wallet.prefs = prefs;
|
||||||
|
wallet.nodeService = nodeService;
|
||||||
|
|
||||||
if (wallet is ElectrumXMixin) {
|
if (wallet is ElectrumXMixin) {
|
||||||
// initialize electrumx instance
|
// initialize electrumx instance
|
||||||
|
@ -226,37 +237,36 @@ abstract class Wallet<T extends CryptoCurrency> {
|
||||||
|
|
||||||
static Wallet _loadWallet({
|
static Wallet _loadWallet({
|
||||||
required WalletInfo walletInfo,
|
required WalletInfo walletInfo,
|
||||||
required NodeService nodeService,
|
|
||||||
}) {
|
}) {
|
||||||
switch (walletInfo.coin) {
|
switch (walletInfo.coin) {
|
||||||
case Coin.bitcoin:
|
case Coin.bitcoin:
|
||||||
return BitcoinWallet(
|
return BitcoinWallet(
|
||||||
Bitcoin(CryptoCurrencyNetwork.main),
|
Bitcoin(CryptoCurrencyNetwork.main),
|
||||||
nodeService: nodeService,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
case Coin.bitcoinTestNet:
|
case Coin.bitcoinTestNet:
|
||||||
return BitcoinWallet(
|
return BitcoinWallet(
|
||||||
Bitcoin(CryptoCurrencyNetwork.test),
|
Bitcoin(CryptoCurrencyNetwork.test),
|
||||||
nodeService: nodeService,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
case Coin.bitcoincash:
|
case Coin.bitcoincash:
|
||||||
return BitcoincashWallet(
|
return BitcoincashWallet(
|
||||||
Bitcoincash(CryptoCurrencyNetwork.main),
|
Bitcoincash(CryptoCurrencyNetwork.main),
|
||||||
nodeService: nodeService,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
case Coin.bitcoincashTestnet:
|
case Coin.bitcoincashTestnet:
|
||||||
return BitcoincashWallet(
|
return BitcoincashWallet(
|
||||||
Bitcoincash(CryptoCurrencyNetwork.test),
|
Bitcoincash(CryptoCurrencyNetwork.test),
|
||||||
nodeService: nodeService,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
case Coin.epicCash:
|
case Coin.epicCash:
|
||||||
return EpiccashWallet(
|
return EpiccashWallet(
|
||||||
Epiccash(CryptoCurrencyNetwork.main),
|
Epiccash(CryptoCurrencyNetwork.main),
|
||||||
nodeService: nodeService,
|
);
|
||||||
|
|
||||||
|
case Coin.wownero:
|
||||||
|
return WowneroWallet(
|
||||||
|
Wownero(CryptoCurrencyNetwork.main),
|
||||||
);
|
);
|
||||||
|
|
||||||
default:
|
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
|
// Should fire events
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
// Awaiting this lock could be dangerous.
|
// Awaiting this lock could be dangerous.
|
||||||
|
@ -388,13 +405,16 @@ abstract class Wallet<T extends CryptoCurrency> {
|
||||||
// final feeObj = _getFees();
|
// final feeObj = _getFees();
|
||||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.60, walletId));
|
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.60, walletId));
|
||||||
|
|
||||||
|
await utxosRefreshFuture;
|
||||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.70, walletId));
|
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.70, walletId));
|
||||||
// _feeObject = Future(() => feeObj);
|
// _feeObject = Future(() => feeObj);
|
||||||
|
|
||||||
await utxosRefreshFuture;
|
await fetchFuture;
|
||||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.80, walletId));
|
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.80, walletId));
|
||||||
|
|
||||||
await fetchFuture;
|
if (this is MultiAddress) {
|
||||||
|
await (this as MultiAddress).checkReceivingAddressForTransactions();
|
||||||
|
}
|
||||||
// await getAllTxsToWatch();
|
// await getAllTxsToWatch();
|
||||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.90, walletId));
|
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.90, walletId));
|
||||||
|
|
||||||
|
@ -458,6 +478,7 @@ abstract class Wallet<T extends CryptoCurrency> {
|
||||||
newAddress: address!.value,
|
newAddress: address!.value,
|
||||||
isar: mainDB.isar,
|
isar: mainDB.isar,
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: make sure subclasses override this if they require some set up
|
// TODO: make sure subclasses override this if they require some set up
|
||||||
// especially xmr/wow/epiccash
|
// especially xmr/wow/epiccash
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue