Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/wallets/wallet/impl/monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
6 changes: 3 additions & 3 deletions lib/wallets/wallet/impl/wownero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
42 changes: 34 additions & 8 deletions lib/wallets/wallet/intermediate/lib_monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/app_config/templates/pubspec.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion test/services/node_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ void main() {
final service = NodeService(secureStorageInterface: fakeStore);
final currentLength = service.nodes.length;

final editedNode = nodeA.copyWith(name: "Some new kind of name");
final editedNode = nodeA.copyWith(
name: "Some new kind of name",
loginName: null,
trusted: null,
);

await service.edit(editedNode, "123456", true);

Expand Down
Loading