mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
show sent tx immediately in history
This commit is contained in:
parent
afc25e3f06
commit
f0a8d65b3e
8 changed files with 184 additions and 280 deletions
|
@ -1267,46 +1267,31 @@ class BitcoinWallet extends CoinServiceAPI
|
|||
// transactions locally in a good way
|
||||
@override
|
||||
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
|
||||
// final priceData =
|
||||
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||
// final locale =
|
||||
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||
// final String worthNow = Format.localizedStringAsFixed(
|
||||
// value:
|
||||
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||
// Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||
// .toDecimal(scaleOnInfinitePrecision: 2),
|
||||
// decimalPlaces: 2,
|
||||
// locale: locale!);
|
||||
//
|
||||
// final tx = models.Transaction(
|
||||
// txid: txData["txid"] as String,
|
||||
// confirmedStatus: false,
|
||||
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
// txType: "Sent",
|
||||
// amount: txData["recipientAmt"] as int,
|
||||
// worthNow: worthNow,
|
||||
// worthAtBlockTimestamp: worthNow,
|
||||
// fees: txData["fee"] as int,
|
||||
// inputSize: 0,
|
||||
// outputSize: 0,
|
||||
// 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!);
|
||||
final transaction = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
type: isar_models.TransactionType.outgoing,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: txData["recipientAmt"] as int,
|
||||
fee: txData["fee"] as int,
|
||||
height: null,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
? await db.getAddress(walletId, txData["address"] as String)
|
||||
: null;
|
||||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1200,46 +1200,31 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
// transactions locally in a good way
|
||||
@override
|
||||
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
|
||||
// final priceData =
|
||||
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||
// final locale =
|
||||
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||
// final String worthNow = Format.localizedStringAsFixed(
|
||||
// value:
|
||||
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||
// Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||
// .toDecimal(scaleOnInfinitePrecision: 2),
|
||||
// decimalPlaces: 2,
|
||||
// locale: locale!);
|
||||
//
|
||||
// final tx = models.Transaction(
|
||||
// txid: txData["txid"] as String,
|
||||
// confirmedStatus: false,
|
||||
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
// txType: "Sent",
|
||||
// amount: txData["recipientAmt"] as int,
|
||||
// worthNow: worthNow,
|
||||
// worthAtBlockTimestamp: worthNow,
|
||||
// fees: txData["fee"] as int,
|
||||
// inputSize: 0,
|
||||
// outputSize: 0,
|
||||
// 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!);
|
||||
final transaction = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
type: isar_models.TransactionType.outgoing,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: txData["recipientAmt"] as int,
|
||||
fee: txData["fee"] as int,
|
||||
height: null,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
? await db.getAddress(walletId, txData["address"] as String)
|
||||
: null;
|
||||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
bool validateCashAddr(String cashAddr) {
|
||||
|
|
|
@ -1059,46 +1059,31 @@ class DogecoinWallet extends CoinServiceAPI
|
|||
// transactions locally in a good way
|
||||
@override
|
||||
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
|
||||
// final priceData =
|
||||
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||
// final locale =
|
||||
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||
// final String worthNow = Format.localizedStringAsFixed(
|
||||
// value:
|
||||
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||
// Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||
// .toDecimal(scaleOnInfinitePrecision: 2),
|
||||
// decimalPlaces: 2,
|
||||
// locale: locale!);
|
||||
//
|
||||
// final tx = models.Transaction(
|
||||
// txid: txData["txid"] as String,
|
||||
// confirmedStatus: false,
|
||||
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
// txType: "Sent",
|
||||
// amount: txData["recipientAmt"] as int,
|
||||
// worthNow: worthNow,
|
||||
// worthAtBlockTimestamp: worthNow,
|
||||
// fees: txData["fee"] as int,
|
||||
// inputSize: 0,
|
||||
// outputSize: 0,
|
||||
// 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!);
|
||||
final transaction = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
type: isar_models.TransactionType.outgoing,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: txData["recipientAmt"] as int,
|
||||
fee: txData["fee"] as int,
|
||||
height: null,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
? await db.getAddress(walletId, txData["address"] as String)
|
||||
: null;
|
||||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -818,44 +818,31 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
// transactions locally in a good way
|
||||
@override
|
||||
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
|
||||
// final currentPrice = await firoPrice;
|
||||
// final locale =
|
||||
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||
// final String worthNow = Format.localizedStringAsFixed(
|
||||
// value:
|
||||
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||
// Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||
// .toDecimal(scaleOnInfinitePrecision: 2),
|
||||
// decimalPlaces: 2,
|
||||
// locale: locale!);
|
||||
//
|
||||
// final tx = models.Transaction(
|
||||
// txid: txData["txid"] as String,
|
||||
// confirmedStatus: false,
|
||||
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
// txType: "Sent",
|
||||
// amount: txData["recipientAmt"] as int,
|
||||
// worthNow: worthNow,
|
||||
// worthAtBlockTimestamp: worthNow,
|
||||
// fees: txData["fee"] as int,
|
||||
// inputSize: 0,
|
||||
// outputSize: 0,
|
||||
// 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!);
|
||||
final transaction = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
type: isar_models.TransactionType.outgoing,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: txData["recipientAmt"] as int,
|
||||
fee: txData["fee"] as int,
|
||||
height: null,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
? await db.getAddress(walletId, txData["address"] as String)
|
||||
: null;
|
||||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
/// Holds the max fee that can be sent
|
||||
|
|
|
@ -1214,46 +1214,31 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
// transactions locally in a good way
|
||||
@override
|
||||
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
|
||||
// final priceData =
|
||||
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||
// final locale =
|
||||
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||
// final String worthNow = Format.localizedStringAsFixed(
|
||||
// value:
|
||||
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||
// Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||
// .toDecimal(scaleOnInfinitePrecision: 2),
|
||||
// decimalPlaces: 2,
|
||||
// locale: locale!);
|
||||
//
|
||||
// final tx = models.Transaction(
|
||||
// txid: txData["txid"] as String,
|
||||
// confirmedStatus: false,
|
||||
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
// txType: "Sent",
|
||||
// amount: txData["recipientAmt"] as int,
|
||||
// worthNow: worthNow,
|
||||
// worthAtBlockTimestamp: worthNow,
|
||||
// fees: txData["fee"] as int,
|
||||
// inputSize: 0,
|
||||
// outputSize: 0,
|
||||
// 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!);
|
||||
final transaction = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
type: isar_models.TransactionType.outgoing,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: txData["recipientAmt"] as int,
|
||||
fee: txData["fee"] as int,
|
||||
height: null,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
? await db.getAddress(walletId, txData["address"] as String)
|
||||
: null;
|
||||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -110,8 +110,15 @@ class Manager with ChangeNotifier {
|
|||
try {
|
||||
final txid = await _currentWallet.confirmSend(txData: txData);
|
||||
|
||||
try {
|
||||
txData["txid"] = txid;
|
||||
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();
|
||||
return txid;
|
||||
|
|
|
@ -1203,46 +1203,31 @@ class NamecoinWallet extends CoinServiceAPI
|
|||
// transactions locally in a good way
|
||||
@override
|
||||
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
|
||||
// final priceData =
|
||||
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||
// final locale =
|
||||
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||
// final String worthNow = Format.localizedStringAsFixed(
|
||||
// value:
|
||||
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||
// Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||
// .toDecimal(scaleOnInfinitePrecision: 2),
|
||||
// decimalPlaces: 2,
|
||||
// locale: locale!);
|
||||
//
|
||||
// final tx = models.Transaction(
|
||||
// txid: txData["txid"] as String,
|
||||
// confirmedStatus: false,
|
||||
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
// txType: "Sent",
|
||||
// amount: txData["recipientAmt"] as int,
|
||||
// worthNow: worthNow,
|
||||
// worthAtBlockTimestamp: worthNow,
|
||||
// fees: txData["fee"] as int,
|
||||
// inputSize: 0,
|
||||
// outputSize: 0,
|
||||
// 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!);
|
||||
final transaction = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
type: isar_models.TransactionType.outgoing,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: txData["recipientAmt"] as int,
|
||||
fee: txData["fee"] as int,
|
||||
height: null,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
? await db.getAddress(walletId, txData["address"] as String)
|
||||
: null;
|
||||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1131,46 +1131,31 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
// transactions locally in a good way
|
||||
@override
|
||||
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
|
||||
// final priceData =
|
||||
// await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||
// Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||
// final locale =
|
||||
// Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||
// final String worthNow = Format.localizedStringAsFixed(
|
||||
// value:
|
||||
// ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||
// Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||
// .toDecimal(scaleOnInfinitePrecision: 2),
|
||||
// decimalPlaces: 2,
|
||||
// locale: locale!);
|
||||
//
|
||||
// final tx = models.Transaction(
|
||||
// txid: txData["txid"] as String,
|
||||
// confirmedStatus: false,
|
||||
// timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
// txType: "Sent",
|
||||
// amount: txData["recipientAmt"] as int,
|
||||
// worthNow: worthNow,
|
||||
// worthAtBlockTimestamp: worthNow,
|
||||
// fees: txData["fee"] as int,
|
||||
// inputSize: 0,
|
||||
// outputSize: 0,
|
||||
// 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!);
|
||||
// }
|
||||
final transaction = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
type: isar_models.TransactionType.outgoing,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: txData["recipientAmt"] as int,
|
||||
fee: txData["fee"] as int,
|
||||
height: null,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
? await db.getAddress(walletId, txData["address"] as String)
|
||||
: null;
|
||||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue