mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
clean up and optimizations
This commit is contained in:
parent
d270ea38a2
commit
e406374796
1 changed files with 29 additions and 96 deletions
|
@ -1930,12 +1930,13 @@ class FiroWallet extends CoinServiceAPI
|
||||||
if ((await db
|
if ((await db
|
||||||
.getTransactions(walletId)
|
.getTransactions(walletId)
|
||||||
.filter()
|
.filter()
|
||||||
.txidMatches(txid)
|
.txidEqualTo(txid)
|
||||||
.findFirst()) ==
|
.count()) ==
|
||||||
null) {
|
0) {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
" txid not found in address history already ${transaction['tx_hash']}",
|
" txid not found in address history already ${transaction['tx_hash']}",
|
||||||
level: LogLevel.Info);
|
level: LogLevel.Info,
|
||||||
|
);
|
||||||
needsRefresh = true;
|
needsRefresh = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1958,79 +1959,27 @@ class FiroWallet extends CoinServiceAPI
|
||||||
|
|
||||||
final currentChainHeight = await chainHeight;
|
final currentChainHeight = await chainHeight;
|
||||||
|
|
||||||
final txTxns = await db
|
final txCount = await db.getTransactions(walletId).count();
|
||||||
.getTransactions(walletId)
|
|
||||||
.filter()
|
|
||||||
.isLelantusIsNull()
|
|
||||||
.or()
|
|
||||||
.isLelantusEqualTo(false)
|
|
||||||
.findAll();
|
|
||||||
final ltxTxns = await db
|
|
||||||
.getTransactions(walletId)
|
|
||||||
.filter()
|
|
||||||
.isLelantusEqualTo(true)
|
|
||||||
.findAll();
|
|
||||||
|
|
||||||
for (isar_models.Transaction tx in txTxns) {
|
const paginateLimit = 50;
|
||||||
isar_models.Transaction? lTx;
|
|
||||||
try {
|
|
||||||
lTx = ltxTxns.firstWhere((e) => e.txid == tx.txid);
|
|
||||||
} catch (_) {
|
|
||||||
lTx = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) {
|
for (int i = 0; i < txCount; i += paginateLimit) {
|
||||||
if (txTracker.wasNotifiedPending(tx.txid) &&
|
final transactions = await db
|
||||||
!txTracker.wasNotifiedConfirmed(tx.txid)) {
|
.getTransactions(walletId)
|
||||||
|
.offset(i)
|
||||||
|
.limit(paginateLimit)
|
||||||
|
.findAll();
|
||||||
|
for (final tx in transactions) {
|
||||||
|
if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) {
|
||||||
// get all transactions that were notified as pending but not as confirmed
|
// get all transactions that were notified as pending but not as confirmed
|
||||||
unconfirmedTxnsToNotifyConfirmed.add(tx);
|
if (txTracker.wasNotifiedPending(tx.txid) &&
|
||||||
}
|
!txTracker.wasNotifiedConfirmed(tx.txid)) {
|
||||||
if (lTx != null &&
|
unconfirmedTxnsToNotifyConfirmed.add(tx);
|
||||||
(lTx.inputs.isEmpty || lTx.inputs.first.txid.isEmpty) &&
|
|
||||||
lTx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) ==
|
|
||||||
false &&
|
|
||||||
tx.type == isar_models.TransactionType.incoming) {
|
|
||||||
// If this is a received that is past 1 or more confirmations and has not been minted,
|
|
||||||
if (!txTracker.wasNotifiedPending(tx.txid)) {
|
|
||||||
unconfirmedTxnsToNotifyPending.add(tx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!txTracker.wasNotifiedPending(tx.txid)) {
|
|
||||||
// get all transactions that were not notified as pending yet
|
|
||||||
unconfirmedTxnsToNotifyPending.add(tx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (isar_models.Transaction tx in txTxns) {
|
|
||||||
if (!tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) &&
|
|
||||||
tx.inputs.first.txid.isNotEmpty) {
|
|
||||||
// Get all normal txs that are at 0 confirmations
|
|
||||||
unconfirmedTxnsToNotifyPending
|
|
||||||
.removeWhere((e) => e.txid == tx.inputs.first.txid);
|
|
||||||
Logging.instance.log("removed tx: ${tx.txid}", level: LogLevel.Info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (isar_models.Transaction lTX in ltxTxns) {
|
|
||||||
isar_models.Transaction? tx;
|
|
||||||
try {
|
|
||||||
tx = ltxTxns.firstWhere((e) => e.txid == lTX.txid);
|
|
||||||
} catch (_) {
|
|
||||||
tx = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tx == null) {
|
|
||||||
// if this is a ltx transaction that is unconfirmed and not represented in the normal transaction set.
|
|
||||||
if (!lTX.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) {
|
|
||||||
if (!txTracker.wasNotifiedPending(lTX.txid)) {
|
|
||||||
unconfirmedTxnsToNotifyPending.add(lTX);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (txTracker.wasNotifiedPending(lTX.txid) &&
|
// get all transactions that were not notified as pending yet
|
||||||
!txTracker.wasNotifiedConfirmed(lTX.txid)) {
|
if (!txTracker.wasNotifiedPending(tx.txid)) {
|
||||||
unconfirmedTxnsToNotifyConfirmed.add(lTX);
|
unconfirmedTxnsToNotifyPending.add(tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3329,27 +3278,13 @@ class FiroWallet extends CoinServiceAPI
|
||||||
.getAddresses(walletId)
|
.getAddresses(walletId)
|
||||||
.filter()
|
.filter()
|
||||||
.not()
|
.not()
|
||||||
.typeEqualTo(isar_models.AddressType.nonWallet)
|
.group(
|
||||||
.and()
|
(q) => q
|
||||||
.group((q) => q
|
.typeEqualTo(isar_models.AddressType.nonWallet)
|
||||||
.subTypeEqualTo(isar_models.AddressSubType.receiving)
|
.or()
|
||||||
.or()
|
.subTypeEqualTo(isar_models.AddressSubType.nonWallet),
|
||||||
.subTypeEqualTo(isar_models.AddressSubType.change))
|
)
|
||||||
.findAll();
|
.findAll();
|
||||||
// final List<String> allAddresses = [];
|
|
||||||
// final receivingAddresses =
|
|
||||||
// DB.instance.get<dynamic>(boxName: walletId, key: 'receivingAddresses')
|
|
||||||
// as List<dynamic>;
|
|
||||||
// final changeAddresses =
|
|
||||||
// DB.instance.get<dynamic>(boxName: walletId, key: 'changeAddresses')
|
|
||||||
// as List<dynamic>;
|
|
||||||
//
|
|
||||||
// for (var i = 0; i < receivingAddresses.length; i++) {
|
|
||||||
// allAddresses.add(receivingAddresses[i] as String);
|
|
||||||
// }
|
|
||||||
// for (var i = 0; i < changeAddresses.length; i++) {
|
|
||||||
// allAddresses.add(changeAddresses[i] as String);
|
|
||||||
// }
|
|
||||||
return allAddresses;
|
return allAddresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3647,7 +3582,7 @@ class FiroWallet extends CoinServiceAPI
|
||||||
fractionDigits: Coin.firo.decimals,
|
fractionDigits: Coin.firo.decimals,
|
||||||
).toJsonString(),
|
).toJsonString(),
|
||||||
fee: fees,
|
fee: fees,
|
||||||
height: txObject["height"] as int? ?? 0,
|
height: txObject["height"] as int?,
|
||||||
isCancelled: false,
|
isCancelled: false,
|
||||||
isLelantus: false,
|
isLelantus: false,
|
||||||
slateId: null,
|
slateId: null,
|
||||||
|
@ -4569,8 +4504,6 @@ class FiroWallet extends CoinServiceAPI
|
||||||
final response = await cachedElectrumXClient.getUsedCoinSerials(
|
final response = await cachedElectrumXClient.getUsedCoinSerials(
|
||||||
coin: coin,
|
coin: coin,
|
||||||
);
|
);
|
||||||
print("getUsedCoinSerials");
|
|
||||||
print(response);
|
|
||||||
return response;
|
return response;
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log("Exception rethrown in firo_wallet.dart: $e\n$s",
|
Logging.instance.log("Exception rethrown in firo_wallet.dart: $e\n$s",
|
||||||
|
|
Loading…
Reference in a new issue