mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-18 08:45:05 +00:00
save [skip ci]
This commit is contained in:
parent
720914727e
commit
8efe70fb24
6 changed files with 181 additions and 103 deletions
|
@ -87,7 +87,7 @@ class LitecoinTransactionPriority extends BitcoinTransactionPriority {
|
|||
}
|
||||
|
||||
@override
|
||||
String get units => 'Latoshi';
|
||||
String get units => 'Litoshi';
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
|
|
@ -178,6 +178,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
if (resp.mwebUtxosHeight > mwebUtxosHeight) {
|
||||
mwebUtxosHeight = resp.mwebUtxosHeight;
|
||||
await checkMwebUtxosSpent();
|
||||
// update the confirmations for each transaction:
|
||||
for (final transaction in transactionHistory.transactions.values) {
|
||||
if (transaction.isPending) continue;
|
||||
final confirmations = mwebUtxosHeight - transaction.height + 1;
|
||||
|
@ -266,6 +267,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
}
|
||||
if (!(tx.inputAddresses?.contains(utxo.address) ?? false)) {
|
||||
addressRecord.txCount++;
|
||||
print("COUNT UPDATED HERE 2!!!!! ${addressRecord.txCount}");
|
||||
}
|
||||
addressRecord.balance += utxo.value.toInt();
|
||||
addressRecord.setAsUsed();
|
||||
|
@ -283,6 +285,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
final req = UtxosRequest(scanSecret: hex.decode(scanSecret), fromHeight: restoreHeight);
|
||||
bool initDone = false;
|
||||
|
||||
// process old utxos:
|
||||
for (final utxo in mwebUtxosBox.values) {
|
||||
if (utxo.address.isEmpty) {
|
||||
initDone = true;
|
||||
|
@ -305,6 +308,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
}
|
||||
}
|
||||
|
||||
// process new utxos as they come in:
|
||||
await for (Utxo sUtxo in _stub.utxos(req)) {
|
||||
final utxo = MwebUtxo(
|
||||
address: sUtxo.address,
|
||||
|
@ -327,6 +331,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
|
||||
final mwebAddrs = (walletAddresses as LitecoinWalletAddresses).mwebAddrs;
|
||||
|
||||
// don't process utxos with addresses that are not in the mwebAddrs list:
|
||||
if (utxo.address.isNotEmpty && !mwebAddrs.contains(utxo.address)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -362,7 +367,10 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
if (utxo == null) continue;
|
||||
final addressRecord = walletAddresses.allAddresses
|
||||
.firstWhere((addressRecord) => addressRecord.address == utxo.address);
|
||||
if (!inputAddresses.contains(utxo.address)) addressRecord.txCount++;
|
||||
if (!inputAddresses.contains(utxo.address)) {
|
||||
addressRecord.txCount++;
|
||||
print("COUNT UPDATED HERE 3!!!!! ${addressRecord.address} ${addressRecord.txCount} !!!!!!");
|
||||
}
|
||||
addressRecord.balance -= utxo.value.toInt();
|
||||
amount += utxo.value.toInt();
|
||||
inputAddresses.add(utxo.address);
|
||||
|
@ -471,6 +479,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
|
||||
@override
|
||||
Future<ElectrumBalance> fetchBalances() async {
|
||||
print("FETCH BALANCES");
|
||||
final balance = await super.fetchBalances();
|
||||
var confirmed = balance.confirmed;
|
||||
var unconfirmed = balance.unconfirmed;
|
||||
|
@ -523,6 +532,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
continue;
|
||||
}
|
||||
addressRecord.txCount++;
|
||||
print("COUNT UPDATED HERE 0!!!!! ${addressRecord.address} ${addressRecord.txCount} !!!!!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,23 +654,26 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
tx.outputs = resp.outputId;
|
||||
return tx
|
||||
..addListener((transaction) async {
|
||||
final addresses = <String>{};
|
||||
transaction.inputAddresses?.forEach((id) async {
|
||||
final utxo = mwebUtxosBox.get(id);
|
||||
await mwebUtxosBox.delete(id);
|
||||
if (utxo == null) return;
|
||||
final addressRecord = walletAddresses.allAddresses
|
||||
.firstWhere((addressRecord) => addressRecord.address == utxo.address);
|
||||
if (!addresses.contains(utxo.address)) {
|
||||
addressRecord.txCount++;
|
||||
addresses.add(utxo.address);
|
||||
}
|
||||
addressRecord.balance -= utxo.value.toInt();
|
||||
});
|
||||
transaction.inputAddresses?.addAll(addresses);
|
||||
print("BEING ADDED HERE@@@@@@@@@@@@@@@@@@@@@@@3");
|
||||
print("LISTENER CALLED @@@@@@@@@@@@@@@@@@");
|
||||
// final addresses = <String>{};
|
||||
// transaction.inputAddresses?.forEach((id) async {
|
||||
// final utxo = mwebUtxosBox.get(id);
|
||||
// await mwebUtxosBox.delete(id);
|
||||
// if (utxo == null) return;
|
||||
// final addressRecord = walletAddresses.allAddresses
|
||||
// .firstWhere((addressRecord) => addressRecord.address == utxo.address);
|
||||
// if (!addresses.contains(utxo.address)) {
|
||||
// addressRecord.txCount++;
|
||||
// print("COUNT UPDATED HERE 1!!!!! ${addressRecord.address} ${addressRecord.txCount} !!!!!!");
|
||||
// addresses.add(utxo.address);
|
||||
// }
|
||||
// addressRecord.balance -= utxo.value.toInt();
|
||||
// });
|
||||
// transaction.inputAddresses?.addAll(addresses);
|
||||
// print("BEING ADDED HERE@@@@@@@@@@@@@@@@@@@@@@@3");
|
||||
|
||||
transactionHistory.addOne(transaction);
|
||||
// transactionHistory.addOne(transaction);
|
||||
// await transactionHistory.save();
|
||||
await updateUnspent();
|
||||
await updateBalance();
|
||||
});
|
||||
|
|
|
@ -52,7 +52,7 @@ class TransactionsPage extends StatelessWidget {
|
|||
try {
|
||||
final uri = Uri.parse(
|
||||
"https://guides.cakewallet.com/docs/FAQ/why_are_my_funds_not_appearing/");
|
||||
launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} catch (_) {}
|
||||
},
|
||||
title: S.of(context).syncing_wallet_alert_title,
|
||||
|
@ -83,10 +83,6 @@ class TransactionsPage extends StatelessWidget {
|
|||
}
|
||||
|
||||
final transaction = item.transaction;
|
||||
final transactionType = dashboardViewModel.type == WalletType.ethereum &&
|
||||
transaction.evmSignatureName == 'approval'
|
||||
? ' (${transaction.evmSignatureName})'
|
||||
: '';
|
||||
|
||||
return Observer(
|
||||
builder: (_) => TransactionRow(
|
||||
|
@ -101,7 +97,9 @@ class TransactionsPage extends StatelessWidget {
|
|||
: item.formattedFiatAmount,
|
||||
isPending: transaction.isPending,
|
||||
title: item.formattedTitle +
|
||||
item.formattedStatus + ' $transactionType',
|
||||
item.formattedStatus +
|
||||
' ${item.formattedType}',
|
||||
tag: item.tag,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -5,14 +5,16 @@ import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
|
|||
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
|
||||
|
||||
class TransactionRow extends StatelessWidget {
|
||||
TransactionRow(
|
||||
{required this.direction,
|
||||
required this.formattedDate,
|
||||
required this.formattedAmount,
|
||||
required this.formattedFiatAmount,
|
||||
required this.isPending,
|
||||
required this.title,
|
||||
required this.onTap});
|
||||
TransactionRow({
|
||||
required this.direction,
|
||||
required this.formattedDate,
|
||||
required this.formattedAmount,
|
||||
required this.formattedFiatAmount,
|
||||
required this.isPending,
|
||||
required this.title,
|
||||
required this.onTap,
|
||||
required this.tag,
|
||||
});
|
||||
|
||||
final VoidCallback onTap;
|
||||
final TransactionDirection direction;
|
||||
|
@ -21,6 +23,7 @@ class TransactionRow extends StatelessWidget {
|
|||
final String formattedFiatAmount;
|
||||
final bool isPending;
|
||||
final String title;
|
||||
final String tag;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -38,48 +41,69 @@ class TransactionRow extends StatelessWidget {
|
|||
width: 36,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Theme.of(context).extension<TransactionTradeTheme>()!.rowsColor
|
||||
),
|
||||
child: Image.asset(
|
||||
direction == TransactionDirection.incoming
|
||||
? 'assets/images/down_arrow.png'
|
||||
: 'assets/images/up_arrow.png'),
|
||||
color: Theme.of(context).extension<TransactionTradeTheme>()!.rowsColor),
|
||||
child: Image.asset(direction == TransactionDirection.incoming
|
||||
? 'assets/images/down_arrow.png'
|
||||
: 'assets/images/up_arrow.png'),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(title,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor)),
|
||||
Text(formattedAmount,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor))
|
||||
]),
|
||||
SizedBox(height: 5),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(formattedDate,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.dateSectionRowColor)),
|
||||
Text(formattedFiatAmount,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.dateSectionRowColor))
|
||||
])
|
||||
],
|
||||
)
|
||||
)
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
if (tag.isNotEmpty)
|
||||
Container(
|
||||
height: 17,
|
||||
padding: EdgeInsets.only(left: 6, right: 6),
|
||||
margin: EdgeInsets.only(right: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.5)),
|
||||
color: Colors.white),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
tag,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 7,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
formattedAmount,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
SizedBox(height: 5),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[
|
||||
Text(formattedDate,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color:
|
||||
Theme.of(context).extension<CakeTextTheme>()!.dateSectionRowColor)),
|
||||
Text(formattedFiatAmount,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color:
|
||||
Theme.of(context).extension<CakeTextTheme>()!.dateSectionRowColor))
|
||||
])
|
||||
],
|
||||
))
|
||||
],
|
||||
),
|
||||
));
|
||||
|
|
|
@ -103,40 +103,63 @@ class UnspentCoinsListItem extends StatelessWidget {
|
|||
),
|
||||
maxLines: 1,
|
||||
),
|
||||
if (isChange)
|
||||
Container(
|
||||
height: 17,
|
||||
padding: EdgeInsets.only(left: 6, right: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.5)),
|
||||
color: Colors.white),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
S.of(context).unspent_change,
|
||||
style: TextStyle(
|
||||
color: itemColor,
|
||||
fontSize: 7,
|
||||
fontWeight: FontWeight.w600,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
if (isChange)
|
||||
Container(
|
||||
height: 17,
|
||||
padding: EdgeInsets.only(left: 6, right: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.5)),
|
||||
color: Colors.white),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
S.of(context).unspent_change,
|
||||
style: TextStyle(
|
||||
color: itemColor,
|
||||
fontSize: 7,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isSilentPayment)
|
||||
Container(
|
||||
height: 17,
|
||||
padding: EdgeInsets.only(left: 6, right: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.5)),
|
||||
color: Colors.white),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
S.of(context).silent_payments,
|
||||
style: TextStyle(
|
||||
color: itemColor,
|
||||
fontSize: 7,
|
||||
fontWeight: FontWeight.w600,
|
||||
if (address.toLowerCase().contains("mweb"))
|
||||
Container(
|
||||
height: 17,
|
||||
padding: EdgeInsets.only(left: 6, right: 6),
|
||||
margin: EdgeInsets.only(left: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.5)),
|
||||
color: Colors.white),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
"MWEB",
|
||||
style: TextStyle(
|
||||
color: itemColor,
|
||||
fontSize: 7,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isSilentPayment)
|
||||
Container(
|
||||
height: 17,
|
||||
padding: EdgeInsets.only(left: 6, right: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.5)),
|
||||
color: Colors.white),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
S.of(context).silent_payments,
|
||||
style: TextStyle(
|
||||
color: itemColor,
|
||||
fontSize: 7,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -56,7 +56,8 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
}
|
||||
|
||||
String get formattedPendingStatus {
|
||||
if (balanceViewModel.wallet.type == WalletType.monero || balanceViewModel.wallet.type == WalletType.haven) {
|
||||
if (balanceViewModel.wallet.type == WalletType.monero ||
|
||||
balanceViewModel.wallet.type == WalletType.haven) {
|
||||
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
|
||||
return ' (${transaction.confirmations}/10)';
|
||||
}
|
||||
|
@ -79,6 +80,25 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
return transaction.isPending ? S.current.pending : '';
|
||||
}
|
||||
|
||||
String get formattedType {
|
||||
if (transaction.evmSignatureName == 'approval') {
|
||||
return ' (${transaction.evmSignatureName})';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
String get tag {
|
||||
List<String> addresses =
|
||||
(transaction.inputAddresses ?? []) + (transaction.outputAddresses ?? []);
|
||||
for (var address in addresses) {
|
||||
if (address.toLowerCase().contains('mweb')) {
|
||||
return 'MWEB';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
CryptoCurrency? get assetOfTransaction {
|
||||
try {
|
||||
if (balanceViewModel.wallet.type == WalletType.ethereum) {
|
||||
|
|
Loading…
Reference in a new issue