Skip to content

Upgrade to soon-to-be-released bitcoin#528

Draft
tcharding wants to merge 2 commits intorust-bitcoin:masterfrom
tcharding:push-ttwqxqrtktxl
Draft

Upgrade to soon-to-be-released bitcoin#528
tcharding wants to merge 2 commits intorust-bitcoin:masterfrom
tcharding:push-ttwqxqrtktxl

Conversation

@tcharding
Copy link
Member

@tcharding tcharding commented Mar 4, 2026

Upgrade to the upcoming bitcoin beta release (master branch of bitcoin with a few PRs merged in: #5704, #5657, and #5710).

Expect all red in CI. Locally, with the bitcoin branch available, I can run the integration tests (with test17 and test29).

@tcharding tcharding requested a review from jamillambert as a code owner March 4, 2026 03:10
@tcharding tcharding marked this pull request as draft March 4, 2026 03:11
@tcharding tcharding changed the title Upgrade bitcoin dependency Upgrade to bitcoin-0.33.0-beta++ dependency Mar 4, 2026
@tcharding tcharding changed the title Upgrade to bitcoin-0.33.0-beta++ dependency Upgrade to soon-to-be-released bitcoin Mar 4, 2026
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.

I assume the first patch ignoring the .claude folder is for your local dev only and you didn't want to use a global ignore.

I couldn't find the branch on your rust-bitcoin fork that you were using. I used instead the current master with the PRs you listed added. But then I had to change HeaderDecoderError and TransactionDecoderError to be wrapped in DecodeError.

After I did that it builds and the tests all pass. Besides the points below it all looks good.

pub average_fee: Amount,
/// Average feerate.
pub average_fee_rate: Option<FeeRate>,
pub average_fee_rate: FeeRate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This field and some of the others changed are optional in v25. Why the removal of Option?

Edit: I realised it was removed due to the change in the return type in rust-bitcoin. But it highlights an existing error that it, in fact all fields in the v25 GetBlockStats are optional. Opened #530

/// Models the result of JSON-RPC method `getblockstats`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
// #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
// FIMXE: How do we serde a `Vec<FeeRate>`?
Copy link
Collaborator

Choose a reason for hiding this comment

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

AI says you can use a helper and gave the below, it is possible to use the existing bitcoin::fee_rate::serde::as_sat_per_vb_floor but still needs a helper for the vec.

mod fee_rate_vec_serde {
    use bitcoin::FeeRate;
    use serde::{Deserialize, Deserializer, Serialize, Serializer};

    pub fn serialize<S>(rates: &Vec<FeeRate>, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer,
    {
        let sats: Vec<u64> = rates.iter().map(|rate| rate.to_sat_per_vb_floor()).collect();
        sats.serialize(serializer)
    }

    pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<FeeRate>, D::Error>
    where
        D: Deserializer<'de>,
    {
        let sats = Vec::<u32>::deserialize(deserializer)?;
        Ok(sats.into_iter().map(FeeRate::from_sat_per_vb).collect())
    }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes, I didn't know that at the time I wrote the comment. I actually added this sort of thing in rust-bitcoin/rust-bitcoin#5704

I'm not sure if we should push Vec support upstream for all the types that currently have serde support as modules (ie Amount). Or just hack it in here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it makes more sense to have them upstream, I don't see the downside and it then enables it for everyone.

Opened: rust-bitcoin/rust-bitcoin#5786

let bytes = bitcoin::hex::decode_to_vec(sig).map_err(E::Hex)?;
let (sighash_byte, signature) = bytes.split_last().ok_or(E::EmptySignature)?;
Ok(Signature {
signature: secp256k1::schnorr::Signature::from_slice(signature)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lint warning:
warning: use of deprecated associated function `bitcoin::secp256k1::schnorr::Signature::from_slice`: Use `from_byte_array` instead

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this is non-trivial to remove so I just left it in for now.

let bytes = bitcoin::hex::decode_to_vec(sig).map_err(E::Hex)?;
let (sighash_byte, signature) = bytes.split_last().ok_or(E::EmptySignature)?;
Ok(Signature {
signature: secp256k1::schnorr::Signature::from_slice(signature)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lint warning:
warning: use of deprecated associated function `bitcoin::secp256k1::schnorr::Signature::from_slice`: Use `from_byte_array` instead

average_fee: Amount::from_sat(self.average_fee),
average_fee_rate,
average_fee: Amount::from_sat(self.average_fee).expect("TODO: Handle this error"),
average_fee_rate: average_fee_rate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
average_fee_rate: average_fee_rate,
average_fee_rate,

Was this change left over from a previous revision? there is no need for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure, thanks man. I wasn't expecting such a thorough review. Appreciate it!

@@ -0,0 +1,72 @@
// SPDX-License-Identifier: CC0-1.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file was removed intentionally on master.

Copy link
Member Author

Choose a reason for hiding this comment

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

Woops.

@tcharding
Copy link
Member Author

I assume the first patch ignoring the .claude folder is for your local dev only and you didn't want to use a global ignore.

Oh that is sloppy of me, will remove.

I couldn't find the branch on your rust-bitcoin fork that you were using. I used instead the current master with the PRs you listed added. But then I had to change HeaderDecoderError and TransactionDecoderError to be wrapped in DecodeError.

After I did that it builds and the tests all pass. Besides the points below it all looks good.

My bad, I never pushed the branch. I only added the three PRs and didn't have to touch the decoder errors from memory. I"ll investigate. Thanks for going to the trouble of building this, I did not expect that. Pleasant surprise.

Upgrade to the upcoming bitcoin beta release. This is a local branch
with a few PRs merged as described in

  rust-bitcoin/rust-bitcoin#5742
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.

2 participants