| 1976 | AUTODATA(json_command, &preapprovekeysend_command); |
| 1977 | |
| 1978 | static struct command_result *json_signinvoice(struct command *cmd, |
| 1979 | const char *buffer, |
| 1980 | const jsmntok_t *obj UNNEEDED, |
| 1981 | const jsmntok_t *params) |
| 1982 | { |
| 1983 | const char *invstring; |
| 1984 | struct json_stream *response; |
| 1985 | struct bolt11 *b11; |
| 1986 | struct sha256 hash; |
| 1987 | const u5 *sig; |
| 1988 | bool have_n; |
| 1989 | const char *fail; |
| 1990 | |
| 1991 | if (!param_check(cmd, buffer, params, |
| 1992 | p_req("invstring", param_invstring, &invstring), |
| 1993 | NULL)) |
| 1994 | return command_param_failed(); |
| 1995 | |
| 1996 | b11 = bolt11_decode_nosig(cmd, invstring, cmd->ld->our_features, |
| 1997 | NULL, chainparams, &hash, &sig, &have_n, |
| 1998 | &fail); |
| 1999 | |
| 2000 | if (!b11) |
| 2001 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2002 | "Unparsable invoice '%s': %s", |
| 2003 | invstring, fail); |
| 2004 | |
| 2005 | /* This adds the signature */ |
| 2006 | char *b11enc = bolt11_encode(cmd, b11, have_n, |
| 2007 | hsm_sign_b11, cmd->ld); |
| 2008 | |
| 2009 | /* BOLT #11: |
| 2010 | * A writer: |
| 2011 | *... |
| 2012 | * - MUST include either exactly one `d` or exactly one `h` field. |
| 2013 | */ |
| 2014 | if (!b11->description && !b11->description_hash) |
| 2015 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2016 | "Missing description in invoice"); |
| 2017 | |
| 2018 | if (command_check_only(cmd)) |
| 2019 | return command_check_done(cmd); |
| 2020 | |
| 2021 | response = json_stream_success(cmd); |
| 2022 | json_add_invstring(response, b11enc); |
| 2023 | return command_success(cmd, response); |
| 2024 | } |
| 2025 | |
| 2026 | static const struct json_command signinvoice_command = { |
| 2027 | "signinvoice", |
nothing calls this directly
no test coverage detected