fix: null check on chainTipUpdate

This commit is contained in:
Rafael Saes 2023-12-07 18:05:57 -03:00
parent 717f7457b5
commit ea2161010f

View file

@ -814,9 +814,6 @@ abstract class ElectrumWalletBase
await updateUnspent(); await updateUnspent();
await updateBalance(); await updateBalance();
await updateTransactions(); await updateTransactions();
final currentHeight = await electrumClient.getCurrentBlockChainTip();
if (currentHeight != null) walletInfo.restoreHeight = currentHeight;
rescan(height: walletInfo.restoreHeight);
} catch (e, s) { } catch (e, s) {
print(e.toString()); print(e.toString());
_onError?.call(FlutterErrorDetails( _onError?.call(FlutterErrorDetails(
@ -829,10 +826,11 @@ abstract class ElectrumWalletBase
}); });
await _chainTipUpdateSubject?.close(); await _chainTipUpdateSubject?.close();
_chainTipUpdateSubject = electrumClient.chainTipUpdate(); _chainTipUpdateSubject = electrumClient.chainTipUpdate();
_chainTipUpdateSubject!.listen((event) async { _chainTipUpdateSubject?.listen((_) async {
try { try {
print(["NEW HEIGHT!", event]); final currentHeight = await electrumClient.getCurrentBlockChainTip();
// _setListeners(walletInfo.restoreHeight, chainTip_setListeners: event); if (currentHeight != null) walletInfo.restoreHeight = currentHeight;
_setListeners(walletInfo.restoreHeight, chainTip: currentHeight);
} catch (e, s) { } catch (e, s) {
print(e.toString()); print(e.toString());
_onError?.call(FlutterErrorDetails( _onError?.call(FlutterErrorDetails(