-
Notifications
You must be signed in to change notification settings - Fork 873
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
[discussion] allow PublicKeys to be input and output as base58check #3105
Comments
Interesting, TIL about base58check! I've noticed the same issue about truncating an address and it still being valid in I'd be curious to know why it wasn't used for Solana, given it's used for Bitcoin. Is there some tradeoff that means we wouldn't want to use it for some reason? In general it should be pretty easy to write a codec for I think allowing them as input throughout the library gets trickier though. A good starting point here would probably be for someone to implement a web3js codec + other functions we have for addresses for Then we can figure out if/how to inline it and use it across the library without introducing too much complexity. We'd also need to update the Kinobi renderer + generated clients if we made that sort of change to the library, to similarly accept them as input. |
New package makes sense to me, so we don't have to worry about breaking any APIs for the existing codecs packages. It shouldn't be imported/reexported from any of them, either.
I'm envisioning something like a flag ( |
I don't think that really matches the intention here. If you have a plain current I think one way would be to introduce an opaque type called something like It's typescript so you can of course just cast, but if you don't do that then you can accept a base58check address from your user, validate it, convert it to a You could do all of that without touching any existing APIs, and just cast it to |
Related: solana-labs/solana#6970 |
I've only thought about this for two seconds, but my initial thoughts are:
|
Motivation
StackOverflow is filled with people that truncated one character of a wallet address and send tokens to that address. Sadly with how base58 works, a truncated address can still be valid. Boo.
What if we allowed inputs for publickey values to be either base58 or base58check? And likewise, made a way to get base58 check outputs from publickey?
We'd need support from a lot of other software (eg, wallets would need to output checked addresses) but starting with web3 is a good start.
Example use case
An app outputs base58checked using web3.js
Someone pasted that into another app, and truncates it.
The app tells the user the address is invalid, instead of sending tokens to another address.
The text was updated successfully, but these errors were encountered: