keys, err := kc.scan()
if err != nil {
fmt.Printf("can't load keys: %v\n", err.Error())
-
}
kc.all = keys
sort.Sort(kc.all)
for _, k := range keys {
kc.byPubs[k.XPub] = append(kc.byPubs[k.XPub], k)
}
- //log.Printf("reloaded keys, cache has %d keys", len(ac.all))
fmt.Printf("reloaded keys, cache has %d keys\n", len(kc.all))
}
return xpb, xkey, err
}
-// UpdateAlias of an existing xpub
-func (h *HSM) UpdateAlias(xpub chainkd.XPub, auth, newAlias string) error {
- xpb, xkey, err := h.loadDecryptedKey(xpub, auth)
- if err != nil {
- return err
- }
- xkey.Alias = newAlias
- return h.keyStore.StoreKey(xpb.File, xkey, auth)
-}
-
// ResetPassword the passphrase of an existing xpub
func (h *HSM) ResetPassword(xpub chainkd.XPub, auth, newAuth string) error {
xpb, xkey, err := h.loadDecryptedKey(xpub, auth)
package pseudohsm
import (
+ "fmt"
"testing"
"github.com/bytom/errors"
if len(xpubs) != 2 {
t.Error("expected 2 entries in the db")
}
- /*err = hsm.UpdateAlias(xpub.XPub, "password", "updatealias")
- err = hsm.UpdateAlias(xpub.XPub, "password", "updatealias")
- if err != nil {
- t.Fatal(err)
- }*/
err = hsm.ResetPassword(xpub2.XPub, "nopassword", "1password")
if err != nil {
t.Fatal(err)
func TestKeyWithEmptyAlias(t *testing.T) {
hsm, _ := New(dirPath)
for i := 0; i < 2; i++ {
- xpub, err := hsm.XCreate("xxs", "xx")
+ xpub, err := hsm.XCreate(fmt.Sprintf("xx%d", i), "xx")
if errors.Root(err) != nil {
t.Fatal(err)
}