Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CW-909-monero-background-sync-investigation #2041

Open
wants to merge 433 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
433 commits
Select commit Hold shift + click to select a range
7b5c36e
wip
fossephate Sep 4, 2024
aa6cac8
wip
fossephate Sep 5, 2024
c8aa159
[skip ci] wip
fossephate Sep 5, 2024
20fa6a0
updates [skip ci]
fossephate Sep 5, 2024
14891ec
ios fixes
fossephate Sep 5, 2024
5dbc414
fix workflows + ios fix
fossephate Sep 5, 2024
a87a028
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 5, 2024
fbffda7
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 6, 2024
a812ea8
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 6, 2024
bae741a
test old mweb version
fossephate Sep 6, 2024
ec60fa9
update go version and mwebd hash
fossephate Sep 6, 2024
91ab7ed
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 6, 2024
5d7db4e
sync first wallet
fossephate Sep 9, 2024
91f4904
minor fix
fossephate Sep 9, 2024
56c505d
review updates pt.1
fossephate Sep 9, 2024
0f5ee47
Update cw_bitcoin/lib/litecoin_wallet.dart
fossephate Sep 9, 2024
577aec0
remove non-litecoin address types regex [skip ci]
OmarHatem28 Sep 9, 2024
729df41
Merge remote-tracking branch 'origin/mweb' into mweb
OmarHatem28 Sep 9, 2024
728a0bf
more minor fixes
fossephate Sep 9, 2024
69297d2
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 9, 2024
3a70d72
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 9, 2024
18a9bde
remove duplicate [skip ci]
OmarHatem28 Sep 9, 2024
dc77dee
Update lib/store/settings_store.dart
fossephate Sep 9, 2024
fd578dd
script updates, swap params on createLitecoinWalletService
fossephate Sep 9, 2024
3963233
topup fix
fossephate Sep 9, 2024
910825d
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 9, 2024
1061b7d
[skip ci] wip
fossephate Sep 10, 2024
150d065
[skip ci] testing
fossephate Sep 10, 2024
5be1284
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 10, 2024
69332b3
[skip ci] file didn't get saved
fossephate Sep 10, 2024
352865f
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 10, 2024
075ab2b
silent payments scanning support (hopefully)
fossephate Sep 10, 2024
d8d26a0
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 10, 2024
5bda80f
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 10, 2024
2c38641
more address generation reliability fixes
fossephate Sep 10, 2024
2573ca6
[skip ci] minor
fossephate Sep 10, 2024
5086e39
Merge branch 'main' into mweb
OmarHatem28 Sep 11, 2024
1e73a51
minor code cleanup
fossephate Sep 11, 2024
818b69c
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 11, 2024
0899197
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 11, 2024
c35908c
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 11, 2024
9f1b954
save
fossephate Sep 11, 2024
180b967
updates
fossephate Sep 11, 2024
9c91f66
minor fix with channel id (needs testing)
fossephate Sep 11, 2024
a673d39
hopefully prevents send issue
fossephate Sep 11, 2024
f53f96c
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 11, 2024
c94c10c
[skip ci] wip address changes
fossephate Sep 11, 2024
9c3a83f
save
fossephate Sep 11, 2024
cd307bf
[skip ci] save
fossephate Sep 11, 2024
554df09
save mweb addresses, auto-restart sync process if it gets stuck [skip…
fossephate Sep 11, 2024
f8d76fb
address generation issues mostly resolved
fossephate Sep 12, 2024
8aa95a2
more performance fixes
fossephate Sep 12, 2024
e55bd85
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 12, 2024
ce7de06
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 12, 2024
ec25c2b
[skip ci]
fossephate Sep 12, 2024
cb89291
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 12, 2024
e6b9a49
silent payments fix
fossephate Sep 12, 2024
756fb3d
ui improvements, still figuring out silent payments issues
fossephate Sep 12, 2024
ab3c149
minor notification updates
fossephate Sep 12, 2024
9dd696a
this should maybe be refactored, pt.1
fossephate Sep 12, 2024
6a4327a
separate mweb balances, pt.2
fossephate Sep 12, 2024
5c9a902
[skip ci] save
fossephate Sep 13, 2024
245f4d6
add translations [skip ci]
fossephate Sep 13, 2024
3a969ac
fix sending with mweb amounts
fossephate Sep 13, 2024
4503ad5
works for simple mweb-mweb case, further testing needed
fossephate Sep 13, 2024
17695d1
found an edge case
fossephate Sep 13, 2024
e970f70
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 16, 2024
e51d6ea
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 16, 2024
35c4f3e
save
fossephate Sep 16, 2024
4f9d602
working!
fossephate Sep 17, 2024
3004720
make notifications silent
fossephate Sep 17, 2024
4411f7b
updates - slow when syncing multiple wallets
fossephate Sep 17, 2024
e37c01b
untested round robin
fossephate Sep 17, 2024
1864a8f
updates
fossephate Sep 18, 2024
34d5d96
[skip ci] Merge branch 'main' of https://github.com/cake-tech/cake_wa…
fossephate Sep 18, 2024
82757b3
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 18, 2024
c42928e
round robin 2.0
fossephate Sep 18, 2024
e68b2ea
updates
fossephate Sep 18, 2024
b3495fe
stopsync monero (TODO)
fossephate Sep 18, 2024
0c73e05
add start message
fossephate Sep 18, 2024
d3cf372
[skip ci] make failed broadcast error message less serious
fossephate Sep 19, 2024
c49f2ed
minor
fossephate Sep 19, 2024
8d4443e
capture all grpc errors and much better error handling overall
fossephate Sep 19, 2024
0cd21f2
[skip ci] minor
fossephate Sep 19, 2024
618a2c2
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 19, 2024
7ee8949
prevent transactions with < 6 confirmations from being used + hide mw…
fossephate Sep 20, 2024
03a3fb8
fix
fossephate Sep 20, 2024
fc51847
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 20, 2024
f2ddbcf
merge fixes pt.1 [skip ci]
fossephate Sep 20, 2024
6bcda3b
fix mweb tags
fossephate Sep 20, 2024
4f046fe
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 21, 2024
b9961cf
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 21, 2024
d653713
[skip ci] Merge branch 'main' of https://github.com/cake-tech/cake_wa…
fossephate Sep 23, 2024
fb6cea2
fix
fossephate Sep 23, 2024
69e2547
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 23, 2024
491ea45
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 23, 2024
b3e346d
[skip ci] fix tag spacing
fossephate Sep 23, 2024
8d7bad3
fix transaction history not showing up
fossephate Sep 23, 2024
8034d91
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 23, 2024
e48cd0d
fix mweb crash on non-fully deleted mweb cache, sync status ETA, othe…
fossephate Sep 23, 2024
dbc2fb3
[skip ci] minor code cleanup
fossephate Sep 23, 2024
371fb8c
[skip ci] minor code cleanup
fossephate Sep 23, 2024
a226a33
additional cleanup
fossephate Sep 23, 2024
7435db0
silent payments eta fixes and updates
fossephate Sep 23, 2024
af2f0e2
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 24, 2024
cb74505
revert sync eta changes into separate pr
fossephate Sep 24, 2024
ea1d4cb
[skip ci] minor
fossephate Sep 24, 2024
633d524
[skip ci] minor
fossephate Sep 24, 2024
6a4eaec
revert sync status title
fossephate Sep 24, 2024
6f462aa
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 24, 2024
948eb64
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 24, 2024
fe171c4
stuck sync timer
fossephate Sep 24, 2024
840287c
review fixes, additional cleanup
fossephate Sep 24, 2024
31affa6
[skip ci] minor
fossephate Sep 24, 2024
967e333
[skip ci] minor
fossephate Sep 24, 2024
4e6f0dd
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 24, 2024
5cb8c4f
[skip ci] minor
fossephate Sep 24, 2024
29164b2
trigger build
fossephate Sep 24, 2024
ea92998
review fixes, pt.2
fossephate Sep 24, 2024
efa8324
check if still processing utxos before updating sync status [skip ci]
fossephate Sep 24, 2024
55d8b96
[skip ci] minor
fossephate Sep 24, 2024
154eee3
balance fix
fossephate Sep 24, 2024
d040793
minor
fossephate Sep 24, 2024
f66e369
minor
fossephate Sep 24, 2024
6f2cb4d
[skip ci] minor
fossephate Sep 24, 2024
1de4ccd
[skip ci] fix test net btc
fossephate Sep 25, 2024
48061ea
don't use mwebd for non-mweb tx's
fossephate Sep 25, 2024
dcac601
[skip ci] minor cleanup
fossephate Sep 25, 2024
3724681
don't show all 1000+ mweb addresses on receive page
fossephate Sep 25, 2024
69bef9d
Merge branch 'mweb' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 25, 2024
91ffe6c
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Sep 30, 2024
239adc2
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Oct 21, 2024
91998d4
[skip-ci] show mweb confirmations, show last mweb balance while syncing
fossephate Oct 21, 2024
139bb32
potential send-all fix
fossephate Oct 21, 2024
dddb54d
[skip-ci] undo fix that didn't work
fossephate Oct 22, 2024
3c2d1e4
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Oct 22, 2024
5967cf5
[skip-ci] undo unnecessary changes
fossephate Oct 22, 2024
7f9e4a2
[skip ci] add export mweb logs screen
fossephate Oct 22, 2024
73f80b1
[skip ci] cleanup
fossephate Oct 22, 2024
6e441f4
confirmation fixes
fossephate Oct 22, 2024
da13642
merge main [skip ci]
fossephate Oct 23, 2024
7b276a3
catch electrum call errors
fossephate Oct 23, 2024
7874675
[skip ci] undo some changes
fossephate Oct 24, 2024
87cca2d
potential electrum fixes + mweb logs display only last 10000 characters
fossephate Oct 24, 2024
456c856
[skip ci] merge main
fossephate Oct 24, 2024
804d27c
Add question mark and link to MWEB card
tuxpizza Oct 24, 2024
8fc980f
updates
fossephate Oct 25, 2024
6ec3b33
Merge branch 'mweb_enhancements_4' of https://github.com/cake-tech/ca…
fossephate Oct 25, 2024
6e45d99
show negative unconfirmed mweb balanaces + other fixes [skip ci]
fossephate Oct 25, 2024
f14dfc6
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Oct 28, 2024
767b507
error handling
fossephate Oct 28, 2024
04afc64
[skip ci] [wip] check if node supports mweb
fossephate Oct 28, 2024
8c7db80
check fee before building tx
fossephate Oct 28, 2024
8dc1ed6
Merge branch 'mweb_enhancements_4' of https://github.com/cake-tech/ca…
fossephate Oct 28, 2024
a5db347
[skip ci] minor
fossephate Oct 28, 2024
6dd6f06
[skip ci] minor
fossephate Oct 28, 2024
3132db7
mweb node setting [wip] [skip ci]
fossephate Oct 28, 2024
31054bb
prioritize mweb coins when selecting inputs from the pool
fossephate Oct 29, 2024
ea30166
potential connection edgecase fix
fossephate Oct 29, 2024
352ec75
translations + mweb node fixes
fossephate Oct 29, 2024
43e53c2
don't use mweb for exchange refund address
fossephate Oct 29, 2024
26a757f
add peg in / out labels and make 6 confs only show up for peg in / out
fossephate Oct 29, 2024
7e656c4
bump bitcoin_base version to v9
fossephate Oct 30, 2024
4f2637e
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Oct 30, 2024
85fb138
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Oct 30, 2024
85b3969
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Oct 31, 2024
1e3781f
[skip ci] fix logs page
fossephate Oct 31, 2024
f61f590
don't fetch txinfo for non-mweb addresses [skip ci]
fossephate Oct 31, 2024
0cc9018
fix non-mweb confirmations
fossephate Oct 31, 2024
7f862d8
rename always scan to enable mweb
fossephate Nov 1, 2024
35d7909
Update litecoin_wallet_addresses.dart
fossephate Nov 1, 2024
57a88cc
Update cw_mweb.dart
fossephate Nov 1, 2024
bb6d89a
[skip ci] review updates pt.1
fossephate Nov 1, 2024
50f69ff
[skip ci] minor code cleanup
fossephate Nov 1, 2024
e42996d
[skip ci] use exception handler
fossephate Nov 1, 2024
1b8ed92
[skip ci] merge main
fossephate Nov 4, 2024
c14ea77
Merge branch 'main' into mweb_enhancements_4
fossephate Nov 4, 2024
d3974be
exception handling [skip ci]
fossephate Nov 4, 2024
0603aaa
[skip ci]
fossephate Nov 4, 2024
887021a
[skip ci] exception handling
fossephate Nov 4, 2024
fad4a6d
trigger build
fossephate Nov 4, 2024
65af9bb
pegout label fixes
fossephate Nov 4, 2024
d9df5be
fix showing change transactions on peg-out
fossephate Nov 4, 2024
579b9de
minor code cleanup and minor peg-out fix
fossephate Nov 4, 2024
86a30c5
final balance fixes
fossephate Nov 4, 2024
0861572
[skip ci] Merge branch 'main' of https://github.com/cake-tech/cake_wa…
fossephate Nov 5, 2024
97a345e
non-mweb confirmations potential fix
fossephate Nov 5, 2024
4c4f697
[skip ci] wip
fossephate Nov 5, 2024
2914e4d
Merge branch 'mweb_enhancements_4' into mweb-bg-sync-2
fossephate Nov 6, 2024
f099bba
merge build fix
fossephate Nov 6, 2024
8824453
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Nov 8, 2024
26ad16e
translations + minor fixes
fossephate Nov 8, 2024
d07cf07
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Nov 12, 2024
f9ff0b4
merge main
fossephate Nov 20, 2024
a032d86
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Dec 18, 2024
7338e49
enable core library desugaring
fossephate Dec 18, 2024
7c651d7
ui updates
fossephate Dec 18, 2024
ac847d8
on battery and on data sync options
fossephate Dec 18, 2024
c2e764f
[skip ci] sync stuck watch dog
fossephate Dec 18, 2024
d4346e4
testing
fossephate Dec 19, 2024
f312072
improvements
fossephate Dec 19, 2024
699e8e3
[skip ci] change default sync frequency
fossephate Dec 19, 2024
f4f2678
only one notification
fossephate Dec 19, 2024
26ed988
test fix
fossephate Dec 19, 2024
ddd89bf
actual fix
fossephate Dec 19, 2024
187dc98
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Dec 20, 2024
4406ee7
minor
fossephate Dec 20, 2024
77940a8
minor
fossephate Dec 26, 2024
3fca1ee
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Dec 26, 2024
9be1f7f
make notifications silent
fossephate Dec 26, 2024
585ced1
[skip ci] minor
fossephate Dec 26, 2024
08aed18
monero background sync view key update
fossephate Dec 26, 2024
7b786c2
minor
fossephate Dec 26, 2024
df6a2eb
[skip ci] Merge branch 'main' of https://github.com/cake-tech/cake_wa…
fossephate Dec 30, 2024
a2b3eef
switch to sp node in bg service
fossephate Dec 30, 2024
2e13a93
Merge branch 'mweb-bg-sync-2' of https://github.com/cake-tech/cake_wa…
fossephate Dec 30, 2024
e243009
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Jan 2, 2025
a7cd8ad
Merge branch 'mweb-bg-sync-2' of https://github.com/cake-tech/cake_wa…
fossephate Jan 2, 2025
ef6ed48
minor fix
fossephate Jan 2, 2025
44b715c
background sync updates and testing [skip ci]
fossephate Jan 3, 2025
fce3d51
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Jan 6, 2025
9f6998b
Merge branch 'mweb-bg-sync-2' of https://github.com/cake-tech/cake_wa…
fossephate Jan 6, 2025
51259a8
[skip ci] working
fossephate Jan 6, 2025
0f7b104
[skip ci] save
fossephate Jan 6, 2025
c59e4df
cleanup [skip ci]
fossephate Jan 6, 2025
cab76cc
cleanup [skip ci]
fossephate Jan 6, 2025
df70bb7
save
fossephate Jan 6, 2025
a9f7dec
[skip ci] wip
fossephate Jan 9, 2025
582830d
experimental
fossephate Jan 10, 2025
840c151
save
fossephate Jan 11, 2025
b089d92
cleanup
fossephate Jan 11, 2025
53dd533
updates to bg sync
fossephate Jan 13, 2025
cc3eec6
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Jan 15, 2025
399aaff
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Jan 15, 2025
fddbe7c
[skip ci] Merge branch 'main' of https://github.com/cake-tech/cake_wa…
fossephate Jan 15, 2025
6c04666
Merge branch 'main' into CW-909-monero-background-sync-investigation
MrCyjaneK Feb 21, 2025
fcc2769
Enhance background sync and wallet initialization across multiple wal…
MrCyjaneK Feb 20, 2025
dc04009
fix generated code, fix zano, update monero_c
MrCyjaneK Feb 21, 2025
1493dd4
[skip slack] remove print statement
MrCyjaneK Feb 21, 2025
1287a31
Clear status code to prevent errors during bg sync
MrCyjaneK Feb 21, 2025
8c02973
[skip-ci] merge main
fossephate Feb 22, 2025
025f7a9
don't create subaddresses on out of bounds accounts
MrCyjaneK Feb 24, 2025
74b0076
don't stop wallet when coming back to the foreground
fossephate Feb 24, 2025
900475f
final fix for background sync
MrCyjaneK Feb 24, 2025
cfbf1f7
Merge branch 'main' into CW-909-monero-background-sync-investigation
OmarHatem28 Feb 25, 2025
feeba34
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
fossephate Feb 28, 2025
c7a2388
Update lib/di.dart
fossephate Mar 2, 2025
6112d49
remove unnecessary timeout
fossephate Mar 2, 2025
cf91996
Update cw_zano/lib/zano_wallet.dart
fossephate Mar 2, 2025
a6d16bb
enable debug screen only in debug
MrCyjaneK Mar 2, 2025
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
5 changes: 5 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ android {
}
}

