}) error {
return a.hsm.ResetPassword(x.XPub, x.OldPassword, x.NewPassword)
}
+
+func (a *BlockchainReactor) pseudohsmUpdateAlias(ctx context.Context, x struct {
+ Password string
+ NewAlias string
+ XPub chainkd.XPub `json:"xpubs"`
+}) error {
+ return a.hsm.UpdateAlias(x.XPub, x.Password, x.NewAlias)
+}
+
+
// remote hsm used
/*
func RemoteHSM(hsm *remoteHSM) RunOption {
m.Handle("/delete-key", jsonHandler(bcr.pseudohsmDeleteKey))
m.Handle("/sign-transactions", jsonHandler(bcr.pseudohsmSignTemplates))
m.Handle("/reset-password", jsonHandler(bcr.pseudohsmResetPassword))
- //m.Handle("/hsm/update-alias", jsonHandler(bcr.pseudohsmUpdateAlias))
+ m.Handle("/update-alias", jsonHandler(bcr.pseudohsmUpdateAlias))
latencyHandler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
"delete-key": {deleteKey},
"sign-transactions": {signTransactions},
"reset-password": {resetPassword},
+ "update-alias": {updateAlias},
}
func main() {
key.NewPassword = args[1]
key.XPub= *xpub
client.Call(context.Background(), "/reset-password", &key, nil)
-}
\ No newline at end of file
+}
+
+func updateAlias(client *rpc.Client, args []string) {
+ if len(args) != 3 {
+ fatalln("error: resetpassword args not vaild")
+ }
+ type Key struct {
+ Password string
+ NewAlias string
+ XPub chainkd.XPub `json:"xpubs"`
+ }
+ var key Key
+ xpub := new(chainkd.XPub)
+ data, err := hex.DecodeString(args[2])
+ if err != nil {
+ fatalln("error: resetPassword %v", err)
+ }
+ copy(xpub[:], data)
+ key.Password = args[0]
+ key.NewAlias = args[1]
+ key.XPub= *xpub
+ client.Call(context.Background(), "/update-alias", &key, nil)
+}