mirror of
https://github.com/jb55/nostril.git
synced 2024-11-24 00:49:07 -05:00
dm: allow kind override for encrypted content in other kinds
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
0c583e9868
commit
098f639f46
|
@ -556,7 +556,7 @@ static int mine_event(struct nostr_event *ev, int difficulty)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int make_encrypted_dm(secp256k1_context *ctx, struct key *key,
|
static int make_encrypted_dm(secp256k1_context *ctx, struct key *key,
|
||||||
struct nostr_event *ev, unsigned char nostr_pubkey[32])
|
struct nostr_event *ev, unsigned char nostr_pubkey[32], int kind)
|
||||||
{
|
{
|
||||||
size_t inl = strlen(ev->content);
|
size_t inl = strlen(ev->content);
|
||||||
int enclen = inl + 16;
|
int enclen = inl + 16;
|
||||||
|
@ -630,7 +630,7 @@ static int make_encrypted_dm(secp256k1_context *ctx, struct key *key,
|
||||||
}
|
}
|
||||||
|
|
||||||
ev->content = (const char*)cur.start;
|
ev->content = (const char*)cur.start;
|
||||||
ev->kind = 4;
|
ev->kind = kind;
|
||||||
|
|
||||||
if (!hex_encode(nostr_pubkey, 32, (char*)cur.p, cur.end - cur.p))
|
if (!hex_encode(nostr_pubkey, 32, (char*)cur.p, cur.end - cur.p))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -683,7 +683,8 @@ int main(int argc, const char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.flags & HAS_ENCRYPT) {
|
if (args.flags & HAS_ENCRYPT) {
|
||||||
if (!make_encrypted_dm(ctx, &key, &ev, args.encrypt_to)) {
|
int kind = args.flags & HAS_KIND? args.kind : 4;
|
||||||
|
if (!make_encrypted_dm(ctx, &key, &ev, args.encrypt_to, kind)) {
|
||||||
fprintf(stderr, "error making encrypted dm\n");
|
fprintf(stderr, "error making encrypted dm\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user