@@ -30,7 +30,7 @@ pub use lightning_types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
3030
3131pub use lightning_invoice:: Bolt11Invoice ;
3232
33- pub use bitcoin:: { Address , BlockHash , Network , OutPoint , Txid } ;
33+ pub use bitcoin:: { Address , BlockHash , FeeRate , Network , OutPoint , Txid } ;
3434
3535pub use bip39:: Mnemonic ;
3636
@@ -51,7 +51,6 @@ use lightning::util::ser::Writeable;
5151use lightning_invoice:: SignedRawBolt11Invoice ;
5252
5353use std:: convert:: TryInto ;
54- use std:: fmt;
5554use std:: str:: FromStr ;
5655
5756impl UniffiCustomTypeConverter for PublicKey {
@@ -346,61 +345,3 @@ impl UniffiCustomTypeConverter for NodeAlias {
346345 obj. to_string ( )
347346 }
348347}
349-
350- /// Represents fee rate.
351- ///
352- /// This is a simple wrapper around [`bitcoin::FeeRate`], only used for UniFFI bindings.
353- #[ derive( Debug , Clone , Copy , Eq , PartialEq ) ]
354- pub struct FeeRate ( pub ( crate ) bitcoin:: FeeRate ) ;
355-
356- impl FeeRate {
357- /// Constructs `FeeRate` from satoshis per 1000 weight units.
358- pub const fn from_sat_per_kwu ( sat_kwu : u64 ) -> Self {
359- Self ( bitcoin:: FeeRate :: from_sat_per_kwu ( sat_kwu) )
360- }
361-
362- /// Constructs `FeeRate` from satoshis per virtual bytes.
363- ///
364- /// # Errors
365- ///
366- /// Returns [`FeeRateError::ConversionError`] on arithmetic overflow.
367- pub fn from_sat_per_vb ( sat_vb : u64 ) -> Result < Self , FeeRateError > {
368- Ok ( Self ( bitcoin:: FeeRate :: from_sat_per_vb ( sat_vb) . ok_or ( FeeRateError :: ConversionError ) ?) )
369- }
370-
371- /// Constructs `FeeRate` from satoshis per virtual bytes without overflow check.
372- pub const fn from_sat_per_vb_unchecked ( sat_vb : u64 ) -> Self {
373- Self ( bitcoin:: FeeRate :: from_sat_per_vb_unchecked ( sat_vb) )
374- }
375-
376- /// Returns raw fee rate as satoshis per 1000 weight units.
377- pub const fn as_sat_per_kwu ( & self ) -> u64 {
378- self . 0 . to_sat_per_kwu ( )
379- }
380-
381- /// Converts to sat/vB rounding down.
382- pub const fn as_sat_per_vb_floor ( & self ) -> u64 {
383- self . 0 . to_sat_per_vb_floor ( )
384- }
385-
386- /// Converts to sat/vB rounding up.
387- pub const fn as_sat_per_vb_ceil ( self ) -> u64 {
388- self . 0 . to_sat_per_vb_ceil ( )
389- }
390- }
391-
392- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
393- /// A fee rate error that possibly needs to be handled by the user.
394- pub enum FeeRateError {
395- ConversionError ,
396- }
397-
398- impl std:: error:: Error for FeeRateError { }
399-
400- impl fmt:: Display for FeeRateError {
401- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
402- match self {
403- Self :: ConversionError => write ! ( f, "Fee-rate conversion failed." ) ,
404- }
405- }
406- }
0 commit comments