@@ -106,6 +106,7 @@ static void json_invoice(struct command *cmd,
106
106
jsmntok_t * msatoshi , * label , * desc , * exp ;
107
107
u64 * msatoshi_val ;
108
108
const char * label_val ;
109
+ const char * desc_val ;
109
110
struct json_result * response = new_json_result (cmd );
110
111
struct wallet * wallet = cmd -> ld -> wallet ;
111
112
struct bolt11 * b11 ;
@@ -148,6 +149,19 @@ static void json_invoice(struct command *cmd,
148
149
INVOICE_MAX_LABEL_LEN );
149
150
return ;
150
151
}
152
+ /* description */
153
+ if (desc -> end - desc -> start >= BOLT11_FIELD_BYTE_LIMIT ) {
154
+ command_fail (cmd ,
155
+ "Descriptions greater than %d bytes "
156
+ "not yet supported "
157
+ "(description length %d)" ,
158
+ BOLT11_FIELD_BYTE_LIMIT ,
159
+ desc -> end - desc -> start );
160
+ return ;
161
+ }
162
+ desc_val = tal_strndup (cmd , buffer + desc -> start ,
163
+ desc -> end - desc -> start );
164
+ /* expiry */
151
165
if (exp && !json_tok_u64 (buffer , exp , & expiry )) {
152
166
command_fail (cmd , "Expiry '%.*s' invalid seconds" ,
153
167
exp -> end - exp -> start ,
@@ -172,13 +186,8 @@ static void json_invoice(struct command *cmd,
172
186
b11 -> receiver_id = cmd -> ld -> id ;
173
187
b11 -> min_final_cltv_expiry = cmd -> ld -> config .cltv_final ;
174
188
b11 -> expiry = expiry ;
175
- if (desc -> end - desc -> start >= BOLT11_FIELD_BYTE_LIMIT ) {
176
- b11 -> description_hash = tal (b11 , struct sha256 );
177
- sha256 (b11 -> description_hash , buffer + desc -> start ,
178
- desc -> end - desc -> start );
179
- } else
180
- b11 -> description = tal_strndup (b11 , buffer + desc -> start ,
181
- desc -> end - desc -> start );
189
+ b11 -> description = tal_steal (b11 , desc_val );
190
+ b11 -> description_hash = NULL ;
182
191
183
192
/* FIXME: add private routes if necessary! */
184
193
b11enc = bolt11_encode (cmd , b11 , false, hsm_sign_b11 , cmd -> ld );
@@ -190,8 +199,6 @@ static void json_invoice(struct command *cmd,
190
199
json_add_u64 (response , "expiry_time" , invoice -> expiry_time );
191
200
json_add_u64 (response , "expires_at" , invoice -> expiry_time );
192
201
json_add_string (response , "bolt11" , b11enc );
193
- if (b11 -> description_hash )
194
- json_add_string (response , "description" , b11 -> description );
195
202
json_object_end (response );
196
203
197
204
command_success (cmd , response );
0 commit comments