mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
json: Add helper to serialize short_channel_id_dir
We'll need it in the next commit to exclude channels and their directions.
This commit is contained in:
parent
5e3134083e
commit
c2538392e9
2 changed files with 18 additions and 1 deletions
|
@ -3,7 +3,6 @@
|
||||||
#include <bitcoin/privkey.h>
|
#include <bitcoin/privkey.h>
|
||||||
#include <bitcoin/psbt.h>
|
#include <bitcoin/psbt.h>
|
||||||
#include <bitcoin/pubkey.h>
|
#include <bitcoin/pubkey.h>
|
||||||
#include <bitcoin/short_channel_id.h>
|
|
||||||
#include <ccan/ccan/str/hex/hex.h>
|
#include <ccan/ccan/str/hex/hex.h>
|
||||||
#include <common/amount.h>
|
#include <common/amount.h>
|
||||||
#include <common/channel_id.h>
|
#include <common/channel_id.h>
|
||||||
|
@ -164,6 +163,18 @@ void json_add_short_channel_id(struct json_stream *response,
|
||||||
short_channel_id_outnum(scid));
|
short_channel_id_outnum(scid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void json_add_short_channel_id_dir(struct json_stream *response,
|
||||||
|
const char *fieldname,
|
||||||
|
const struct short_channel_id_dir *scidd)
|
||||||
|
{
|
||||||
|
json_add_member(response, fieldname, true, "%dx%dx%d/%d",
|
||||||
|
short_channel_id_blocknum(&scidd->scid),
|
||||||
|
short_channel_id_txnum(&scidd->scid),
|
||||||
|
short_channel_id_outnum(&scidd->scid),
|
||||||
|
scidd->dir
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void json_add_address(struct json_stream *response, const char *fieldname,
|
void json_add_address(struct json_stream *response, const char *fieldname,
|
||||||
const struct wireaddr *addr)
|
const struct wireaddr *addr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#ifndef LIGHTNING_COMMON_JSON_HELPERS_H
|
#ifndef LIGHTNING_COMMON_JSON_HELPERS_H
|
||||||
#define LIGHTNING_COMMON_JSON_HELPERS_H
|
#define LIGHTNING_COMMON_JSON_HELPERS_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <bitcoin/short_channel_id.h>
|
||||||
#include <bitcoin/tx.h>
|
#include <bitcoin/tx.h>
|
||||||
#include <common/json.h>
|
#include <common/json.h>
|
||||||
#include <wire/wire.h>
|
#include <wire/wire.h>
|
||||||
|
@ -92,6 +93,11 @@ void json_add_short_channel_id(struct json_stream *response,
|
||||||
const char *fieldname,
|
const char *fieldname,
|
||||||
const struct short_channel_id *id);
|
const struct short_channel_id *id);
|
||||||
|
|
||||||
|
/* '"fieldname" : "1234:5:6/7"' */
|
||||||
|
void json_add_short_channel_id_dir(struct json_stream *response,
|
||||||
|
const char *fieldname,
|
||||||
|
const struct short_channel_id_dir *id);
|
||||||
|
|
||||||
/* JSON serialize a network address for a node */
|
/* JSON serialize a network address for a node */
|
||||||
void json_add_address(struct json_stream *response, const char *fieldname,
|
void json_add_address(struct json_stream *response, const char *fieldname,
|
||||||
const struct wireaddr *addr);
|
const struct wireaddr *addr);
|
||||||
|
|
Loading…
Add table
Reference in a new issue