@@ -368,12 +368,24 @@ export class ElectrumExplorer implements Explorer {
368368 const feeEstimates : { [ target : number ] : number } = { } ;
369369 for ( const target of T ) {
370370 //100000 = 10 ^ 8 sats/BTC / 10 ^3 bytes/kbyte
371+ //Don't throw. Instead try twice just in case the fist try was a spuripus error.
372+ //The reason for not throwing is blockchainEstimatefee throws
373+ //even if the call is successful but for some reason the electrum server
374+ //cannot provide the fee for a certain target time. This has been observed to
375+ //occur on electrs on testnet.
376+ let fee : number | undefined = undefined ;
371377 try {
372378 const client = this . #getClientOrThrow( ) ;
373- const fee = await client . blockchainEstimatefee ( target ) ;
379+ fee = await client . blockchainEstimatefee ( target ) ;
374380 feeEstimates [ target ] = 100000 * fee ;
375- } catch ( error : unknown ) {
376- throw new Error ( `Failed to fetch fee estimates: ${ getErrorMsg ( error ) } ` ) ;
381+ } catch ( error : unknown ) { }
382+ if ( fee === undefined ) {
383+ try {
384+ await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ; //sleep 0.1 sec
385+ const client = this . #getClientOrThrow( ) ;
386+ fee = await client . blockchainEstimatefee ( target ) ;
387+ feeEstimates [ target ] = 100000 * fee ;
388+ } catch ( error : unknown ) { }
377389 }
378390 }
379391 checkFeeEstimates ( feeEstimates ) ;
0 commit comments