mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
lightningd/peer_control: Add RPC for fetching scb for all the in-memory channels.
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <common/jsonrpc_errors.h>
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/key_derive.h>
|
#include <common/key_derive.h>
|
||||||
#include <common/param.h>
|
#include <common/param.h>
|
||||||
|
#include <common/scb_wiregen.h>
|
||||||
#include <common/shutdown_scriptpubkey.h>
|
#include <common/shutdown_scriptpubkey.h>
|
||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
@@ -1757,6 +1758,57 @@ static const struct json_command listpeers_command = {
|
|||||||
/* Comment added to satisfice AUTODATA */
|
/* Comment added to satisfice AUTODATA */
|
||||||
AUTODATA(json_command, &listpeers_command);
|
AUTODATA(json_command, &listpeers_command);
|
||||||
|
|
||||||
|
static void json_add_scb(struct command *cmd,
|
||||||
|
const char *fieldname,
|
||||||
|
struct json_stream *response,
|
||||||
|
struct channel *c)
|
||||||
|
{
|
||||||
|
u8 *scb = tal_arr(cmd, u8, 0);
|
||||||
|
|
||||||
|
towire_scb_chan(&scb, c->scb);
|
||||||
|
json_add_hex_talarr(response, fieldname,
|
||||||
|
scb);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This will return a SCB for all the channels currently loaded
|
||||||
|
* in the in-memory channel */
|
||||||
|
static struct command_result *json_staticbackup(struct command *cmd,
|
||||||
|
const char *buffer,
|
||||||
|
const jsmntok_t *obj UNNEEDED,
|
||||||
|
const jsmntok_t *params)
|
||||||
|
{
|
||||||
|
struct json_stream *response;
|
||||||
|
struct peer *peer;
|
||||||
|
struct channel *channel;
|
||||||
|
|
||||||
|
if (!param(cmd, buffer, params, NULL))
|
||||||
|
return command_param_failed();
|
||||||
|
|
||||||
|
response = json_stream_success(cmd);
|
||||||
|
|
||||||
|
json_array_start(response, "scb");
|
||||||
|
|
||||||
|
list_for_each(&cmd->ld->peers, peer, list)
|
||||||
|
list_for_each(&peer->channels, channel, list){
|
||||||
|
if (!channel->scb)
|
||||||
|
continue;
|
||||||
|
json_add_scb(cmd, NULL, response, channel);
|
||||||
|
}
|
||||||
|
json_array_end(response);
|
||||||
|
|
||||||
|
return command_success(cmd, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct json_command staticbackup_command = {
|
||||||
|
"staticbackup",
|
||||||
|
"backup",
|
||||||
|
json_staticbackup,
|
||||||
|
"Returns SCB of all the channels currently present in the DB"
|
||||||
|
};
|
||||||
|
/* Comment added to satisfice AUTODATA */
|
||||||
|
AUTODATA(json_command, &staticbackup_command);
|
||||||
|
|
||||||
|
|
||||||
struct command_result *
|
struct command_result *
|
||||||
command_find_channel(struct command *cmd,
|
command_find_channel(struct command *cmd,
|
||||||
const char *buffer, const jsmntok_t *tok,
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
|||||||
Reference in New Issue
Block a user