Skip to content

Commit

Permalink
feat: add loop to find closest target's fee estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
slavastartsev committed Sep 25, 2024
1 parent 22ebd24 commit 7573f1c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sdk/src/esplora.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ export class EsploraClient {
*/
async getFeeEstimate(confirmationTarget: number): Promise<number> {
const response = await this.getJson<Record<number, number>>(`${this.basePath}/fee-estimates`);
return response[confirmationTarget];
if (response[confirmationTarget]) return response[confirmationTarget];
const TARGET_MAX = 1008;
for (let target = confirmationTarget; target <= TARGET_MAX; target++) {
if (response[target]) return response[target];
}
}

/**
Expand Down

0 comments on commit 7573f1c

Please sign in to comment.