| 2394 | } |
| 2395 | |
| 2396 | struct command_result *payment_abort(struct payment *p, enum jsonrpc_errcode code, const char *fmt, ...) { |
| 2397 | va_list ap; |
| 2398 | struct payment *root = payment_root(p); |
| 2399 | payment_set_step(p, PAYMENT_STEP_FAILED); |
| 2400 | p->end_time = clock_time(); |
| 2401 | |
| 2402 | /* We can fail twice, it seems. */ |
| 2403 | tal_free(p->failreason); |
| 2404 | va_start(ap, fmt); |
| 2405 | p->failreason = tal_vfmt(p, fmt, ap); |
| 2406 | va_end(ap); |
| 2407 | |
| 2408 | root->abort = true; |
| 2409 | |
| 2410 | /* Only set the abort error if it's not yet set, otherwise we |
| 2411 | * might end up clobbering the earliest and decisive failure |
| 2412 | * with less relevant ones. */ |
| 2413 | if (root->aborterror == NULL) |
| 2414 | root->aborterror = tal_dup_talarr(root, char, p->failreason); |
| 2415 | |
| 2416 | paymod_log(p, LOG_INFORM, "%s", p->failreason); |
| 2417 | |
| 2418 | /* Do not use payment_continue, because that'd continue |
| 2419 | * applying the modifiers before calling |
| 2420 | * payment_finished(). */ |
| 2421 | return payment_finished(p); |
| 2422 | } |
| 2423 | |
| 2424 | struct command_result *payment_fail(struct payment *p, const char *fmt, ...) |
| 2425 | { |
no test coverage detected