bitcoin icon indicating copy to clipboard operation
bitcoin copied to clipboard

scripted-diff: Update DeriveType enum values to mention ranged derivations

Open rkrux opened this issue 5 months ago • 1 comments
trafficstars

While reviewing the MuSig2 descriptors PR #31244, I realized that the enum DeriveType here logically refers to the derive type for ranged descriptors. This became evident to me while going through the implementations of IsRanged & IsHardened functions of BIP32PubkeyProvider, and the ParsePubkeyInner function. Initially I got confused by reading IsRange translating to != DeriveType::NO, but later realised it specifically referred to the presence of ranged derivations. I propose explicitly mentioning "ranged" in the values of the DeriveType enum would make it easier to parse the descriptors code.

This enum is used in one file only - script/descriptors.cpp. That's why I explicitly passed it as the argument in the sed command in the script below.

-BEGIN VERIFY SCRIPT- sed -i 's/HARDENED/HARDENED_RANGED/g' src/script/descriptor.cpp sed -i 's/NO,/NON_RANGED,/g' src/script/descriptor.cpp sed -i 's/DeriveType::NO/DeriveType::NON_RANGED/g' src/script/descriptor.cpp -END VERIFY SCRIPT-

rkrux avatar Jun 13 '25 10:06 rkrux

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32745.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK l0rinc
Stale ACK hodlinator, PeterWrighten

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

DrahtBot avatar Jun 13 '25 10:06 DrahtBot

Concept ACK d60b008 It's a good refactoring for understanding, but perhaps you should still check and modify other documents to make sure it would not missing the explanation of this change in them.

Yes, I had confirmed regarding this, and I did add a note in the commit message & the PR description that all these enum values are contained within one file only.

rkrux avatar Jun 16 '25 07:06 rkrux

Concept ACK, didn't review it very thoroughly - ping me if you need a full review

l0rinc avatar Jun 16 '25 10:06 l0rinc

Rebased over master to incorporate changes from #31244.

rkrux avatar Aug 01 '25 12:08 rkrux