chaintopology: new command 'parsefeerate'

Useful for parsing a passed in feerate before calling lightningd with
it, e.g. when you need to know what the feerate is for a fundpsbt before
calling fundpsbt

Changelog-Added: JSON-RPC: new command `parsefeerate` which takes a feerate string and returns the calculated perkw/perkb
This commit is contained in:
niftynei
2021-06-23 14:31:47 -05:00
committed by neil saitug
parent 2532aa003a
commit 43ae30df21
9 changed files with 148 additions and 10 deletions

View File

@@ -553,6 +553,33 @@ static const struct json_command feerates_command = {
};
AUTODATA(json_command, &feerates_command);
static struct command_result *json_parse_feerate(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
const jsmntok_t *params)
{
struct json_stream *response;
u32 *feerate;
if (!param(cmd, buffer, params,
p_req("feerate", param_feerate, &feerate),
NULL))
return command_param_failed();
response = json_stream_success(cmd);
json_add_num(response, feerate_style_name(FEERATE_PER_KSIPA),
feerate_to_style(*feerate, FEERATE_PER_KSIPA));
return command_success(cmd, response);
}
static const struct json_command parse_feerate_command = {
"parsefeerate",
"bitcoin",
json_parse_feerate,
"Return current feerate in perkw + perkb for given feerate string."
};
AUTODATA(json_command, &parse_feerate_command);
static void next_updatefee_timer(struct chain_topology *topo)
{
/* This takes care of its own lifetime. */