show sent tx immediately in history

This commit is contained in:
julian 2023-02-02 16:19:14 -06:00
parent afc25e3f06
commit f0a8d65b3e
8 changed files with 184 additions and 280 deletions

View file

@ -1267,46 +1267,31 @@ class BitcoinWallet extends CoinServiceAPI
// transactions locally in a good way // transactions locally in a good way
@override @override
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async { Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
// final priceData = final transaction = isar_models.Transaction(
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); walletId: walletId,
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; txid: txData["txid"] as String,
// final locale = timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; type: isar_models.TransactionType.outgoing,
// final String worthNow = Format.localizedStringAsFixed( subType: isar_models.TransactionSubType.none,
// value: amount: txData["recipientAmt"] as int,
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / fee: txData["fee"] as int,
// Decimal.fromInt(Constants.satsPerCoin(coin))) height: null,
// .toDecimal(scaleOnInfinitePrecision: 2), isCancelled: false,
// decimalPlaces: 2, isLelantus: false,
// locale: locale!); otherData: null,
// slateId: null,
// final tx = models.Transaction( );
// txid: txData["txid"] as String,
// confirmedStatus: false, final address = txData["address"] is String
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, ? await db.getAddress(walletId, txData["address"] as String)
// txType: "Sent", : null;
// amount: txData["recipientAmt"] as int,
// worthNow: worthNow, await db.addNewTransactionData(
// worthAtBlockTimestamp: worthNow, [
// fees: txData["fee"] as int, Tuple4(transaction, [], [], address),
// inputSize: 0, ],
// outputSize: 0, walletId,
// inputs: [], );
// outputs: [],
// address: txData["address"] as String,
// height: -1,
// confirmations: 0,
// );
//
// if (cachedTxData == null) {
// final data = await _fetchTransactionData();
// _transactionData = Future(() => data);
// }
//
// final transactions = cachedTxData!.getAllTransactions();
// transactions[tx.txid] = tx;
// cachedTxData = models.TransactionData.fromMap(transactions);
// _transactionData = Future(() => cachedTxData!);
} }
@override @override

View file

@ -1200,46 +1200,31 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
// transactions locally in a good way // transactions locally in a good way
@override @override
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async { Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
// final priceData = final transaction = isar_models.Transaction(
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); walletId: walletId,
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; txid: txData["txid"] as String,
// final locale = timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; type: isar_models.TransactionType.outgoing,
// final String worthNow = Format.localizedStringAsFixed( subType: isar_models.TransactionSubType.none,
// value: amount: txData["recipientAmt"] as int,
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / fee: txData["fee"] as int,
// Decimal.fromInt(Constants.satsPerCoin(coin))) height: null,
// .toDecimal(scaleOnInfinitePrecision: 2), isCancelled: false,
// decimalPlaces: 2, isLelantus: false,
// locale: locale!); otherData: null,
// slateId: null,
// final tx = models.Transaction( );
// txid: txData["txid"] as String,
// confirmedStatus: false, final address = txData["address"] is String
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, ? await db.getAddress(walletId, txData["address"] as String)
// txType: "Sent", : null;
// amount: txData["recipientAmt"] as int,
// worthNow: worthNow, await db.addNewTransactionData(
// worthAtBlockTimestamp: worthNow, [
// fees: txData["fee"] as int, Tuple4(transaction, [], [], address),
// inputSize: 0, ],
// outputSize: 0, walletId,
// inputs: [], );
// outputs: [],
// address: txData["address"] as String,
// height: -1,
// confirmations: 0,
// );
//
// if (cachedTxData == null) {
// final data = await _fetchTransactionData();
// _transactionData = Future(() => data);
// }
//
// final transactions = cachedTxData!.getAllTransactions();
// transactions[tx.txid] = tx;
// cachedTxData = models.TransactionData.fromMap(transactions);
// _transactionData = Future(() => cachedTxData!);
} }
bool validateCashAddr(String cashAddr) { bool validateCashAddr(String cashAddr) {

View file

@ -1059,46 +1059,31 @@ class DogecoinWallet extends CoinServiceAPI
// transactions locally in a good way // transactions locally in a good way
@override @override
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async { Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
// final priceData = final transaction = isar_models.Transaction(
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); walletId: walletId,
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; txid: txData["txid"] as String,
// final locale = timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; type: isar_models.TransactionType.outgoing,
// final String worthNow = Format.localizedStringAsFixed( subType: isar_models.TransactionSubType.none,
// value: amount: txData["recipientAmt"] as int,
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / fee: txData["fee"] as int,
// Decimal.fromInt(Constants.satsPerCoin(coin))) height: null,
// .toDecimal(scaleOnInfinitePrecision: 2), isCancelled: false,
// decimalPlaces: 2, isLelantus: false,
// locale: locale!); otherData: null,
// slateId: null,
// final tx = models.Transaction( );
// txid: txData["txid"] as String,
// confirmedStatus: false, final address = txData["address"] is String
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, ? await db.getAddress(walletId, txData["address"] as String)
// txType: "Sent", : null;
// amount: txData["recipientAmt"] as int,
// worthNow: worthNow, await db.addNewTransactionData(
// worthAtBlockTimestamp: worthNow, [
// fees: txData["fee"] as int, Tuple4(transaction, [], [], address),
// inputSize: 0, ],
// outputSize: 0, walletId,
// inputs: [], );
// outputs: [],
// address: txData["address"] as String,
// height: -1,
// confirmations: 0,
// );
//
// if (cachedTxData == null) {
// final data = await _fetchTransactionData();
// _transactionData = Future(() => data);
// }
//
// final transactions = cachedTxData!.getAllTransactions();
// transactions[tx.txid] = tx;
// cachedTxData = models.TransactionData.fromMap(transactions);
// _transactionData = Future(() => cachedTxData!);
} }
@override @override

