| 2410 | } |
| 2411 | |
| 2412 | struct command_result *payment_abort(struct payment *p, enum jsonrpc_errcode code, const char *fmt, ...) { |
| 2413 | va_list ap; |
| 2414 | struct payment *root = payment_root(p); |
| 2415 | payment_set_step(p, PAYMENT_STEP_FAILED); |
| 2416 | p->end_time = clock_time(); |
| 2417 | |
| 2418 | /* We can fail twice, it seems. */ |
| 2419 | tal_free(p->failreason); |
| 2420 | va_start(ap, fmt); |
| 2421 | p->failreason = tal_vfmt(p, fmt, ap); |
| 2422 | va_end(ap); |
| 2423 | |
| 2424 | root->abort = true; |
| 2425 | |
| 2426 | /* Only set the abort error if it's not yet set, otherwise we |
| 2427 | * might end up clobbering the earliest and decisive failure |
| 2428 | * with less relevant ones. */ |
| 2429 | if (root->aborterror == NULL) |
| 2430 | root->aborterror = tal_dup_talarr(root, char, p->failreason); |
| 2431 | |
| 2432 | paymod_log(p, LOG_INFORM, "%s", p->failreason); |
| 2433 | |
| 2434 | /* Do not use payment_continue, because that'd continue |
| 2435 | * applying the modifiers before calling |
| 2436 | * payment_finished(). */ |
| 2437 | return payment_finished(p); |
| 2438 | } |
| 2439 | |
| 2440 | struct command_result *payment_fail(struct payment *p, const char *fmt, ...) |
| 2441 | { |
no test coverage detected