diff --git a/sdk/src/esplora.ts b/sdk/src/esplora.ts index 4b7637f3..02b78224 100644 --- a/sdk/src/esplora.ts +++ b/sdk/src/esplora.ts @@ -334,10 +334,10 @@ export class EsploraClient { async getFeeEstimate(confirmationTarget: number): Promise { const response = await this.getJson>(`${this.basePath}/fee-estimates`); if (response[confirmationTarget]) return response[confirmationTarget]; - const TARGET_MAX = 1008; - for (let target = confirmationTarget + 1; target <= TARGET_MAX; target++) { - if (response[target]) return response[target]; - } + const [_, result] = Object.entries(response) + .sort(([a], [b]) => Number(b) - Number(a)) + .pop(); + return result; } /**