@@ -313,101 +313,6 @@ static const struct json_command enableoffer_command = {
313313};
314314AUTODATA (json_command , & enableoffer_command );
315315
316-
317- /* We do some sanity checks now, since we're looking up prev payment anyway,
318- * but our main purpose is to fill in prev_basetime tweak. */
319- static struct command_result * prev_payment (struct command * cmd ,
320- const struct json_escape * label ,
321- const struct tlv_invoice_request * invreq ,
322- u64 * * prev_basetime )
323- {
324- struct sha256 invreq_oid ;
325- u64 last_recurrence = UINT64_MAX ;
326- bool prev_unpaid = false;
327-
328- invreq_offer_id (invreq , & invreq_oid );
329-
330- for (struct db_stmt * stmt = payments_by_label (cmd -> ld -> wallet , label );
331- stmt ;
332- stmt = payments_next (cmd -> ld -> wallet , stmt )) {
333- const struct wallet_payment * payment ;
334- const struct tlv_invoice * inv ;
335- const char * fail ;
336- struct sha256 inv_oid ;
337-
338- payment = payment_get_details (tmpctx , stmt );
339- if (!payment -> invstring )
340- continue ;
341-
342- inv = invoice_decode (tmpctx , payment -> invstring ,
343- strlen (payment -> invstring ),
344- NULL , chainparams , & fail );
345- if (!inv )
346- continue ;
347-
348- /* They can reuse labels across different offers. */
349- invoice_offer_id (inv , & inv_oid );
350- if (!sha256_eq (& inv_oid , & invreq_oid ))
351- continue ;
352-
353- /* Be paranoid, in case someone inserts their own
354- * clashing label! */
355- if (!inv -> invreq_recurrence_counter )
356- continue ;
357-
358- /* BOLT-recurrence #12:
359- * - if `offer_recurrence_base` is present:
360- * - MUST include `invreq_recurrence_start`
361- * - MUST set `period_offset` to the period the sender wants for the
362- * initial request
363- * - MUST set `period_offset` to the same value on all following requests.
364- */
365- if (inv -> invreq_recurrence_start
366- && invreq -> invreq_recurrence_start
367- && * inv -> invreq_recurrence_start != * invreq -> invreq_recurrence_start ) {
368- tal_free (stmt );
369- return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
370- "recurrence_start was"
371- " previously %u" ,
372- * inv -> invreq_recurrence_start );
373- }
374-
375- /* They should all have the same basetime */
376- if (!* prev_basetime )
377- * prev_basetime = tal_dup (cmd , u64 , inv -> invoice_recurrence_basetime );
378-
379- /* Track highest one for better diagnostics */
380- if (last_recurrence == UINT64_MAX
381- || last_recurrence < * inv -> invreq_recurrence_counter ) {
382- last_recurrence = * inv -> invreq_recurrence_counter ;
383- }
384-
385- if (* inv -> invreq_recurrence_counter == * invreq -> invreq_recurrence_counter - 1 ) {
386- /* Got it! */
387- if (payment -> status == PAYMENT_COMPLETE ) {
388- tal_free (stmt );
389- return NULL ;
390- } else
391- prev_unpaid = true;
392- }
393- }
394-
395- /* We found one, but it didn't succeed */
396- if (prev_unpaid )
397- return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
398- "previous invoice payment did not succeed" );
399-
400- /* We found one, but it was not the previus one */
401- if (last_recurrence != UINT64_MAX )
402- return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
403- "previous invoice has not been paid (last was %" PRIu64 ")" ,
404- last_recurrence );
405-
406- return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
407- "No previous payment attempted for this"
408- " label and offer" );
409- }
410-
411316/* FIXME(vincenzopalazzo): move this to comm/bolt12.h */
412317static struct command_result * param_b12_invreq (struct command * cmd ,
413318 const char * name ,
@@ -483,7 +388,7 @@ static struct command_result *json_createinvoicerequest(struct command *cmd,
483388 if (!param_check (cmd , buffer , params ,
484389 p_req ("bolt12" , param_b12_invreq , & invreq ),
485390 p_req ("savetodb" , param_bool , & save ),
486- p_opt ("recurrence_label " , param_label , & label ),
391+ p_opt ("label " , param_label , & label ),
487392 p_opt_def ("single_use" , param_bool , & single_use , true),
488393 NULL ))
489394 return command_param_failed ();
@@ -493,21 +398,6 @@ static struct command_result *json_createinvoicerequest(struct command *cmd,
493398 else
494399 status = OFFER_MULTIPLE_USE_UNUSED ;
495400
496- /* If it's a recurring payment, we look for previous to copy basetime */
497- if (invreq -> invreq_recurrence_counter ) {
498- if (!label )
499- return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
500- "Need payment label for recurring payments" );
501-
502- if (* invreq -> invreq_recurrence_counter != 0 ) {
503- struct command_result * err
504- = prev_payment (cmd , label , invreq ,
505- & prev_basetime );
506- if (err )
507- return err ;
508- }
509- }
510-
511401 /* If the payer_id is not our node id, we sanity check that it
512402 * correctly maps from invreq_metadata */
513403 if (!pubkey_eq (invreq -> invreq_payer_id , & cmd -> ld -> our_pubkey )) {
0 commit comments