@@ -396,10 +396,10 @@ static void payment_succeeded(struct payment *payment,
396
396
}
397
397
}
398
398
399
- static void payment_failed (struct command * aux_cmd ,
400
- struct payment * payment ,
401
- enum jsonrpc_errcode code ,
402
- const char * fmt ,
399
+ static void payment_give_up (struct command * aux_cmd ,
400
+ struct payment * payment ,
401
+ enum jsonrpc_errcode code ,
402
+ const char * fmt ,
403
403
...)
404
404
PRINTF_FMT (4 ,5 );
405
405
@@ -415,11 +415,13 @@ any_attempts_succeeded(const struct payment *payment)
415
415
return NULL ;
416
416
}
417
417
418
- static void payment_failed (struct command * aux_cmd ,
419
- struct payment * payment ,
420
- enum jsonrpc_errcode code ,
421
- const char * fmt ,
422
- ...)
418
+ /* We won't try sending any more. Usually this means we return this
419
+ * failure to the user, but see below. */
420
+ static void payment_give_up (struct command * aux_cmd ,
421
+ struct payment * payment ,
422
+ enum jsonrpc_errcode code ,
423
+ const char * fmt ,
424
+ ...)
423
425
{
424
426
va_list args ;
425
427
const char * msg ;
@@ -555,18 +557,18 @@ static void update_knowledge_from_error(struct command *aux_cmd,
555
557
json_tok_full_len (error ), json_tok_full (buf , error ));
556
558
557
559
if (ecode == PAY_INJECTPAYMENTONION_ALREADY_PAID ) {
558
- payment_failed (aux_cmd , attempt -> payment ,
559
- PAY_INJECTPAYMENTONION_FAILED ,
560
- "Already paid this invoice successfully" );
560
+ payment_give_up (aux_cmd , attempt -> payment ,
561
+ PAY_INJECTPAYMENTONION_FAILED ,
562
+ "Already paid this invoice successfully" );
561
563
return ;
562
564
}
563
565
if (ecode != PAY_INJECTPAYMENTONION_FAILED ) {
564
- payment_failed (aux_cmd , attempt -> payment ,
565
- PLUGIN_ERROR ,
566
- "Unexpected injectpaymentonion error %i: %.*s" ,
567
- ecode ,
568
- json_tok_full_len (error ),
569
- json_tok_full (buf , error ));
566
+ payment_give_up (aux_cmd , attempt -> payment ,
567
+ PLUGIN_ERROR ,
568
+ "Unexpected injectpaymentonion error %i: %.*s" ,
569
+ ecode ,
570
+ json_tok_full_len (error ),
571
+ json_tok_full (buf , error ));
570
572
return ;
571
573
}
572
574
@@ -669,10 +671,10 @@ static void update_knowledge_from_error(struct command *aux_cmd,
669
671
case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS :
670
672
/* FIXME: Maybe this was actually a height
671
673
* disagreement, so check height */
672
- payment_failed (aux_cmd , attempt -> payment ,
673
- PAY_DESTINATION_PERM_FAIL ,
674
- "Destination said it doesn't know invoice: %s" ,
675
- errmsg );
674
+ payment_give_up (aux_cmd , attempt -> payment ,
675
+ PAY_DESTINATION_PERM_FAIL ,
676
+ "Destination said it doesn't know invoice: %s" ,
677
+ errmsg );
676
678
return ;
677
679
678
680
case WIRE_MPP_TIMEOUT :
@@ -1001,8 +1003,8 @@ static struct command_result *do_inject(struct command *aux_cmd,
1001
1003
onion = create_onion (tmpctx , attempt , effective_bheight );
1002
1004
/* FIXME: Handle this better! */
1003
1005
if (!onion ) {
1004
- payment_failed (aux_cmd , attempt -> payment , PAY_UNSPECIFIED_ERROR ,
1005
- "Could not create payment onion: path too long!" );
1006
+ payment_give_up (aux_cmd , attempt -> payment , PAY_UNSPECIFIED_ERROR ,
1007
+ "Could not create payment onion: path too long!" );
1006
1008
return command_still_pending (aux_cmd );
1007
1009
}
1008
1010
@@ -1040,10 +1042,10 @@ static struct command_result *reserve_done_err(struct command *aux_cmd,
1040
1042
const jsmntok_t * result ,
1041
1043
struct attempt * attempt )
1042
1044
{
1043
- payment_failed (aux_cmd , attempt -> payment , PAY_UNSPECIFIED_ERROR ,
1044
- "Reservation failed: '%.*s'" ,
1045
- json_tok_full_len (result ),
1046
- json_tok_full (buf , result ));
1045
+ payment_give_up (aux_cmd , attempt -> payment , PAY_UNSPECIFIED_ERROR ,
1046
+ "Reservation failed: '%.*s'" ,
1047
+ json_tok_full_len (result ),
1048
+ json_tok_full (buf , result ));
1047
1049
return command_still_pending (aux_cmd );
1048
1050
}
1049
1051
@@ -1101,10 +1103,10 @@ static struct command_result *getroutes_done(struct command *aux_cmd,
1101
1103
/* Even if we're amazingly slow, we should make one attempt. */
1102
1104
if (payment -> total_num_attempts > 0
1103
1105
&& time_greater_ (time_mono ().ts , payment -> deadline .ts )) {
1104
- payment_failed (aux_cmd , payment , PAY_UNSPECIFIED_ERROR ,
1105
- "Timed out after after %" PRIu64 " attempts. %s" ,
1106
- payment -> total_num_attempts ,
1107
- payment -> prior_results );
1106
+ payment_give_up (aux_cmd , payment , PAY_UNSPECIFIED_ERROR ,
1107
+ "Timed out after after %" PRIu64 " attempts. %s" ,
1108
+ payment -> total_num_attempts ,
1109
+ payment -> prior_results );
1108
1110
return command_still_pending (aux_cmd );
1109
1111
}
1110
1112
@@ -1189,7 +1191,7 @@ static struct command_result *getroutes_done_err(struct command *aux_cmd,
1189
1191
1190
1192
/* Simple case: failed immediately. */
1191
1193
if (payment -> total_num_attempts == 0 ) {
1192
- payment_failed (aux_cmd , payment , code , "Failed: %s" , msg );
1194
+ payment_give_up (aux_cmd , payment , code , "Failed: %s" , msg );
1193
1195
return command_still_pending (aux_cmd );
1194
1196
}
1195
1197
@@ -1202,12 +1204,12 @@ static struct command_result *getroutes_done_err(struct command *aux_cmd,
1202
1204
else
1203
1205
complaint = tal_fmt (tmpctx , "Then routing for remaining %s failed" ,
1204
1206
fmt_amount_msat (tmpctx , payment -> amount_being_routed ));
1205
- payment_failed (aux_cmd , payment , PAY_UNSPECIFIED_ERROR ,
1206
- "Failed after %" PRIu64 " attempts. %s%s: %s" ,
1207
- payment -> total_num_attempts ,
1208
- payment -> prior_results ,
1209
- complaint ,
1210
- msg );
1207
+ payment_give_up (aux_cmd , payment , PAY_UNSPECIFIED_ERROR ,
1208
+ "Failed after %" PRIu64 " attempts. %s%s: %s" ,
1209
+ payment -> total_num_attempts ,
1210
+ payment -> prior_results ,
1211
+ complaint ,
1212
+ msg );
1211
1213
return command_still_pending (aux_cmd );
1212
1214
}
1213
1215
@@ -1499,7 +1501,7 @@ static struct command_result *populate_private_layer(struct command *cmd,
1499
1501
}
1500
1502
1501
1503
/* Nothing actually created yet, so this is the last point we don't use
1502
- * "payment_failed " */
1504
+ * "payment_give_up " */
1503
1505
if (all_failed )
1504
1506
return command_fail (aux_cmd , PAY_ROUTE_NOT_FOUND ,
1505
1507
"No usable blinded paths: %s" , errors );
0 commit comments