Skip to content

Implement settxfee method and test #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

GideonBature
Copy link
Contributor

The JSON-RPC method settxfee does return a type. We want to test this to catch any changes in behavior in future Core versions.

This PR adds a client function that errors if the return value is anything other than the type it returns, along with an integration test that calls this function.

Ref: #116

() => {
impl Client {
pub fn set_tx_fee(&self, fee_rate: bitcoin::FeeRate) -> Result<SetTxFee> {
let fee_rate_btc_kvb = fee_rate.to_sat_per_vb_floor() as f64 / 100_000.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct and drinks on me because you found an API hole in rust-bitcoin. See rust-bitcoin/rust-bitcoin#4688 if you are interested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woaw, interesting, reading through the issue and conversations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly copilot picked this out as an issue with the PR: although mathematically correct, it says "rust-bitcoin does not provide a safe, explicit conversion between FeeRate and the units expected by Core's settxfee". It managed to actually look at the referenced issue and give a sane answer. It has improved even in the last 6 months. Still can't trust it though 😊.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mad, keep me posted of any AI wins please. I"m a bit of a ludite and I don't want to fall too far behind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly copilot picked this out as an issue with the PR: although mathematically correct, it says "rust-bitcoin does not provide a safe, explicit conversion between FeeRate and the units expected by Core's settxfee". It managed to actually look at the referenced issue and give a sane answer. It has improved even in the last 6 months. Still can't trust it though 😊.

Woah, that’s cool. They’ve definitely come a long way...

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rebase mate.

Reviewed: ab928fa

Improve test expect message
@GideonBature
Copy link
Contributor Author

rebased and worked on the suggestion given.

Copy link
Collaborator

@jamillambert jamillambert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 52e1b53

() => {
impl Client {
pub fn set_tx_fee(&self, fee_rate: bitcoin::FeeRate) -> Result<SetTxFee> {
let fee_rate_btc_kvb = fee_rate.to_sat_per_vb_floor() as f64 / 100_000.0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly copilot picked this out as an issue with the PR: although mathematically correct, it says "rust-bitcoin does not provide a safe, explicit conversion between FeeRate and the units expected by Core's settxfee". It managed to actually look at the referenced issue and give a sane answer. It has improved even in the last 6 months. Still can't trust it though 😊.

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 52e1b53

@tcharding tcharding merged commit 9b7b9b0 into rust-bitcoin:master Jul 10, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants