@@ -396,10 +396,10 @@ static void payment_succeeded(struct payment *payment,
396396 }
397397}
398398
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 ,
403403 ...)
404404 PRINTF_FMT (4 ,5 );
405405
@@ -415,11 +415,13 @@ any_attempts_succeeded(const struct payment *payment)
415415 return NULL ;
416416}
417417
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+ ...)
423425{
424426 va_list args ;
425427 const char * msg ;
@@ -555,18 +557,18 @@ static void update_knowledge_from_error(struct command *aux_cmd,
555557 json_tok_full_len (error ), json_tok_full (buf , error ));
556558
557559 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" );
561563 return ;
562564 }
563565 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 ));
570572 return ;
571573 }
572574
@@ -669,10 +671,10 @@ static void update_knowledge_from_error(struct command *aux_cmd,
669671 case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS :
670672 /* FIXME: Maybe this was actually a height
671673 * 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 );
676678 return ;
677679
678680 case WIRE_MPP_TIMEOUT :
@@ -1001,8 +1003,8 @@ static struct command_result *do_inject(struct command *aux_cmd,
10011003 onion = create_onion (tmpctx , attempt , effective_bheight );
10021004 /* FIXME: Handle this better! */
10031005 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!" );
10061008 return command_still_pending (aux_cmd );
10071009 }
10081010
@@ -1040,10 +1042,10 @@ static struct command_result *reserve_done_err(struct command *aux_cmd,
10401042 const jsmntok_t * result ,
10411043 struct attempt * attempt )
10421044{
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 ));
10471049 return command_still_pending (aux_cmd );
10481050}
10491051
@@ -1101,10 +1103,10 @@ static struct command_result *getroutes_done(struct command *aux_cmd,
11011103 /* Even if we're amazingly slow, we should make one attempt. */
11021104 if (payment -> total_num_attempts > 0
11031105 && 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 );
11081110 return command_still_pending (aux_cmd );
11091111 }
11101112
@@ -1189,7 +1191,7 @@ static struct command_result *getroutes_done_err(struct command *aux_cmd,
11891191
11901192 /* Simple case: failed immediately. */
11911193 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 );
11931195 return command_still_pending (aux_cmd );
11941196 }
11951197
@@ -1202,12 +1204,12 @@ static struct command_result *getroutes_done_err(struct command *aux_cmd,
12021204 else
12031205 complaint = tal_fmt (tmpctx , "Then routing for remaining %s failed" ,
12041206 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 );
12111213 return command_still_pending (aux_cmd );
12121214}
12131215
@@ -1499,7 +1501,7 @@ static struct command_result *populate_private_layer(struct command *cmd,
14991501 }
15001502
15011503 /* Nothing actually created yet, so this is the last point we don't use
1502- * "payment_failed " */
1504+ * "payment_give_up " */
15031505 if (all_failed )
15041506 return command_fail (aux_cmd , PAY_ROUTE_NOT_FOUND ,
15051507 "No usable blinded paths: %s" , errors );
0 commit comments