-
Notifications
You must be signed in to change notification settings - Fork 622
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
PrivateKey
should have methods to derive addresses more easily
#1865
Comments
I spent some clock cycles this week thinking about the various keys/address APIs, and how we could improve them. This issue made me chuckle. |
I disagree with direct |
@stevenroose the reason to go directly to address is to transfer |
Just throwing in my 2 cents: Out of my many years working on and with bitcoinjs-lib in my day job... the amount of times I have written code where I want to go from a private key to an address are is zero. Especially in a post-BIP32 world, we work with xpubs almost exclusively for address derivation. Our seed mnemonics only ever touch code that is meant for signing. Not necessarily NACKing this, but I don't see the utility... maybe a more concrete use case would make things clearer? |
@junderw the xpub API in this library goes through |
@Kixunil that's not really true. That's only the private part, the xpriv. But wallets will more likely store xpubs, so from there you derive I agree with @junderw that sk->addr is very uncommon. Even in hal where might be one of the few cases where that happens (because it's a utility), I first do privkey info, then pubkey info and then address info from the pubkey info. Like the privkey->addr step doesn't make sense without going through the pubkey step. And IMO that has nothing to do with the API. |
Ah, good point about xpubs. I wonder if |
It could, but then we couldn't parse one from a script or a string. |
Oh, true. So the xpub API should be improved somehow. Will try to think of something later. |
Yeah no network in pubkey please, really doesn't make sense. It's bad enough we have a "privatekey" struct that has a network and compression. Over the years I made multiple attempts to get rid of None really worked out easily, but I personally avoid the This week been doing some taproot stuff and I noticed there are various new key types all over the place. XOnly, KeyPair, Untweaked, Tweaked, ... |
I exclusively use I'm not sure I've ever used privkeys in non-toy code, and even in toy code I try to avoid it, so I don't have much of an opinion there. |
Hehe, I do the exact opposite. I try to avoid IMO we'd be better of having some kind of Like, while I was doing the MR of removing |
Currently, if you want to derive p2tr you need to write:
This is pretty hard to discover for newbies - the
.inner
and.0
is annoying, there'sSECP256K1
stuff, you need to sync networks...Having
.to_p2tr_address()
and other methods would make it much easier to use.The text was updated successfully, but these errors were encountered: