Skip to content

Commit

Permalink
Merge pull request #1850 from synonymdev/update-refreshLdk
Browse files Browse the repository at this point in the history
fix(lightning): Update refreshLdk
  • Loading branch information
Jasonvdb authored May 21, 2024
2 parents 1c0e3ee + e8f7b00 commit 510f311
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/utils/lightning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,27 +659,30 @@ export const refreshLdk = async ({

// Calls that don't require sequential execution.
const promises: Promise<Result<any>>[] = [
lm.syncLdk(),
lm.setFees(),
addPeers({ selectedNetwork, selectedWallet }),
];
const results = await Promise.all(promises);
// Handle & Return syncLdk errors.
if (results[0].isErr()) {
showToast({
type: 'error',
title: i18n.t('wallet:ldk_sync_error_title'),
description: results[0].error.message,
});
return handleRefreshError(results[0].error.message);
}
for (const result of results) {
if (result.isErr()) {
//setFees & addPeers can fail, but we should still continue and make UI ready so payments can be attempted
console.error(result.error.message);
console.error(
`refreshLdk setFees/addPeers error: ${result.error.message}`,
);
}
}

const syncResult = await lm.syncLdk();
if (syncResult.isErr()) {
showToast({
type: 'error',
title: i18n.t('wallet:ldk_sync_error_title'),
description: syncResult.error.message,
});
return handleRefreshError(syncResult.error.message);
}

await Promise.all([
updateLightningChannelsThunk(),
syncLightningTxsWithActivityList(),
Expand Down

0 comments on commit 510f311

Please sign in to comment.