compileOptions {
coreLibraryDesugaringEnabled true
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
Expand Down Expand Up @@ -94,6 +98,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
}
configurations {
implementation.exclude module:'proto-google-common-protos'
Expand Down
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifestBase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />


<!-- background sync -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

<application
android:name=".Application"
android:label="${APP_NAME}"
Expand Down Expand Up @@ -101,6 +104,10 @@
<data android:scheme="nano-gpt" />
</intent-filter>
</activity>
<service
android:name="id.flutter.flutter_background_service.BackgroundService"
android:foregroundServiceType="dataSync"
/>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
Expand Down
18 changes: 16 additions & 2 deletions cw_bitcoin/lib/electrum_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ abstract class ElectrumWalletBase

@action
@override
Future<void> startSync() async {
Future<void> startSync({bool isBackgroundSync = false}) async {
try {
if (syncStatus is SyncronizingSyncStatus) {
return;
Expand All @@ -471,7 +471,8 @@ abstract class ElectrumWalletBase
await updateBalance();
await updateFeeRates();

_updateFeeRateTimer ??=
_updateFeeRateTimer?.cancel();
_updateFeeRateTimer =
Timer.periodic(const Duration(minutes: 1), (timer) async => await updateFeeRates());

if (alwaysScan == true) {
Expand All @@ -487,6 +488,19 @@ abstract class ElectrumWalletBase
}
}

@action
@override
Future<void> stopSync({bool isBackgroundSync = false}) async {
syncStatus = NotConnectedSyncStatus();
try {
await _receiveStream?.cancel();
electrumClient.onConnectionStatusChange = null;
await electrumClient.close();
} catch (_) {}
_updateFeeRateTimer?.cancel();
_autoSaveTimer?.cancel();
}

@action
Future<void> updateFeeRates() async {
if (await checkIfMempoolAPIIsEnabled() && type == WalletType.bitcoin) {
Expand Down
5 changes: 3 additions & 2 deletions cw_bitcoin/lib/litecoin_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {

@action
@override
Future<void> startSync() async {
Future<void> startSync({bool isBackgroundSync = false}) async {
printV("startSync() called!");
printV("STARTING SYNC - MWEB ENABLED: $mwebEnabled");
if (!mwebEnabled) {
Expand Down Expand Up @@ -437,12 +437,13 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {

@action
@override
Future<void> stopSync() async {
Future<void> stopSync({bool isBackgroundSync = false}) async {
printV("stopSync() called!");
_syncTimer?.cancel();
_utxoStream?.cancel();
_feeRatesTimer?.cancel();
await CwMweb.stop();
await super.stopSync();
printV("stopped syncing!");
}

Expand Down
9 changes: 9 additions & 0 deletions cw_core/lib/sync_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,12 @@ class LostConnectionSyncStatus extends NotConnectedSyncStatus {
@override
String toString() => 'Reconnecting';
}

// when the application has been paused by the OS:
class StoppedSyncingSyncStatus extends NotConnectedSyncStatus {
@override
double progress() => 0.0;

@override
String toString() => 'stopped';
}
9 changes: 7 additions & 2 deletions cw_core/lib/wallet_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans

bool get isHardwareWallet => walletInfo.isHardwareWallet;

Future<void> init();

Future<void> connectToNode({required Node node});

// there is a default definition here because only coins with a pow node (nano based) need to override this
Future<void> connectToPowNode({required Node node}) async {}

Future<void> startSync();
Future<void> startSync({bool isBackgroundSync = false});

Future<void> stopSync() async {}
Future<void> stopSync({bool isBackgroundSync = false}) async {}

Future<PendingTransaction> createTransaction(Object credentials);

Expand Down Expand Up @@ -100,4 +102,7 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
Future<bool> verifyMessage(String message, String signature, {String? address = null});

bool isTestnet = false;

// TODO: use proxy layer
Future<void> reopenWallet() async {}
}
2 changes: 1 addition & 1 deletion cw_evm/lib/evm_chain_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ abstract class EVMChainWalletBase

@action
@override
Future<void> startSync() async {
Future<void> startSync({bool isBackgroundSync = false}) async {
try {
syncStatus = AttemptingSyncStatus();
await _updateBalance();
Expand Down
2 changes: 1 addition & 1 deletion cw_haven/lib/haven_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ abstract class HavenWalletBase
}

@override
Future<void> startSync() async {
Future<void> startSync({bool isBackgroundSync = false}) async {
try {
_setInitialHeight();
} catch (_) {}
Expand Down
2 changes: 1 addition & 1 deletion cw_monero/lib/api/account_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ List<monero.SubaddressAccountRow> getAllAccount() {
int size = monero.SubaddressAccount_getAll_size(subaddressAccount!);
if (size == 0) {
monero.Wallet_addSubaddressAccount(wptr!);
return getAllAccount();
return [];
}
return List.generate(size, (index) {
return monero.SubaddressAccount_getAll_byIndex(subaddressAccount!, index: index);
Expand Down
5 changes: 5 additions & 0 deletions cw_monero/lib/api/subaddress_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_monero/api/account_list.dart';
import 'package:cw_monero/api/transaction_history.dart';
import 'package:cw_monero/api/wallet.dart';
Expand Down Expand Up @@ -123,6 +124,10 @@ int numSubaddresses(int subaccountIndex) {
}

void addSubaddressSync({required int accountIndex, required String label}) {
if (monero.Wallet_numSubaddressAccounts(wptr!) <= accountIndex) {
printV("accountIndex is out of bounds");
return;
}
Comment on lines +127 to +130
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? wouldn't it create the account normally and then create the subaddress?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In background sync it is numSubaddressAccount is always zero.

monero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex, label: label);
refreshSubaddresses(accountIndex: accountIndex);
}
Expand Down
88 changes: 63 additions & 25 deletions cw_monero/lib/api/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,25 @@ String getSeed() {
}

String getSeedLegacy(String? language) {
final cakepassphrase = getPassphrase();
var legacy = monero.Wallet_seed(wptr!, seedOffset: cakepassphrase);
switch (language) {
case "Chinese (Traditional)": language = "Chinese (simplified)"; break;
case "Chinese (Simplified)": language = "Chinese (simplified)"; break;
case "Korean": language = "English"; break;
case "Czech": language = "English"; break;
case "Japanese": language = "English"; break;
case "Chinese (Traditional)":
language = "Chinese (simplified)";
break;
case "Chinese (Simplified)":
language = "Chinese (simplified)";
break;
case "Korean":
language = "English";
break;
case "Czech":
language = "English";
break;
case "Japanese":
language = "English";
break;
}
final cakepassphrase = getPassphrase();
var legacy = monero.Wallet_seed(wptr!, seedOffset: cakepassphrase);
if (monero.Wallet_status(wptr!) != 0) {
monero.Wallet_setSeedLanguage(wptr!, language: language ?? "English");
legacy = monero.Wallet_seed(wptr!, seedOffset: cakepassphrase);
Expand All @@ -86,21 +96,33 @@ String getSeedLegacy(String? language) {
}

String getPassphrase() {
return monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase");
final toret = monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.passphrase");
monero.Wallet_status(wptr!); // clear status code
return toret;
}

Map<int, Map<int, Map<int, String>>> addressCache = {};

String getAddress({int accountIndex = 0, int addressIndex = 0}) {
// printV("getaddress: ${accountIndex}/${addressIndex}: ${monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex)}: ${monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex)}");
while (monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex)-1 < addressIndex) {
printV("adding subaddress");

int count = 0;

while (monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex) - 1 < addressIndex) {
if (monero.Wallet_numSubaddressAccounts(wptr!) <= accountIndex) {
printV("accountIndex is out of bounds");
break;
}
monero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex);
if (count > 10) {
break;
}
count++;
}

addressCache[wptr!.address] ??= {};
addressCache[wptr!.address]![accountIndex] ??= {};
addressCache[wptr!.address]![accountIndex]![addressIndex] ??= monero.Wallet_address(wptr!,
accountIndex: accountIndex, addressIndex: addressIndex);
addressCache[wptr!.address]![accountIndex]![addressIndex] ??=
monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex);
return addressCache[wptr!.address]![accountIndex]![addressIndex]!;
}

Expand Down Expand Up @@ -155,7 +177,8 @@ Future<bool> setupNodeSync(

if (kDebugMode && debugMonero) {
monero.Wallet_init3(
wptr!, argv0: '',
wptr!,
argv0: '',
defaultLogBaseName: 'moneroc',
console: true,
logPath: '',
Expand All @@ -170,17 +193,29 @@ void startRefreshSync() {
monero.Wallet_startRefresh(wptr!);
}

void setupBackgroundSync(
{required int backgroundSyncType,
required String walletPassword,
required String backgroundCachePassword}) {
monero.Wallet_setupBackgroundSync(wptr!,
backgroundSyncType: backgroundSyncType,
walletPassword: walletPassword,
backgroundCachePassword: backgroundCachePassword);
}


void stopSync() {
monero.Wallet_init(wptr!, daemonAddress: "");
}

void setRefreshFromBlockHeight({required int height}) =>
monero.Wallet_setRefreshFromBlockHeight(wptr!,
refresh_from_block_height: height);
monero.Wallet_setRefreshFromBlockHeight(wptr!, refresh_from_block_height: height);

void setRecoveringFromSeed({required bool isRecovery}) =>
monero.Wallet_setRecoveringFromSeed(wptr!, recoveringFromSeed: isRecovery);

final storeMutex = Mutex();


int lastStorePointer = 0;
int lastStoreHeight = 0;
void storeSync({bool force = false}) async {
Expand All @@ -190,7 +225,7 @@ void storeSync({bool force = false}) async {
});
if (lastStorePointer == wptr!.address &&
lastStoreHeight + 5000 > monero.Wallet_blockChainHeight(wptr!) &&
!synchronized &&
!synchronized &&
!force) {
return;
}
Expand All @@ -216,6 +251,10 @@ void closeCurrentWallet() {
monero.Wallet_stop(wptr!);
}

void stopWallet() {
monero.Wallet_stop(wptr!);
}

String getSecretViewKey() => monero.Wallet_secretViewKey(wptr!);

String getPublicViewKey() => monero.Wallet_publicViewKey(wptr!);
Expand Down Expand Up @@ -250,8 +289,7 @@ class SyncListener {
_cachedBlockchainHeight = 0;
_lastKnownBlockHeight = 0;
_initialSyncHeight = 0;
_updateSyncInfoTimer ??=
Timer.periodic(Duration(milliseconds: 1200), (_) async {
_updateSyncInfoTimer ??= Timer.periodic(Duration(milliseconds: 1200), (_) async {
if (isNewTransactionExist()) {
onNewTransaction();
}
Expand Down Expand Up @@ -290,8 +328,8 @@ class SyncListener {
void stop() => _updateSyncInfoTimer?.cancel();
}

SyncListener setListeners(void Function(int, int, double) onNewBlock,
void Function() onNewTransaction) {
SyncListener setListeners(
void Function(int, int, double) onNewBlock, void Function() onNewTransaction) {
final listener = SyncListener(onNewBlock, onNewTransaction);
// setListenerNative();
return listener;
Expand Down Expand Up @@ -353,8 +391,7 @@ String getSubaddressLabel(int accountIndex, int addressIndex) {
accountIndex: accountIndex, addressIndex: addressIndex);
}

Future setTrustedDaemon(bool trusted) async =>
monero.Wallet_setTrustedDaemon(wptr!, arg: trusted);
Future setTrustedDaemon(bool trusted) async => monero.Wallet_setTrustedDaemon(wptr!, arg: trusted);

Future<bool> trustedDaemon() async => monero.Wallet_trustedDaemon(wptr!);

Expand All @@ -363,5 +400,6 @@ String signMessage(String message, {String address = ""}) {
}

bool verifyMessage(String message, String address, String signature) {
return monero.Wallet_verifySignedMessage(wptr!, message: message, address: address, signature: signature);
return monero.Wallet_verifySignedMessage(wptr!,
message: message, address: address, signature: signature);
}
Loading
Loading