Skip to content
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

Slip132: make x/tpub/prv classified as hash-class keys and add tests #39

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

Conversation

kaiwolfram
Copy link
Contributor

Some tests for the slip132 lib to increase code coverage #11.
I changed from_derivation_path and to_derivation_path because they didn't work with testnet paths.

@codecov-commenter
Copy link

Codecov Report

Merging #39 (6db9eec) into master (b1566e2) will increase coverage by 9.8%.
The diff coverage is 99.4%.

@@           Coverage Diff            @@
##           master     #39     +/-   ##
========================================
+ Coverage    31.1%   40.9%   +9.8%     
========================================
  Files          45      45             
  Lines        4745    5238    +493     
========================================
+ Hits         1478    2144    +666     
+ Misses       3267    3094    -173     
Impacted Files Coverage Δ
hd/src/standards.rs 0.0% <0.0%> (ø)
slip132/src/lib.rs 93.4% <99.8%> (+76.6%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1566e2...6db9eec. Read the comment docs.

Copy link
Member

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

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

Thank you for this huge work! Tests looks good, however one breaking change from treating xpub/tpub types, which will affect all software which already uses this library - descriptors will stop working b/c of it. Pls see my comments and let me know what do you think.

Also, if it is not hard, can you please run cargo +nightly fmt --all and cargo clippy --all to get the CI passing?

@@ -551,7 +542,7 @@ impl VersionResolver for DefaultResolver {
fn application(kv: &KeyVersion) -> Option<Self::Application> {
match kv.as_bytes() {
&VERSION_MAGIC_XPUB | &VERSION_MAGIC_XPRV | &VERSION_MAGIC_TPUB
| &VERSION_MAGIC_TPRV => None,
| &VERSION_MAGIC_TPRV => Some(KeyApplication::Hashed),
Copy link
Member

Choose a reason for hiding this comment

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

The idea with returning None here was the fact that Xpub's and related test types are allowed to be used in descriptors in any context, not just pre-segwit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, thanks for clarifying and sorry for the late reply. Maybe we should add a note to the docs then. Right now it says Returns None if the version is not recognized/unknown to the resolver. Using this library I'd be confused why xpub related types are unknown

Comment on lines -573 to +571
&VERSION_MAGIC_XPUB | &VERSION_MAGIC_XPRV => None,
&VERSION_MAGIC_TPUB | &VERSION_MAGIC_TPRV => None,
&VERSION_MAGIC_XPUB | &VERSION_MAGIC_XPRV => Some(vec![
ChildNumber::Hardened { index: 44 },
ChildNumber::Hardened { index: 0 },
]),
&VERSION_MAGIC_TPUB | &VERSION_MAGIC_TPRV => Some(vec![
ChildNumber::Hardened { index: 44 },
ChildNumber::Hardened { index: 1 },
]),
Copy link
Member

Choose a reason for hiding this comment

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

Ibid

@dr-orlovsky dr-orlovsky mentioned this pull request Jun 30, 2022
@dr-orlovsky
Copy link
Member

I have to release a new 0.8 version today, so I created a PR with a non-breaking subset of your code #41. I am going to merge it - and we can continue discussion whether it is desirable to classify ordinary xpubs/tpubs as belonging to a specific Slip class here and than, if we decide to do so, merge that from this PR into v0.9

@dr-orlovsky dr-orlovsky added this to the v0.9.0 milestone Jun 30, 2022
@dr-orlovsky dr-orlovsky added question Further information is requested *compatibility* Issues affecting compatibility and interoperability test Test implementation or failures labels Jul 2, 2022
@dr-orlovsky dr-orlovsky changed the title Test slip132 lib Slip132: make x/tpub/prv classified as hash-class keys and add tests Jul 2, 2022
@dr-orlovsky dr-orlovsky force-pushed the master branch 3 times, most recently from b5a5f91 to e989537 Compare July 2, 2022 18:12
@dr-orlovsky dr-orlovsky modified the milestones: v0.9.0, v0.10.0 Mar 24, 2023
@dr-orlovsky
Copy link
Member

v0.10 is a new breaking version I am working on these days, so the parts of this PR which haven't got into #41 can be re-based onto the current master. @kaiwolfram are you still interested in working on this PR or should I do that by myself?

@kaiwolfram
Copy link
Contributor Author

v0.10 is a new breaking version I am working on these days, so the parts of this PR which haven't got into #41 can be re-based onto the current master. @kaiwolfram are you still interested in working on this PR or should I do that by myself?

Hi, it would be better if you do that. I'm currently busy with other stuff. Thank you.

@dr-orlovsky dr-orlovsky modified the milestones: v0.10.0, v0.11.0 Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*compatibility* Issues affecting compatibility and interoperability question Further information is requested test Test implementation or failures
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants