diff options
Diffstat (limited to 'accounts/hd.go')
-rw-r--r-- | accounts/hd.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/accounts/hd.go b/accounts/hd.go index 6ed631807..d14dbc842 100644 --- a/accounts/hd.go +++ b/accounts/hd.go @@ -17,6 +17,7 @@ package accounts import ( + "encoding/json" "errors" "fmt" "math" @@ -133,3 +134,17 @@ func (path DerivationPath) String() string { } return result } + +func (path DerivationPath) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf("\"%s\"", path.String())), nil +} + +func (dp *DerivationPath) UnmarshalJSON(b []byte) error { + var path string + var err error + if err = json.Unmarshal(b, &path); err != nil { + return err + } + *dp, err = ParseDerivationPath(path) + return err +} |