paymod: Consolidate parsing RPC results in libplugin

We handle these in a number of different ways, and regularly get the parsing
and logic for optional fields wrong, so let's consolidate them here.
This commit is contained in:
Christian Decker
2020-06-09 18:30:14 +02:00
parent 4b3e849ce9
commit f557955515
6 changed files with 414 additions and 97 deletions

View File

@@ -254,4 +254,59 @@ void NORETURN LAST_ARG_NULL plugin_main(char *argv[],
const struct plugin_hook *hook_subs,
size_t num_hook_subs,
...);
struct listpeers_channel {
bool private;
struct bitcoin_txid funding_txid;
const char *state;
struct short_channel_id *scid;
int *direction;
struct amount_msat total_msat;
struct amount_msat spendable_msat;
/* TODO Add fields as we need them. */
};
struct listpeers_peer {
struct node_id id;
bool connected;
const char **netaddr;
struct feature_set *features;
struct listpeers_channel **channels;
};
struct listpeers_result {
struct listpeers_peer **peers;
};
struct listpeers_result *json_to_listpeers_result(const tal_t *ctx,
const char *buffer,
const jsmntok_t *tok);
struct createonion_response {
u8 *onion;
struct secret *shared_secrets;
};
struct createonion_response *json_to_createonion_response(const tal_t *ctx,
const char *buffer,
const jsmntok_t *toks);
enum route_hop_style {
ROUTE_HOP_LEGACY = 1,
ROUTE_HOP_TLV = 2,
};
struct route_hop {
struct short_channel_id channel_id;
int direction;
struct node_id nodeid;
struct amount_msat amount;
u32 delay;
struct pubkey *blinding;
enum route_hop_style style;
};
struct route_hop *json_to_route(const tal_t *ctx, const char *buffer,
const jsmntok_t *toks);
#endif /* LIGHTNING_PLUGINS_LIBPLUGIN_H */