| 1453 | } |
| 1454 | |
| 1455 | static struct command_result *do_inject(struct command *aux_cmd, |
| 1456 | struct attempt *attempt) |
| 1457 | { |
| 1458 | struct out_req *req; |
| 1459 | const u8 *onion; |
| 1460 | struct xpay *xpay = xpay_of(attempt->payment->plugin); |
| 1461 | /* In case a block comes in, we give CLTVs an extra 1. */ |
| 1462 | u32 effective_bheight = xpay->blockheight + 1; |
| 1463 | |
| 1464 | onion = create_onion(tmpctx, attempt, effective_bheight); |
| 1465 | /* FIXME: Handle this better! */ |
| 1466 | if (!onion) { |
| 1467 | payment_give_up(aux_cmd, attempt->payment, PAY_UNSPECIFIED_ERROR, |
| 1468 | "Could not create payment onion: path too long!"); |
| 1469 | return command_still_pending(aux_cmd); |
| 1470 | } |
| 1471 | |
| 1472 | outgoing_notify_start(attempt); |
| 1473 | attempt->start_time = time_mono(); |
| 1474 | |
| 1475 | req = jsonrpc_request_start(aux_cmd, |
| 1476 | "injectpaymentonion", |
| 1477 | injectpaymentonion_succeeded, |
| 1478 | injectpaymentonion_failed, |
| 1479 | attempt); |
| 1480 | json_add_hex_talarr(req->js, "onion", onion); |
| 1481 | json_add_sha256(req->js, "payment_hash", &attempt->payment->payment_hash); |
| 1482 | /* If no route, its the same as delivery (self-pay) */ |
| 1483 | json_add_amount_msat(req->js, "amount_msat", inject_amount(attempt)); |
| 1484 | json_add_u32(req->js, "cltv_expiry", initial_cltv_delta(attempt) + effective_bheight); |
| 1485 | json_add_u64(req->js, "partid", attempt->partid); |
| 1486 | json_add_u64(req->js, "groupid", attempt->payment->group_id); |
| 1487 | /* Use invstring for payments, destination directly for keysend */ |
| 1488 | if (attempt->payment->invstring) |
| 1489 | json_add_string(req->js, "invstring", attempt->payment->invstring); |
| 1490 | else |
| 1491 | json_add_pubkey(req->js, "destination", &attempt->payment->destination); |
| 1492 | json_add_amount_msat(req->js, "destination_msat", attempt_deliver(attempt)); |
| 1493 | if (attempt->payment->localinvreqid) |
| 1494 | json_add_sha256(req->js, "localinvreqid", attempt->payment->localinvreqid); |
| 1495 | if (attempt->payment->label) |
| 1496 | json_add_escaped_string(req->js, "label", attempt->payment->label); |
| 1497 | return send_payment_req(aux_cmd, attempt->payment, req); |
| 1498 | } |
| 1499 | |
| 1500 | static struct command_result *reserve_done(struct command *aux_cmd, |
| 1501 | const char *method, |
no test coverage detected