mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 06:55:13 +01:00
json: add channel_id helper
This commit is contained in:
parent
4034d0c306
commit
3674de9865
3 changed files with 13 additions and 2 deletions
|
@ -142,6 +142,13 @@ void json_add_node_id(struct json_stream *response,
|
||||||
json_add_hex(response, fieldname, id->k, sizeof(id->k));
|
json_add_hex(response, fieldname, id->k, sizeof(id->k));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void json_add_channel_id(struct json_stream *response,
|
||||||
|
const char *fieldname,
|
||||||
|
const struct channel_id *cid)
|
||||||
|
{
|
||||||
|
json_add_hex(response, fieldname, cid->id, sizeof(cid->id));
|
||||||
|
}
|
||||||
|
|
||||||
void json_add_pubkey(struct json_stream *response,
|
void json_add_pubkey(struct json_stream *response,
|
||||||
const char *fieldname,
|
const char *fieldname,
|
||||||
const struct pubkey *key)
|
const struct pubkey *key)
|
||||||
|
|
|
@ -89,6 +89,11 @@ void json_add_node_id(struct json_stream *response,
|
||||||
const char *fieldname,
|
const char *fieldname,
|
||||||
const struct node_id *id);
|
const struct node_id *id);
|
||||||
|
|
||||||
|
/* '"fieldname" : "0289abcdef..."' or "0289abcdef..." if fieldname is NULL */
|
||||||
|
void json_add_channel_id(struct json_stream *response,
|
||||||
|
const char *fieldname,
|
||||||
|
const struct channel_id *cid);
|
||||||
|
|
||||||
/* '"fieldname" : <hexrev>' or "<hexrev>" if fieldname is NULL */
|
/* '"fieldname" : <hexrev>' or "<hexrev>" if fieldname is NULL */
|
||||||
void json_add_txid(struct json_stream *result, const char *fieldname,
|
void json_add_txid(struct json_stream *result, const char *fieldname,
|
||||||
const struct bitcoin_txid *txid);
|
const struct bitcoin_txid *txid);
|
||||||
|
|
|
@ -219,8 +219,7 @@ static void channel_state_changed_notification_serialize(struct json_stream *str
|
||||||
{
|
{
|
||||||
json_object_start(stream, "channel_state_changed");
|
json_object_start(stream, "channel_state_changed");
|
||||||
json_add_node_id(stream, "peer_id", peer_id);
|
json_add_node_id(stream, "peer_id", peer_id);
|
||||||
json_add_string(stream, "channel_id",
|
json_add_channel_id(stream, "channel_id", cid);
|
||||||
type_to_string(tmpctx, struct channel_id, cid));
|
|
||||||
if (scid)
|
if (scid)
|
||||||
json_add_short_channel_id(stream, "short_channel_id", scid);
|
json_add_short_channel_id(stream, "short_channel_id", scid);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue