@@ -1812,6 +1812,84 @@ pub struct FundRawTransactionResult {
18121812 pub change_position : i32 ,
18131813}
18141814
1815+ #[ derive( Clone , PartialEq , Eq , Debug , Default ) ]
1816+ pub struct BumpFeeOptions {
1817+ pub conf_target : Option < u16 > ,
1818+ /// Specify a fee rate instead of relying on the built-in fee estimator.
1819+ pub fee_rate : Option < FeeRate > ,
1820+ /// Whether this transaction could be replaced due to BIP125 (replace-by-fee)
1821+ pub replaceable : Option < bool > ,
1822+ /// The fee estimate mode
1823+ pub estimate_mode : Option < EstimateMode > ,
1824+ }
1825+
1826+ impl BumpFeeOptions {
1827+ pub fn to_serializable ( & self , version : usize ) -> SerializableBumpFeeOptions {
1828+ let fee_rate = self . fee_rate . map ( |x| {
1829+ if version < 210000 {
1830+ x. btc_per_kvbyte ( )
1831+ } else {
1832+ x. sat_per_vbyte ( )
1833+ }
1834+ } ) ;
1835+
1836+ SerializableBumpFeeOptions {
1837+ fee_rate,
1838+ conf_target : self . conf_target ,
1839+ replaceable : self . replaceable ,
1840+ estimate_mode : self . estimate_mode ,
1841+ }
1842+ }
1843+ }
1844+
1845+ #[ derive( Copy , Clone , PartialEq , Eq , Debug , Default ) ]
1846+ pub struct FeeRate ( Amount ) ;
1847+
1848+ impl FeeRate {
1849+ pub fn new ( amount_per_vbyte : Amount ) -> Self {
1850+ Self ( amount_per_vbyte)
1851+ }
1852+ pub fn sat_per_vbyte ( & self ) -> f64 {
1853+ // multiply by the number of decimals to get sat
1854+ self . 0 . as_sat ( ) as f64
1855+ }
1856+ pub fn btc_per_kvbyte ( & self ) -> f64 {
1857+ // divide by 10^8 to get btc/vbyte, then multiply by 10^3 to get btc/kbyte
1858+ self . 0 . as_sat ( ) as f64 / 100_000.0
1859+ }
1860+ }
1861+
1862+ #[ derive( Serialize , Clone , PartialEq , Debug , Default ) ]
1863+ #[ serde( rename_all = "camelCase" ) ]
1864+ pub struct SerializableBumpFeeOptions {
1865+ #[ serde( rename = "conf_target" , skip_serializing_if = "Option::is_none" ) ]
1866+ pub conf_target : Option < u16 > ,
1867+ /// Specify a fee rate instead of relying on the built-in fee estimator.
1868+ #[ serde( rename = "fee_rate" ) ]
1869+ pub fee_rate : Option < f64 > ,
1870+ /// Whether this transaction could be replaced due to BIP125 (replace-by-fee)
1871+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1872+ pub replaceable : Option < bool > ,
1873+ /// The fee estimate mode
1874+ #[ serde( rename = "estimate_mode" , skip_serializing_if = "Option::is_none" ) ]
1875+ pub estimate_mode : Option < EstimateMode > ,
1876+ }
1877+
1878+ #[ derive( Deserialize , Clone , PartialEq , Eq , Debug ) ]
1879+ #[ serde( rename_all = "camelCase" ) ]
1880+ pub struct BumpFeeResult {
1881+ /// The base64-encoded unsigned PSBT of the new transaction. Only returned when wallet private keys are disabled.
1882+ pub psbt : Option < String > ,
1883+ /// The id of the new transaction. Only returned when wallet private keys are enabled.
1884+ pub txid : Option < bitcoin:: Txid > ,
1885+ #[ serde( with = "bitcoin::util::amount::serde::as_btc" ) ]
1886+ pub origfee : Amount ,
1887+ #[ serde( with = "bitcoin::util::amount::serde::as_btc" ) ]
1888+ pub fee : Amount ,
1889+ /// Errors encountered during processing.
1890+ pub errors : Vec < String > ,
1891+ }
1892+
18151893#[ derive( Deserialize , Clone , PartialEq , Eq , Debug ) ]
18161894pub struct GetBalancesResultEntry {
18171895 #[ serde( with = "bitcoin::util::amount::serde::as_btc" ) ]
0 commit comments