View file

@ -818,44 +818,31 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
// transactions locally in a good way // transactions locally in a good way
@override @override
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async { Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
// final currentPrice = await firoPrice; final transaction = isar_models.Transaction(
// final locale = walletId: walletId,
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; txid: txData["txid"] as String,
// final String worthNow = Format.localizedStringAsFixed( timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
// value: type: isar_models.TransactionType.outgoing,
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / subType: isar_models.TransactionSubType.none,
// Decimal.fromInt(Constants.satsPerCoin(coin))) amount: txData["recipientAmt"] as int,
// .toDecimal(scaleOnInfinitePrecision: 2), fee: txData["fee"] as int,
// decimalPlaces: 2, height: null,
// locale: locale!); isCancelled: false,
// isLelantus: false,
// final tx = models.Transaction( otherData: null,
// txid: txData["txid"] as String, slateId: null,
// confirmedStatus: false, );
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
// txType: "Sent", final address = txData["address"] is String
// amount: txData["recipientAmt"] as int, ? await db.getAddress(walletId, txData["address"] as String)
// worthNow: worthNow, : null;
// worthAtBlockTimestamp: worthNow,
// fees: txData["fee"] as int, await db.addNewTransactionData(
// inputSize: 0, [
// outputSize: 0, Tuple4(transaction, [], [], address),
// inputs: [], ],
// outputs: [], walletId,
// address: txData["address"] as String, );
// height: -1,
// confirmations: 0,
// );
//
// if (cachedTxData == null) {
// final data = await _fetchTransactionData();
// _transactionData = Future(() => data);
// }
//
// final transactions = cachedTxData!.getAllTransactions();
// transactions[tx.txid] = tx;
// cachedTxData = models.TransactionData.fromMap(transactions);
// _transactionData = Future(() => cachedTxData!);
} }
/// Holds the max fee that can be sent /// Holds the max fee that can be sent

View file

@ -1214,46 +1214,31 @@ class LitecoinWallet extends CoinServiceAPI
// transactions locally in a good way // transactions locally in a good way
@override @override
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async { Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
// final priceData = final transaction = isar_models.Transaction(
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); walletId: walletId,
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; txid: txData["txid"] as String,
// final locale = timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; type: isar_models.TransactionType.outgoing,
// final String worthNow = Format.localizedStringAsFixed( subType: isar_models.TransactionSubType.none,
// value: amount: txData["recipientAmt"] as int,
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / fee: txData["fee"] as int,
// Decimal.fromInt(Constants.satsPerCoin(coin))) height: null,
// .toDecimal(scaleOnInfinitePrecision: 2), isCancelled: false,
// decimalPlaces: 2, isLelantus: false,
// locale: locale!); otherData: null,
// slateId: null,
// final tx = models.Transaction( );
// txid: txData["txid"] as String,
// confirmedStatus: false, final address = txData["address"] is String
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, ? await db.getAddress(walletId, txData["address"] as String)
// txType: "Sent", : null;
// amount: txData["recipientAmt"] as int,
// worthNow: worthNow, await db.addNewTransactionData(
// worthAtBlockTimestamp: worthNow, [
// fees: txData["fee"] as int, Tuple4(transaction, [], [], address),
// inputSize: 0, ],
// outputSize: 0, walletId,
// inputs: [], );
// outputs: [],
// address: txData["address"] as String,
// height: -1,
// confirmations: 0,
// );
//
// if (cachedTxData == null) {
// final data = await _refreshTransactions();
// _transactionData = Future(() => data);
// }
//
// final transactions = cachedTxData!.getAllTransactions();
// transactions[tx.txid] = tx;
// cachedTxData = models.TransactionData.fromMap(transactions);
// _transactionData = Future(() => cachedTxData!);
} }
@override @override

