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

Support for tprv keys #15

Open
afomi opened this issue Jan 23, 2024 · 2 comments
Open

Support for tprv keys #15

afomi opened this issue Jan 23, 2024 · 2 comments

Comments

@afomi
Copy link

afomi commented Jan 23, 2024

Noticed something when using the library on test net and wanted to run it by you, @libitx, before working on a PR.

mnemonic = BSV.Mnemonic.new(128)
seed = BSV.Mnemonic.to_seed(mnemonic)
extkey = BSV.ExtKey.from_seed!(seed)
xprv = extkey |> BSV.ExtKey.to_string
BSV.ExtKey.from_string(xprv)

raises

** (FunctionClauseError) no function clause matching in BSV.ExtKey.from_string/1

Am I missing something regarding test keys; support for tprv and tpub.
Would an addition be valid?

@libitx
Copy link
Owner

libitx commented Feb 2, 2024

You're not missing anything - it's a bug.

The from_string implementations need to match against trpv and tpub, maybe something like:

def from_string(<<pre::binary-4, _::binary>> = xprv) when pre in ["xprv", "tprv"] do

I'm not working on bsv projects at the moment but will accept a PR for this if you have time.

@libitx
Copy link
Owner

libitx commented Feb 2, 2024

Or even this would do tbh...

def from_string(<<_ , "prv", _::binary>> = xprv) do

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

No branches or pull requests

2 participants