mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 22:31:48 +01:00
lightningd/peer_control: Add RPC for fetching scb for all the in-memory channels.
This commit is contained in:
parent
eca844eb36
commit
1a1be6abd6
1 changed files with 52 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <common/jsonrpc_errors.h>
|
||||
#include <common/key_derive.h>
|
||||
#include <common/param.h>
|
||||
#include <common/scb_wiregen.h>
|
||||
#include <common/shutdown_scriptpubkey.h>
|
||||
#include <common/status.h>
|
||||
#include <common/timeout.h>
|
||||
|
@ -1757,6 +1758,57 @@ static const struct json_command listpeers_command = {
|
|||
/* Comment added to satisfice AUTODATA */
|
||||
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 *
|
||||
command_find_channel(struct command *cmd,
|
||||
const char *buffer, const jsmntok_t *tok,
|
||||
|
|
Loading…
Add table
Reference in a new issue