nostrdb: ndb_note_json: return length
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
Daniel D’Aquino
parent
319579f912
commit
57db252783
@@ -4756,7 +4756,7 @@ int ndb_note_json(struct ndb_note *note, char *buf, int buflen)
|
||||
|
||||
make_cursor((unsigned char *)buf, (unsigned char*)buf + buflen, &cur);
|
||||
|
||||
return cursor_push_str(c, "{\"id\":\"") &&
|
||||
int ok = cursor_push_str(c, "{\"id\":\"") &&
|
||||
cursor_push_hex(c, ndb_note_id(note), 32) &&
|
||||
cursor_push_str(c, "\",\"pubkey\":\"") &&
|
||||
cursor_push_hex(c, ndb_note_pubkey(note), 32) &&
|
||||
@@ -4772,6 +4772,11 @@ int ndb_note_json(struct ndb_note *note, char *buf, int buflen)
|
||||
cursor_push_hex(c, ndb_note_sig(note), 64) &&
|
||||
cursor_push_c_str(c, "\"}");
|
||||
|
||||
if (!ok) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return cur.p - cur.start;
|
||||
}
|
||||
|
||||
int ndb_calculate_id(struct ndb_note *note, unsigned char *buf, int buflen) {
|
||||
|
||||
Reference in New Issue
Block a user