Skip to content

Conversation

@natobritto
Copy link
Contributor

The RPC has missing fields which are enabled only when coinstatsindex option is called or muhash hash type is used. Argument list is also added to header comment.

Partially fixes issue #474.

jamillambert
jamillambert previously approved these changes Jan 27, 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.

ACK d776988

/// The total amount.
pub total_amount: Amount,
/// The serialized hash (only present if 'muhash' hash_type is chosen).
pub muhash: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

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

Which hash algo is used? We can use a concrete type if we know the algo. Is it SHA256?

lolz, I see we have a FIXME already in the code asking this same question for hash_serialized_2.

So can you either add a FIXME to this line and hash_serialized_3 or work out an answer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The algorithm is MuHash3072, which from what I understand is like a bucket of hashes. There are libraries that could handle MuHash such as google/rust-multihash (discontinued) or kaspa_muhash. I don't really know how to work with MuHash, or want to include a unknown library in types crate, I decided to put a FIXME there.

Copy link
Member

Choose a reason for hiding this comment

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


/// Detailed block-level info. Part of `gettxoutsetinfo`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct BlockInfo {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this should be called GetTxOutSetInfoBlockInfo? Since we only have one namespace at the model (and also version specific eg types::v30) level this takes up a name that is quite ambiguous.

Precedent is set by ScanTxOutSetFoo for method scantxoutset.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, my bad this was an oversight. Fixed


/// Categories of unspendable amounts. Part of `gettxoutsetinfo`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct Unspendables {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps same comment as on BlockInfo although 'unspendables' seems less common?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with the prefix, went ahead and also added it here.

UnspendablesUnclaimedRewards(amount::ParseAmountError),
/// Conversion of the `total_unspendable_amount` field failed.
TotalUnspendableAmount(amount::ParseAmountError),
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this error stuff. Including the variants for optional stuff. @jamillambert did we do this before or did we use a nested error type? I can't remember.

Copy link
Contributor Author

@natobritto natobritto Jan 29, 2026

Choose a reason for hiding this comment

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

In v26 there is an example: SubmitPackage (response for RPC) has optional field fees nested within tx_result list, called SubmitPackageTxResultFees, which has errors defined for all its fields too.

Copy link
Member

Choose a reason for hiding this comment

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

Aight, good enough for me. Thanks

Comment on lines 97 to 112
Some(b) => {
let prevout_spent =
Amount::from_btc(b.prevout_spent).map_err(E::PrevoutSpent)?;
let coinbase = Amount::from_btc(b.coinbase).map_err(E::Coinbase)?;
let new_outputs_ex_coinbase = Amount::from_btc(b.new_outputs_ex_coinbase)
.map_err(E::NewOutputsExCoinbase)?;
let unspendable = Amount::from_btc(b.unspendable).map_err(E::Unspendable)?;
let unspendables = model::Unspendables {
genesis_block: Amount::from_btc(b.unspendables.genesis_block)
.map_err(E::UnspendablesGenesisBlock)?,
bip30: Amount::from_btc(b.unspendables.bip30)
.map_err(E::UnspendablesBip30)?,
scripts: Amount::from_btc(b.unspendables.scripts)
.map_err(E::UnspendablesScripts)?,
unclaimed_rewards: Amount::from_btc(b.unspendables.unclaimed_rewards)
.map_err(E::UnspendablesUnclaimedRewards)?,
Copy link
Member

Choose a reason for hiding this comment

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

Can we put all the conversion logic up above the return statement please? I know is subjective but that is how we have done in everywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

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.

Thanks for your work man, this was a big one.

Reviewed: d776988

@tcharding
Copy link
Member

tcharding commented Jan 29, 2026

You can fix formatting by running just fmt.

The RPC has missing fields which are enabled only when `coinstatsindex`
or muhash hash type is used. Argument list is also added to header coment.
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 01f13a9

@tcharding tcharding merged commit 909850a into rust-bitcoin:master Jan 29, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants