Skip to content

Add support for bitcoin core 29.0 #131

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GideonBature
Copy link
Contributor

@GideonBature GideonBature commented Apr 19, 2025

This PR adds support for the newly released bitcoin core version - v29.0

Updated RPCs

  • Implement getmininginfo which now returns nBits and the current target in the target field. It also returns a next object which specifies the height, nBits, difficulty, and target for the next block. (test added)
  • Implement getblock and getblockheader which now return the current target in the target field (test added)
  • Implement getblockchaininfo and getchainstates which now return nBits and the current target in the target field. (test added)
  • Implement getblocktemplate whose RPC curtime (BIP22) and mintime (BIP23) fields now account for the timewarp fix proposed in BIP94 on all networks. (test added)

New RPCs

  • Implement getdescriptoractivity rpc method which can be used to find all spend/receive activity relevant to a given set of descriptors within a set of specified blocks. (test added)

Closes #129

@GideonBature GideonBature force-pushed the support-29.0 branch 4 times, most recently from 5438355 to 1dbf4df Compare April 19, 2025 18:15
@tcharding
Copy link
Member

CI fail can be fixed by creating the RPC help file, I haven't downloaded Core v29 yet but I'd expect that on this branch we could do:

contrib/run-bitcoind.sh start v29
bt29 help > verify/rpc-api-v29.txt

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.

Man this is looking pretty good! This crate is hard to work on so don't feel bad if you miss things. I'm having a hard time reviewing because the changeset is so big but I've left a few comments that will make it a fair bit smaller. Keep at it! Appreciate your effort.

@GideonBature
Copy link
Contributor Author

CI fail can be fixed by creating the RPC help file, I haven't downloaded Core v29 yet but I'd expect that on this branch we could do:

contrib/run-bitcoind.sh start v29
bt29 help > verify/rpc-api-v29.txt

I tried running the command after starting the bitcoind v29, but it keeps say the bt29 command not found, checked the repository to see if I can get anything that relates to that, but didn't find any...

@GideonBature GideonBature force-pushed the support-29.0 branch 2 times, most recently from dc856f3 to 3c6c22f Compare April 22, 2025 20:08
@tcharding
Copy link
Member

Oh I have a shell alias for each version, for v28 I have

bt28: aliased to bitcoin-cli -rpcconnect=localhost:28049 -rpcuser=*** -rpcpassword=***

And fill in the stars for your setup. Remember the leading 280 comes from the config file of .run-bitcoind.conf

@GideonBature
Copy link
Contributor Author

Oh I have a shell alias for each version, for v28 I have

bt28: aliased to bitcoin-cli -rpcconnect=localhost:28049 -rpcuser=*** -rpcpassword=***

And fill in the stars for your setup. Remember the leading 280 comes from the config file of .run-bitcoind.conf

Thank you... It's done!

@GideonBature GideonBature force-pushed the support-29.0 branch 2 times, most recently from 798a62e to 2308f10 Compare April 23, 2025 05:19
@GideonBature GideonBature force-pushed the support-29.0 branch 2 times, most recently from 20080f5 to 87a78dd Compare April 28, 2025 15:15
@tcharding
Copy link
Member

Can you get rid of all the formatting changes please.

@GideonBature GideonBature force-pushed the support-29.0 branch 2 times, most recently from fb921bd to 5709498 Compare April 29, 2025 16:46
@GideonBature
Copy link
Contributor Author

Can you get rid of all the formatting changes please.

Done!

@GideonBature GideonBature force-pushed the support-29.0 branch 3 times, most recently from fa9350a to 1db66bf Compare April 29, 2025 17:13
@tcharding
Copy link
Member

It is surprising to see changes to types modules for any version other than v29. There are changes to v17. Please either remove them or justify why the changes are made.

@GideonBature
Copy link
Contributor Author

It is surprising to see changes to types modules for any version other than v29. There are changes to v17. Please either remove them or justify why the changes are made.

Alright, so for v29, the getblocktemplate returns a Target field, in that case, I saw that v17 already has the getblocktemplate error, thus, I decided to add the target field Error variant to it so I could just reuse it for v29 instead of implementing the same thing for v29... I don't know if that counts... That was the reason why I added the additional field, but if it doesn't align with how the codebase is supposed to be, I can revert it back to it's original form and re-implement the error for v29 with target field....

@tcharding
Copy link
Member

Yes please. Anything that is different in one version to another should have a separate type, errors included. I'm not totally convince that we should re-use errors at all but we already do in submitpackage IIRC and its kinda nice.

@GideonBature
Copy link
Contributor Author

Yes please. Anything that is different in one version to another should have a separate type, errors included. I'm not totally convince that we should re-use errors at all but we already do in submitpackage IIRC and its kinda nice.

Alright, noted, I am going to do that right away...

@GideonBature GideonBature force-pushed the support-29.0 branch 4 times, most recently from 3daa910 to f9e0d08 Compare May 1, 2025 21:45
@tcharding
Copy link
Member

Can you add support to the run-bitcoind.sh script for running v29 as well mate?

@tcharding
Copy link
Member

I just merged #142 so the docs format in v29/mod.rs will need updating in this PR.

@GideonBature
Copy link
Contributor Author

Can you add support to the run-bitcoind.sh script for running v29 as well mate?

Definitely, although from how the script is, except I add it to the examples there, by default it should work with v29 if it is indicated in the config file.

@GideonBature
Copy link
Contributor Author

I just merged #142 so the docs format in v29/mod.rs will need updating in this PR.

Noted!

@tcharding
Copy link
Member

Can you add support to the run-bitcoind.sh script for running v29 as well mate?

Definitely, although from how the script is, except I add it to the examples there, by default it should work with v29 if it is indicated in the config file.

oooo, my bad I ran contrib/run-bitcoind.sh v29 (missing start) and from the error assumed we need to add something. Appologies.

@tcharding
Copy link
Member

tcharding commented May 2, 2025

Needs a CI job man in the Integration job add a feature).

@tcharding
Copy link
Member

tcharding commented May 2, 2025

If you run cd verify; cargo run -- v29 we get these warnings

Checking that the status claimed in the version specific rustdocs is correct ... 
missing model type: dumpwallet DumpWallet
missing return type: signrawtransactionwithwallet SignRawTransactionWithWallet
missing model type: signrawtransactionwithwallet SignRawTransactionWithWallet

Looks like the Method constructor on DumpWallet is wrong, I'll let you debug the other one.

@GideonBature
Copy link
Contributor Author

Needs a CI job man in the Integration job add a feature).

If you run cd verify; cargo run -- v29 we get these warnings

Checking that the status claimed in the version specific rustdocs is correct ... 
missing model type: dumpwallet DumpWallet
missing return type: signrawtransactionwithwallet SignRawTransactionWithWallet
missing model type: signrawtransactionwithwallet SignRawTransactionWithWallet

Looks like the Method constructor on DumpWallet is wrong, I'll let you debug the other one.

Thank you for pointing this out, for the signrawtransactionwithwallet, I missed the type, instead of SignRawTransaction, I used SignRawTransactionWithWallet.

@tcharding
Copy link
Member

verify is useful huh

@GideonBature
Copy link
Contributor Author

Needs a CI job man in the Integration job add a feature).

Please I need more clarity on this... I added v29_0 in the rust.yaml in the .github directory, I don't know if it's same with what you are requesting for...

@GideonBature
Copy link
Contributor Author

verify is useful huh

Very useful.

@tcharding
Copy link
Member

On this branch are you able to run the v29 nodes with contrib/run-bitcoind.sh and then hit an RPC endpoint? I"m not able to run bitcoin-cli -rpcconnect=localhost:29049 -rpcuser=user -rpcpassword=password help . I can start the nodes but get

bt29 help
error: timeout on transient error: Could not connect to the server localhost:29049 (error code 2 - "error while reading header, or invalid header")

@tcharding
Copy link
Member

Can you please update verify/src/method/v29.rs to match what was done in #140


/// Arg for the `getblocktemplate` method. (v29+).
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct TemplateRequestV29 {
Copy link
Member

Choose a reason for hiding this comment

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

This guy should be in v29/mod.rs (see how we handle AddressType in v17 and v23). You'll need to move the other one and remove the V29 from the type name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, noted...

Copy link
Contributor Author

@GideonBature GideonBature May 5, 2025

Choose a reason for hiding this comment

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

I will open another PR that will address moving the one for v17.

@tcharding
Copy link
Member

On further thought, so that I have a chance of reviewing this with more accuracy can you please split it up so that the first patch adds support for v29 putting 'TODO' for all the new methods. The add the methods as separate patches, either one per method if they are big or all together if it looks easy enough to review. Thanks man.

@GideonBature
Copy link
Contributor Author

GideonBature commented May 5, 2025

On this branch are you able to run the v29 nodes with contrib/run-bitcoind.sh and then hit an RPC endpoint? I"m not able to run bitcoin-cli -rpcconnect=localhost:29049 -rpcuser=user -rpcpassword=password help . I can start the nodes but get

bt29 help
error: timeout on transient error: Could not connect to the server localhost:29049 (error code 2 - "error while reading header, or invalid header")

woaw. I was able to run the command from my own end. That was what I used to generate the rpc-api txt file for v29. I was also able to run the script for v29 successfully... But I will check it again...

@GideonBature
Copy link
Contributor Author

Can you please update verify/src/method/v29.rs to match what was done in #140

Done, I observed something, there were no division for util and signer.

@GideonBature
Copy link
Contributor Author

On further thought, so that I have a chance of reviewing this with more accuracy can you please split it up so that the first patch adds support for v29 putting 'TODO' for all the new methods. The add the methods as separate patches, either one per method if they are big or all together if it looks easy enough to review. Thanks man.

Alright, there is only one new method for v29, which is the getdescriptoractivity, the other methods just had additional fields to the existing ones. Should I still go ahead with the split?

@tcharding
Copy link
Member

tcharding commented May 5, 2025

oh bother, that's not worth the effort splitting man. Leave it as is, I'll work through it. My bad.

@tcharding
Copy link
Member

What's the status of this bro? The client still has methods in that are not needed.

@GideonBature
Copy link
Contributor Author

What's the status of this bro? The client still has methods in that are not needed.

Yes, I want to create another PR to move the other ones out of client to where they belong in v17/mod.rs reason been that those where not part of this PR, the one that is part of this PR has been moved, already... So I will open another PR to move the other one as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Bitcoin Core 29.0
2 participants