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

Make getDerivedHDAddress return address, not key #218

Conversation

chromatic
Copy link
Contributor

Addresses GH #217.

I proved the first test correct with a third-party derivation library; looking for feedback before I go further.

@xanimo
Copy link
Member

xanimo commented Jun 10, 2024

So I think we should leave the old one unchanged (due to not wanting breaking changes that other API's depend on) and duplicate that function where you made those changes and add a new suffix, e.g. getDerivedHDAddressAsP2PKH. I think the reason for this confusion is lack of specificity re naming conventions, and referencing from sources like Learn me a bitcoin wherein the dgub 112 char key is mentioned as an address and not a p2pkh legacy address.

image

@chromatic chromatic force-pushed the getderivedhdaddress-returns-address branch from 6dddb2b to bdffe31 Compare June 11, 2024 02:46
@chromatic
Copy link
Contributor Author

That makes sense and I'm content to rework (or let someone else rework) this PR for that approach. If that's the approach you prefer, I do think clarifying the documentation of both functions is valuable.

@xanimo
Copy link
Member

xanimo commented Jun 12, 2024

Yeah if you wouldn't mind reworking those functions while leaving getDerivedHDAddress the same, it would be much appreciated.

@chromatic chromatic force-pushed the getderivedhdaddress-returns-address branch from bdffe31 to b403f69 Compare June 15, 2024 12:49
@chromatic
Copy link
Contributor Author

I've rewritten my commit to go in that direction. This has tests but not documentation in docs/ or examples.

This derives a key from a given public or private key and returns the derived
key in P2PKH form.
@chromatic chromatic force-pushed the getderivedhdaddress-returns-address branch from b403f69 to e84242c Compare June 16, 2024 00:32
@xanimo
Copy link
Member

xanimo commented Jun 16, 2024

Looks good. Will do a formal review later this afternoon.

Copy link
Member

@xanimo xanimo left a comment

Choose a reason for hiding this comment

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

Requesting fixes for a couple nits.

* @param account The account that the derived address would belong to.
* @param ischange Boolean value representing either a change or receiving address.
* @param addressindex The index of the receiving/change address per account.
* @param outp2pkh The derived address in P2PSH form.
Copy link
Member

Choose a reason for hiding this comment

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

nit: P2PKH

res = getDerivedHDAddressAsP2PKH(masterkey_main_ext, 0, true, 0, extout);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "D91jVi3CVGhRmyt83fhMdL4UJWtDuiTZET");
res = getDerivedHDAddressAsP2PKH(masterkey_main_ext, 0, false, 0, extout);
Copy link
Member

Choose a reason for hiding this comment

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

nit: L144-148 and L156-161 are duplicate test cases

@edtubbs
Copy link
Collaborator

edtubbs commented Jun 20, 2024

This looks good. I agree with the other comments and on updating address.md and example.c as you mentioned. Thanks.

@michilumin michilumin self-assigned this Aug 27, 2024
@michilumin michilumin self-requested a review August 27, 2024 20:39
Copy link
Contributor

@michilumin michilumin left a comment

Choose a reason for hiding this comment

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

Good change, logical - thanks for that input @chromatic . Appreciated.

@michilumin michilumin merged commit 8270a89 into dogecoinfoundation:0.1.4-dev Aug 27, 2024
14 checks passed
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.

4 participants