mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-15 16:50:16 +01:00
nip46: add nip04_encrypt and nip04_decrypt to client.
This commit is contained in:
@@ -193,6 +193,22 @@ func (bunker *BunkerClient) NIP44Decrypt(
|
|||||||
return bunker.RPC(ctx, "nip44_decrypt", []string{targetPublicKey, ciphertext})
|
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) {
|
func (bunker *BunkerClient) RPC(ctx context.Context, method string, params []string) (string, error) {
|
||||||
id := bunker.idPrefix + "-" + strconv.FormatUint(bunker.serial.Add(1), 10)
|
id := bunker.idPrefix + "-" + strconv.FormatUint(bunker.serial.Add(1), 10)
|
||||||
req, err := json.Marshal(Request{
|
req, err := json.Marshal(Request{
|
||||||
|
|||||||
Reference in New Issue
Block a user