mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
tools/generate-wire.py: remove length argument from fromwire_ routines.
We always hand in "NULL" (which means use tal_len on the msg), except for two places which do that manually for no good reason. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
719290a4c4
commit
e92b710406
33 changed files with 217 additions and 263 deletions
|
@ -259,7 +259,7 @@ static void gossip_in(struct peer *peer, const u8 *msg)
|
|||
u8 *gossip;
|
||||
u16 type;
|
||||
|
||||
if (!fromwire_gossip_send_gossip(msg, msg, NULL,
|
||||
if (!fromwire_gossip_send_gossip(msg, msg,
|
||||
&peer->gossip_index, &gossip))
|
||||
status_failed(STATUS_FAIL_GOSSIP_IO,
|
||||
"Got bad message from gossipd: %s",
|
||||
|
@ -335,7 +335,7 @@ static void send_announcement_signatures(struct peer *peer)
|
|||
strerror(errno));
|
||||
|
||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||
if (!msg || !fromwire_hsm_cannouncement_sig_reply(msg, NULL,
|
||||
if (!msg || !fromwire_hsm_cannouncement_sig_reply(msg,
|
||||
&peer->announcement_node_sigs[LOCAL]))
|
||||
status_failed(STATUS_FAIL_HSM_IO,
|
||||
"Reading cannouncement_sig_resp: %s",
|
||||
|
@ -399,7 +399,7 @@ static u8 *create_channel_update(const tal_t *ctx,
|
|||
strerror(errno));
|
||||
|
||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||
if (!msg || !fromwire_hsm_cupdate_sig_reply(ctx, msg, NULL, &cupdate))
|
||||
if (!msg || !fromwire_hsm_cupdate_sig_reply(ctx, msg, &cupdate))
|
||||
status_failed(STATUS_FAIL_HSM_IO,
|
||||
"Reading cupdate_sig_req: %s",
|
||||
strerror(errno));
|
||||
|
@ -450,7 +450,7 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
|
|||
return;
|
||||
|
||||
peer->old_remote_per_commit = peer->remote_per_commit;
|
||||
if (!fromwire_funding_locked(msg, NULL, &chanid,
|
||||
if (!fromwire_funding_locked(msg, &chanid,
|
||||
&peer->remote_per_commit))
|
||||
peer_failed(&peer->cs, peer->gossip_index,
|
||||
&peer->channel_id,
|
||||
|
@ -517,7 +517,7 @@ static void handle_peer_announcement_signatures(struct peer *peer, const u8 *msg
|
|||
{
|
||||
struct channel_id chanid;
|
||||
|
||||
if (!fromwire_announcement_signatures(msg, NULL,
|
||||
if (!fromwire_announcement_signatures(msg,
|
||||
&chanid,
|
||||
&peer->short_channel_ids[REMOTE],
|
||||
&peer->announcement_node_sigs[REMOTE],
|
||||
|
@ -568,7 +568,7 @@ static bool get_shared_secret(const struct htlc *htlc,
|
|||
status_failed(STATUS_FAIL_HSM_IO, "Writing ecdh req");
|
||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||
/* Gives all-zero shares_secret if it was invalid. */
|
||||
if (!msg || !fromwire_hsm_ecdh_resp(msg, NULL, shared_secret))
|
||||
if (!msg || !fromwire_hsm_ecdh_resp(msg, shared_secret))
|
||||
status_failed(STATUS_FAIL_HSM_IO, "Reading ecdh response");
|
||||
tal_free(tmpctx);
|
||||
|
||||
|
@ -586,7 +586,7 @@ static void handle_peer_add_htlc(struct peer *peer, const u8 *msg)
|
|||
enum channel_add_err add_err;
|
||||
struct htlc *htlc;
|
||||
|
||||
if (!fromwire_update_add_htlc(msg, NULL, &channel_id, &id, &amount_msat,
|
||||
if (!fromwire_update_add_htlc(msg, &channel_id, &id, &amount_msat,
|
||||
&payment_hash, &cltv_expiry,
|
||||
onion_routing_packet))
|
||||
peer_failed(&peer->cs,
|
||||
|
@ -615,7 +615,7 @@ static void handle_peer_feechange(struct peer *peer, const u8 *msg)
|
|||
struct channel_id channel_id;
|
||||
u32 feerate;
|
||||
|
||||
if (!fromwire_update_fee(msg, NULL, &channel_id, &feerate)) {
|
||||
if (!fromwire_update_fee(msg, &channel_id, &feerate)) {
|
||||
peer_failed(&peer->cs,
|
||||
peer->gossip_index,
|
||||
&peer->channel_id,
|
||||
|
@ -1163,7 +1163,7 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg)
|
|||
peer->channel->view[LOCAL]
|
||||
.feerate_per_kw));
|
||||
|
||||
if (!fromwire_commitment_signed(tmpctx, msg, NULL,
|
||||
if (!fromwire_commitment_signed(tmpctx, msg,
|
||||
&channel_id, &commit_sig, &htlc_sigs))
|
||||
peer_failed(&peer->cs,
|
||||
peer->gossip_index,
|
||||
|
@ -1294,7 +1294,7 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg)
|
|||
tal_t *tmpctx = tal_tmpctx(msg);
|
||||
const struct htlc **changed_htlcs = tal_arr(msg, const struct htlc *, 0);
|
||||
|
||||
if (!fromwire_revoke_and_ack(msg, NULL, &channel_id, &old_commit_secret,
|
||||
if (!fromwire_revoke_and_ack(msg, &channel_id, &old_commit_secret,
|
||||
&next_per_commit)) {
|
||||
peer_failed(&peer->cs,
|
||||
peer->gossip_index,
|
||||
|
@ -1369,7 +1369,7 @@ static void handle_peer_fulfill_htlc(struct peer *peer, const u8 *msg)
|
|||
struct preimage preimage;
|
||||
enum channel_remove_err e;
|
||||
|
||||
if (!fromwire_update_fulfill_htlc(msg, NULL, &channel_id,
|
||||
if (!fromwire_update_fulfill_htlc(msg, &channel_id,
|
||||
&id, &preimage)) {
|
||||
peer_failed(&peer->cs,
|
||||
peer->gossip_index,
|
||||
|
@ -1408,7 +1408,7 @@ static void handle_peer_fail_htlc(struct peer *peer, const u8 *msg)
|
|||
u8 *reason;
|
||||
struct htlc *htlc;
|
||||
|
||||
if (!fromwire_update_fail_htlc(msg, msg, NULL,
|
||||
if (!fromwire_update_fail_htlc(msg, msg,
|
||||
&channel_id, &id, &reason)) {
|
||||
peer_failed(&peer->cs,
|
||||
peer->gossip_index,
|
||||
|
@ -1449,7 +1449,7 @@ static void handle_peer_fail_malformed_htlc(struct peer *peer, const u8 *msg)
|
|||
struct htlc *htlc;
|
||||
u8 *fail;
|
||||
|
||||
if (!fromwire_update_fail_malformed_htlc(msg, NULL, &channel_id, &id,
|
||||
if (!fromwire_update_fail_malformed_htlc(msg, &channel_id, &id,
|
||||
&sha256_of_onion,
|
||||
&failure_code)) {
|
||||
peer_failed(&peer->cs,
|
||||
|
@ -1517,7 +1517,7 @@ static void handle_pong(struct peer *peer, const u8 *pong)
|
|||
u8 *ignored;
|
||||
|
||||
status_trace("Got pong!");
|
||||
if (!fromwire_pong(pong, pong, NULL, &ignored))
|
||||
if (!fromwire_pong(pong, pong, &ignored))
|
||||
peer_failed(&peer->cs,
|
||||
peer->gossip_index,
|
||||
&peer->channel_id,
|
||||
|
@ -1542,7 +1542,7 @@ static void handle_peer_shutdown(struct peer *peer, const u8 *shutdown)
|
|||
msg = create_channel_update(peer, peer, true);
|
||||
wire_sync_write(GOSSIP_FD, take(msg));
|
||||
|
||||
if (!fromwire_shutdown(peer, shutdown, NULL, &channel_id, &scriptpubkey))
|
||||
if (!fromwire_shutdown(peer, shutdown, &channel_id, &scriptpubkey))
|
||||
peer_failed(&peer->cs,
|
||||
peer->gossip_index,
|
||||
&peer->channel_id,
|
||||
|
@ -1793,7 +1793,7 @@ static void peer_reconnect(struct peer *peer)
|
|||
/* Read until they say something interesting */
|
||||
while ((msg = channeld_read_peer_msg(peer)) == NULL);
|
||||
|
||||
if (!fromwire_channel_reestablish(msg, NULL, &channel_id,
|
||||
if (!fromwire_channel_reestablish(msg, &channel_id,
|
||||
&next_local_commitment_number,
|
||||
&next_remote_revocation_number)) {
|
||||
peer_failed(&peer->cs,
|
||||
|
@ -1951,7 +1951,7 @@ static void handle_funding_locked(struct peer *peer, const u8 *msg)
|
|||
{
|
||||
struct pubkey next_per_commit_point;
|
||||
|
||||
if (!fromwire_channel_funding_locked(msg, NULL,
|
||||
if (!fromwire_channel_funding_locked(msg,
|
||||
&peer->short_channel_ids[LOCAL]))
|
||||
master_badmsg(WIRE_CHANNEL_FUNDING_LOCKED, msg);
|
||||
|
||||
|
@ -2003,7 +2003,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
|
|||
status_failed(STATUS_FAIL_MASTER_IO,
|
||||
"funding not locked for offer_htlc");
|
||||
|
||||
if (!fromwire_channel_offer_htlc(inmsg, NULL, &amount_msat,
|
||||
if (!fromwire_channel_offer_htlc(inmsg, &amount_msat,
|
||||
&cltv_expiry, &payment_hash,
|
||||
onion_routing_packet))
|
||||
master_badmsg(WIRE_CHANNEL_OFFER_HTLC, inmsg);
|
||||
|
@ -2073,7 +2073,7 @@ static void handle_feerates(struct peer *peer, const u8 *inmsg)
|
|||
{
|
||||
u32 feerate;
|
||||
|
||||
if (!fromwire_channel_feerates(inmsg, NULL, &feerate,
|
||||
if (!fromwire_channel_feerates(inmsg, &feerate,
|
||||
&peer->feerate_min,
|
||||
&peer->feerate_max))
|
||||
master_badmsg(WIRE_CHANNEL_FEERATES, inmsg);
|
||||
|
@ -2104,7 +2104,7 @@ static void handle_preimage(struct peer *peer, const u8 *inmsg)
|
|||
u64 id;
|
||||
struct preimage preimage;
|
||||
|
||||
if (!fromwire_channel_fulfill_htlc(inmsg, NULL, &id, &preimage))
|
||||
if (!fromwire_channel_fulfill_htlc(inmsg, &id, &preimage))
|
||||
master_badmsg(WIRE_CHANNEL_FULFILL_HTLC, inmsg);
|
||||
|
||||
switch (channel_fulfill_htlc(peer->channel, REMOTE, id, &preimage)) {
|
||||
|
@ -2138,7 +2138,7 @@ static u8 *foreign_channel_update(const tal_t *ctx,
|
|||
msg = towire_gossip_get_update(tmpctx, scid);
|
||||
msg = gossipd_wait_sync_reply(tmpctx, peer, take(msg),
|
||||
WIRE_GOSSIP_GET_UPDATE_REPLY);
|
||||
if (!fromwire_gossip_get_update_reply(ctx, msg, NULL, &update))
|
||||
if (!fromwire_gossip_get_update_reply(ctx, msg, &update))
|
||||
status_failed(STATUS_FAIL_GOSSIP_IO,
|
||||
"Invalid update reply");
|
||||
tal_free(tmpctx);
|
||||
|
@ -2244,7 +2244,7 @@ static void handle_fail(struct peer *peer, const u8 *inmsg)
|
|||
enum channel_remove_err e;
|
||||
struct htlc *h;
|
||||
|
||||
if (!fromwire_channel_fail_htlc(inmsg, inmsg, NULL, &id, &errpkt,
|
||||
if (!fromwire_channel_fail_htlc(inmsg, inmsg, &id, &errpkt,
|
||||
&failcode, &scid))
|
||||
master_badmsg(WIRE_CHANNEL_FAIL_HTLC, inmsg);
|
||||
|
||||
|
@ -2303,7 +2303,7 @@ static void handle_ping_cmd(struct peer *peer, const u8 *inmsg)
|
|||
u16 num_pong_bytes, ping_len;
|
||||
u8 *ping;
|
||||
|
||||
if (!fromwire_channel_ping(inmsg, NULL, &num_pong_bytes, &ping_len))
|
||||
if (!fromwire_channel_ping(inmsg, &num_pong_bytes, &ping_len))
|
||||
master_badmsg(WIRE_CHANNEL_PING, inmsg);
|
||||
|
||||
ping = make_ping(peer, num_pong_bytes, ping_len);
|
||||
|
@ -2332,7 +2332,7 @@ static void handle_shutdown_cmd(struct peer *peer, const u8 *inmsg)
|
|||
{
|
||||
u8 *scriptpubkey;
|
||||
|
||||
if (!fromwire_channel_send_shutdown(peer, inmsg, NULL, &scriptpubkey))
|
||||
if (!fromwire_channel_send_shutdown(peer, inmsg, &scriptpubkey))
|
||||
master_badmsg(WIRE_CHANNEL_SEND_SHUTDOWN, inmsg);
|
||||
|
||||
/* We can't send this until commit (if any) is done, so start timer<. */
|
||||
|
@ -2448,7 +2448,7 @@ static void init_channel(struct peer *peer)
|
|||
status_setup_sync(MASTER_FD);
|
||||
|
||||
msg = wire_sync_read(peer, MASTER_FD);
|
||||
if (!fromwire_channel_init(peer, msg, NULL,
|
||||
if (!fromwire_channel_init(peer, msg,
|
||||
&peer->chain_hash,
|
||||
&funding_txid, &funding_txout,
|
||||
&funding_satoshi,
|
||||
|
|
|
@ -123,7 +123,7 @@ static void do_reconnect(struct crypto_state *cs,
|
|||
/* Wait for them to say something interesting */
|
||||
msg = closing_read_peer_msg(tmpctx, cs, gossip_index, channel_id);
|
||||
|
||||
if (!fromwire_channel_reestablish(msg, NULL, &their_channel_id,
|
||||
if (!fromwire_channel_reestablish(msg, &their_channel_id,
|
||||
&next_local_commitment_number,
|
||||
&next_remote_revocation_number)) {
|
||||
peer_failed(cs, gossip_index, channel_id,
|
||||
|
@ -218,7 +218,7 @@ static void tell_master_their_offer(u64 their_offer,
|
|||
|
||||
/* Wait for master to ack, to make sure it's in db. */
|
||||
msg = wire_sync_read(NULL, REQ_FD);
|
||||
if (!fromwire_closing_received_signature_reply(msg,NULL))
|
||||
if (!fromwire_closing_received_signature_reply(msg))
|
||||
master_badmsg(WIRE_CLOSING_RECEIVED_SIGNATURE_REPLY, msg);
|
||||
tal_free(msg);
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ static uint64_t receive_offer(struct crypto_state *cs,
|
|||
msg = tal_free(msg);
|
||||
} while (!msg);
|
||||
|
||||
if (!fromwire_closing_signed(msg, NULL, &their_channel_id,
|
||||
if (!fromwire_closing_signed(msg, &their_channel_id,
|
||||
&received_fee, &their_sig))
|
||||
peer_failed(cs, gossip_index, channel_id,
|
||||
"Expected closing_signed: %s",
|
||||
|
@ -463,7 +463,7 @@ int main(int argc, char *argv[])
|
|||
status_setup_sync(REQ_FD);
|
||||
|
||||
msg = wire_sync_read(ctx, REQ_FD);
|
||||
if (!fromwire_closing_init(ctx, msg, NULL,
|
||||
if (!fromwire_closing_init(ctx, msg,
|
||||
&cs, &gossip_index, &seed,
|
||||
&funding_txid, &funding_txout,
|
||||
&funding_satoshi,
|
||||
|
|
|
@ -6,7 +6,7 @@ bool check_ping_make_pong(const tal_t *ctx, const u8 *ping, u8 **pong)
|
|||
u16 num_pong_bytes;
|
||||
u8 *ignored;
|
||||
|
||||
if (!fromwire_ping(ctx, ping, NULL, &num_pong_bytes, &ignored))
|
||||
if (!fromwire_ping(ctx, ping, &num_pong_bytes, &ignored))
|
||||
return false;
|
||||
tal_free(ignored);
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ char *sanitize_error(const tal_t *ctx, const u8 *errmsg,
|
|||
if (!channel_id)
|
||||
channel_id = &dummy;
|
||||
|
||||
if (!fromwire_error(ctx, errmsg, NULL, channel_id, &data))
|
||||
if (!fromwire_error(ctx, errmsg, channel_id, &data))
|
||||
return tal_fmt(ctx, "Invalid ERROR message '%s'",
|
||||
tal_hex(ctx, errmsg));
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ static bool is_all_channel_error(const u8 *msg)
|
|||
struct channel_id channel_id;
|
||||
u8 *data;
|
||||
|
||||
if (!fromwire_error(msg, msg, NULL, &channel_id, &data))
|
||||
if (!fromwire_error(msg, msg, &channel_id, &data))
|
||||
return false;
|
||||
tal_free(data);
|
||||
return channel_id_is_all(&channel_id);
|
||||
|
@ -332,7 +332,7 @@ static struct io_plan *peer_init_received(struct io_conn *conn,
|
|||
struct peer *peer,
|
||||
u8 *msg)
|
||||
{
|
||||
if (!fromwire_init(peer, msg, NULL, &peer->gfeatures, &peer->lfeatures)){
|
||||
if (!fromwire_init(peer, msg, &peer->gfeatures, &peer->lfeatures)){
|
||||
status_trace("peer %s bad fromwire_init '%s', closing",
|
||||
type_to_string(trc, struct pubkey, &peer->id),
|
||||
tal_hex(trc, msg));
|
||||
|
@ -449,7 +449,7 @@ static void send_node_announcement(struct daemon *daemon)
|
|||
status_failed(STATUS_FAIL_MASTER_IO, "Could not write to HSM: %s", strerror(errno));
|
||||
|
||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||
if (!fromwire_hsm_node_announcement_sig_reply(msg, NULL, &sig))
|
||||
if (!fromwire_hsm_node_announcement_sig_reply(msg, &sig))
|
||||
status_failed(STATUS_FAIL_MASTER_IO, "HSM returned an invalid node_announcement sig");
|
||||
|
||||
/* We got the signature for out provisional node_announcement back
|
||||
|
@ -505,7 +505,7 @@ static void handle_pong(struct peer *peer, const u8 *pong)
|
|||
u8 *ignored;
|
||||
|
||||
status_trace("Got pong!");
|
||||
if (!fromwire_pong(pong, pong, NULL, &ignored)) {
|
||||
if (!fromwire_pong(pong, pong, &ignored)) {
|
||||
peer_error(peer, "Bad pong");
|
||||
return;
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ static void handle_get_update(struct peer *peer, const u8 *msg)
|
|||
size_t i;
|
||||
const u8 *update;
|
||||
|
||||
if (!fromwire_gossip_get_update(msg, NULL, &schanid)) {
|
||||
if (!fromwire_gossip_get_update(msg, &schanid)) {
|
||||
status_trace("peer %s sent bad gossip_get_update %s",
|
||||
type_to_string(trc, struct pubkey, &peer->id),
|
||||
tal_hex(trc, msg));
|
||||
|
@ -771,7 +771,7 @@ static void handle_local_add_channel(struct peer *peer, u8 *msg)
|
|||
struct routing_channel *chan;
|
||||
|
||||
if (!fromwire_gossip_local_add_channel(
|
||||
msg, NULL, &scid, &chain_hash, &remote_node_id, &flags,
|
||||
msg, &scid, &chain_hash, &remote_node_id, &flags,
|
||||
&cltv_expiry_delta, &htlc_minimum_msat, &fee_base_msat,
|
||||
&fee_proportional_millionths)) {
|
||||
status_trace("Unable to parse local_add_channel message: %s", tal_hex(msg, msg));
|
||||
|
@ -1006,7 +1006,7 @@ static struct io_plan *hand_back_peer(struct io_conn *conn,
|
|||
struct returning_peer *rpeer = tal(daemon, struct returning_peer);
|
||||
|
||||
rpeer->daemon = daemon;
|
||||
if (!fromwire_gossipctl_hand_back_peer(msg, msg, NULL,
|
||||
if (!fromwire_gossipctl_hand_back_peer(msg, msg,
|
||||
&rpeer->id, &rpeer->cs,
|
||||
&rpeer->gossip_index,
|
||||
&rpeer->inner_msg))
|
||||
|
@ -1022,7 +1022,7 @@ static struct io_plan *release_peer(struct io_conn *conn, struct daemon *daemon,
|
|||
struct pubkey id;
|
||||
struct peer *peer;
|
||||
|
||||
if (!fromwire_gossipctl_release_peer(msg, NULL, &id))
|
||||
if (!fromwire_gossipctl_release_peer(msg, &id))
|
||||
master_badmsg(WIRE_GOSSIPCTL_RELEASE_PEER, msg);
|
||||
|
||||
peer = find_peer(daemon, &id);
|
||||
|
@ -1055,7 +1055,7 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
|
|||
u8 *out;
|
||||
struct route_hop *hops;
|
||||
|
||||
fromwire_gossip_getroute_request(msg, NULL, &source, &destination,
|
||||
fromwire_gossip_getroute_request(msg, &source, &destination,
|
||||
&msatoshi, &riskfactor, &final_cltv);
|
||||
status_trace("Trying to find a route from %s to %s for %d msatoshi",
|
||||
pubkey_to_hexstr(tmpctx, &source),
|
||||
|
@ -1081,7 +1081,7 @@ static struct io_plan *getchannels_req(struct io_conn *conn, struct daemon *daem
|
|||
struct node_map_iter i;
|
||||
struct short_channel_id *scid;
|
||||
|
||||
fromwire_gossip_getchannels_request(msg, msg, NULL, &scid);
|
||||
fromwire_gossip_getchannels_request(msg, msg, &scid);
|
||||
|
||||
entries = tal_arr(tmpctx, struct gossip_getchannels_entry, num_chans);
|
||||
n = node_map_first(daemon->rstate->nodes, &i);
|
||||
|
@ -1145,7 +1145,7 @@ static struct io_plan *getnodes(struct io_conn *conn, struct daemon *daemon,
|
|||
const struct gossip_getnodes_entry **nodes;
|
||||
struct pubkey *ids;
|
||||
|
||||
fromwire_gossip_getnodes_request(tmpctx, msg, NULL, &ids);
|
||||
fromwire_gossip_getnodes_request(tmpctx, msg, &ids);
|
||||
|
||||
nodes = tal_arr(tmpctx, const struct gossip_getnodes_entry *, 0);
|
||||
if (ids) {
|
||||
|
@ -1176,7 +1176,7 @@ static struct io_plan *ping_req(struct io_conn *conn, struct daemon *daemon,
|
|||
struct peer *peer;
|
||||
u8 *ping;
|
||||
|
||||
if (!fromwire_gossip_ping(msg, NULL, &id, &num_pong_bytes, &len))
|
||||
if (!fromwire_gossip_ping(msg, &id, &num_pong_bytes, &len))
|
||||
master_badmsg(WIRE_GOSSIP_PING, msg);
|
||||
|
||||
peer = find_peer(daemon, &id);
|
||||
|
@ -1251,7 +1251,6 @@ static void gossip_send_keepalive_update(struct routing_state *rstate,
|
|||
struct node_connection *nc)
|
||||
{
|
||||
tal_t *tmpctx = tal_tmpctx(nc);
|
||||
size_t plen = tal_len(nc->channel_update);
|
||||
secp256k1_ecdsa_signature sig;
|
||||
struct bitcoin_blkid chain_hash;
|
||||
struct short_channel_id scid;
|
||||
|
@ -1262,7 +1261,7 @@ static void gossip_send_keepalive_update(struct routing_state *rstate,
|
|||
|
||||
/* Parse old update */
|
||||
if (!fromwire_channel_update(
|
||||
nc->channel_update, &plen, &sig, &chain_hash, &scid, ×tamp,
|
||||
nc->channel_update, &sig, &chain_hash, &scid, ×tamp,
|
||||
&flags, &cltv_expiry_delta, &htlc_minimum_msat, &fee_base_msat,
|
||||
&fee_proportional_millionths)) {
|
||||
status_failed(
|
||||
|
@ -1284,7 +1283,7 @@ static void gossip_send_keepalive_update(struct routing_state *rstate,
|
|||
}
|
||||
|
||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||
if (!msg || !fromwire_hsm_cupdate_sig_reply(tmpctx, msg, NULL, &update)) {
|
||||
if (!msg || !fromwire_hsm_cupdate_sig_reply(tmpctx, msg, &update)) {
|
||||
status_failed(STATUS_FAIL_HSM_IO,
|
||||
"Reading cupdate_sig_req: %s",
|
||||
strerror(errno));
|
||||
|
@ -1502,7 +1501,7 @@ static struct io_plan *gossip_init(struct daemon_conn *master,
|
|||
u16 port;
|
||||
|
||||
if (!fromwire_gossipctl_init(
|
||||
daemon, msg, NULL, &daemon->broadcast_interval, &chain_hash,
|
||||
daemon, msg, &daemon->broadcast_interval, &chain_hash,
|
||||
&daemon->id, &port, &daemon->globalfeatures,
|
||||
&daemon->localfeatures, &daemon->wireaddrs, daemon->rgb,
|
||||
daemon->alias, &daemon->update_channel_interval)) {
|
||||
|
@ -1526,7 +1525,7 @@ static struct io_plan *resolve_channel_req(struct io_conn *conn,
|
|||
struct node_connection *nc;
|
||||
struct pubkey *keys;
|
||||
|
||||
if (!fromwire_gossip_resolve_channel_request(msg, NULL, &scid))
|
||||
if (!fromwire_gossip_resolve_channel_request(msg, &scid))
|
||||
master_badmsg(WIRE_GOSSIP_RESOLVE_CHANNEL_REQUEST, msg);
|
||||
|
||||
nc = get_connection_by_scid(daemon->rstate, &scid, 0);
|
||||
|
@ -1734,7 +1733,7 @@ static struct io_plan *reach_peer(struct io_conn *conn,
|
|||
{
|
||||
struct pubkey id;
|
||||
|
||||
if (!fromwire_gossipctl_reach_peer(msg, NULL, &id))
|
||||
if (!fromwire_gossipctl_reach_peer(msg, &id))
|
||||
master_badmsg(WIRE_GOSSIPCTL_REACH_PEER, msg);
|
||||
|
||||
/* Master can't check this itself, because that's racy. */
|
||||
|
@ -1752,7 +1751,7 @@ static struct io_plan *addr_hint(struct io_conn *conn,
|
|||
{
|
||||
struct addrhint *a = tal(daemon, struct addrhint);
|
||||
|
||||
if (!fromwire_gossipctl_peer_addrhint(msg, NULL, &a->id, &a->addr))
|
||||
if (!fromwire_gossipctl_peer_addrhint(msg, &a->id, &a->addr))
|
||||
master_badmsg(WIRE_GOSSIPCTL_PEER_ADDRHINT, msg);
|
||||
|
||||
/* Replace any old one. */
|
||||
|
@ -1773,7 +1772,7 @@ static struct io_plan *get_peers(struct io_conn *conn,
|
|||
struct wireaddr *wireaddr = tal_arr(conn, struct wireaddr, n);
|
||||
struct pubkey *specific_id = NULL;
|
||||
|
||||
if (!fromwire_gossip_getpeers_request(msg, msg, NULL, &specific_id))
|
||||
if (!fromwire_gossip_getpeers_request(msg, msg, &specific_id))
|
||||
master_badmsg(WIRE_GOSSIPCTL_PEER_ADDRHINT, msg);
|
||||
|
||||
list_for_each(&daemon->peers, peer, list) {
|
||||
|
@ -1798,7 +1797,7 @@ static struct io_plan *handle_txout_reply(struct io_conn *conn,
|
|||
struct short_channel_id scid;
|
||||
u8 *outscript;
|
||||
|
||||
if (!fromwire_gossip_get_txout_reply(msg, msg, NULL, &scid, &outscript))
|
||||
if (!fromwire_gossip_get_txout_reply(msg, msg, &scid, &outscript))
|
||||
master_badmsg(WIRE_GOSSIP_GET_TXOUT_REPLY, msg);
|
||||
|
||||
if (handle_pending_cannouncement(daemon->rstate, &scid, outscript))
|
||||
|
@ -1821,7 +1820,7 @@ static struct io_plan *handle_disable_channel(struct io_conn *conn,
|
|||
secp256k1_ecdsa_signature sig;
|
||||
u64 htlc_minimum_msat;
|
||||
|
||||
if (!fromwire_gossip_disable_channel(msg, NULL, &scid, &direction, &active) ) {
|
||||
if (!fromwire_gossip_disable_channel(msg, &scid, &direction, &active) ) {
|
||||
status_trace("Unable to parse %s",
|
||||
gossip_wire_type_name(fromwire_peektype(msg)));
|
||||
goto fail;
|
||||
|
@ -1853,7 +1852,7 @@ static struct io_plan *handle_disable_channel(struct io_conn *conn,
|
|||
}
|
||||
|
||||
if (!fromwire_channel_update(
|
||||
nc->channel_update, NULL, &sig, &chain_hash, &scid, ×tamp,
|
||||
nc->channel_update, &sig, &chain_hash, &scid, ×tamp,
|
||||
&flags, &cltv_expiry_delta, &htlc_minimum_msat, &fee_base_msat,
|
||||
&fee_proportional_millionths)) {
|
||||
status_failed(
|
||||
|
@ -1879,7 +1878,7 @@ static struct io_plan *handle_disable_channel(struct io_conn *conn,
|
|||
}
|
||||
|
||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||
if (!msg || !fromwire_hsm_cupdate_sig_reply(tmpctx, msg, NULL, &msg)) {
|
||||
if (!msg || !fromwire_hsm_cupdate_sig_reply(tmpctx, msg, &msg)) {
|
||||
status_failed(STATUS_FAIL_HSM_IO,
|
||||
"Reading cupdate_sig_req: %s",
|
||||
strerror(errno));
|
||||
|
@ -1901,7 +1900,7 @@ static struct io_plan *handle_routing_failure(struct io_conn *conn,
|
|||
u8 *channel_update;
|
||||
|
||||
if (!fromwire_gossip_routing_failure(msg,
|
||||
msg, NULL,
|
||||
msg,
|
||||
&erring_node,
|
||||
&erring_channel,
|
||||
&failcode,
|
||||
|
@ -1923,7 +1922,7 @@ handle_mark_channel_unroutable(struct io_conn *conn,
|
|||
{
|
||||
struct short_channel_id channel;
|
||||
|
||||
if (!fromwire_gossip_mark_channel_unroutable(msg, NULL, &channel))
|
||||
if (!fromwire_gossip_mark_channel_unroutable(msg, &channel))
|
||||
master_badmsg(WIRE_GOSSIP_MARK_CHANNEL_UNROUTABLE, msg);
|
||||
|
||||
mark_channel_unroutable(daemon->rstate, &channel);
|
||||
|
|
|
@ -648,7 +648,7 @@ const struct short_channel_id *handle_channel_announcement(
|
|||
announce, tal_len(announce), 0);
|
||||
pending->update_timestamps[0] = pending->update_timestamps[1] = 0;
|
||||
|
||||
if (!fromwire_channel_announcement(pending, pending->announce, NULL,
|
||||
if (!fromwire_channel_announcement(pending, pending->announce,
|
||||
&node_signature_1,
|
||||
&node_signature_2,
|
||||
&bitcoin_signature_1,
|
||||
|
@ -880,7 +880,7 @@ void handle_channel_update(struct routing_state *rstate, const u8 *update)
|
|||
size_t len = tal_len(update);
|
||||
|
||||
serialized = tal_dup_arr(tmpctx, u8, update, len, 0);
|
||||
if (!fromwire_channel_update(serialized, NULL, &signature,
|
||||
if (!fromwire_channel_update(serialized, &signature,
|
||||
&chain_hash, &short_channel_id,
|
||||
×tamp, &flags, &expiry,
|
||||
&htlc_minimum_msat, &fee_base_msat,
|
||||
|
@ -1025,7 +1025,7 @@ void handle_node_announcement(
|
|||
size_t len = tal_len(node_ann);
|
||||
|
||||
serialized = tal_dup_arr(tmpctx, u8, node_ann, len, 0);
|
||||
if (!fromwire_node_announcement(tmpctx, serialized, NULL,
|
||||
if (!fromwire_node_announcement(tmpctx, serialized,
|
||||
&signature, &features, ×tamp,
|
||||
&node_id, rgb_color, alias,
|
||||
&addresses)) {
|
||||
|
|
|
@ -56,13 +56,13 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx UNNEEDED)
|
|||
|
||||
/* AUTOGENERATED MOCKS START */
|
||||
/* Generated stub for fromwire_channel_announcement */
|
||||
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
|
||||
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_channel_update */
|
||||
bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
|
||||
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_node_announcement */
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_peektype */
|
||||
int fromwire_peektype(const u8 *cursor UNNEEDED)
|
||||
|
|
|
@ -20,13 +20,13 @@ struct broadcast_state *new_broadcast_state(tal_t *ctx UNNEEDED)
|
|||
|
||||
/* AUTOGENERATED MOCKS START */
|
||||
/* Generated stub for fromwire_channel_announcement */
|
||||
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
|
||||
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_channel_update */
|
||||
bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
|
||||
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_node_announcement */
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_peektype */
|
||||
int fromwire_peektype(const u8 *cursor UNNEEDED)
|
||||
|
|
|
@ -18,13 +18,13 @@ void status_fmt(enum log_level level, const char *fmt, ...)
|
|||
|
||||
/* AUTOGENERATED MOCKS START */
|
||||
/* Generated stub for fromwire_channel_announcement */
|
||||
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
|
||||
bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *node_signature_1 UNNEEDED, secp256k1_ecdsa_signature *node_signature_2 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_1 UNNEEDED, secp256k1_ecdsa_signature *bitcoin_signature_2 UNNEEDED, u8 **features UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *node_id_1 UNNEEDED, struct pubkey *node_id_2 UNNEEDED, struct pubkey *bitcoin_key_1 UNNEEDED, struct pubkey *bitcoin_key_2 UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_channel_update */
|
||||
bool fromwire_channel_update(const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
|
||||
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_node_announcement */
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_peektype */
|
||||
int fromwire_peektype(const u8 *cursor UNNEEDED)
|
||||
|
|
|
@ -12,15 +12,13 @@ void hsm_setup(int fd)
|
|||
bool hsm_do_ecdh(struct secret *ss, const struct pubkey *point)
|
||||
{
|
||||
u8 *req = towire_hsm_ecdh_req(NULL, point), *resp;
|
||||
size_t len;
|
||||
|
||||
if (!wire_sync_write(hsm_fd, req))
|
||||
goto fail;
|
||||
resp = wire_sync_read(req, hsm_fd);
|
||||
if (!resp)
|
||||
goto fail;
|
||||
len = tal_count(resp);
|
||||
if (!fromwire_hsm_ecdh_resp(resp, &len, ss))
|
||||
if (!fromwire_hsm_ecdh_resp(resp, ss))
|
||||
goto fail;
|
||||
tal_free(req);
|
||||
return true;
|
||||
|
|
20
hsmd/hsm.c
20
hsmd/hsm.c
|
@ -123,7 +123,7 @@ static struct io_plan *handle_ecdh(struct io_conn *conn, struct daemon_conn *dc)
|
|||
struct pubkey point;
|
||||
struct secret ss;
|
||||
|
||||
if (!fromwire_hsm_ecdh_req(dc->msg_in, NULL, &point)) {
|
||||
if (!fromwire_hsm_ecdh_req(dc->msg_in, &point)) {
|
||||
daemon_conn_send(c->master,
|
||||
take(towire_hsmstatus_client_bad_request(c,
|
||||
&c->id,
|
||||
|
@ -160,7 +160,7 @@ static struct io_plan *handle_cannouncement_sig(struct io_conn *conn,
|
|||
u8 *ca;
|
||||
struct pubkey bitcoin_id;
|
||||
|
||||
if (!fromwire_hsm_cannouncement_sig_req(ctx, dc->msg_in, NULL,
|
||||
if (!fromwire_hsm_cannouncement_sig_req(ctx, dc->msg_in,
|
||||
&bitcoin_id, &ca)) {
|
||||
status_broken("Failed to parse cannouncement_sig_req: %s",
|
||||
tal_hex(trc, dc->msg_in));
|
||||
|
@ -202,14 +202,14 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
|
|||
struct bitcoin_blkid chain_hash;
|
||||
u8 *cu;
|
||||
|
||||
if (!fromwire_hsm_cupdate_sig_req(tmpctx, dc->msg_in, NULL, &cu)) {
|
||||
if (!fromwire_hsm_cupdate_sig_req(tmpctx, dc->msg_in, &cu)) {
|
||||
status_broken("Failed to parse %s: %s",
|
||||
hsm_client_wire_type_name(fromwire_peektype(dc->msg_in)),
|
||||
tal_hex(trc, dc->msg_in));
|
||||
return io_close(conn);
|
||||
}
|
||||
|
||||
if (!fromwire_channel_update(cu, NULL, &sig, &chain_hash,
|
||||
if (!fromwire_channel_update(cu, &sig, &chain_hash,
|
||||
&scid, ×tamp, &flags,
|
||||
&cltv_expiry_delta, &htlc_minimum_msat,
|
||||
&fee_base_msat, &fee_proportional_mill)) {
|
||||
|
@ -522,7 +522,7 @@ static void init_hsm(struct daemon_conn *master, const u8 *msg)
|
|||
{
|
||||
bool new;
|
||||
|
||||
if (!fromwire_hsm_init(msg, NULL, &new))
|
||||
if (!fromwire_hsm_init(msg, &new))
|
||||
master_badmsg(WIRE_HSM_INIT, msg);
|
||||
|
||||
if (new)
|
||||
|
@ -539,7 +539,7 @@ static void pass_client_hsmfd(struct daemon_conn *master, const u8 *msg)
|
|||
u64 capabilities;
|
||||
struct pubkey id;
|
||||
|
||||
if (!fromwire_hsm_client_hsmfd(msg, NULL, &id, &capabilities))
|
||||
if (!fromwire_hsm_client_hsmfd(msg, &id, &capabilities))
|
||||
master_badmsg(WIRE_HSM_CLIENT_HSMFD, msg);
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) != 0)
|
||||
|
@ -620,7 +620,7 @@ static void sign_funding_tx(struct daemon_conn *master, const u8 *msg)
|
|||
u8 **scriptSigs;
|
||||
|
||||
/* FIXME: Check fee is "reasonable" */
|
||||
if (!fromwire_hsm_sign_funding(tmpctx, msg, NULL,
|
||||
if (!fromwire_hsm_sign_funding(tmpctx, msg,
|
||||
&satoshi_out, &change_out,
|
||||
&change_keyindex, &local_pubkey,
|
||||
&remote_pubkey, &utxomap))
|
||||
|
@ -687,7 +687,7 @@ static void sign_withdrawal_tx(struct daemon_conn *master, const u8 *msg)
|
|||
struct pubkey changekey;
|
||||
u8 *scriptpubkey;
|
||||
|
||||
if (!fromwire_hsm_sign_withdrawal(tmpctx, msg, NULL, &satoshi_out,
|
||||
if (!fromwire_hsm_sign_withdrawal(tmpctx, msg, &satoshi_out,
|
||||
&change_out, &change_keyindex,
|
||||
&scriptpubkey, &utxos)) {
|
||||
status_broken("Failed to parse sign_withdrawal: %s",
|
||||
|
@ -758,7 +758,7 @@ static void sign_invoice(struct daemon_conn *master, const u8 *msg)
|
|||
struct hash_u5 hu5;
|
||||
struct privkey node_pkey;
|
||||
|
||||
if (!fromwire_hsm_sign_invoice(tmpctx, msg, NULL, &u5bytes, &hrpu8)) {
|
||||
if (!fromwire_hsm_sign_invoice(tmpctx, msg, &u5bytes, &hrpu8)) {
|
||||
status_broken("Failed to parse sign_invoice: %s",
|
||||
tal_hex(trc, msg));
|
||||
return;
|
||||
|
@ -798,7 +798,7 @@ static void sign_node_announcement(struct daemon_conn *master, const u8 *msg)
|
|||
u8 *reply;
|
||||
u8 *ann;
|
||||
|
||||
if (!fromwire_hsm_node_announcement_sig_req(msg, msg, NULL, &ann)) {
|
||||
if (!fromwire_hsm_node_announcement_sig_req(msg, msg, &ann)) {
|
||||
status_failed(STATUS_FAIL_GOSSIP_IO,
|
||||
"Failed to parse node_announcement_sig_req: %s",
|
||||
tal_hex(trc, msg));
|
||||
|
|
|
@ -23,7 +23,7 @@ static void peer_got_funding_locked(struct channel *channel, const u8 *msg)
|
|||
{
|
||||
struct pubkey next_per_commitment_point;
|
||||
|
||||
if (!fromwire_channel_got_funding_locked(msg, NULL,
|
||||
if (!fromwire_channel_got_funding_locked(msg,
|
||||
&next_per_commitment_point)) {
|
||||
channel_internal_error(channel,
|
||||
"bad channel_got_funding_locked %s",
|
||||
|
@ -47,7 +47,7 @@ static void peer_got_shutdown(struct channel *channel, const u8 *msg)
|
|||
u8 *scriptpubkey;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
|
||||
if (!fromwire_channel_got_shutdown(channel, msg, NULL, &scriptpubkey)) {
|
||||
if (!fromwire_channel_got_shutdown(channel, msg, &scriptpubkey)) {
|
||||
channel_internal_error(channel, "bad channel_got_shutdown %s",
|
||||
tal_hex(msg, msg));
|
||||
return;
|
||||
|
@ -132,7 +132,7 @@ static void peer_start_closingd_after_shutdown(struct channel *channel,
|
|||
/* We expect 2 fds. */
|
||||
assert(tal_count(fds) == 2);
|
||||
|
||||
if (!fromwire_channel_shutdown_complete(msg, NULL, &cs, &gossip_index)) {
|
||||
if (!fromwire_channel_shutdown_complete(msg, &cs, &gossip_index)) {
|
||||
channel_internal_error(channel, "bad shutdown_complete: %s",
|
||||
tal_hex(msg, msg));
|
||||
return;
|
||||
|
@ -225,7 +225,7 @@ bool peer_start_channeld(struct channel *channel,
|
|||
fatal("Could not write to HSM: %s", strerror(errno));
|
||||
|
||||
msg = hsm_sync_read(tmpctx, ld);
|
||||
if (!fromwire_hsm_client_hsmfd_reply(msg, NULL))
|
||||
if (!fromwire_hsm_client_hsmfd_reply(msg))
|
||||
fatal("Bad reply from HSM: %s", tal_hex(tmpctx, msg));
|
||||
|
||||
hsmfd = fdpass_recv(ld->hsm_fd);
|
||||
|
|
|
@ -74,7 +74,7 @@ static void peer_received_closing_signature(struct channel *channel,
|
|||
struct bitcoin_tx *tx;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
|
||||
if (!fromwire_closing_received_signature(msg, msg, NULL, &sig, &tx)) {
|
||||
if (!fromwire_closing_received_signature(msg, msg, &sig, &tx)) {
|
||||
channel_internal_error(channel, "Bad closing_received_signature %s",
|
||||
tal_hex(msg, msg));
|
||||
return;
|
||||
|
@ -97,7 +97,7 @@ static void peer_closing_complete(struct channel *channel, const u8 *msg)
|
|||
/* FIXME: We should save this, to return to gossipd */
|
||||
u64 gossip_index;
|
||||
|
||||
if (!fromwire_closing_complete(msg, NULL, &gossip_index)) {
|
||||
if (!fromwire_closing_complete(msg, &gossip_index)) {
|
||||
channel_internal_error(channel, "Bad closing_complete %s",
|
||||
tal_hex(msg, msg));
|
||||
return;
|
||||
|
|
|
@ -70,7 +70,7 @@ void peer_connection_failed(struct lightningd *ld, const u8 *msg)
|
|||
bool addr_unknown;
|
||||
char *error;
|
||||
|
||||
if (!fromwire_gossip_peer_connection_failed(msg, NULL, &id, &timediff,
|
||||
if (!fromwire_gossip_peer_connection_failed(msg, &id, &timediff,
|
||||
&attempts, &addr_unknown))
|
||||
fatal(
|
||||
"Gossip gave bad GOSSIP_PEER_CONNECTION_FAILED message %s",
|
||||
|
@ -94,7 +94,7 @@ void peer_already_connected(struct lightningd *ld, const u8 *msg)
|
|||
{
|
||||
struct pubkey id;
|
||||
|
||||
if (!fromwire_gossip_peer_already_connected(msg, NULL, &id))
|
||||
if (!fromwire_gossip_peer_already_connected(msg, &id))
|
||||
fatal("Gossip gave bad GOSSIP_PEER_ALREADY_CONNECTED message %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ static void ping_reply(struct subd *subd, const u8 *msg, const int *fds,
|
|||
|
||||
log_debug(subd->ld->log, "Got ping reply!");
|
||||
if (streq(subd->name, "lightning_channeld"))
|
||||
ok = fromwire_channel_ping_reply(msg, NULL, &totlen);
|
||||
ok = fromwire_channel_ping_reply(msg, &totlen);
|
||||
else
|
||||
ok = fromwire_gossip_ping_reply(msg, NULL, &sent, &totlen);
|
||||
ok = fromwire_gossip_ping_reply(msg, &sent, &totlen);
|
||||
|
||||
if (!ok)
|
||||
command_fail(cmd, "Bad reply message");
|
||||
|
|
|
@ -34,7 +34,7 @@ static void peer_nongossip(struct subd *gossip, const u8 *msg,
|
|||
u8 *gfeatures, *lfeatures, *in_pkt;
|
||||
u64 gossip_index;
|
||||
|
||||
if (!fromwire_gossip_peer_nongossip(msg, msg, NULL,
|
||||
if (!fromwire_gossip_peer_nongossip(msg, msg,
|
||||
&id, &addr, &cs, &gossip_index,
|
||||
&gfeatures,
|
||||
&lfeatures,
|
||||
|
@ -79,7 +79,7 @@ static void get_txout(struct subd *gossip, const u8 *msg)
|
|||
{
|
||||
struct short_channel_id *scid = tal(gossip, struct short_channel_id);
|
||||
|
||||
if (!fromwire_gossip_get_txout(msg, NULL, scid))
|
||||
if (!fromwire_gossip_get_txout(msg, scid))
|
||||
fatal("Gossip gave bad GOSSIP_GET_TXOUT message %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
|
@ -165,7 +165,7 @@ void gossip_init(struct lightningd *ld)
|
|||
fatal("Could not write to HSM: %s", strerror(errno));
|
||||
|
||||
msg = hsm_sync_read(tmpctx, ld);
|
||||
if (!fromwire_hsm_client_hsmfd_reply(msg, NULL))
|
||||
if (!fromwire_hsm_client_hsmfd_reply(msg))
|
||||
fatal("Malformed hsmfd response: %s", tal_hex(msg, msg));
|
||||
|
||||
hsmfd = fdpass_recv(ld->hsm_fd);
|
||||
|
@ -196,7 +196,7 @@ static void json_getnodes_reply(struct subd *gossip, const u8 *reply,
|
|||
struct json_result *response = new_json_result(cmd);
|
||||
size_t i, j;
|
||||
|
||||
if (!fromwire_gossip_getnodes_reply(reply, reply, NULL, &nodes)) {
|
||||
if (!fromwire_gossip_getnodes_reply(reply, reply, &nodes)) {
|
||||
command_fail(cmd, "Malformed gossip_getnodes response");
|
||||
return;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ static void json_getroute_reply(struct subd *gossip, const u8 *reply, const int
|
|||
struct route_hop *hops;
|
||||
size_t i;
|
||||
|
||||
fromwire_gossip_getroute_reply(reply, reply, NULL, &hops);
|
||||
fromwire_gossip_getroute_reply(reply, reply, &hops);
|
||||
|
||||
if (tal_count(hops) == 0) {
|
||||
command_fail(cmd, "Could not find a route");
|
||||
|
@ -362,7 +362,7 @@ static void json_listchannels_reply(struct subd *gossip, const u8 *reply,
|
|||
struct gossip_getchannels_entry *entries;
|
||||
struct json_result *response = new_json_result(cmd);
|
||||
|
||||
if (!fromwire_gossip_getchannels_reply(reply, reply, NULL, &entries)) {
|
||||
if (!fromwire_gossip_getchannels_reply(reply, reply, &entries)) {
|
||||
command_fail(cmd, "Invalid reply from gossipd");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ void hsm_init(struct lightningd *ld, bool newdir)
|
|||
|
||||
ld->wallet->bip32_base = tal(ld->wallet, struct ext_key);
|
||||
msg = hsm_sync_read(tmpctx, ld);
|
||||
if (!fromwire_hsm_init_reply(msg, NULL,
|
||||
if (!fromwire_hsm_init_reply(msg,
|
||||
&ld->id,
|
||||
&ld->peer_seed,
|
||||
ld->wallet->bip32_base))
|
||||
|
|
|
@ -91,7 +91,7 @@ static bool hsm_sign_b11(const u5 *u5bytes,
|
|||
fatal("Could not write to HSM: %s", strerror(errno));
|
||||
|
||||
msg = hsm_sync_read(ld, ld);
|
||||
if (!fromwire_hsm_sign_invoice_reply(msg, NULL, rsig))
|
||||
if (!fromwire_hsm_sign_invoice_reply(msg, rsig))
|
||||
fatal("HSM gave bad sign_invoice_reply %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ bool log_status_msg(struct log *log, const u8 *msg)
|
|||
u8 *data;
|
||||
enum log_level level;
|
||||
|
||||
if (fromwire_status_log(msg, msg, NULL, &level, &entry)) {
|
||||
if (fromwire_status_log(msg, msg, &level, &entry)) {
|
||||
if (level != LOG_IO_IN && level != LOG_IO_OUT) {
|
||||
log_(log, level, "%s", entry);
|
||||
return true;
|
||||
}
|
||||
} else if (fromwire_status_io(msg, msg, NULL, &level, &data)) {
|
||||
} else if (fromwire_status_io(msg, msg, &level, &data)) {
|
||||
if (level == LOG_IO_IN || level == LOG_IO_OUT) {
|
||||
log_io(log, level, "", data, tal_len(data));
|
||||
return true;
|
||||
|
|
|
@ -50,7 +50,7 @@ static void handle_onchain_init_reply(struct channel *channel, const u8 *msg)
|
|||
{
|
||||
u8 state;
|
||||
|
||||
if (!fromwire_onchain_init_reply(msg, NULL, &state)) {
|
||||
if (!fromwire_onchain_init_reply(msg, &state)) {
|
||||
channel_internal_error(channel, "Invalid onchain_init_reply");
|
||||
return;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ static void handle_onchain_broadcast_tx(struct channel *channel, const u8 *msg)
|
|||
{
|
||||
struct bitcoin_tx *tx;
|
||||
|
||||
if (!fromwire_onchain_broadcast_tx(msg, msg, NULL, &tx)) {
|
||||
if (!fromwire_onchain_broadcast_tx(msg, msg, &tx)) {
|
||||
channel_internal_error(channel, "Invalid onchain_broadcast_tx");
|
||||
return;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ static void handle_onchain_unwatch_tx(struct channel *channel, const u8 *msg)
|
|||
struct bitcoin_txid txid;
|
||||
struct txwatch *txw;
|
||||
|
||||
if (!fromwire_onchain_unwatch_tx(msg, NULL, &txid)) {
|
||||
if (!fromwire_onchain_unwatch_tx(msg, &txid)) {
|
||||
channel_internal_error(channel, "Invalid onchain_unwatch_tx");
|
||||
return;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ static void handle_extracted_preimage(struct channel *channel, const u8 *msg)
|
|||
{
|
||||
struct preimage preimage;
|
||||
|
||||
if (!fromwire_onchain_extracted_preimage(msg, NULL, &preimage)) {
|
||||
if (!fromwire_onchain_extracted_preimage(msg, &preimage)) {
|
||||
channel_internal_error(channel, "Invalid extracted_preimage");
|
||||
return;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ static void handle_missing_htlc_output(struct channel *channel, const u8 *msg)
|
|||
{
|
||||
struct htlc_stub htlc;
|
||||
|
||||
if (!fromwire_onchain_missing_htlc_output(msg, NULL, &htlc)) {
|
||||
if (!fromwire_onchain_missing_htlc_output(msg, &htlc)) {
|
||||
channel_internal_error(channel, "Invalid missing_htlc_output");
|
||||
return;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ static void handle_onchain_htlc_timeout(struct channel *channel, const u8 *msg)
|
|||
{
|
||||
struct htlc_stub htlc;
|
||||
|
||||
if (!fromwire_onchain_htlc_timeout(msg, NULL, &htlc)) {
|
||||
if (!fromwire_onchain_htlc_timeout(msg, &htlc)) {
|
||||
channel_internal_error(channel, "Invalid onchain_htlc_timeout");
|
||||
return;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ static void onchain_add_utxo(struct channel *channel, const u8 *msg)
|
|||
u->close_info->channel_id = channel->dbid;
|
||||
u->close_info->peer_id = channel->peer->id;
|
||||
|
||||
if (!fromwire_onchain_add_utxo(msg, NULL, &u->txid, &u->outnum,
|
||||
if (!fromwire_onchain_add_utxo(msg, &u->txid, &u->outnum,
|
||||
&u->close_info->commitment_point,
|
||||
&u->amount)) {
|
||||
fatal("onchaind gave invalid add_utxo message: %s", tal_hex(msg, msg));
|
||||
|
|
|
@ -234,7 +234,7 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp,
|
|||
/* This is a new channel_info.their_config so set its ID to 0 */
|
||||
channel_info.their_config.id = 0;
|
||||
|
||||
if (!fromwire_opening_funder_reply(resp, resp, NULL,
|
||||
if (!fromwire_opening_funder_reply(resp, resp,
|
||||
&channel_info.their_config,
|
||||
&remote_commit,
|
||||
&remote_commit_sig,
|
||||
|
@ -340,7 +340,7 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp,
|
|||
fatal("Could not write to HSM: %s", strerror(errno));
|
||||
|
||||
msg = hsm_sync_read(fc, ld);
|
||||
if (!fromwire_hsm_sign_funding_reply(tmpctx, msg, NULL, &fundingtx))
|
||||
if (!fromwire_hsm_sign_funding_reply(tmpctx, msg, &fundingtx))
|
||||
fatal("HSM gave bad sign_funding_reply %s",
|
||||
tal_hex(msg, resp));
|
||||
|
||||
|
@ -405,7 +405,7 @@ static void opening_fundee_finished(struct subd *openingd,
|
|||
/* This is a new channel_info.their_config, set its ID to 0 */
|
||||
channel_info.their_config.id = 0;
|
||||
|
||||
if (!fromwire_opening_fundee_reply(tmpctx, reply, NULL,
|
||||
if (!fromwire_opening_fundee_reply(tmpctx, reply,
|
||||
&channel_info.their_config,
|
||||
&remote_commit,
|
||||
&remote_commit_sig,
|
||||
|
@ -743,10 +743,10 @@ static void gossip_peer_released(struct subd *gossip,
|
|||
|
||||
c = active_channel_by_id(ld, &fc->peerid, &uc);
|
||||
|
||||
if (!fromwire_gossipctl_release_peer_reply(fc, resp, NULL, &addr, &cs,
|
||||
if (!fromwire_gossipctl_release_peer_reply(fc, resp, &addr, &cs,
|
||||
&gossip_index,
|
||||
&gfeatures, &lfeatures)) {
|
||||
if (!fromwire_gossipctl_release_peer_replyfail(resp, NULL)) {
|
||||
if (!fromwire_gossipctl_release_peer_replyfail(resp)) {
|
||||
fatal("Gossip daemon gave invalid reply %s",
|
||||
tal_hex(gossip, resp));
|
||||
}
|
||||
|
|
|
@ -173,19 +173,19 @@ static u8 *channel_update_from_onion_error(const tal_t *ctx,
|
|||
* TODO > BOLT 1.0: Add new failcodes when updating to a
|
||||
* new BOLT version. */
|
||||
if (!fromwire_temporary_channel_failure(ctx,
|
||||
onion_message, NULL,
|
||||
onion_message,
|
||||
&channel_update) &&
|
||||
!fromwire_amount_below_minimum(ctx,
|
||||
onion_message, NULL, &unused64,
|
||||
onion_message, &unused64,
|
||||
&channel_update) &&
|
||||
!fromwire_fee_insufficient(ctx,
|
||||
onion_message, NULL, &unused64,
|
||||
onion_message, &unused64,
|
||||
&channel_update) &&
|
||||
!fromwire_incorrect_cltv_expiry(ctx,
|
||||
onion_message, NULL, &unused32,
|
||||
onion_message, &unused32,
|
||||
&channel_update) &&
|
||||
!fromwire_expiry_too_soon(ctx,
|
||||
onion_message, NULL,
|
||||
onion_message,
|
||||
&channel_update))
|
||||
/* No channel update. */
|
||||
channel_update = NULL;
|
||||
|
|
|
@ -149,7 +149,7 @@ static void json_pay_getroute_reply(struct subd *gossip,
|
|||
double feepercent;
|
||||
struct json_result *data;
|
||||
|
||||
fromwire_gossip_getroute_reply(reply, reply, NULL, &route);
|
||||
fromwire_gossip_getroute_reply(reply, reply, &route);
|
||||
|
||||
if (tal_count(route) == 0) {
|
||||
command_fail_detailed(pay->cmd, PAY_ROUTE_NOT_FOUND, NULL,
|
||||
|
|
|
@ -288,7 +288,7 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
|
|||
u64 gossip_index;
|
||||
struct uncommitted_channel *uc;
|
||||
|
||||
if (!fromwire_gossip_peer_connected(msg, msg, NULL,
|
||||
if (!fromwire_gossip_peer_connected(msg, msg,
|
||||
&id, &addr, &cs, &gossip_index,
|
||||
&gfeatures, &lfeatures))
|
||||
fatal("Gossip gave bad GOSSIP_PEER_CONNECTED message %s",
|
||||
|
@ -593,7 +593,7 @@ static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg,
|
|||
struct json_result *response = new_json_result(gpa->cmd);
|
||||
struct peer *p;
|
||||
|
||||
if (!fromwire_gossip_getpeers_reply(msg, msg, NULL, &ids, &addrs)) {
|
||||
if (!fromwire_gossip_getpeers_reply(msg, msg, &ids, &addrs)) {
|
||||
command_fail(gpa->cmd, "Bad response from gossipd");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -333,7 +333,7 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds,
|
|||
u8 *failurestr;
|
||||
struct lightningd *ld = subd->ld;
|
||||
|
||||
if (!fromwire_channel_offer_htlc_reply(msg, msg, NULL,
|
||||
if (!fromwire_channel_offer_htlc_reply(msg, msg,
|
||||
&hout->key.id,
|
||||
&failure_code,
|
||||
&failurestr)) {
|
||||
|
@ -515,7 +515,7 @@ static void channel_resolve_reply(struct subd *gossip, const u8 *msg,
|
|||
{
|
||||
struct pubkey *nodes, *peer_id;
|
||||
|
||||
if (!fromwire_gossip_resolve_channel_reply(msg, msg, NULL, &nodes)) {
|
||||
if (!fromwire_gossip_resolve_channel_reply(msg, msg, &nodes)) {
|
||||
log_broken(gossip->log,
|
||||
"bad fromwire_gossip_resolve_channel_reply %s",
|
||||
tal_hex(msg, msg));
|
||||
|
@ -966,7 +966,7 @@ void peer_sending_commitsig(struct channel *channel, const u8 *msg)
|
|||
secp256k1_ecdsa_signature *htlc_sigs;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
|
||||
if (!fromwire_channel_sending_commitsig(msg, msg, NULL,
|
||||
if (!fromwire_channel_sending_commitsig(msg, msg,
|
||||
&commitnum,
|
||||
&feerate,
|
||||
&changed_htlcs,
|
||||
|
@ -1112,7 +1112,7 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg)
|
|||
size_t i;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
|
||||
if (!fromwire_channel_got_commitsig(msg, msg, NULL,
|
||||
if (!fromwire_channel_got_commitsig(msg, msg,
|
||||
&commitnum,
|
||||
&feerate,
|
||||
&commit_sig,
|
||||
|
@ -1204,7 +1204,7 @@ void peer_got_revoke(struct channel *channel, const u8 *msg)
|
|||
size_t i;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
|
||||
if (!fromwire_channel_got_revoke(msg, msg, NULL,
|
||||
if (!fromwire_channel_got_revoke(msg, msg,
|
||||
&revokenum, &per_commitment_secret,
|
||||
&next_per_commitment_point,
|
||||
&changed)) {
|
||||
|
|
|
@ -362,7 +362,7 @@ static bool log_status_fail(struct subd *sd, const u8 *msg)
|
|||
enum status_failreason failreason;
|
||||
char *desc;
|
||||
|
||||
if (!fromwire_status_fail(msg, msg, NULL, &failreason, &desc))
|
||||
if (!fromwire_status_fail(msg, msg, &failreason, &desc))
|
||||
return false;
|
||||
|
||||
/* No 'default:' here so gcc gives warning if a new type added */
|
||||
|
@ -401,7 +401,7 @@ static bool handle_peer_error(struct subd *sd, const u8 *msg, int fds[2])
|
|||
u64 gossip_index;
|
||||
u8 *err_for_them;
|
||||
|
||||
if (!fromwire_status_peer_error(msg, msg, NULL,
|
||||
if (!fromwire_status_peer_error(msg, msg,
|
||||
&channel_id, &desc,
|
||||
&cs, &gossip_index, &err_for_them))
|
||||
return false;
|
||||
|
|
|
@ -950,12 +950,12 @@ static void wait_for_resolved(struct tracked_output **outs)
|
|||
status_trace("Got new message %s",
|
||||
onchain_wire_type_name(fromwire_peektype(msg)));
|
||||
|
||||
if (fromwire_onchain_depth(msg, NULL, &txid, &depth))
|
||||
if (fromwire_onchain_depth(msg, &txid, &depth))
|
||||
tx_new_depth(outs, &txid, depth);
|
||||
else if (fromwire_onchain_spent(msg, msg, NULL, &tx, &input_num,
|
||||
else if (fromwire_onchain_spent(msg, msg, &tx, &input_num,
|
||||
&tx_blockheight))
|
||||
output_spent(&outs, tx, input_num, tx_blockheight);
|
||||
else if (fromwire_onchain_known_preimage(msg, NULL, &preimage))
|
||||
else if (fromwire_onchain_known_preimage(msg, &preimage))
|
||||
handle_preimage(outs, &preimage);
|
||||
else
|
||||
master_badmsg(-1, msg);
|
||||
|
@ -1982,7 +1982,7 @@ int main(int argc, char *argv[])
|
|||
missing_htlc_msgs = tal_arr(ctx, u8 *, 0);
|
||||
|
||||
msg = wire_sync_read(ctx, REQ_FD);
|
||||
if (!fromwire_onchain_init(ctx, msg, NULL,
|
||||
if (!fromwire_onchain_init(ctx, msg,
|
||||
&seed, &shachain,
|
||||
&funding_amount_satoshi,
|
||||
&old_remote_per_commit_point,
|
||||
|
@ -2021,7 +2021,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
for (u64 i = 0; i < num_htlcs; i++) {
|
||||
msg = wire_sync_read(ctx, REQ_FD);
|
||||
if (!fromwire_onchain_htlc(msg, NULL, &htlcs[i],
|
||||
if (!fromwire_onchain_htlc(msg, &htlcs[i],
|
||||
&tell_if_missing[i],
|
||||
&tell_immediately[i]))
|
||||
master_badmsg(WIRE_ONCHAIN_HTLC, msg);
|
||||
|
|
|
@ -270,7 +270,7 @@ static u8 *funder_channel(struct state *state,
|
|||
* `delayed_payment_basepoint` are not valid DER-encoded compressed
|
||||
* secp256k1 pubkeys.
|
||||
*/
|
||||
if (!fromwire_accept_channel(msg, NULL, &id_in,
|
||||
if (!fromwire_accept_channel(msg, &id_in,
|
||||
&state->remoteconf->dust_limit_satoshis,
|
||||
&state->remoteconf
|
||||
->max_htlc_value_in_flight_msat,
|
||||
|
@ -386,7 +386,7 @@ static u8 *funder_channel(struct state *state,
|
|||
*/
|
||||
msg = opening_read_peer_msg(state);
|
||||
|
||||
if (!fromwire_funding_signed(msg, NULL, &id_in, &sig))
|
||||
if (!fromwire_funding_signed(msg, &id_in, &sig))
|
||||
peer_failed(&state->cs, state->gossip_index,
|
||||
&state->channel_id,
|
||||
"Parsing funding_signed: %s", tal_hex(msg, msg));
|
||||
|
@ -475,7 +475,7 @@ static u8 *fundee_channel(struct state *state,
|
|||
* `delayed_payment_basepoint` are not valid DER-encoded compressed
|
||||
* secp256k1 pubkeys.
|
||||
*/
|
||||
if (!fromwire_open_channel(peer_msg, NULL, &chain_hash,
|
||||
if (!fromwire_open_channel(peer_msg, &chain_hash,
|
||||
&state->channel_id,
|
||||
&state->funding_satoshis, &state->push_msat,
|
||||
&state->remoteconf->dust_limit_satoshis,
|
||||
|
@ -572,7 +572,7 @@ static u8 *fundee_channel(struct state *state,
|
|||
|
||||
msg = opening_read_peer_msg(state);
|
||||
|
||||
if (!fromwire_funding_created(msg, NULL, &id_in,
|
||||
if (!fromwire_funding_created(msg, &id_in,
|
||||
&state->funding_txid,
|
||||
&state->funding_txout,
|
||||
&theirsig))
|
||||
|
@ -699,7 +699,7 @@ int main(int argc, char *argv[])
|
|||
status_setup_sync(REQ_FD);
|
||||
|
||||
msg = wire_sync_read(state, REQ_FD);
|
||||
if (!fromwire_opening_init(msg, NULL,
|
||||
if (!fromwire_opening_init(msg,
|
||||
&network_index,
|
||||
&state->localconf,
|
||||
&state->max_to_self_delay,
|
||||
|
@ -732,7 +732,7 @@ int main(int argc, char *argv[])
|
|||
type_to_string(trc, struct pubkey,
|
||||
&state->next_per_commit[LOCAL]));
|
||||
msg = wire_sync_read(state, REQ_FD);
|
||||
if (fromwire_opening_funder(state, msg, NULL,
|
||||
if (fromwire_opening_funder(state, msg,
|
||||
&state->funding_satoshis,
|
||||
&state->push_msat,
|
||||
&state->feerate_per_kw, &max_minimum_depth,
|
||||
|
@ -742,7 +742,7 @@ int main(int argc, char *argv[])
|
|||
max_minimum_depth, change_satoshis,
|
||||
change_keyindex, channel_flags,
|
||||
utxos, &bip32_base);
|
||||
else if (fromwire_opening_fundee(state, msg, NULL, &minimum_depth,
|
||||
else if (fromwire_opening_fundee(state, msg, &minimum_depth,
|
||||
&min_feerate, &max_feerate, &peer_msg))
|
||||
msg = fundee_channel(state, &our_funding_pubkey, &our_points,
|
||||
minimum_depth, min_feerate, max_feerate,
|
||||
|
|
|
@ -187,24 +187,20 @@ class Field(object):
|
|||
|
||||
raise ValueError('Unknown size {} for {}'.format(base_size,fieldname))
|
||||
|
||||
fromwire_impl_templ = """bool fromwire_{name}({ctx}const void *p, size_t *plen{args})
|
||||
fromwire_impl_templ = """bool fromwire_{name}({ctx}const void *p{args})
|
||||
{{
|
||||
{fields}
|
||||
const u8 *cursor = p;
|
||||
size_t tmp_len;
|
||||
size_t plen = tal_len(p);
|
||||
|
||||
if (!plen) {{
|
||||
tmp_len = tal_count(p);
|
||||
plen = &tmp_len;
|
||||
}}
|
||||
if (fromwire_u16(&cursor, plen) != {enum.name})
|
||||
if (fromwire_u16(&cursor, &plen) != {enum.name})
|
||||
return false;
|
||||
{subcalls}
|
||||
return cursor != NULL;
|
||||
}}
|
||||
"""
|
||||
|
||||
fromwire_header_templ = """bool fromwire_{name}({ctx}const void *p, size_t *plen{args});
|
||||
fromwire_header_templ = """bool fromwire_{name}({ctx}const void *p{args});
|
||||
"""
|
||||
|
||||
towire_header_templ = """u8 *towire_{name}(const tal_t *ctx{args});
|
||||
|
@ -274,19 +270,19 @@ class Message(object):
|
|||
|
||||
def print_fromwire_array(self, subcalls, basetype, f, name, num_elems):
|
||||
if f.has_array_helper():
|
||||
subcalls.append('\tfromwire_{}_array(&cursor, plen, {}, {});'
|
||||
subcalls.append('\tfromwire_{}_array(&cursor, &plen, {}, {});'
|
||||
.format(basetype, name, num_elems))
|
||||
else:
|
||||
subcalls.append('\tfor (size_t i = 0; i < {}; i++)'
|
||||
.format(num_elems))
|
||||
if f.fieldtype.is_assignable():
|
||||
subcalls.append('\t\t({})[i] = fromwire_{}(&cursor, plen);'
|
||||
subcalls.append('\t\t({})[i] = fromwire_{}(&cursor, &plen);'
|
||||
.format(name, basetype))
|
||||
elif basetype in varlen_structs:
|
||||
subcalls.append('\t\t({})[i] = fromwire_{}(ctx, &cursor, plen);'
|
||||
subcalls.append('\t\t({})[i] = fromwire_{}(ctx, &cursor, &plen);'
|
||||
.format(name, basetype))
|
||||
else:
|
||||
subcalls.append('\t\tfromwire_{}(&cursor, plen, {} + i);'
|
||||
subcalls.append('\t\tfromwire_{}(&cursor, &plen, {} + i);'
|
||||
.format(basetype, name))
|
||||
|
||||
def print_fromwire(self,is_header):
|
||||
|
@ -321,7 +317,7 @@ class Message(object):
|
|||
subcalls.append('\t/*{} */'.format(c))
|
||||
|
||||
if f.is_padding():
|
||||
subcalls.append('\tfromwire_pad(&cursor, plen, {});'
|
||||
subcalls.append('\tfromwire_pad(&cursor, &plen, {});'
|
||||
.format(f.num_elems))
|
||||
elif f.is_array():
|
||||
self.print_fromwire_array(subcalls, basetype, f, f.name,
|
||||
|
@ -340,16 +336,16 @@ class Message(object):
|
|||
elif f.is_assignable():
|
||||
subcalls.append("\t//3th case {name}".format(name=f.name))
|
||||
if f.is_len_var:
|
||||
subcalls.append('\t{} = fromwire_{}(&cursor, plen);'
|
||||
subcalls.append('\t{} = fromwire_{}(&cursor, &plen);'
|
||||
.format(f.name, basetype))
|
||||
else:
|
||||
subcalls.append('\t*{} = fromwire_{}(&cursor, plen);'
|
||||
subcalls.append('\t*{} = fromwire_{}(&cursor, &plen);'
|
||||
.format(f.name, basetype))
|
||||
elif basetype in varlen_structs:
|
||||
subcalls.append('\t*{} = fromwire_{}(ctx, &cursor, plen);'
|
||||
subcalls.append('\t*{} = fromwire_{}(ctx, &cursor, &plen);'
|
||||
.format(f.name, basetype))
|
||||
else:
|
||||
subcalls.append('\tfromwire_{}(&cursor, plen, {});'
|
||||
subcalls.append('\tfromwire_{}(&cursor, &plen, {});'
|
||||
.format(basetype, f.name))
|
||||
|
||||
return template.format(
|
||||
|
|
|
@ -74,10 +74,10 @@ bool derive_basepoints(const struct privkey *seed UNNEEDED,
|
|||
bool extract_channel_id(const u8 *in_pkt UNNEEDED, struct channel_id *channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "extract_channel_id called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_getpeers_reply */
|
||||
bool fromwire_gossip_getpeers_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, struct pubkey **id UNNEEDED, struct wireaddr **addr UNNEEDED)
|
||||
bool fromwire_gossip_getpeers_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey **id UNNEEDED, struct wireaddr **addr UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_getpeers_reply called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_peer_connected */
|
||||
bool fromwire_gossip_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, struct pubkey *id UNNEEDED, struct wireaddr *addr UNNEEDED, struct crypto_state *crypto_state UNNEEDED, u64 *gossip_index UNNEEDED, u8 **gfeatures UNNEEDED, u8 **lfeatures UNNEEDED)
|
||||
bool fromwire_gossip_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *id UNNEEDED, struct wireaddr *addr UNNEEDED, struct crypto_state *crypto_state UNNEEDED, u64 *gossip_index UNNEEDED, u8 **gfeatures UNNEEDED, u8 **lfeatures UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_peer_connected called!\n"); abort(); }
|
||||
/* Generated stub for funding_spent */
|
||||
enum watch_result funding_spent(struct channel *channel UNNEEDED,
|
||||
|
|
|
@ -290,7 +290,7 @@ static void json_withdraw(struct command *cmd,
|
|||
|
||||
msg = hsm_sync_read(cmd, cmd->ld);
|
||||
|
||||
if (!fromwire_hsm_sign_withdrawal_reply(msg, msg, NULL, &tx))
|
||||
if (!fromwire_hsm_sign_withdrawal_reply(msg, msg, &tx))
|
||||
fatal("HSM gave bad sign_withdrawal_reply %s",
|
||||
tal_hex(withdraw, msg));
|
||||
|
||||
|
|
|
@ -84,10 +84,10 @@ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
|
|||
struct pubkey ignored_pubkey;
|
||||
struct bitcoin_blkid ignored_chainhash;
|
||||
|
||||
if (fromwire_channel_reestablish(in_pkt, NULL, channel_id,
|
||||
if (fromwire_channel_reestablish(in_pkt, channel_id,
|
||||
&ignored_u64, &ignored_u64))
|
||||
return true;
|
||||
if (fromwire_open_channel(in_pkt, NULL, &ignored_chainhash,
|
||||
if (fromwire_open_channel(in_pkt, &ignored_chainhash,
|
||||
channel_id, &ignored_u64,
|
||||
&ignored_u64, &ignored_u64,
|
||||
&ignored_u64, &ignored_u64,
|
||||
|
|
|
@ -228,10 +228,10 @@ static void *towire_struct_channel_announcement(const tal_t *ctx,
|
|||
&s->bitcoin_key_2);
|
||||
}
|
||||
|
||||
static struct msg_channel_announcement *fromwire_struct_channel_announcement(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_channel_announcement *fromwire_struct_channel_announcement(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_channel_announcement *s = tal(ctx, struct msg_channel_announcement);
|
||||
if (!fromwire_channel_announcement(s, p, plen,
|
||||
if (!fromwire_channel_announcement(s, p,
|
||||
&s->node_signature_1,
|
||||
&s->node_signature_2,
|
||||
&s->bitcoin_signature_1,
|
||||
|
@ -271,11 +271,11 @@ static void *towire_struct_open_channel(const tal_t *ctx,
|
|||
s->channel_flags);
|
||||
}
|
||||
|
||||
static struct msg_open_channel *fromwire_struct_open_channel(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_open_channel *fromwire_struct_open_channel(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_open_channel *s = tal(ctx, struct msg_open_channel);
|
||||
|
||||
if (fromwire_open_channel(p, plen,
|
||||
if (fromwire_open_channel(p,
|
||||
&s->chain_hash,
|
||||
&s->temporary_channel_id,
|
||||
&s->funding_satoshis,
|
||||
|
@ -318,11 +318,11 @@ static void *towire_struct_accept_channel(const tal_t *ctx,
|
|||
&s->first_per_commitment_point);
|
||||
}
|
||||
|
||||
static struct msg_accept_channel *fromwire_struct_accept_channel(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_accept_channel *fromwire_struct_accept_channel(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_accept_channel *s = tal(ctx, struct msg_accept_channel);
|
||||
|
||||
if (fromwire_accept_channel(p, plen,
|
||||
if (fromwire_accept_channel(p,
|
||||
&s->temporary_channel_id,
|
||||
&s->dust_limit_satoshis,
|
||||
&s->max_htlc_value_in_flight_msat,
|
||||
|
@ -354,10 +354,10 @@ static void *towire_struct_node_announcement(const tal_t *ctx,
|
|||
s->addresses);
|
||||
}
|
||||
|
||||
static struct msg_node_announcement *fromwire_struct_node_announcement(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_node_announcement *fromwire_struct_node_announcement(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_node_announcement *s = tal(ctx, struct msg_node_announcement);
|
||||
if (!fromwire_node_announcement(s, p, plen,
|
||||
if (!fromwire_node_announcement(s, p,
|
||||
&s->signature,
|
||||
&s->features,
|
||||
&s->timestamp,
|
||||
|
@ -384,11 +384,11 @@ static void *towire_struct_channel_update(const tal_t *ctx,
|
|||
s->fee_proportional_millionths);
|
||||
}
|
||||
|
||||
static struct msg_channel_update *fromwire_struct_channel_update(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_channel_update *fromwire_struct_channel_update(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_channel_update *s = tal(ctx, struct msg_channel_update);
|
||||
|
||||
if (fromwire_channel_update(p, plen,
|
||||
if (fromwire_channel_update(p,
|
||||
&s->signature,
|
||||
&s->chain_hash,
|
||||
&s->short_channel_id,
|
||||
|
@ -410,11 +410,11 @@ static void *towire_struct_funding_locked(const tal_t *ctx,
|
|||
&s->next_per_commitment_point);
|
||||
}
|
||||
|
||||
static struct msg_funding_locked *fromwire_struct_funding_locked(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_funding_locked *fromwire_struct_funding_locked(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_funding_locked *s = tal(ctx, struct msg_funding_locked);
|
||||
|
||||
if (fromwire_funding_locked(p, plen,
|
||||
if (fromwire_funding_locked(p,
|
||||
&s->channel_id,
|
||||
&s->next_per_commitment_point))
|
||||
return s;
|
||||
|
@ -431,11 +431,11 @@ static void *towire_struct_announcement_signatures(const tal_t *ctx,
|
|||
&s->announcement_bitcoin_signature);
|
||||
}
|
||||
|
||||
static struct msg_announcement_signatures *fromwire_struct_announcement_signatures(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_announcement_signatures *fromwire_struct_announcement_signatures(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_announcement_signatures *s = tal(ctx, struct msg_announcement_signatures);
|
||||
|
||||
if (fromwire_announcement_signatures(p, plen,
|
||||
if (fromwire_announcement_signatures(p,
|
||||
&s->channel_id,
|
||||
&s->short_channel_id,
|
||||
&s->announcement_node_signature,
|
||||
|
@ -453,11 +453,11 @@ static void *towire_struct_update_fail_htlc(const tal_t *ctx,
|
|||
s->reason);
|
||||
}
|
||||
|
||||
static struct msg_update_fail_htlc *fromwire_struct_update_fail_htlc(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_update_fail_htlc *fromwire_struct_update_fail_htlc(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_update_fail_htlc *s = tal(ctx, struct msg_update_fail_htlc);
|
||||
|
||||
if (!fromwire_update_fail_htlc(ctx, p, plen,
|
||||
if (!fromwire_update_fail_htlc(ctx, p,
|
||||
&s->channel_id,
|
||||
&s->id,
|
||||
&s->reason))
|
||||
|
@ -475,11 +475,11 @@ static void *towire_struct_update_fulfill_htlc(const tal_t *ctx,
|
|||
&s->payment_preimage);
|
||||
}
|
||||
|
||||
static struct msg_update_fulfill_htlc *fromwire_struct_update_fulfill_htlc(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_update_fulfill_htlc *fromwire_struct_update_fulfill_htlc(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_update_fulfill_htlc *s = tal(ctx, struct msg_update_fulfill_htlc);
|
||||
|
||||
if (fromwire_update_fulfill_htlc(p, plen,
|
||||
if (fromwire_update_fulfill_htlc(p,
|
||||
&s->channel_id,
|
||||
&s->id,
|
||||
&s->payment_preimage))
|
||||
|
@ -496,11 +496,11 @@ static void *towire_struct_commitment_signed(const tal_t *ctx,
|
|||
s->htlc_signature);
|
||||
}
|
||||
|
||||
static struct msg_commitment_signed *fromwire_struct_commitment_signed(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_commitment_signed *fromwire_struct_commitment_signed(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_commitment_signed *s = tal(ctx, struct msg_commitment_signed);
|
||||
|
||||
if (!fromwire_commitment_signed(s, p, plen,
|
||||
if (!fromwire_commitment_signed(s, p,
|
||||
&s->channel_id,
|
||||
&s->signature,
|
||||
&s->htlc_signature))
|
||||
|
@ -517,11 +517,11 @@ static void *towire_struct_revoke_and_ack(const tal_t *ctx,
|
|||
&s->next_per_commitment_point);
|
||||
}
|
||||
|
||||
static struct msg_revoke_and_ack *fromwire_struct_revoke_and_ack(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_revoke_and_ack *fromwire_struct_revoke_and_ack(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_revoke_and_ack *s = tal(ctx, struct msg_revoke_and_ack);
|
||||
|
||||
if (!fromwire_revoke_and_ack(p, plen,
|
||||
if (!fromwire_revoke_and_ack(p,
|
||||
&s->channel_id,
|
||||
&s->per_commitment_secret,
|
||||
&s->next_per_commitment_point))
|
||||
|
@ -538,11 +538,11 @@ static void *towire_struct_funding_signed(const tal_t *ctx,
|
|||
&s->signature);
|
||||
}
|
||||
|
||||
static struct msg_funding_signed *fromwire_struct_funding_signed(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_funding_signed *fromwire_struct_funding_signed(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_funding_signed *s = tal(ctx, struct msg_funding_signed);
|
||||
|
||||
if (fromwire_funding_signed(p, plen,
|
||||
if (fromwire_funding_signed(p,
|
||||
&s->temporary_channel_id,
|
||||
&s->signature))
|
||||
return s;
|
||||
|
@ -558,11 +558,11 @@ static void *towire_struct_closing_signed(const tal_t *ctx,
|
|||
&s->signature);
|
||||
}
|
||||
|
||||
static struct msg_closing_signed *fromwire_struct_closing_signed(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_closing_signed *fromwire_struct_closing_signed(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_closing_signed *s = tal(ctx, struct msg_closing_signed);
|
||||
|
||||
if (fromwire_closing_signed(p, plen,
|
||||
if (fromwire_closing_signed(p,
|
||||
&s->channel_id,
|
||||
&s->fee_satoshis,
|
||||
&s->signature))
|
||||
|
@ -578,11 +578,11 @@ static void *towire_struct_shutdown(const tal_t *ctx,
|
|||
s->scriptpubkey);
|
||||
}
|
||||
|
||||
static struct msg_shutdown *fromwire_struct_shutdown(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_shutdown *fromwire_struct_shutdown(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_shutdown *s = tal(ctx, struct msg_shutdown);
|
||||
|
||||
if (!fromwire_shutdown(s, p, plen,
|
||||
if (!fromwire_shutdown(s, p,
|
||||
&s->channel_id,
|
||||
&s->scriptpubkey))
|
||||
return tal_free(s);
|
||||
|
@ -599,11 +599,11 @@ static void *towire_struct_funding_created(const tal_t *ctx,
|
|||
&s->signature);
|
||||
}
|
||||
|
||||
static struct msg_funding_created *fromwire_struct_funding_created(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_funding_created *fromwire_struct_funding_created(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_funding_created *s = tal(ctx, struct msg_funding_created);
|
||||
|
||||
if (fromwire_funding_created(p, plen,
|
||||
if (fromwire_funding_created(p,
|
||||
&s->temporary_channel_id,
|
||||
&s->txid,
|
||||
&s->output_index,
|
||||
|
@ -620,11 +620,11 @@ static void *towire_struct_error(const tal_t *ctx,
|
|||
s->data);
|
||||
}
|
||||
|
||||
static struct msg_error *fromwire_struct_error(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_error *fromwire_struct_error(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_error *s = tal(ctx, struct msg_error);
|
||||
|
||||
if (!fromwire_error(s, p, plen,
|
||||
if (!fromwire_error(s, p,
|
||||
&s->channel_id,
|
||||
&s->data))
|
||||
return tal_free(s);
|
||||
|
@ -643,11 +643,11 @@ static void *towire_struct_update_add_htlc(const tal_t *ctx,
|
|||
s->onion_routing_packet);
|
||||
}
|
||||
|
||||
static struct msg_update_add_htlc *fromwire_struct_update_add_htlc(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_update_add_htlc *fromwire_struct_update_add_htlc(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_update_add_htlc *s = tal(ctx, struct msg_update_add_htlc);
|
||||
|
||||
if (fromwire_update_add_htlc(p, plen,
|
||||
if (fromwire_update_add_htlc(p,
|
||||
&s->channel_id,
|
||||
&s->id,
|
||||
&s->amount_msat,
|
||||
|
@ -667,11 +667,11 @@ static void *towire_struct_update_fee(const tal_t *ctx,
|
|||
s->feerate_per_kw);
|
||||
}
|
||||
|
||||
static struct msg_update_fee *fromwire_struct_update_fee(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_update_fee *fromwire_struct_update_fee(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_update_fee *s = tal(ctx, struct msg_update_fee);
|
||||
|
||||
if (fromwire_update_fee(p, plen,
|
||||
if (fromwire_update_fee(p,
|
||||
&s->channel_id,
|
||||
&s->feerate_per_kw))
|
||||
return s;
|
||||
|
@ -686,11 +686,11 @@ static void *towire_struct_init(const tal_t *ctx,
|
|||
s->localfeatures);
|
||||
}
|
||||
|
||||
static struct msg_init *fromwire_struct_init(const tal_t *ctx, const void *p, size_t *plen)
|
||||
static struct msg_init *fromwire_struct_init(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_init *s = tal(ctx, struct msg_init);
|
||||
|
||||
if (!fromwire_init(s, p, plen,
|
||||
if (!fromwire_init(s, p,
|
||||
&s->globalfeatures,
|
||||
&s->localfeatures))
|
||||
return tal_free(s);
|
||||
|
@ -831,15 +831,14 @@ static bool node_announcement_eq(const struct msg_node_announcement *a,
|
|||
/* Try flipping each bit, try running short. */
|
||||
#define test_corruption(a, b, type) \
|
||||
for (i = 0; i < tal_count(msg) * 8; i++) { \
|
||||
len = tal_count(msg); \
|
||||
msg[i / 8] ^= (1 << (i%8)); \
|
||||
b = fromwire_struct_##type(ctx, msg, &len); \
|
||||
b = fromwire_struct_##type(ctx, msg); \
|
||||
assert(!b || !type##_eq(a, b)); \
|
||||
msg[i / 8] ^= (1 << (i%8)); \
|
||||
} \
|
||||
for (i = 0; i < tal_count(msg); i++) { \
|
||||
len = i; \
|
||||
b = fromwire_struct_##type(ctx, msg, &len); \
|
||||
u8 *trunc = tal_dup_arr(ctx, u8, msg, i, 0); \
|
||||
b = fromwire_struct_##type(ctx, trunc); \
|
||||
assert(!b); \
|
||||
}
|
||||
|
||||
|
@ -865,7 +864,7 @@ int main(void)
|
|||
struct msg_update_add_htlc uah, *uah2;
|
||||
struct msg_node_announcement na, *na2;
|
||||
void *ctx = tal(NULL, char);
|
||||
size_t i, len;
|
||||
size_t i;
|
||||
u8 *msg;
|
||||
|
||||
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
|
||||
|
@ -880,9 +879,7 @@ int main(void)
|
|||
memset(ca.features, 2, 2);
|
||||
|
||||
msg = towire_struct_channel_announcement(ctx, &ca);
|
||||
len = tal_count(msg);
|
||||
ca2 = fromwire_struct_channel_announcement(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
ca2 = fromwire_struct_channel_announcement(ctx, msg);
|
||||
assert(channel_announcement_eq(&ca, ca2));
|
||||
test_corruption(&ca, ca2, channel_announcement);
|
||||
|
||||
|
@ -890,18 +887,14 @@ int main(void)
|
|||
set_pubkey(&fl.next_per_commitment_point);
|
||||
|
||||
msg = towire_struct_funding_locked(ctx, &fl);
|
||||
len = tal_count(msg);
|
||||
fl2 = fromwire_struct_funding_locked(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
fl2 = fromwire_struct_funding_locked(ctx, msg);
|
||||
assert(funding_locked_eq(&fl, fl2));
|
||||
test_corruption(&fl, fl2, funding_locked);
|
||||
|
||||
memset(&as, 2, sizeof(as));
|
||||
|
||||
msg = towire_struct_announcement_signatures(ctx, &as);
|
||||
len = tal_count(msg);
|
||||
as2 = fromwire_struct_announcement_signatures(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
as2 = fromwire_struct_announcement_signatures(ctx, msg);
|
||||
assert(announcement_signatures_eq(&as, as2));
|
||||
test_corruption(&as, as2, announcement_signatures);
|
||||
|
||||
|
@ -910,9 +903,7 @@ int main(void)
|
|||
memset(ufh.reason, 2, 2);
|
||||
|
||||
msg = towire_struct_update_fail_htlc(ctx, &ufh);
|
||||
len = tal_count(msg);
|
||||
ufh2 = fromwire_struct_update_fail_htlc(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
ufh2 = fromwire_struct_update_fail_htlc(ctx, msg);
|
||||
assert(update_fail_htlc_eq(&ufh, ufh2));
|
||||
test_corruption(&ufh, ufh2, update_fail_htlc);
|
||||
|
||||
|
@ -921,36 +912,28 @@ int main(void)
|
|||
memset(cs.htlc_signature, 2, sizeof(secp256k1_ecdsa_signature)*2);
|
||||
|
||||
msg = towire_struct_commitment_signed(ctx, &cs);
|
||||
len = tal_count(msg);
|
||||
cs2 = fromwire_struct_commitment_signed(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
cs2 = fromwire_struct_commitment_signed(ctx, msg);
|
||||
assert(commitment_signed_eq(&cs, cs2));
|
||||
test_corruption(&cs, cs2, commitment_signed);
|
||||
|
||||
memset(&fs, 2, sizeof(fs));
|
||||
|
||||
msg = towire_struct_funding_signed(ctx, &fs);
|
||||
len = tal_count(msg);
|
||||
fs2 = fromwire_struct_funding_signed(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
fs2 = fromwire_struct_funding_signed(ctx, msg);
|
||||
assert(funding_signed_eq(&fs, fs2));
|
||||
test_corruption(&fs, fs2, funding_signed);
|
||||
|
||||
memset(&cls, 2, sizeof(cls));
|
||||
|
||||
msg = towire_struct_closing_signed(ctx, &cls);
|
||||
len = tal_count(msg);
|
||||
cls2 = fromwire_struct_closing_signed(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
cls2 = fromwire_struct_closing_signed(ctx, msg);
|
||||
assert(closing_signed_eq(&cls, cls2));
|
||||
test_corruption(&cls, cls2, closing_signed);
|
||||
|
||||
memset(&uflh, 2, sizeof(uflh));
|
||||
|
||||
msg = towire_struct_update_fulfill_htlc(ctx, &uflh);
|
||||
len = tal_count(msg);
|
||||
uflh2 = fromwire_struct_update_fulfill_htlc(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
uflh2 = fromwire_struct_update_fulfill_htlc(ctx, msg);
|
||||
assert(update_fulfill_htlc_eq(&uflh, uflh2));
|
||||
test_corruption(&uflh, uflh2, update_fulfill_htlc);
|
||||
|
||||
|
@ -959,9 +942,7 @@ int main(void)
|
|||
memset(e.data, 2, 2);
|
||||
|
||||
msg = towire_struct_error(ctx, &e);
|
||||
len = tal_count(msg);
|
||||
e2 = fromwire_struct_error(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
e2 = fromwire_struct_error(ctx, msg);
|
||||
assert(error_eq(&e, e2));
|
||||
test_corruption(&e, e2, error);
|
||||
|
||||
|
@ -972,18 +953,14 @@ int main(void)
|
|||
memset(init.localfeatures, 2, 2);
|
||||
|
||||
msg = towire_struct_init(ctx, &init);
|
||||
len = tal_count(msg);
|
||||
init2 = fromwire_struct_init(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
init2 = fromwire_struct_init(ctx, msg);
|
||||
assert(init_eq(&init, init2));
|
||||
test_corruption(&init, init2, init);
|
||||
|
||||
memset(&uf, 2, sizeof(uf));
|
||||
|
||||
msg = towire_struct_update_fee(ctx, &uf);
|
||||
len = tal_count(msg);
|
||||
uf2 = fromwire_struct_update_fee(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
uf2 = fromwire_struct_update_fee(ctx, msg);
|
||||
assert(update_fee_eq(&uf, uf2));
|
||||
test_corruption(&uf, uf2, update_fee);
|
||||
|
||||
|
@ -992,18 +969,14 @@ int main(void)
|
|||
memset(shutdown.scriptpubkey, 2, 2);
|
||||
|
||||
msg = towire_struct_shutdown(ctx, &shutdown);
|
||||
len = tal_count(msg);
|
||||
shutdown2 = fromwire_struct_shutdown(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
shutdown2 = fromwire_struct_shutdown(ctx, msg);
|
||||
assert(shutdown_eq(&shutdown, shutdown2));
|
||||
test_corruption(&shutdown, shutdown2, shutdown);
|
||||
|
||||
memset(&fc, 2, sizeof(fc));
|
||||
|
||||
msg = towire_struct_funding_created(ctx, &fc);
|
||||
len = tal_count(msg);
|
||||
fc2 = fromwire_struct_funding_created(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
fc2 = fromwire_struct_funding_created(ctx, msg);
|
||||
assert(funding_created_eq(&fc, fc2));
|
||||
test_corruption(&fc, fc2, funding_created);
|
||||
|
||||
|
@ -1011,9 +984,7 @@ int main(void)
|
|||
set_pubkey(&raa.next_per_commitment_point);
|
||||
|
||||
msg = towire_struct_revoke_and_ack(ctx, &raa);
|
||||
len = tal_count(msg);
|
||||
raa2 = fromwire_struct_revoke_and_ack(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
raa2 = fromwire_struct_revoke_and_ack(ctx, msg);
|
||||
assert(revoke_and_ack_eq(&raa, raa2));
|
||||
test_corruption(&raa, raa2, revoke_and_ack);
|
||||
|
||||
|
@ -1026,18 +997,14 @@ int main(void)
|
|||
set_pubkey(&oc.first_per_commitment_point);
|
||||
|
||||
msg = towire_struct_open_channel(ctx, &oc);
|
||||
len = tal_count(msg);
|
||||
oc2 = fromwire_struct_open_channel(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
oc2 = fromwire_struct_open_channel(ctx, msg);
|
||||
assert(open_channel_eq(&oc, oc2));
|
||||
test_corruption(&oc, oc2, open_channel);
|
||||
|
||||
memset(&cu, 2, sizeof(cu));
|
||||
|
||||
msg = towire_struct_channel_update(ctx, &cu);
|
||||
len = tal_count(msg);
|
||||
cu2 = fromwire_struct_channel_update(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
cu2 = fromwire_struct_channel_update(ctx, msg);
|
||||
assert(channel_update_eq(&cu, cu2));
|
||||
test_corruption(&cu, cu2, channel_update);
|
||||
|
||||
|
@ -1050,18 +1017,14 @@ int main(void)
|
|||
set_pubkey(&ac.first_per_commitment_point);
|
||||
|
||||
msg = towire_struct_accept_channel(ctx, &ac);
|
||||
len = tal_count(msg);
|
||||
ac2 = fromwire_struct_accept_channel(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
ac2 = fromwire_struct_accept_channel(ctx, msg);
|
||||
assert(accept_channel_eq(&ac, ac2));
|
||||
test_corruption(&ac, ac2, accept_channel);
|
||||
|
||||
memset(&uah, 2, sizeof(uah));
|
||||
|
||||
msg = towire_struct_update_add_htlc(ctx, &uah);
|
||||
len = tal_count(msg);
|
||||
uah2 = fromwire_struct_update_add_htlc(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
uah2 = fromwire_struct_update_add_htlc(ctx, msg);
|
||||
assert(update_add_htlc_eq(&uah, uah2));
|
||||
test_corruption(&uah, uah2, update_add_htlc);
|
||||
|
||||
|
@ -1073,9 +1036,7 @@ int main(void)
|
|||
memset(na.addresses, 2, 2);
|
||||
|
||||
msg = towire_struct_node_announcement(ctx, &na);
|
||||
len = tal_count(msg);
|
||||
na2 = fromwire_struct_node_announcement(ctx, msg, &len);
|
||||
assert(len == 0);
|
||||
na2 = fromwire_struct_node_announcement(ctx, msg);
|
||||
assert(node_announcement_eq(&na, na2));
|
||||
test_corruption(&na, na2, node_announcement);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue