| 1485 | } |
| 1486 | |
| 1487 | static struct command_result * |
| 1488 | payment_waitsendpay_finished(struct command *cmd, const char *buffer, |
| 1489 | const jsmntok_t *toks, struct payment *p) |
| 1490 | { |
| 1491 | u8 *update; |
| 1492 | |
| 1493 | assert(p->route != NULL); |
| 1494 | |
| 1495 | p->end_time = time_now(); |
| 1496 | p->result = tal_sendpay_result_from_json(p, buffer, toks); |
| 1497 | |
| 1498 | if (p->result == NULL) { |
| 1499 | paymod_log(p, LOG_UNUSUAL, |
| 1500 | "Unable to parse `waitsendpay` result: %.*s", |
| 1501 | json_tok_full_len(toks), |
| 1502 | json_tok_full(buffer, toks)); |
| 1503 | payment_set_step(p, PAYMENT_STEP_FAILED); |
| 1504 | payment_continue(p); |
| 1505 | return command_still_pending(cmd); |
| 1506 | } |
| 1507 | |
| 1508 | payment_result_infer(p->route, p->result); |
| 1509 | |
| 1510 | if (p->result->state == PAYMENT_COMPLETE) { |
| 1511 | payment_set_step(p, PAYMENT_STEP_SUCCESS); |
| 1512 | payment_continue(p); |
| 1513 | return command_still_pending(cmd); |
| 1514 | } |
| 1515 | |
| 1516 | payment_chanhints_apply_route(p, true); |
| 1517 | |
| 1518 | /* Tell gossipd, if we received an update */ |
| 1519 | update = channel_update_from_onion_error(tmpctx, p->result->raw_message); |
| 1520 | if (update) { |
| 1521 | struct out_req *req; |
| 1522 | paymod_log(p, LOG_DBG, |
| 1523 | "Extracted channel_update %s from onionreply %s", |
| 1524 | tal_hex(tmpctx, update), |
| 1525 | tal_hex(tmpctx, p->result->raw_message)); |
| 1526 | req = jsonrpc_request_start(p->plugin, NULL, "addgossip", |
| 1527 | payment_addgossip_success, |
| 1528 | payment_addgossip_failure, p); |
| 1529 | json_add_hex_talarr(req->js, "message", update); |
| 1530 | send_outreq(p->plugin, req); |
| 1531 | return command_still_pending(cmd); |
| 1532 | } |
| 1533 | |
| 1534 | return payment_addgossip_success(cmd, NULL, NULL, p); |
| 1535 | } |
| 1536 | |
| 1537 | static struct command_result *payment_sendonion_success(struct command *cmd, |
| 1538 | const char *buffer, |
nothing calls this directly
no test coverage detected