mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
fix bitcoin transaction refresh
This commit is contained in:
parent
5819241c15
commit
5e7bd0d8ae
1 changed files with 29 additions and 23 deletions
|
@ -1,6 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:bech32/bech32.dart';
|
import 'package:bech32/bech32.dart';
|
||||||
|
@ -1998,15 +1997,15 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool _duplicateTxCheck(
|
bool _duplicateTxCheck(
|
||||||
// List<Map<String, dynamic>> allTransactions, String txid) {
|
List<Map<String, dynamic>> allTransactions, String txid) {
|
||||||
// for (int i = 0; i < allTransactions.length; i++) {
|
for (int i = 0; i < allTransactions.length; i++) {
|
||||||
// if (allTransactions[i]["txid"] == txid) {
|
if (allTransactions[i]["txid"] == txid) {
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
Future<void> _refreshTransactions() async {
|
Future<void> _refreshTransactions() async {
|
||||||
final List<isar_models.Address> allAddresses =
|
final List<isar_models.Address> allAddresses =
|
||||||
|
@ -2041,14 +2040,14 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
coin: coin,
|
coin: coin,
|
||||||
);
|
);
|
||||||
|
|
||||||
// if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) {
|
if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) {
|
||||||
tx["address"] = await isar.addresses
|
tx["address"] = await isar.addresses
|
||||||
.filter()
|
.filter()
|
||||||
.valueEqualTo(txHash["address"] as String)
|
.valueEqualTo(txHash["address"] as String)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
tx["height"] = txHash["height"];
|
tx["height"] = txHash["height"];
|
||||||
allTransactions.add(tx);
|
allTransactions.add(tx);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2064,13 +2063,10 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
// await fastFetch(vHashes.toList());
|
// await fastFetch(vHashes.toList());
|
||||||
|
|
||||||
final List<
|
final List<
|
||||||
Tuple3<isar_models.Transaction, List<isar_models.Output>,
|
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||||
List<isar_models.Input>>> txnsData = [];
|
List<isar_models.Input>, isar_models.Address>> txnsData = [];
|
||||||
|
|
||||||
for (final txObject in allTransactions) {
|
for (final txObject in allTransactions) {
|
||||||
print("=========================================================");
|
|
||||||
log(txObject.toString());
|
|
||||||
|
|
||||||
final data = await parseTransaction(
|
final data = await parseTransaction(
|
||||||
txObject,
|
txObject,
|
||||||
cachedElectrumXClient,
|
cachedElectrumXClient,
|
||||||
|
@ -2102,6 +2098,16 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
await tx.inputs.save();
|
await tx.inputs.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if address exists in db and add if it does not
|
||||||
|
if (await isar.addresses
|
||||||
|
.where()
|
||||||
|
.valueEqualTo(data.item4.value)
|
||||||
|
.findFirst() ==
|
||||||
|
null) {
|
||||||
|
await isar.addresses.put(data.item4);
|
||||||
|
}
|
||||||
|
// link and save address
|
||||||
|
tx.address.value = data.item4;
|
||||||
await tx.address.save();
|
await tx.address.save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue