Returns magic value to send generic incorrect_or_unknown_payment_details */
| 222 | |
| 223 | /* Returns magic value to send generic incorrect_or_unknown_payment_details */ |
| 224 | static const u8 *hook_gives_failmsg(const tal_t *ctx, |
| 225 | struct lightningd *ld, |
| 226 | const char *buffer, |
| 227 | const jsmntok_t *toks) |
| 228 | { |
| 229 | const jsmntok_t *resulttok; |
| 230 | const jsmntok_t *t; |
| 231 | const u8 *failmsg; |
| 232 | |
| 233 | /* No plugin registered on hook at all? */ |
| 234 | if (!buffer) |
| 235 | return NULL; |
| 236 | |
| 237 | resulttok = json_get_member(buffer, toks, "result"); |
| 238 | if (resulttok) { |
| 239 | if (json_tok_streq(buffer, resulttok, "continue")) { |
| 240 | return NULL; |
| 241 | } else if (json_tok_streq(buffer, resulttok, "reject")) { |
| 242 | /* htlc_set_fail makes this a per-htlc |
| 243 | * incorrect_or_unknown_payment_details */ |
| 244 | return tal_arr(ctx, u8, 0); |
| 245 | } else |
| 246 | fatal("Invalid invoice_payment hook result: %.*s", |
| 247 | toks[0].end - toks[0].start, buffer); |
| 248 | } |
| 249 | |
| 250 | t = json_get_member(buffer, toks, "failure_message"); |
| 251 | if (!t) { |
| 252 | fatal("Missing failure_message in invoice_payment hook result: %.*s", |
| 253 | toks[0].end - toks[0].start, buffer); |
| 254 | } |
| 255 | |
| 256 | failmsg = json_tok_bin_from_hex(ctx, buffer, t); |
| 257 | if (!failmsg) |
| 258 | fatal("Invalid invoice_payment_hook failure_message: %.*s", |
| 259 | toks[0].end - toks[1].start, buffer); |
| 260 | return failmsg; |
| 261 | } |
| 262 | |
| 263 | static void |
| 264 | invoice_payment_hooks_done(struct invoice_payment_hook_payload *payload STEALS) |
no test coverage detected