| 1719 | } |
| 1720 | |
| 1721 | static struct command_result *payment_createonion_success(struct command *cmd, |
| 1722 | const char *method, |
| 1723 | const char *buffer, |
| 1724 | const jsmntok_t *toks, |
| 1725 | struct payment *p) |
| 1726 | { |
| 1727 | struct out_req *req; |
| 1728 | struct route_hop *first = &p->route[0]; |
| 1729 | struct secret *secrets; |
| 1730 | struct payment *root = payment_root(p); |
| 1731 | |
| 1732 | /* The delay on the first hop needs to be offset by chainlag, |
| 1733 | * as it would otherwise use the current height in |
| 1734 | * `lightningd`. All other hops have already been adjusted |
| 1735 | * during the payload encoding. |
| 1736 | */ |
| 1737 | u32 delay = first->delay + p->chainlag; |
| 1738 | |
| 1739 | p->createonion_response = json_to_createonion_response(p, buffer, toks); |
| 1740 | |
| 1741 | req = jsonrpc_request_start(payment_cmd(p), "sendonion", |
| 1742 | payment_sendonion_success, |
| 1743 | payment_rpc_failure, p); |
| 1744 | json_add_hex_talarr(req->js, "onion", p->createonion_response->onion); |
| 1745 | |
| 1746 | json_object_start(req->js, "first_hop"); |
| 1747 | json_add_amount_msat(req->js, "amount_msat", first->amount); |
| 1748 | json_add_num(req->js, "delay", delay); |
| 1749 | json_add_node_id(req->js, "id", &first->node_id); |
| 1750 | json_add_short_channel_id(req->js, "channel", first->scid); |
| 1751 | json_object_end(req->js); |
| 1752 | |
| 1753 | json_add_sha256(req->js, "payment_hash", p->payment_hash); |
| 1754 | json_add_amount_msat(req->js, "amount_msat", p->our_amount); |
| 1755 | |
| 1756 | json_array_start(req->js, "shared_secrets"); |
| 1757 | secrets = p->createonion_response->shared_secrets; |
| 1758 | for(size_t i=0; i<tal_count(secrets); i++) |
| 1759 | json_add_secret(req->js, NULL, &secrets[i]); |
| 1760 | json_array_end(req->js); |
| 1761 | |
| 1762 | json_add_num(req->js, "partid", p->partid); |
| 1763 | json_add_u64(req->js, "groupid", p->groupid); |
| 1764 | |
| 1765 | if (p->label) |
| 1766 | json_add_string(req->js, "label", p->label); |
| 1767 | |
| 1768 | if (!root->invstring_used) { |
| 1769 | /* FIXME: rename parameter to invstring */ |
| 1770 | json_add_string(req->js, "bolt11", p->invstring); |
| 1771 | |
| 1772 | if (p->description) |
| 1773 | json_add_string(req->js, "description", p->description); |
| 1774 | } |
| 1775 | |
| 1776 | if (p->pay_destination) |
| 1777 | json_add_node_id(req->js, "destination", p->pay_destination); |
| 1778 |
nothing calls this directly
no test coverage detected