mirror of
https://github.com/jb55/nostril.git
synced 2024-11-22 08:39:06 -05:00
simple explicit tags option
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
ff2e204569
commit
3e177964c7
18
nostril.c
18
nostril.c
|
@ -40,6 +40,7 @@ struct args {
|
||||||
|
|
||||||
unsigned char encrypt_to[32];
|
unsigned char encrypt_to[32];
|
||||||
const char *sec;
|
const char *sec;
|
||||||
|
const char *tags;
|
||||||
const char *content;
|
const char *content;
|
||||||
|
|
||||||
uint64_t created_at;
|
uint64_t created_at;
|
||||||
|
@ -60,6 +61,8 @@ struct nostr_event {
|
||||||
uint64_t created_at;
|
uint64_t created_at;
|
||||||
int kind;
|
int kind;
|
||||||
|
|
||||||
|
const char *explicit_tags;
|
||||||
|
|
||||||
struct nostr_tag tags[MAX_TAGS];
|
struct nostr_tag tags[MAX_TAGS];
|
||||||
int num_tags;
|
int num_tags;
|
||||||
};
|
};
|
||||||
|
@ -139,6 +142,10 @@ static int cursor_push_tags(struct cursor *cur, struct nostr_event *ev)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (ev->explicit_tags) {
|
||||||
|
return cursor_push_str(cur, ev->explicit_tags);
|
||||||
|
}
|
||||||
|
|
||||||
if (!cursor_push_byte(cur, '['))
|
if (!cursor_push_byte(cur, '['))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -258,7 +265,7 @@ static int init_secp_context(secp256k1_context **ctx)
|
||||||
|
|
||||||
static int generate_event_id(struct nostr_event *ev)
|
static int generate_event_id(struct nostr_event *ev)
|
||||||
{
|
{
|
||||||
static unsigned char buf[32000];
|
static unsigned char buf[102400];
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
@ -284,7 +291,7 @@ static int sign_event(secp256k1_context *ctx, struct key *key, struct nostr_even
|
||||||
|
|
||||||
static int print_event(struct nostr_event *ev, int envelope)
|
static int print_event(struct nostr_event *ev, int envelope)
|
||||||
{
|
{
|
||||||
unsigned char buf[32000];
|
unsigned char buf[102400];
|
||||||
char pubkey[65];
|
char pubkey[65];
|
||||||
char id[65];
|
char id[65];
|
||||||
char sig[129];
|
char sig[129];
|
||||||
|
@ -379,6 +386,9 @@ static int parse_args(int argc, const char *argv[], struct args *args)
|
||||||
args->flags |= HAS_KIND;
|
args->flags |= HAS_KIND;
|
||||||
} else if (!strcmp(arg, "--envelope")) {
|
} else if (!strcmp(arg, "--envelope")) {
|
||||||
args->flags |= HAS_ENVELOPE;
|
args->flags |= HAS_ENVELOPE;
|
||||||
|
} else if (!strcmp(arg, "--tags")) {
|
||||||
|
arg = *argv++; argc--;
|
||||||
|
args->tags = arg;
|
||||||
} else if (!strcmp(arg, "--pow")) {
|
} else if (!strcmp(arg, "--pow")) {
|
||||||
arg = *argv++; argc--;
|
arg = *argv++; argc--;
|
||||||
if (!parse_num(arg, &n)) {
|
if (!parse_num(arg, &n)) {
|
||||||
|
@ -606,6 +616,10 @@ int main(int argc, const char *argv[])
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.tags) {
|
||||||
|
ev.explicit_tags = args.tags;
|
||||||
|
}
|
||||||
|
|
||||||
make_event_from_args(&ev, &args);
|
make_event_from_args(&ev, &args);
|
||||||
|
|
||||||
if (args.sec) {
|
if (args.sec) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user