sphinx: Integrating with the new daemon

This commit is contained in:
Christian Decker 2017-04-28 15:20:56 +02:00
parent c44836ee2f
commit b3af8d50a7

View File

@ -1,11 +1,11 @@
#include <ccan/str/hex/hex.h> #include <ccan/str/hex/hex.h>
#include <daemon/jsonrpc.h> #include <daemon/jsonrpc.h>
#include <daemon/log.h> #include <daemon/log.h>
#include <daemon/sphinx.h>
#include <lightningd/channel/gen_channel_wire.h> #include <lightningd/channel/gen_channel_wire.h>
#include <lightningd/htlc_end.h> #include <lightningd/htlc_end.h>
#include <lightningd/lightningd.h> #include <lightningd/lightningd.h>
#include <lightningd/peer_control.h> #include <lightningd/peer_control.h>
#include <lightningd/sphinx.h>
#include <lightningd/subd.h> #include <lightningd/subd.h>
#include <utils.h> #include <utils.h>
@ -56,7 +56,7 @@ static void json_dev_newhtlc(struct command *cmd,
unsigned int expiry; unsigned int expiry;
u64 msatoshi; u64 msatoshi;
struct sha256 rhash; struct sha256 rhash;
struct hoppayload *hoppayloads; struct hop_data *hopsdata;
u8 sessionkey[32]; u8 sessionkey[32];
struct onionpacket *packet; struct onionpacket *packet;
u8 *onion; u8 *onion;
@ -115,13 +115,18 @@ static void json_dev_newhtlc(struct command *cmd,
} }
tal_arr(cmd, struct pubkey, 1); tal_arr(cmd, struct pubkey, 1);
hoppayloads = tal_arrz(cmd, struct hoppayload, 1); hopsdata = tal_arr(cmd, struct hop_data, 1);
hoppayloads[0].amt_to_forward = msatoshi; hopsdata[0].realm = 0;
hoppayloads[0].outgoing_cltv_value = expiry; hopsdata[0].amt_forward = msatoshi;
hopsdata[0].outgoing_cltv = expiry;
/* This is the last hop so set an empty channel_id */
memset(&hopsdata[0].channel_id, 0, sizeof(hopsdata[0].channel_id));
path[0] = *peer->id; path[0] = *peer->id;
randombytes_buf(&sessionkey, sizeof(sessionkey)); randombytes_buf(&sessionkey, sizeof(sessionkey));
packet = create_onionpacket(cmd, path, hoppayloads, sessionkey, packet = create_onionpacket(cmd, path, hopsdata, sessionkey, rhash.u.u8,
rhash.u.u8, sizeof(rhash)); sizeof(rhash));
onion = serialize_onionpacket(cmd, packet); onion = serialize_onionpacket(cmd, packet);
log_debug(peer->log, "JSON command to add new HTLC"); log_debug(peer->log, "JSON command to add new HTLC");