From 243343f0c5c5e77a91204efede00655d0f67be08 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 17 Sep 2024 11:25:13 -0300 Subject: [PATCH] nip46: add nip04_encrypt and nip04_decrypt to client. --- nip46/client.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nip46/client.go b/nip46/client.go index 1375dc7..e311c0d 100644 --- a/nip46/client.go +++ b/nip46/client.go @@ -193,6 +193,22 @@ func (bunker *BunkerClient) NIP44Decrypt( return bunker.RPC(ctx, "nip44_decrypt", []string{targetPublicKey, ciphertext}) } +func (bunker *BunkerClient) NIP04Encrypt( + ctx context.Context, + targetPublicKey string, + plaintext string, +) (string, error) { + return bunker.RPC(ctx, "nip04_encrypt", []string{targetPublicKey, plaintext}) +} + +func (bunker *BunkerClient) NIP04Decrypt( + ctx context.Context, + targetPublicKey string, + ciphertext string, +) (string, error) { + return bunker.RPC(ctx, "nip04_decrypt", []string{targetPublicKey, ciphertext}) +} + func (bunker *BunkerClient) RPC(ctx context.Context, method string, params []string) (string, error) { id := bunker.idPrefix + "-" + strconv.FormatUint(bunker.serial.Add(1), 10) req, err := json.Marshal(Request{