Skip to content

Commit 774a655

Browse files
committed
Merge #531: [client]: Add estimate_smart_fee_with_mode call
5ef6ba1 feat: Add estimate_smart_fee_with_mode call (Maycon Fabio) Pull request description: While I was working on peer-observer/peer-observer#362, I realized that corepc `estimatesmartfee` call was missing an optional param which is the `estimate_mode`. This PR creates a "secondary" method that also accepts an enum for `estimate_mode`, filling this gap for the method. I ran the integration test that I created with all versions of bitcoin core from `v0.17` to `v30.2`, except `v30.0` which I didn't find the binaries, but I suppose it still works. I tried to understand/follow the repo pattern, so let me know if anything is out of place. This is my first PR to corepc, so any feedback is welcome ^^. ACKs for top commit: tcharding: ACK 5ef6ba1 Tree-SHA512: 738b1a5fc59782fe934e7f413a0840248eabe6965bbe12807de1fcd70f0bcadd39db74824e3811e0e62f759839918ee6316988358b95b18163747a289c10cb33
2 parents 36eeb7d + 5ef6ba1 commit 774a655

16 files changed

Lines changed: 55 additions & 14 deletions

File tree

client/src/client_sync/v17/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,15 @@ impl Serialize for ImportMultiTimestamp {
321321
}
322322
}
323323
}
324+
325+
/// Arg for the `estimatesmartfee` method.
326+
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
327+
#[serde(rename_all = "UPPERCASE")]
328+
pub enum FeeEstimateMode {
329+
/// Use default settings based on other criteria
330+
Unset,
331+
/// Force estimatesmartfee to use non-conservative estimates
332+
Economical,
333+
/// Force estimatesmartfee to use conservative estimates
334+
Conservative,
335+
}

client/src/client_sync/v17/util.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ macro_rules! impl_client_v17__estimate_smart_fee {
3333
pub fn estimate_smart_fee(&self, blocks: u32) -> Result<EstimateSmartFee> {
3434
self.call("estimatesmartfee", &[blocks.into()])
3535
}
36+
37+
pub fn estimate_smart_fee_with_mode(
38+
&self,
39+
blocks: u32,
40+
mode: FeeEstimateMode,
41+
) -> Result<EstimateSmartFee> {
42+
self.call("estimatesmartfee", &[blocks.into(), into_json(mode)?])
43+
}
3644
}
3745
};
3846
}

client/src/client_sync/v18/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::types::v18::*;
2424
pub use crate::client_sync::{
2525
v17::{
2626
AddNodeCommand, AddressType, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, TemplateRequest,
27-
TemplateRules, WalletCreateFundedPsbtInput,
27+
TemplateRules, WalletCreateFundedPsbtInput, FeeEstimateMode,
2828
},
2929
};
3030

client/src/client_sync/v19/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::types::v19::*;
2020
pub use crate::client_sync::{
2121
v17::{
2222
AddNodeCommand, AddressType, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, TemplateRequest,
23-
TemplateRules, WalletCreateFundedPsbtInput,
23+
TemplateRules, WalletCreateFundedPsbtInput, FeeEstimateMode,
2424
},
2525
};
2626

client/src/client_sync/v20/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::types::v20::*;
2020
pub use crate::client_sync::{
2121
v17::{
2222
AddressType, AddNodeCommand, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, TemplateRequest, TemplateRules,
23-
WalletCreateFundedPsbtInput,
23+
WalletCreateFundedPsbtInput, FeeEstimateMode,
2424
},
2525
};
2626

client/src/client_sync/v21/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::types::v21::*;
2424
pub use crate::client_sync::{
2525
v17::{
2626
AddNodeCommand, AddressType, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, TemplateRequest,
27-
TemplateRules, WalletCreateFundedPsbtInput,
27+
TemplateRules, WalletCreateFundedPsbtInput, FeeEstimateMode,
2828
},
2929
};
3030

client/src/client_sync/v22/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::types::v22::*;
2121
pub use crate::client_sync::{
2222
v17::{
2323
AddNodeCommand, AddressType, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, TemplateRequest,
24-
TemplateRules, WalletCreateFundedPsbtInput,
24+
TemplateRules, WalletCreateFundedPsbtInput, FeeEstimateMode,
2525
},
2626
v21::ImportDescriptorsRequest,
2727
};

client/src/client_sync/v23/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::types::v23::*;
2121
pub use crate::client_sync::{
2222
v17::{
2323
AddNodeCommand, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, TemplateRequest, TemplateRules,
24-
WalletCreateFundedPsbtInput,
24+
WalletCreateFundedPsbtInput, FeeEstimateMode,
2525
},
2626
v21::ImportDescriptorsRequest,
2727
};

client/src/client_sync/v24/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::types::v24::*;
2020
pub use crate::client_sync::{
2121
v17::{
2222
AddNodeCommand, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, TemplateRequest, TemplateRules,
23-
WalletCreateFundedPsbtInput,
23+
WalletCreateFundedPsbtInput, FeeEstimateMode,
2424
},
2525
v21::ImportDescriptorsRequest,
2626
v23::AddressType,

client/src/client_sync/v25/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::types::v25::*;
2020
pub use crate::client_sync::{
2121
v17::{
2222
AddNodeCommand, ImportMultiRequest, ImportMultiScriptPubKey, ImportMultiTimestamp, Input, Output, SetBanCommand, TemplateRequest, TemplateRules,
23-
WalletCreateFundedPsbtInput,
23+
WalletCreateFundedPsbtInput, FeeEstimateMode,
2424
},
2525
v21::ImportDescriptorsRequest,
2626
v23::AddressType,

0 commit comments

Comments
 (0)