@@ -5,7 +5,7 @@ use std::{borrow::Cow, io::Cursor, net::SocketAddr};
55use bitcoin:: {
66 Block , BlockHash , FeeRate , bip158:: BlockFilter , block:: Header , consensus:: Decodable ,
77} ;
8- use models:: { Html , ServerStatus , TapTweaks } ;
8+ use models:: { FeeEstimates , Html , ServerStatus , TapTweaks } ;
99
1010/// Errors that may occur when querying.
1111pub mod error;
@@ -21,8 +21,8 @@ pub struct Endpoint<'e>(Cow<'e, str>);
2121impl < ' e > Endpoint < ' e > {
2222 /// The original `block-dn` server hosted at `block-dn.org`.
2323 pub const BLOCK_DN_ORG : Self = Self ( Cow :: Borrowed ( "https://block-dn.org" ) ) ;
24- /// Server with additional capabilities hosted by `2140.dev`.
25- pub const DEV_2140 : Self = Self ( Cow :: Borrowed ( "https://taprootdn.xyz" ) ) ;
24+ // Server with additional capabilities hosted by `2140.dev`.
25+ // pub const DEV_2140: Self = Self(Cow::Borrowed("https://taprootdn.xyz"));
2626 /// Local host at port 8080.
2727 pub const LOCAL_HOST : Self = Self ( Cow :: Borrowed ( "https://127.0.0.1:8080" ) ) ;
2828
@@ -178,16 +178,10 @@ impl<'e> Client<'e> {
178178 pub fn estimate_smart_fee ( & self , conf_target : u32 ) -> Result < FeeRate , Error > {
179179 let route = self
180180 . endpoint
181- . append_route ( format ! ( "fees/estimate-fee /{conf_target}" ) ) ;
181+ . append_route ( format ! ( "fees/estimate/{conf_target}" ) ) ;
182182 let response = bitreq:: get ( route) . with_timeout ( self . timeout . 0 ) . send ( ) ?;
183- let sats_vb: [ u8 ; 8 ] = response. as_bytes ( ) . try_into ( ) . map_err ( |_| {
184- Error :: Decoder ( bitcoin:: consensus:: encode:: Error :: ParseFailed (
185- "cannot fit response into 8 byte little endian." ,
186- ) )
187- } ) ?;
188- Ok ( FeeRate :: from_sat_per_vb_unchecked ( u64:: from_le_bytes (
189- sats_vb,
190- ) ) )
183+ let fees = response. json :: < FeeEstimates > ( ) ?;
184+ Ok ( FeeRate :: from_sat_per_kwu ( fees. fee_sat_per_kweight ) )
191185 }
192186}
193187
0 commit comments