@@ -89,6 +89,18 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
8989 late bool _hasSyncAfterStartup;
9090 Timer ? _autoSaveTimer;
9191
92+ void Function ()? _onNewBlock1;
93+ void Function ()? _onNewTransaction1;
94+ void Function ()? _syncStatusChanged1;
95+
96+ void Function ()? get onNewBlock => _onNewBlock1;
97+ void Function ()? get onNewTransaction => _onNewTransaction1;
98+ void Function ()? get syncStatusChanged => _syncStatusChanged1;
99+
100+ set onNewBlock (void Function ()? cb) => _onNewBlock1 = cb;
101+ set onNewTransaction (void Function ()? cb) => _onNewTransaction1 = cb;
102+ set syncStatusChanged (void Function ()? cb) => _syncStatusChanged1 = cb;
103+
92104 Future <void > init () async {
93105 await walletAddresses.init ();
94106 balance = ObservableMap <CryptoCurrency ?, MoneroBalance >.of (< CryptoCurrency ? ,
@@ -126,15 +138,18 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
126138 Future <void > connectToNode ({required Node node}) async {
127139 try {
128140 syncStatus = ConnectingSyncStatus ();
141+ syncStatusChanged? .call ();
129142 await monero_wallet.setupNode (
130143 address: node.uri.toString (),
131144 login: node.login,
132145 password: node.password,
133146 useSSL: node.isSSL,
134147 isLightWallet: false ); // FIXME: hardcoded value
135148 syncStatus = ConnectedSyncStatus ();
149+ syncStatusChanged? .call ();
136150 } catch (e) {
137151 syncStatus = FailedSyncStatus ();
152+ syncStatusChanged? .call ();
138153 print (e);
139154 }
140155 }
@@ -150,8 +165,10 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
150165 monero_wallet.startRefresh ();
151166 _setListeners ();
152167 _listener? .start ();
168+ syncStatusChanged? .call ();
153169 } catch (e) {
154170 syncStatus = FailedSyncStatus ();
171+ syncStatusChanged? .call ();
155172 print (e);
156173 rethrow ;
157174 }
@@ -404,6 +421,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
404421 _askForUpdateBalance ();
405422 walletAddresses.accountList.update ();
406423 syncStatus = SyncedSyncStatus ();
424+ syncStatusChanged? .call ();
407425
408426 if (! _hasSyncAfterStartup) {
409427 _hasSyncAfterStartup = true ;
@@ -415,10 +433,12 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
415433 }
416434 } else {
417435 syncStatus = SyncingSyncStatus (blocksLeft, ptc, height);
436+ syncStatusChanged? .call ();
418437 }
419438 } catch (e) {
420439 print (e.toString ());
421440 }
441+ onNewBlock? .call ();
422442 }
423443
424444 void _onNewTransaction () async {
@@ -429,5 +449,6 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
429449 } catch (e) {
430450 print (e.toString ());
431451 }
452+ onNewTransaction? .call ();
432453 }
433454}
0 commit comments