FIX: ldk throwing 'not started' occasionally

This commit is contained in:
Overtorment 2021-10-01 21:54:11 +01:00
parent 244e19c830
commit 9f7c014adb
No known key found for this signature in database
GPG key ID: AB15F43F78CCBC06

View file

@ -265,7 +265,7 @@ export class LightningLdkWallet extends LightningCustodianWallet {
this._execInBackground(this.reestablishChannels);
if (this.timeToCheckBlockchain()) this._execInBackground(this.checkBlockchain);
} catch (error) {
alert(error.message);
alert('LDK init error: ' + error.message);
}
}
@ -449,7 +449,18 @@ export class LightningLdkWallet extends LightningCustodianWallet {
}
async fetchTransactions() {
if (this.timeToCheckBlockchain()) this._execInBackground(this.checkBlockchain);
if (this.timeToCheckBlockchain()) {
try {
// exception might be in case of incompletely-started LDK
this._listChannels = await RnLdk.listChannels();
this._execInBackground(this.checkBlockchain);
// ^^^ will be executed if above didnt throw exceptions, which means ldk fully started.
// we need this for a case when app returns from background if it was in bg for a really long time.
// ldk needs to update it's blockchain data, and this is practically the only place where it can
// do that (except on cold start)
} catch (_) {}
}
await this.getUserInvoices(); // it internally updates paid user invoices
}
@ -618,7 +629,7 @@ export class LightningLdkWallet extends LightningCustodianWallet {
try {
await func.call(that);
} catch (error) {
alert(error.message);
alert('_execInBackground error:' + error.message);
}
})();
}