11#include "config.h"
2+ #include <ccan/json_escape/json_escape.h>
23#include <ccan/json_out/json_out.h>
34#include <ccan/mem/mem.h>
45#include <ccan/str/hex/hex.h>
@@ -791,19 +792,19 @@ static bool payer_key(const struct offers_data *od,
791792static u8 * recurrence_invreq_metadata (const tal_t * ctx ,
792793 const struct tlv_invoice_request * invreq ,
793794 const struct secret * nodealias_base ,
794- const char * rec_label )
795+ const struct json_escape * rec_label )
795796{
796797 struct sha256 offer_id , tweak ;
797798 u8 * tweak_input ;
798799
799800 /* Use "offer_id || label" as tweak input */
800801 invreq_offer_id (invreq , & offer_id );
801802 tweak_input = tal_arr (tmpctx , u8 ,
802- sizeof (offer_id ) + strlen (rec_label ));
803+ sizeof (offer_id ) + strlen (rec_label -> s ));
803804 memcpy (tweak_input , & offer_id , sizeof (offer_id ));
804805 memcpy (tweak_input + sizeof (offer_id ),
805- rec_label ,
806- strlen (rec_label ));
806+ rec_label -> s ,
807+ strlen (rec_label -> s ));
807808
808809 bolt12_alias_tweak (nodealias_base ,
809810 tweak_input ,
@@ -854,7 +855,8 @@ struct command_result *json_fetchinvoice(struct command *cmd,
854855{
855856 const struct offers_data * od = get_offers_data (cmd -> plugin );
856857 struct amount_msat * msat ;
857- const char * rec_label , * payer_note ;
858+ const char * payer_note ;
859+ struct json_escape * rec_label ;
858860 u8 * payer_metadata ;
859861 struct out_req * req ;
860862 struct tlv_invoice_request * invreq ;
@@ -870,7 +872,7 @@ struct command_result *json_fetchinvoice(struct command *cmd,
870872 p_opt ("quantity" , param_u64 , & quantity ),
871873 p_opt ("recurrence_counter" , param_number , & recurrence_counter ),
872874 p_opt ("recurrence_start" , param_number , & recurrence_start ),
873- p_opt ("recurrence_label" , param_string , & rec_label ),
875+ p_opt ("recurrence_label" , param_label , & rec_label ),
874876 p_opt_def ("timeout" , param_number , & timeout , 60 ),
875877 p_opt ("payer_note" , param_string , & payer_note ),
876878 p_opt ("payer_metadata" , param_bin_from_hex , & payer_metadata ),
@@ -1096,7 +1098,7 @@ struct command_result *json_fetchinvoice(struct command *cmd,
10961098 json_add_string (req -> js , "bolt12" , invrequest_encode (tmpctx , invreq ));
10971099 json_add_bool (req -> js , "savetodb" , false);
10981100 if (rec_label )
1099- json_add_string (req -> js , "label" , rec_label );
1101+ json_add_escaped_string (req -> js , "label" , rec_label );
11001102 return send_outreq (req );
11011103}
11021104
@@ -1105,7 +1107,8 @@ struct command_result *json_cancelrecurringinvoice(struct command *cmd,
11051107 const jsmntok_t * params )
11061108{
11071109 const struct offers_data * od = get_offers_data (cmd -> plugin );
1108- const char * rec_label , * payer_note ;
1110+ const char * payer_note ;
1111+ struct json_escape * rec_label ;
11091112 struct out_req * req ;
11101113 struct tlv_invoice_request * invreq ;
11111114 struct sent * sent = tal (cmd , struct sent );
@@ -1115,7 +1118,7 @@ struct command_result *json_cancelrecurringinvoice(struct command *cmd,
11151118 if (!param_check (cmd , buffer , params ,
11161119 p_req ("offer" , param_offer , & sent -> offer ),
11171120 p_req ("recurrence_counter" , param_number , & recurrence_counter ),
1118- p_req ("recurrence_label" , param_string , & rec_label ),
1121+ p_req ("recurrence_label" , param_label , & rec_label ),
11191122 p_opt ("recurrence_start" , param_number , & recurrence_start ),
11201123 p_opt ("payer_note" , param_string , & payer_note ),
11211124 p_opt ("bip353" , param_bip353 , & bip353 ),
@@ -1250,7 +1253,7 @@ struct command_result *json_cancelrecurringinvoice(struct command *cmd,
12501253 /* We don't want this is the database: that's only for ones we publish */
12511254 json_add_string (req -> js , "bolt12" , invrequest_encode (tmpctx , invreq ));
12521255 json_add_bool (req -> js , "savetodb" , false);
1253- json_add_string (req -> js , "label" , rec_label );
1256+ json_add_escaped_string (req -> js , "label" , rec_label );
12541257 return send_outreq (req );
12551258}
12561259
0 commit comments