View file

@ -110,8 +110,15 @@ class Manager with ChangeNotifier {
try { try {
final txid = await _currentWallet.confirmSend(txData: txData); final txid = await _currentWallet.confirmSend(txData: txData);
try {
txData["txid"] = txid; txData["txid"] = txid;
await _currentWallet.updateSentCachedTxData(txData); await _currentWallet.updateSentCachedTxData(txData);
} catch (e, s) {
// do not rethrow as that would get handled as a send failure further up
// also this is not critical code and transaction should show up on \
// refresh regardless
Logging.instance.log("$e\n$s", level: LogLevel.Warning);
}
notifyListeners(); notifyListeners();
return txid; return txid;

View file

@ -1203,46 +1203,31 @@ class NamecoinWallet extends CoinServiceAPI
// transactions locally in a good way // transactions locally in a good way
@override @override
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async { Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
// final priceData = final transaction = isar_models.Transaction(
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); walletId: walletId,
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; txid: txData["txid"] as String,
// final locale = timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; type: isar_models.TransactionType.outgoing,
// final String worthNow = Format.localizedStringAsFixed( subType: isar_models.TransactionSubType.none,
// value: amount: txData["recipientAmt"] as int,
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / fee: txData["fee"] as int,
// Decimal.fromInt(Constants.satsPerCoin(coin))) height: null,
// .toDecimal(scaleOnInfinitePrecision: 2), isCancelled: false,
// decimalPlaces: 2, isLelantus: false,
// locale: locale!); otherData: null,
// slateId: null,
// final tx = models.Transaction( );
// txid: txData["txid"] as String,
// confirmedStatus: false, final address = txData["address"] is String
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, ? await db.getAddress(walletId, txData["address"] as String)
// txType: "Sent", : null;
// amount: txData["recipientAmt"] as int,
// worthNow: worthNow, await db.addNewTransactionData(
// worthAtBlockTimestamp: worthNow, [
// fees: txData["fee"] as int, Tuple4(transaction, [], [], address),
// inputSize: 0, ],
// outputSize: 0, walletId,
// inputs: [], );
// outputs: [],
// address: txData["address"] as String,
// height: -1,
// confirmations: 0,
// );
//
// if (cachedTxData == null) {
// final data = await _refreshTransactions();
// _transactionData = Future(() => data);
// }
//
// final transactions = cachedTxData!.getAllTransactions();
// transactions[tx.txid] = tx;
// cachedTxData = models.TransactionData.fromMap(transactions);
// _transactionData = Future(() => cachedTxData!);
} }
@override @override

View file

@ -1131,46 +1131,31 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
// transactions locally in a good way // transactions locally in a good way
@override @override
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async { Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
// final priceData = final transaction = isar_models.Transaction(
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); walletId: walletId,
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; txid: txData["txid"] as String,
// final locale = timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; type: isar_models.TransactionType.outgoing,
// final String worthNow = Format.localizedStringAsFixed( subType: isar_models.TransactionSubType.none,
// value: amount: txData["recipientAmt"] as int,
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / fee: txData["fee"] as int,
// Decimal.fromInt(Constants.satsPerCoin(coin))) height: null,
// .toDecimal(scaleOnInfinitePrecision: 2), isCancelled: false,
// decimalPlaces: 2, isLelantus: false,
// locale: locale!); otherData: null,
// slateId: null,
// final tx = models.Transaction( );
// txid: txData["txid"] as String,
// confirmedStatus: false, final address = txData["address"] is String
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, ? await db.getAddress(walletId, txData["address"] as String)
// txType: "Sent", : null;
// amount: txData["recipientAmt"] as int,
// worthNow: worthNow, await db.addNewTransactionData(
// worthAtBlockTimestamp: worthNow, [
// fees: txData["fee"] as int, Tuple4(transaction, [], [], address),
// inputSize: 0, ],
// outputSize: 0, walletId,
// inputs: [], );
// outputs: [],
// address: txData["address"] as String,
// height: -1,
// confirmations: 0,
// );
//
// if (cachedTxData == null) {
// final data = await _refreshTransactions();
// _transactionData = Future(() => data);
// } else {
// final transactions = cachedTxData!.getAllTransactions();
// transactions[tx.txid] = tx;
// cachedTxData = models.TransactionData.fromMap(transactions);
// _transactionData = Future(() => cachedTxData!);
// }
} }
@override @override