You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type discrepancy between corepc-types and Bitcoin Core #429
I'm not sure if the types in corepc-types are supposed to faithfully match what Bitcoin Core RPC returns, but I noticed a discrepancy with tx_rate in GetChainTxStats. Bitcoin Core returns txrate as a double value (and has since the RPC was introduced in v0.15 PR #9733):
{
"txrate": 5.153020888909642
}
The current types use i64 in the JSON structs and u32 in the model, yet f64 should be used if matching Bitcoin Core's output type is the goal?
I understand that this is a breaking change to the interface that people might already be using so wanted to raise it as an issue first before doing anything further.
And, in general, is the intent for the types to always match Bitcoin Core?
I found this as I was looking to extend some of the RPC extraction functionality being built out in peer-observer
Ok I have found a few other type inconsistencies tangential to my peer-observer related work.
Me and my mate Claude hacked together an audit tool to uncover any similar inconsistencies between Bitcoin Core's RPC types and corepc's Rust types across all supported versions (v17-v30).
The first three are the same pattern - Bitcoin Core returns double but corepc uses integer types, causing deserialisation failures. The last one is a width mismatch (u32 vs u64) - unlikely to cause issues in practice but worth fixing for correctness.
Nice work, after seeing your first PR on it we planned to look for other cases.
I am intending to open separate PRs to fix each?
It's up to you, separate or all in one, either is fine.
I haven't finished reviewing #431, but one comment that applies to all these is that in general it's better to fix the existing test of the RPC to check the type instead of adding a second one. Unless of course there is a real need to have two.
While reviewing #440 it became clear that basically any int field we have in types is potentially wrong if the integration test gets back JSON from Core that has the field set to 0.
While reviewing #440 it became clear that basically any int field we have in types is potentially wrong if the integration test gets back JSON from Core that has the field set to 0.
Does this mean there should be more use of node.fund_wallet() or other means to ensure some value initialisation in integration tests (where appropriate)?
What ever means necessary to ensure non-zero values. I think the easiest way is to work on testing this repo with all the same tests that Core uses for testing the RPC code. I thought we had an issue for that but I couldn't find it.
Basically the idea is to come up with a way to pull all the python test code out of Core and use it here to test our serde logic instead of actually hitting a Core node.
But just going through and adding fund_wallet() wouldn't hurt. Perhaps we can add this as part of the wallet creation logic? (Just an idea, I didn't look at the code just now.)
Activity
tcharding commentedon Dec 16, 2025
Thanks for the issue!
corepc-typesdefinitely should match what Core returns, you found a bug! I'll happily review any PRs you raise.deadmanoz commentedon Dec 16, 2025
No problem, I will open PR
0xB10C commentedon Dec 16, 2025
for reference, PR is #430
deadmanoz commentedon Dec 17, 2025
Ok I have found a few other type inconsistencies tangential to my peer-observer related work.
Me and my mate Claude hacked together an audit tool to uncover any similar inconsistencies between Bitcoin Core's RPC types and
corepc's Rust types across all supported versions (v17-v30).getchaintxstats.txrateshould bef64getmininginfo.networkhashpsshould bef64decodepsbt.feeshould bef64decodepsbt.psbt_versionshould beu64The first three are the same pattern - Bitcoin Core returns
doublebutcorepcuses integer types, causing deserialisation failures. The last one is a width mismatch (u32vsu64) - unlikely to cause issues in practice but worth fixing for correctness.I am intending to open separate PRs to fix each?
jamillambert commentedon Dec 17, 2025
Nice work, after seeing your first PR on it we planned to look for other cases.
It's up to you, separate or all in one, either is fine.
I haven't finished reviewing #431, but one comment that applies to all these is that in general it's better to fix the existing test of the RPC to check the type instead of adding a second one. Unless of course there is a real need to have two.
tcharding commentedon Dec 29, 2025
@deadmanoz legendary, thanks for the help man!
tcharding commentedon Dec 30, 2025
While reviewing #440 it became clear that basically any int field we have in
typesis potentially wrong if the integration test gets back JSON from Core that has the field set to 0.ref: #440 (comment)
Merge #431: fix(types): use f64 for DecodePsbt fee field
deadmanoz commentedon Dec 31, 2025
Good point..
Does this mean there should be more use of
node.fund_wallet()or other means to ensure some value initialisation in integration tests (where appropriate)?tcharding commentedon Jan 1, 2026
What ever means necessary to ensure non-zero values. I think the easiest way is to work on testing this repo with all the same tests that Core uses for testing the RPC code. I thought we had an issue for that but I couldn't find it.
Basically the idea is to come up with a way to pull all the python test code out of Core and use it here to test our serde logic instead of actually hitting a Core node.
But just going through and adding
fund_wallet()wouldn't hurt. Perhaps we can add this as part of the wallet creation logic? (Just an idea, I didn't look at the code just now.)Merge #440: fix(types): use f64 for GetMiningInfo networkhashps field
jamillambert commentedon Sep 1, 2026
Issue moved to Forgejo: https://gitea.bitcoin.ninja/rust-bitcoin/corepc/issues/429