Skip to content

feat(cast): display public_key on wallet creation with "new" and "new-mnemonic" sub-commands #10600

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mablr
Copy link
Contributor

@mablr mablr commented May 23, 2025

Motivation

Resolve #9748

Solution

The method used to obtain public_key with the wallet is taken from "public-key" sub-command.

Update tests to match the new outputs:

  • update redactions for pubkey and to match various spacings
  • use raw data for assertion in "wallet_mnemonic_from_entropy" to avoid conflict with redactions

EDIT:

  • pubkey is displayed when verbosity level is >0

PR Checklist

  • Updated tests
  • Added Documentation
  • Breaking changes (no as guarded behind -v flag)

@mablr mablr marked this pull request as draft May 23, 2025 09:28
@mablr mablr force-pushed the feature/cast-wallet-display-pubkey branch 2 times, most recently from 232b8f5 to 90ca4e6 Compare May 23, 2025 10:59
@mablr mablr marked this pull request as ready for review May 23, 2025 11:21
…-mnemonic" subcommands

The method used to obtain public_key with the wallet is taken from "public-key" subcommand.

Update tests to match the new outputs:
  - match pubkey
  - update redactions for pubkey and to match various spacings
  - use raw data for assertion in "wallet_mnemonic_from_entropy" to avoid conflict with redactions
@mablr mablr force-pushed the feature/cast-wallet-display-pubkey branch from 90ca4e6 to ffeefa2 Compare May 26, 2025 22:16
@grandizzy grandizzy added T-feature Type: feature C-cast Command: cast T-likely-breaking Type: requires changes that can be breaking labels Jun 3, 2025
Copy link
Collaborator

@grandizzy grandizzy 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, I think this makes sense (breaking change) @zerosnacks wdyt?

@zerosnacks
Copy link
Member

zerosnacks commented Jun 3, 2025

I think it is a bit verbose and for most use cases the level of detail seems unnecessary

@mablr would you mind expanding on where you use the public keys?

We already have the cast wallet public-key utility available to derive the public key from a private key in instances a user needs this

@mablr
Copy link
Contributor Author

mablr commented Jun 3, 2025

This feature was initially requested by @coffee-converter.

@zerosnacks I agree with you and I shared the same concerns in comments on the related issue: #9748 (comment) & #9748 (comment). Some of the information is outdated, but the main idea is in line with your remark.

After receiving feedback from @mattsse #9748 (comment), who assigned me to the issue, I finally implemented this feature.

@zerosnacks
Copy link
Member

Hey @mablr, I see - thanks for the pointer!

To my understanding @mattsse refers to checking if this is verbose or not to indicate we should only display the public key when a user sets a verbosity flag (shell::verbosity() > 0). This is currently not implemented in the current version of the PR.

In my opinion, I don't see a huge benefit to having this be logged, even at higher verbosity.

I would be in favor of closing the ticket as not planned but if others feel strong about this - it being available at a higher verbosity level also works for me. This would also turn it into a non-breaking addition rather than a breaking change.

@mablr
Copy link
Contributor Author

mablr commented Jun 3, 2025

I think you're right, limiting the pubkey display to a higher verbosity level (e.g. >1) is a good deal.

mablr and others added 2 commits June 3, 2025 18:44
@grandizzy grandizzy self-requested a review June 5, 2025 09:36
@grandizzy grandizzy removed the T-likely-breaking Type: requires changes that can be breaking label Jun 5, 2025
Copy link
Collaborator

@grandizzy grandizzy 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, displaying on verbose lgtm! pending @zerosnacks review before merging

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@mablr I'm opening an alloy issue for the helper

Comment on lines +349 to +353
&SecretKey::from_slice(&wallet.credential().to_bytes())
.map_err(|e| eyre::eyre!("Invalid private key: {}", e))?
.public_key()
.to_encoded_point(false)
.as_bytes()[1..],
Copy link
Member

Choose a reason for hiding this comment

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

makes sense

@mablr do you want to perhaps upstream this to alloy's LocalSigner type as a helper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can do it next week.

Copy link
Member

Choose a reason for hiding this comment

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

sweet, tagged you here alloy-rs/alloy#2555

@mablr
Copy link
Contributor Author

mablr commented Jun 15, 2025

@mattsse Should this PR be marked as "blocked" until alloy-rs/alloy#2572 will land in the next release?
Or this could be merged and then I'll do the integration of the new Alloy helper as a follow-up?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-cast Command: cast T-feature Type: feature
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

feat(cast wallet) display pubkey when creating new keypair or converting private key to an address
4 participants