mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 12:44:26 +01:00
jsonrpc: Add json_add_preimage helper
This commit is contained in:
@@ -138,8 +138,7 @@ invoice_payment_serialize(struct invoice_payment_hook_payload *payload,
|
||||
{
|
||||
json_object_start(stream, "payment");
|
||||
json_add_escaped_string(stream, "label", payload->label);
|
||||
json_add_hex(stream, "preimage",
|
||||
&payload->preimage, sizeof(payload->preimage));
|
||||
json_add_preimage(stream, "preimage", &payload->preimage);
|
||||
json_add_string(stream, "msat",
|
||||
type_to_string(tmpctx, struct amount_msat,
|
||||
&payload->msat));
|
||||
@@ -573,6 +572,7 @@ static void gossipd_incoming_channels_reply(struct subd *gossipd,
|
||||
json_add_sha256(response, "payment_hash", &details->rhash);
|
||||
json_add_u64(response, "expires_at", details->expiry_time);
|
||||
json_add_string(response, "bolt11", details->bolt11);
|
||||
json_add_preimage(response, "preimage", &details->r);
|
||||
|
||||
/* Warn if there's not sufficient incoming capacity. */
|
||||
if (tal_count(info->b11->routes) == 0) {
|
||||
|
||||
@@ -438,6 +438,12 @@ void json_add_sha256(struct json_stream *result, const char *fieldname,
|
||||
json_add_hex(result, fieldname, hash, sizeof(*hash));
|
||||
}
|
||||
|
||||
void json_add_preimage(struct json_stream *result, const char *fieldname,
|
||||
const struct preimage *preimage)
|
||||
{
|
||||
json_add_hex(result, fieldname, preimage, sizeof(*preimage));
|
||||
}
|
||||
|
||||
/**
|
||||
* segwit_addr_net_decode - Try to decode a Bech32 address and detect
|
||||
* testnet/mainnet/regtest/signet
|
||||
|
||||
@@ -27,6 +27,7 @@ struct json_stream;
|
||||
struct pubkey;
|
||||
struct node_id;
|
||||
struct sha256;
|
||||
struct preimage;
|
||||
struct short_channel_id;
|
||||
struct wallet_payment;
|
||||
struct wallet_tx;
|
||||
@@ -206,6 +207,9 @@ void json_add_time(struct json_stream *result, const char *fieldname,
|
||||
void json_add_sha256(struct json_stream *result, const char *fieldname,
|
||||
const struct sha256 *hash);
|
||||
|
||||
void json_add_preimage(struct json_stream *result, const char *fieldname,
|
||||
const struct preimage *preimage);
|
||||
|
||||
struct command_result *param_bitcoin_address(struct command *cmd,
|
||||
const char *name,
|
||||
const char *buffer,
|
||||
|
||||
@@ -108,9 +108,8 @@ void json_add_payment_fields(struct json_stream *response,
|
||||
break;
|
||||
}
|
||||
if (t->payment_preimage)
|
||||
json_add_hex(response, "payment_preimage",
|
||||
t->payment_preimage,
|
||||
sizeof(*t->payment_preimage));
|
||||
json_add_preimage(response, "payment_preimage",
|
||||
t->payment_preimage);
|
||||
if (t->label)
|
||||
json_add_string(response, "label", t->label);
|
||||
if (t->bolt11)
|
||||
|
||||
@@ -170,10 +170,6 @@ void json_add_escaped_string(struct json_stream *result UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
const struct json_escape *esc TAKES UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_escaped_string called!\n"); abort(); }
|
||||
/* Generated stub for json_add_hex */
|
||||
void json_add_hex(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
const void *data UNNEEDED, size_t len UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_hex called!\n"); abort(); }
|
||||
/* Generated stub for json_add_hex_talarr */
|
||||
void json_add_hex_talarr(struct json_stream *result UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
@@ -194,6 +190,10 @@ void json_add_node_id(struct json_stream *response UNNEEDED,
|
||||
void json_add_num(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
unsigned int value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_num called!\n"); abort(); }
|
||||
/* Generated stub for json_add_preimage */
|
||||
void json_add_preimage(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
const struct preimage *preimage UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_preimage called!\n"); abort(); }
|
||||
/* Generated stub for json_add_secret */
|
||||
void json_add_secret(struct json_stream *response UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
|
||||
Reference in New Issue
Block a user