error aware Keyer.GetPublicKey

This commit is contained in:
1l0
2024-09-19 17:47:18 +09:00
committed by fiatjaf_
parent e1cdb71d6f
commit 0b2b69529b
6 changed files with 35 additions and 17 deletions

View File

@@ -16,18 +16,21 @@ type EncryptedKeySigner struct {
callback func(context.Context) string
}
func (es *EncryptedKeySigner) GetPublicKey(ctx context.Context) string {
func (es *EncryptedKeySigner) GetPublicKey(ctx context.Context) (string, error) {
if es.pk != "" {
return es.pk
return es.pk, nil
}
password := es.callback(ctx)
key, err := nip49.Decrypt(es.ncryptsec, password)
if err != nil {
return ""
return "", err
}
pk, err := nostr.GetPublicKey(key)
if err != nil {
return "", err
}
pk, _ := nostr.GetPublicKey(key)
es.pk = pk
return pk
return pk, nil
}
func (es *EncryptedKeySigner) SignEvent(ctx context.Context, evt *nostr.Event) error {