-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add goldens for singleAddressFromKey #433
Conversation
-- ^ corresponding testnet address ("ta...") | ||
-> Text | ||
-- ^ corresponding mainnet address ("ca...") | ||
-> Spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasoning for using Text -> Text -> Text
:
- The human readable parts of the bech32 strings already act as types (just not at compile-time)
- Allows for easy copy-and-paste at call-site for comparison with
jcli
bech32KeyToAddrGolden | ||
"ed25519_pk1yv0er3wlzvcauqj470tesdlcwy4dll9w7cvsvn4q30678gh44tnsxdh75c" | ||
"ta1sv33lyw9mufnrhsz2hea0xphlpcj4hlu4mmpjpjw5z9ltcaz7k4wwywkd6j" | ||
"ca1qv33lyw9mufnrhsz2hea0xphlpcj4hlu4mmpjpjw5z9ltcaz7k4ww0xfchg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A caveat is that it is unreadable if you don't know of the meaning of the human readable parts.
A benefit from passing in Text
directly is that bech32KeyToAddrGolden
has more control, and can output the key in bech32 format despite there being no encodeBech32Key.
Maybe we should add encode/decodeBech32Key
in AddressDerivation
… 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make things more readable without impeding too much on the flexibility, you may use a record type and use record fields at the call-site 👍
Comparing with jcli
da9e6b0
to
4982784
Compare
else error $ "failed to decode key: " ++ hrp ++ " is not ed25519_pk" | ||
|
||
cc :: ChainCode | ||
cc = ChainCode "<ChainCode shouldn't be used by keyToAddress>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that these looks quite redundant with:
Or am I missing something 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:s #435
#219
Overview
bech32KeyToAddrGolden
helper and three goldens testingsingleAddressFromKey
Comments
jcli
.keyToAddress
. This would have required constructing aKey 'AddressK XPub
from bech32, which is inconvenient. I have therefore opted to only testsingleAddressFromKey
.An alternative approach I originally went with but abandoned was to generate the keys properly from mnemonics instead of decoding them from bech32.