File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -172,6 +172,10 @@ where
172172 ( * * self ) . server_features ( )
173173 }
174174
175+ fn mempool_get_info ( & self ) -> Result < MempoolInfoRes , Error > {
176+ ( * * self ) . mempool_get_info ( )
177+ }
178+
175179 fn ping ( & self ) -> Result < ( ) , Error > {
176180 ( * * self ) . ping ( )
177181 }
@@ -398,6 +402,12 @@ pub trait ElectrumApi {
398402 /// Returns the capabilities of the server.
399403 fn server_features ( & self ) -> Result < ServerFeaturesRes , Error > ;
400404
405+ /// Returns information about the current state of the mempool.
406+ ///
407+ /// This method was added in protocol v1.6 and replaces `relay_fee` by providing
408+ /// `minrelaytxfee` along with additional mempool fee information.
409+ fn mempool_get_info ( & self ) -> Result < MempoolInfoRes , Error > ;
410+
401411 /// Pings the server. This method can also be used as a "dummy" call to trigger the processing
402412 /// of incoming block header or script notifications.
403413 fn ping ( & self ) -> Result < ( ) , Error > ;
@@ -607,6 +617,10 @@ mod test {
607617 unreachable ! ( )
608618 }
609619
620+ fn mempool_get_info ( & self ) -> Result < super :: MempoolInfoRes , super :: Error > {
621+ unreachable ! ( )
622+ }
623+
610624 fn ping ( & self ) -> Result < ( ) , super :: Error > {
611625 unreachable ! ( )
612626 }
Original file line number Diff line number Diff line change @@ -362,6 +362,11 @@ impl ElectrumApi for Client {
362362 impl_inner_call ! ( self , server_features)
363363 }
364364
365+ #[ inline]
366+ fn mempool_get_info ( & self ) -> Result < MempoolInfoRes , Error > {
367+ impl_inner_call ! ( self , mempool_get_info)
368+ }
369+
365370 #[ inline]
366371 fn ping ( & self ) -> Result < ( ) , Error > {
367372 impl_inner_call ! ( self , ping)
Original file line number Diff line number Diff line change @@ -1228,6 +1228,17 @@ impl<T: Read + Write> ElectrumApi for RawClient<T> {
12281228 Ok ( serde_json:: from_value ( result) ?)
12291229 }
12301230
1231+ fn mempool_get_info ( & self ) -> Result < MempoolInfoRes , Error > {
1232+ let req = Request :: new_id (
1233+ self . last_id . fetch_add ( 1 , Ordering :: SeqCst ) ,
1234+ "mempool.get_info" ,
1235+ vec ! [ ] ,
1236+ ) ;
1237+ let result = self . call ( req) ?;
1238+
1239+ Ok ( serde_json:: from_value ( result) ?)
1240+ }
1241+
12311242 fn ping ( & self ) -> Result < ( ) , Error > {
12321243 let req = Request :: new_id (
12331244 self . last_id . fetch_add ( 1 , Ordering :: SeqCst ) ,
@@ -1276,6 +1287,16 @@ mod test {
12761287 assert_eq ! ( resp. pruning, None ) ;
12771288 }
12781289
1290+ #[ test]
1291+ fn test_mempool_get_info ( ) {
1292+ let client = get_test_client ( ) ;
1293+
1294+ let resp = client. mempool_get_info ( ) . unwrap ( ) ;
1295+ assert ! ( resp. mempoolminfee >= 0.0 ) ;
1296+ assert ! ( resp. minrelaytxfee >= 0.0 ) ;
1297+ assert ! ( resp. incrementalrelayfee >= 0.0 ) ;
1298+ }
1299+
12791300 #[ test]
12801301 #[ ignore = "depends on a live server" ]
12811302 fn test_batch_response_ordering ( ) {
Original file line number Diff line number Diff line change @@ -235,6 +235,21 @@ impl<'de> Deserialize<'de> for ServerVersionRes {
235235 }
236236}
237237
238+ /// Response to a [`mempool_get_info`](../client/struct.Client.html#method.mempool_get_info) request.
239+ ///
240+ /// Contains information about the current state of the mempool.
241+ #[ derive( Clone , Debug , Deserialize ) ]
242+ pub struct MempoolInfoRes {
243+ /// Dynamic minimum fee rate in BTC/kvB for tx to be accepted given current conditions.
244+ /// The maximum of `minrelaytxfee` and minimum mempool fee.
245+ pub mempoolminfee : f64 ,
246+ /// Static operator-configurable minimum relay fee for transactions, in BTC/kvB.
247+ pub minrelaytxfee : f64 ,
248+ /// Static operator-configurable minimum fee rate increment for mempool limiting or
249+ /// replacement, in BTC/kvB.
250+ pub incrementalrelayfee : f64 ,
251+ }
252+
238253/// Response to a [`block_headers`](../client/struct.Client.html#method.block_headers) request.
239254#[ derive( Clone , Debug , Deserialize ) ]
240255pub struct GetHeadersRes {
You can’t perform that action at this time.
0 commit comments