mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
73cd009a4c
This replacement is a little menial, but it explicitly catches all the places where we allow a local socket. The actual implementation of opening a AF_UNIX socket is almost hidden in the patch. The detection of "valid address" is now more complex: p->addr.itype != ADDR_INTERNAL_WIREADDR || p->addr.u.wireaddr.type != ADDR_TYPE_PADDING But most places we do this, we should audit: I'm pretty sure we can't get an invalid address any more from gossipd (they may be in db, but we should fix that too). Closes: #1323 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
67 lines
2.1 KiB
C
67 lines
2.1 KiB
C
/* lightningd/json.h
|
|
* Helpers for outputting JSON results that are specific only for
|
|
* lightningd.
|
|
*/
|
|
#ifndef LIGHTNING_LIGHTNINGD_JSON_H
|
|
#define LIGHTNING_LIGHTNINGD_JSON_H
|
|
#include "config.h"
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
#define JSMN_STRICT 1
|
|
# include <external/jsmn/jsmn.h>
|
|
|
|
struct bitcoin_txid;
|
|
struct channel_id;
|
|
struct json_result;
|
|
struct pubkey;
|
|
struct route_hop;
|
|
struct short_channel_id;
|
|
struct wallet_payment;
|
|
struct wireaddr;
|
|
struct wireaddr_internal;
|
|
|
|
/* Output a route array. */
|
|
void json_add_route(struct json_result *r, char const *n,
|
|
const struct route_hop *hops, size_t hops_len);
|
|
|
|
/* Output the fields of a wallet payment.
|
|
* Should be used within an object context. */
|
|
void json_add_payment_fields(struct json_result *response,
|
|
const struct wallet_payment *t);
|
|
|
|
/* '"fieldname" : "0289abcdef..."' or "0289abcdef..." if fieldname is NULL */
|
|
void json_add_pubkey(struct json_result *response,
|
|
const char *fieldname,
|
|
const struct pubkey *key);
|
|
|
|
/* '"fieldname" : <hexrev>' or "<hexrev>" if fieldname is NULL */
|
|
void json_add_txid(struct json_result *result, const char *fieldname,
|
|
const struct bitcoin_txid *txid);
|
|
|
|
/* Extract a pubkey from this */
|
|
bool json_tok_pubkey(const char *buffer, const jsmntok_t *tok,
|
|
struct pubkey *pubkey);
|
|
|
|
/* Extract a short_channel_id from this */
|
|
bool json_tok_short_channel_id(const char *buffer, const jsmntok_t *tok,
|
|
struct short_channel_id *scid);
|
|
|
|
/* '"fieldname" : "1234:5:6"' */
|
|
void json_add_short_channel_id(struct json_result *response,
|
|
const char *fieldname,
|
|
const struct short_channel_id *id);
|
|
|
|
bool json_tok_channel_id(const char *buffer, const jsmntok_t *tok,
|
|
struct channel_id *cid);
|
|
|
|
/* JSON serialize a network address for a node */
|
|
void json_add_address(struct json_result *response, const char *fieldname,
|
|
const struct wireaddr *addr);
|
|
|
|
/* JSON serialize a network address for a node. */
|
|
void json_add_address_internal(struct json_result *response,
|
|
const char *fieldname,
|
|
const struct wireaddr_internal *addr);
|
|
#endif /* LIGHTNING_LIGHTNINGD_JSON_H */
|