| 2117 | } |
| 2118 | |
| 2119 | void payment_abort(struct payment *p, const char *fmt, ...) { |
| 2120 | va_list ap; |
| 2121 | struct payment *root = payment_root(p); |
| 2122 | payment_set_step(p, PAYMENT_STEP_FAILED); |
| 2123 | p->end_time = time_now(); |
| 2124 | |
| 2125 | /* We can fail twice, it seems. */ |
| 2126 | tal_free(p->failreason); |
| 2127 | va_start(ap, fmt); |
| 2128 | p->failreason = tal_vfmt(p, fmt, ap); |
| 2129 | va_end(ap); |
| 2130 | |
| 2131 | root->abort = true; |
| 2132 | |
| 2133 | /* Only set the abort error if it's not yet set, otherwise we |
| 2134 | * might end up clobbering the earliest and decisive failure |
| 2135 | * with less relevant ones. */ |
| 2136 | if (root->aborterror == NULL) |
| 2137 | root->aborterror = tal_dup_talarr(root, char, p->failreason); |
| 2138 | |
| 2139 | paymod_log(p, LOG_INFORM, "%s", p->failreason); |
| 2140 | |
| 2141 | /* Do not use payment_continue, because that'd continue |
| 2142 | * applying the modifiers before calling |
| 2143 | * payment_finished(). */ |
| 2144 | payment_finished(p); |
| 2145 | } |
| 2146 | |
| 2147 | void payment_fail(struct payment *p, const char *fmt, ...) |
| 2148 | { |
no test coverage detected