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