mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-12 09:27:01 +00:00
Only fetch full monero transactions via ffi if required
This commit is contained in:
parent
38e66bfcb1
commit
a01dce1c72
5 changed files with 43 additions and 17 deletions
|
@ -61,11 +61,11 @@ class MoneroWallet extends LibMoneroWallet {
|
|||
bool walletExists(String path) => lib_monero.MoneroWallet.isWalletExist(path);
|
||||
|
||||
@override
|
||||
void loadWallet({
|
||||
Future<void> loadWallet({
|
||||
required String path,
|
||||
required String password,
|
||||
}) {
|
||||
libMoneroWallet = lib_monero.MoneroWallet.loadWallet(
|
||||
}) async {
|
||||
libMoneroWallet = await lib_monero.MoneroWallet.loadWallet(
|
||||
path: path,
|
||||
password: password,
|
||||
);
|
||||
|
|
|
@ -97,11 +97,11 @@ class WowneroWallet extends LibMoneroWallet {
|
|||
lib_monero.WowneroWallet.isWalletExist(path);
|
||||
|
||||
@override
|
||||
void loadWallet({
|
||||
Future<void> loadWallet({
|
||||
required String path,
|
||||
required String password,
|
||||
}) {
|
||||
libMoneroWallet = lib_monero.WowneroWallet.loadWallet(
|
||||
}) async {
|
||||
libMoneroWallet = await lib_monero.WowneroWallet.loadWallet(
|
||||
path: path,
|
||||
password: password,
|
||||
);
|
||||
|
|
|
@ -137,7 +137,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
|||
int currentKnownChainHeight = 0;
|
||||
double highestPercentCached = 0;
|
||||
|
||||
void loadWallet({required String path, required String password});
|
||||
Future<void> loadWallet({required String path, required String password});
|
||||
|
||||
Future<lib_monero.Wallet> getCreatedWallet({
|
||||
required String path,
|
||||
|
@ -206,7 +206,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
|||
throw Exception("Password not found $e, $s");
|
||||
}
|
||||
|
||||
loadWallet(path: path, password: password);
|
||||
await loadWallet(path: path, password: password);
|
||||
|
||||
_setListener();
|
||||
|
||||
|
@ -329,7 +329,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
|||
} catch (e, s) {
|
||||
throw Exception("Password not found $e, $s");
|
||||
}
|
||||
loadWallet(path: path, password: password);
|
||||
await loadWallet(path: path, password: password);
|
||||
final wallet = libMoneroWallet!;
|
||||
return (wallet.getAddress().value, wallet.getPrivateViewKey());
|
||||
}
|
||||
|
@ -565,7 +565,26 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
|||
return;
|
||||
}
|
||||
|
||||
final transactions = await base.getTxs(refresh: true);
|
||||
final localTxids = await mainDB.isar.transactionV2s
|
||||
.where()
|
||||
.walletIdEqualTo(walletId)
|
||||
.filter()
|
||||
.heightGreaterThan(0)
|
||||
.txidProperty()
|
||||
.findAll();
|
||||
|
||||
final allTxids = await base.getAllTxids(refresh: true);
|
||||
|
||||
final txidsToFetch = allTxids.toSet().difference(localTxids.toSet());
|
||||
|
||||
if (txidsToFetch.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final transactions = await base.getTxs(
|
||||
txids: txidsToFetch,
|
||||
refresh: false,
|
||||
);
|
||||
|
||||
final allOutputs = await base.getOutputs(includeSpent: true, refresh: true);
|
||||
|
||||
|
@ -692,7 +711,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
|||
fractionDigits: cryptoCurrency.fractionDigits,
|
||||
);
|
||||
} else {
|
||||
final transactions = await libMoneroWallet!.getTxs(refresh: true);
|
||||
final transactions = await libMoneroWallet!.getAllTxs(refresh: true);
|
||||
BigInt transactionBalance = BigInt.zero;
|
||||
for (final tx in transactions) {
|
||||
if (!tx.isSpend) {
|
||||
|
@ -790,8 +809,15 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
|||
}
|
||||
}
|
||||
|
||||
void onNewBlock(int nodeHeight) {
|
||||
// do something?
|
||||
void onNewBlock(int nodeHeight) async {
|
||||
try {
|
||||
await updateTransactions();
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
"onNewBlock(): $e\n$s",
|
||||
level: LogLevel.Warning,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final _utxosUpdateLock = Mutex();
|
||||
|
@ -1161,7 +1187,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
|||
|
||||
try {
|
||||
int highestIndex = -1;
|
||||
final entries = await libMoneroWallet?.getTxs(refresh: true);
|
||||
final entries = await libMoneroWallet?.getAllTxs(refresh: true);
|
||||
if (entries != null) {
|
||||
for (final element in entries) {
|
||||
if (!element.isSpend) {
|
||||
|
|
|
@ -436,10 +436,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: cs_monero
|
||||
sha256: "8b2c1451d8eb09fc2a1248ecd652f2332343946a1d622b2f623b74d5f999c8d5"
|
||||
sha256: ed81d9e74ea71a8b8b0bfed07a284e14b6e5f4d0dbde774735f9f0a9ab60b7fb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0-pre.1"
|
||||
version: "1.0.0-pre.2"
|
||||
cs_monero_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -202,7 +202,7 @@ dependencies:
|
|||
blockchain_utils: ^3.3.0
|
||||
on_chain: ^4.0.1
|
||||
cbor: ^6.3.3
|
||||
cs_monero: 1.0.0-pre.1
|
||||
cs_monero: 1.0.0-pre.2
|
||||
cs_monero_flutter_libs: 1.0.0-pre.0
|
||||
monero_rpc: ^2.0.0
|
||||
digest_auth: ^1.0.1
|
||||
|
|
Loading…
Reference in a new issue