Skip to content

Address all TODO in v24 #308

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 6 commits into from
Jul 24, 2025
Merged

Conversation

jamillambert
Copy link
Collaborator

@jamillambert jamillambert commented Jul 22, 2025

Go through all the TODO in the v24 types table. Add all the missing RPCs.

  • Add gettxspendingprevout method, model and test
  • Add sendall method, model and test
  • Increase client timeout - The migratewallet RPC call takes about 30sec on v24, it's a lot faster on v29. The default timeout was 15sec, increase it to 60 to prevent the timeout during testing. To quote Core "This RPC may take a long time to complete. Increasing the RPC client timeout is recommended."
  • Add migratewallet method, and test - The help says that passphrase is required in v24, but it isn't. The optional argument wallet_name was required for testing. There is nothing to model so the types table was updated accordingly.
  • Add simulaterawtransaction method, model and test - The help says that the rawtxs are optional, but they
    are required for testing or nothing is simulated.
  • Run the formatter

Comment on lines 203 to 208
pub struct GetTxSpendingPrevoutInput {
/// The transaction id.
pub txid: Txid,
/// The output number.
pub vout: u32,
}
Copy link
Member

Choose a reason for hiding this comment

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

In 5579b79

This is the same as a bitcoin::OutPoint - we can use that instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 638 to 641
/// The transaction id of the checked output.
pub txid: Txid,
/// The vout value of the checked output.
pub vout: u32,
Copy link
Member

Choose a reason for hiding this comment

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

Might be able to use an OutPoint here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


impl GetTxSpendingPrevoutItem {
/// Converts version specific type to a version nonspecific, more strongly typed type.
pub fn into_model(self) -> Result<model::GetTxSpendingPrevoutItem, hex::HexToArrayError> {
Copy link
Member

Choose a reason for hiding this comment

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

Whilst this is correct it would be nicer, and more inline with the rest of the crate (I hope) to have a custom error here with two variants, one for each conversion that can fail. If there are other places that do this sort of thing already then feel free to be lazy and leave it as is. If you do chose that can you write an issue explaining the lazy choice please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made the custom error with two variants.

Comment on lines 108 to 111
let spending_txid = match self.spending_txid {
Some(id) => Some(id.parse::<Txid>()?),
None => None,
};
Copy link
Member

Choose a reason for hiding this comment

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

Just FYI this can probably be done more cleanly using map, pretty sure linter should fire for this 'manual implementation of map' or some such error. If not we may not have the linter configured as tightly as in rust-bitcoin.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

macro_rules! impl_client_v24__send_all {
() => {
impl Client {
pub fn send_all(&self, recipients: &[String]) -> Result<SendAll> {
Copy link
Member

Choose a reason for hiding this comment

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

Would be nicer to use Address than String unless there is some specific reason not to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 669 to 671
let recipients = vec![address.to_string()];

let json: SendAll = node.client.send_all(&recipients).expect("sendall");
Copy link
Member

Choose a reason for hiding this comment

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

We can probably just use &[address] inline in send_all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines +154 to +155
let hex =
self.hex.as_ref().map(|h| encode::deserialize_hex(h)).transpose().map_err(E::Hex)?;
Copy link
Member

Choose a reason for hiding this comment

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

This line is changed in fd06f28 but that patch is unrelated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to the correct commit

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.

Reviewed 1de8ce4

Add the struct for the RPC, the model, client macro,
reexports and test.
Add the struct, model, client macro, reexports and test.
New RPC migratewallet takes around 30sec to complete and the client
times out first.

Increase the timeout from default of 15sec to 60sec.
Add the struct, client macro, reexports and test.

No model is required, change the types table to `version`, update verify
and remove TODO.
Add the struct, client macro, model, reexports and test.
Reordering of reexports alphabetically, no other changes.
@jamillambert
Copy link
Collaborator Author

Suggested changes all made.

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 78cbbdc

@tcharding tcharding merged commit b6d31ec into rust-bitcoin:master Jul 24, 2025
30 checks passed
Comment on lines +22 to +25
serde_json::json!({
"txid": out.txid.to_string(),
"vout": out.vout,
})
Copy link
Member

Choose a reason for hiding this comment

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

Something is odd here, we should be able to use into_json(out).

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