@@ -42,9 +42,9 @@ use bitcoin::{Address, Block, BlockHash, FeeRate, MerkleBlock, Script, Transacti
4242use reqwest:: { header, Body , Client , Response } ;
4343
4444use crate :: {
45- sat_per_vbyte_to_feerate, AddressStats , BlockInfo , BlockStatus , Builder , Error , EsploraTx ,
46- MempoolRecentTx , MempoolStats , MerkleProof , OutputStatus , ScriptHashStats , SubmitPackageResult ,
47- TxStatus , Utxo , BASE_BACKOFF_MILLIS , RETRYABLE_ERROR_CODES ,
45+ sat_per_vbyte_to_feerate, AddressStats , Amount , BlockInfo , BlockStatus , Builder , Error ,
46+ EsploraTx , MempoolRecentTx , MempoolStats , MerkleProof , OutputStatus , ScriptHashStats ,
47+ SubmitPackageResult , TxStatus , Utxo , BASE_BACKOFF_MILLIS , RETRYABLE_ERROR_CODES ,
4848} ;
4949
5050/// Returns `true` if the given HTTP status code should trigger a retry.
@@ -383,29 +383,33 @@ impl<S: Sleeper> AsyncClient<S> {
383383 /// Returns a [`SubmitPackageResult`] containing the result for each
384384 /// transaction in the package, keyed by [`Wtxid`](bitcoin::Wtxid).
385385 ///
386- /// Optionally, `maxfeerate` (in sat/vB) and `maxburnamount` (in BTC) can
387- /// be provided to reject transactions that exceed these thresholds.
386+ /// Optionally, `maxfeerate` (as a [`FeeRate`]) and `maxburnamount`
387+ /// (as an [`Amount`]) can be provided to reject transactions that
388+ /// exceed these thresholds.
388389 ///
389390 /// # Errors
390391 ///
391392 /// Returns an [`Error`] if the request fails or the server rejects the package.
392393 pub async fn submit_package (
393394 & self ,
394395 transactions : & [ Transaction ] ,
395- maxfeerate : Option < f64 > ,
396- maxburnamount : Option < f64 > ,
396+ maxfeerate : Option < FeeRate > ,
397+ maxburnamount : Option < Amount > ,
397398 ) -> Result < SubmitPackageResult , Error > {
398399 let serialized_txs = transactions
399400 . iter ( )
400401 . map ( |tx| serialize_hex ( & tx) )
401402 . collect :: < Vec < _ > > ( ) ;
402403
403404 let mut queryparams = HashSet :: < ( & str , String ) > :: new ( ) ;
405+
406+ // Esplora expects `maxfeerate` in sats/vB.
404407 if let Some ( maxfeerate) = maxfeerate {
405- queryparams. insert ( ( "maxfeerate" , maxfeerate. to_string ( ) ) ) ;
408+ queryparams. insert ( ( "maxfeerate" , maxfeerate. to_sat_per_vb_ceil ( ) . to_string ( ) ) ) ;
406409 }
410+ // Esplora expects `maxburnamount` in BTC.
407411 if let Some ( maxburnamount) = maxburnamount {
408- queryparams. insert ( ( "maxburnamount" , maxburnamount. to_string ( ) ) ) ;
412+ queryparams. insert ( ( "maxburnamount" , maxburnamount. to_btc ( ) . to_string ( ) ) ) ;
409413 }
410414
411415 let response = self
0 commit comments