bsv-ex
bsv-ex copied to clipboard
Support for `tprv` keys
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?
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.
Or even this would do tbh...
def from_string(<<_ , "prv", _::binary>> = xprv) do