Browse Source

status: remove trc context now we have tmpctx.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
ccc9414356
  1. 48
      channeld/channel.c
  2. 2
      channeld/full_channel.c
  3. 2
      closingd/closing.c
  4. 12
      common/status.c
  5. 3
      common/status.h
  6. 76
      gossipd/gossip.c
  7. 113
      gossipd/handshake.c
  8. 38
      gossipd/routing.c
  9. 24
      hsmd/hsm.c
  10. 120
      onchaind/onchain.c
  11. 24
      openingd/opening.c

48
channeld/channel.c

@ -517,7 +517,7 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
peer_failed(&peer->cs, peer->gossip_index,
&peer->channel_id,
"Wrong channel id in %s (expected %s)",
tal_hex(trc, msg),
tal_hex(tmpctx, msg),
type_to_string(msg, struct channel_id,
&peer->channel_id));
@ -590,9 +590,9 @@ static void handle_peer_announcement_signatures(struct peer *peer, const u8 *msg
peer_failed(&peer->cs, peer->gossip_index,
&peer->channel_id,
"Wrong channel_id: expected %s, got %s",
type_to_string(trc, struct channel_id,
type_to_string(tmpctx, struct channel_id,
&peer->channel_id),
type_to_string(trc, struct channel_id, &chanid));
type_to_string(tmpctx, struct channel_id, &chanid));
}
peer->have_sigs[REMOTE] = true;
@ -875,10 +875,10 @@ static struct commit_sigs *calc_commitsigs(const tal_t *ctx,
"Deriving local_htlckey");
status_trace("Derived key %s from basepoint %s, point %s",
type_to_string(trc, struct pubkey, &local_htlckey),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey, &local_htlckey),
type_to_string(tmpctx, struct pubkey,
&peer->channel->basepoints[LOCAL].htlc),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&peer->remote_per_commit));
txs = channel_txs(tmpctx, &htlc_map, &wscripts, peer->channel,
@ -894,11 +894,11 @@ static struct commit_sigs *calc_commitsigs(const tal_t *ctx,
status_trace("Creating commit_sig signature %"PRIu64" %s for tx %s wscript %s key %s",
commit_index,
type_to_string(trc, secp256k1_ecdsa_signature,
type_to_string(tmpctx, secp256k1_ecdsa_signature,
&commit_sigs->commit_sig),
type_to_string(trc, struct bitcoin_tx, txs[0]),
tal_hex(trc, wscripts[0]),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct bitcoin_tx, txs[0]),
tal_hex(tmpctx, wscripts[0]),
type_to_string(tmpctx, struct pubkey,
&peer->channel->funding_pubkey[LOCAL]));
dump_htlcs(peer->channel, "Sending commit_sig");
@ -918,11 +918,11 @@ static struct commit_sigs *calc_commitsigs(const tal_t *ctx,
&local_htlcsecretkey, &local_htlckey,
&commit_sigs->htlc_sigs[i]);
status_trace("Creating HTLC signature %s for tx %s wscript %s key %s",
type_to_string(trc, secp256k1_ecdsa_signature,
type_to_string(tmpctx, secp256k1_ecdsa_signature,
&commit_sigs->htlc_sigs[i]),
type_to_string(trc, struct bitcoin_tx, txs[1+i]),
tal_hex(trc, wscripts[1+i]),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct bitcoin_tx, txs[1+i]),
tal_hex(tmpctx, wscripts[1+i]),
type_to_string(tmpctx, struct pubkey,
&local_htlckey));
assert(check_tx_sig(txs[1+i], 0, NULL, wscripts[1+i],
&local_htlckey,
@ -1082,12 +1082,12 @@ static u8 *make_revocation_msg(const struct peer *peer, u64 revoke_index)
status_trace("Sending revocation #%"PRIu64" for %s",
revoke_index,
type_to_string(trc, struct pubkey, &oldpoint));
type_to_string(tmpctx, struct pubkey, &oldpoint));
if (!pubkey_eq(&point, &oldpoint))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Invalid secret %s for commit_point",
tal_hexstr(trc, &old_commit_secret,
tal_hexstr(tmpctx, &old_commit_secret,
sizeof(old_commit_secret)));
/* We're revoking N-1th commit, sending N+1th point. */
@ -1242,10 +1242,10 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Deriving remote_htlckey");
status_trace("Derived key %s from basepoint %s, point %s",
type_to_string(trc, struct pubkey, &remote_htlckey),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey, &remote_htlckey),
type_to_string(tmpctx, struct pubkey,
&peer->channel->basepoints[REMOTE].htlc),
type_to_string(trc, struct pubkey, &point));
type_to_string(tmpctx, struct pubkey, &point));
/* BOLT #2:
*
* A receiving node MUST fail the channel if `signature` is not valid
@ -1410,9 +1410,9 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg)
peer->remote_per_commit = next_per_commit;
status_trace("revoke_and_ack %s: remote_per_commit = %s, old_remote_per_commit = %s",
side_to_str(peer->channel->funder),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&peer->remote_per_commit),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&peer->old_remote_per_commit));
start_commit_timer(peer);
@ -2028,7 +2028,7 @@ static void handle_funding_locked(struct peer *peer, const u8 *msg)
status_trace("funding_locked: sending commit index %"PRIu64": %s",
peer->next_index[LOCAL],
type_to_string(trc, struct pubkey, &next_per_commit_point));
type_to_string(tmpctx, struct pubkey, &next_per_commit_point));
msg = towire_funding_locked(peer,
&peer->channel_id, &next_per_commit_point);
enqueue_peer_msg(peer, take(msg));
@ -2570,9 +2570,9 @@ static void init_channel(struct peer *peer)
" revocations_received = %"PRIu64
" feerates %u/%u (range %u-%u)",
side_to_str(funder),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&peer->remote_per_commit),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&peer->old_remote_per_commit),
peer->next_index[LOCAL], peer->next_index[REMOTE],
peer->revocations_received,

2
channeld/full_channel.c

@ -954,7 +954,7 @@ bool channel_force_htlcs(struct channel *channel,
i, tal_count(htlcs),
htlcs[i].id, htlcs[i].amount_msat,
htlcs[i].cltv_expiry,
type_to_string(trc, struct sha256,
type_to_string(tmpctx, struct sha256,
&htlcs[i].payment_hash));
e = add_htlc(channel, hstates[i],

2
closingd/closing.c

@ -271,7 +271,7 @@ static uint64_t receive_offer(struct crypto_state *cs,
&received_fee, &their_sig))
peer_failed(cs, gossip_index, channel_id,
"Expected closing_signed: %s",
tal_hex(trc, msg));
tal_hex(tmpctx, msg));
/* BOLT #2:
*

12
common/status.c

@ -18,7 +18,6 @@
static int status_fd = -1;
static struct daemon_conn *status_conn;
const void *trc;
volatile bool logging_io = false;
static void got_sigusr1(int signal UNUSED)
@ -42,7 +41,6 @@ void status_setup_sync(int fd)
assert(status_fd == -1);
assert(!status_conn);
status_fd = fd;
trc = tal_tmpctx(NULL);
setup_logging_sighandler();
}
@ -52,8 +50,6 @@ void status_setup_async(struct daemon_conn *master)
assert(!status_conn);
status_conn = master;
/* Don't use tmpctx here, otherwise debug_poll gets upset. */
trc = tal(NULL, char);
setup_logging_sighandler();
}
@ -96,12 +92,6 @@ void status_vfmt(enum log_level level, const char *fmt, va_list ap)
str = tal_vfmt(NULL, fmt, ap);
status_send(take(towire_status_log(NULL, level, str)));
tal_free(str);
/* Free up any temporary children. */
if (tal_first(trc)) {
tal_free(trc);
trc = tal(NULL, char);
}
}
void status_fmt(enum log_level level, const char *fmt, ...)
@ -161,5 +151,5 @@ void master_badmsg(u32 type_expected, const u8 *msg)
type_expected, strerror(errno));
status_failed(STATUS_FAIL_MASTER_IO,
"Error parsing %u: %s",
type_expected, tal_hex(trc, msg));
type_expected, tal_hex(tmpctx, msg));
}

3
common/status.h

@ -16,9 +16,6 @@ struct daemon_conn;
void status_setup_sync(int fd);
void status_setup_async(struct daemon_conn *master);
/* Convenient context, frees up after every status_update/failed */
extern const void *trc;
/* Send a printf-style debugging trace. */
void status_fmt(enum log_level level, const char *fmt, ...)
PRINTF_FMT(2,3);

76
gossipd/gossip.c

@ -310,8 +310,8 @@ static void peer_error(struct peer *peer, const char *fmt, ...)
va_start(ap, fmt);
status_trace("peer %s: %s",
type_to_string(trc, struct pubkey, &peer->id),
tal_vfmt(trc, fmt, ap));
type_to_string(tmpctx, struct pubkey, &peer->id),
tal_vfmt(tmpctx, fmt, ap));
va_end(ap);
/* Send error: we'll close after writing this. */
@ -335,7 +335,7 @@ static struct io_plan *peer_close_after_error(struct io_conn *conn,
struct peer *peer)
{
status_trace("%s: we sent them a fatal error, closing",
type_to_string(trc, struct pubkey, &peer->id));
type_to_string(tmpctx, struct pubkey, &peer->id));
return io_close(conn);
}
@ -345,8 +345,8 @@ static struct io_plan *peer_init_received(struct io_conn *conn,
{
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));
type_to_string(tmpctx, struct pubkey, &peer->id),
tal_hex(tmpctx, msg));
return io_close(conn);
}
@ -483,7 +483,7 @@ static void send_node_announcement(struct daemon *daemon)
if (err)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"rejected own node announcement: %s",
tal_hex(trc, err));
tal_hex(tmpctx, err));
tal_free(tmpctx);
}
@ -609,8 +609,8 @@ static struct io_plan *peer_msgin(struct io_conn *conn,
switch (t) {
case WIRE_ERROR:
status_trace("%s sent ERROR %s",
type_to_string(trc, struct pubkey, &peer->id),
sanitize_error(trc, msg, NULL));
type_to_string(tmpctx, struct pubkey, &peer->id),
sanitize_error(tmpctx, msg, NULL));
return io_close(conn);
case WIRE_CHANNEL_ANNOUNCEMENT:
@ -659,7 +659,7 @@ static struct io_plan *peer_msgin(struct io_conn *conn,
* understands it. */
if (t & 1) {
status_trace("Peer %s sent packet with unknown message type %u, ignoring",
type_to_string(trc, struct pubkey, &peer->id), t);
type_to_string(tmpctx, struct pubkey, &peer->id), t);
} else
peer_error(peer, "Packet with unknown message type %u", t);
@ -743,16 +743,16 @@ static void handle_get_update(struct peer *peer, const u8 *msg)
if (!fromwire_gossip_get_update(msg, &scid)) {
status_trace("peer %s sent bad gossip_get_update %s",
type_to_string(trc, struct pubkey, &peer->id),
tal_hex(trc, msg));
type_to_string(tmpctx, struct pubkey, &peer->id),
tal_hex(tmpctx, msg));
return;
}
chan = get_channel(rstate, &scid);
if (!chan) {
status_unusual("peer %s scid %s: unknown channel",
type_to_string(trc, struct pubkey, &peer->id),
type_to_string(trc, struct short_channel_id,
type_to_string(tmpctx, struct pubkey, &peer->id),
type_to_string(tmpctx, struct short_channel_id,
&scid));
update = NULL;
} else {
@ -767,17 +767,17 @@ static void handle_get_update(struct peer *peer, const u8 *msg)
.channel_update_msgidx);
else {
status_unusual("peer %s scid %s: not our channel?",
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&peer->id),
type_to_string(trc,
type_to_string(tmpctx,
struct short_channel_id,
&scid));
update = NULL;
}
}
status_trace("peer %s schanid %s: %s update",
type_to_string(trc, struct pubkey, &peer->id),
type_to_string(trc, struct short_channel_id, &scid),
type_to_string(tmpctx, struct pubkey, &peer->id),
type_to_string(tmpctx, struct short_channel_id, &scid),
update ? "got" : "no");
msg = towire_gossip_get_update_reply(msg, update);
@ -854,7 +854,7 @@ static struct io_plan *owner_msg_in(struct io_conn *conn,
handle_local_add_channel(peer, dc->msg_in);
} else {
status_broken("peer %s: send us unknown msg of type %s",
type_to_string(trc, struct pubkey, &peer->id),
type_to_string(tmpctx, struct pubkey, &peer->id),
gossip_wire_type_name(type));
/* Calls forget_peer */
return io_close(conn);
@ -869,7 +869,7 @@ static void forget_peer(struct io_conn *conn UNUSED, struct daemon_conn *dc)
status_trace("Forgetting %s peer %s",
peer->local ? "local" : "remote",
type_to_string(trc, struct pubkey, &peer->id));
type_to_string(tmpctx, struct pubkey, &peer->id));
/* Free peer. */
tal_free(dc->ctx);
@ -976,7 +976,7 @@ static struct io_plan *handle_returning_peer(struct io_conn *conn,
if (!peer)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"hand_back_peer unknown peer: %s",
type_to_string(trc, struct pubkey, &rpeer->id));
type_to_string(tmpctx, struct pubkey, &rpeer->id));
/* We don't need the gossip_fd; we know what gossip it got
* from gossip_index */
@ -985,7 +985,7 @@ static struct io_plan *handle_returning_peer(struct io_conn *conn,
/* Possible if there's a reconnect: ignore handed back. */
if (peer->local) {
status_trace("hand_back_peer %s: reconnected, dropping handback",
type_to_string(trc, struct pubkey, &rpeer->id));
type_to_string(tmpctx, struct pubkey, &rpeer->id));
close(rpeer->peer_fd);
tal_free(rpeer);
@ -993,7 +993,7 @@ static struct io_plan *handle_returning_peer(struct io_conn *conn,
}
status_trace("hand_back_peer %s: now local again",
type_to_string(trc, struct pubkey, &rpeer->id));
type_to_string(tmpctx, struct pubkey, &rpeer->id));
/* Now we talk to peer directly again. */
daemon_conn_clear(peer->remote);
@ -1052,7 +1052,7 @@ static struct io_plan *disconnect_peer(struct io_conn *conn, struct daemon *daem
daemon_conn_send(&daemon->master, take(msg));
} else {
status_trace("disconnect_peer: peer %s %s",
type_to_string(trc, struct pubkey, &id),
type_to_string(tmpctx, struct pubkey, &id),
!peer ? "not connected" : "not gossiping");
msg = towire_gossipctl_peer_disconnect_replyfail(msg, peer ? true : false);
daemon_conn_send(&daemon->master, take(msg));
@ -1073,7 +1073,7 @@ static struct io_plan *release_peer(struct io_conn *conn, struct daemon *daemon,
if (!peer || !peer->local || peer->local->return_to_master) {
/* This can happen with dying peers, or reconnect */
status_trace("release_peer: peer %s %s",
type_to_string(trc, struct pubkey, &id),
type_to_string(tmpctx, struct pubkey, &id),
!peer ? "not found"
: peer->local ? "already releasing"
: "not local");
@ -1376,7 +1376,7 @@ static void gossip_send_keepalive_update(struct routing_state *rstate,
if (err)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"rejected keepalive channel_update: %s",
tal_hex(trc, err));
tal_hex(tmpctx, err));
tal_free(tmpctx);
}
@ -1571,16 +1571,16 @@ static struct io_plan *resolve_channel_req(struct io_conn *conn,
chan = get_channel(daemon->rstate, &scid);
if (!chan) {
status_trace("Failed to resolve channel %s",
type_to_string(trc, struct short_channel_id, &scid));
type_to_string(tmpctx, struct short_channel_id, &scid));
keys = NULL;
} else {
keys = tal_arr(msg, struct pubkey, 2);
keys[0] = chan->nodes[0]->id;
keys[1] = chan->nodes[1]->id;
status_trace("Resolved channel %s %s<->%s",
type_to_string(trc, struct short_channel_id, &scid),
type_to_string(trc, struct pubkey, &keys[0]),
type_to_string(trc, struct pubkey, &keys[1]));
type_to_string(tmpctx, struct short_channel_id, &scid),
type_to_string(tmpctx, struct pubkey, &keys[0]),
type_to_string(tmpctx, struct pubkey, &keys[1]));
}
daemon_conn_send(&daemon->master,
take(towire_gossip_resolve_channel_reply(msg, keys)));
@ -1602,7 +1602,7 @@ static struct io_plan *connection_out(struct io_conn *conn,
{
/* FIXME: Timeout */
status_trace("Connected out for %s",
type_to_string(trc, struct pubkey, &reach->id));
type_to_string(tmpctx, struct pubkey, &reach->id));
return initiator_handshake(conn, &reach->daemon->id, &reach->id,
&reach->addr,
@ -1627,7 +1627,7 @@ static void connect_failed(struct io_conn *conn, struct reaching *reach)
tal_free(reach);
} else {
status_trace("Failed connected out for %s, will try again",
type_to_string(trc, struct pubkey, &reach->id));
type_to_string(tmpctx, struct pubkey, &reach->id));
/* FIXME: Configurable timer! */
new_reltimer(&reach->daemon->timers, reach, time_from_sec(5),
try_connect, reach);
@ -1682,7 +1682,7 @@ static void try_connect(struct reaching *reach)
/* Already succeeded somehow? */
if (find_peer(reach->daemon, &reach->id)) {
status_trace("Already reached %s, not retrying",
type_to_string(trc, struct pubkey, &reach->id));
type_to_string(tmpctx, struct pubkey, &reach->id));
tal_free(reach);
return;
}
@ -1691,7 +1691,7 @@ static void try_connect(struct reaching *reach)
if (!a) {
/* FIXME: now try node table, dns lookups... */
status_info("No address known for %s, giving up",
type_to_string(trc, struct pubkey, &reach->id));
type_to_string(tmpctx, struct pubkey, &reach->id));
daemon_conn_send(
&reach->daemon->master,
take(towire_gossip_peer_connection_failed(
@ -1719,7 +1719,7 @@ static void try_connect(struct reaching *reach)
if (fd < 0) {
status_broken("Can't open %i socket for %s (%s), giving up",
a->addr.type,
type_to_string(trc, struct pubkey, &reach->id),
type_to_string(tmpctx, struct pubkey, &reach->id),
strerror(errno));
tal_free(reach);
return;
@ -1738,7 +1738,7 @@ static bool try_reach_peer(struct daemon *daemon, const struct pubkey *id)
if (find_reaching(daemon, id)) {
/* FIXME: Perhaps kick timer in this case? */
status_trace("try_reach_peer: already trying to reach %s",
type_to_string(trc, struct pubkey, id));
type_to_string(tmpctx, struct pubkey, id));
return false;
}
@ -1747,7 +1747,7 @@ static bool try_reach_peer(struct daemon *daemon, const struct pubkey *id)
peer = find_peer(daemon, id);
if (peer) {
status_trace("reach_peer: have %s, will retry if it dies",
type_to_string(trc, struct pubkey, id));
type_to_string(tmpctx, struct pubkey, id));
peer->reach_again = true;
return true;
}
@ -1944,7 +1944,7 @@ static struct io_plan *handle_disable_channel(struct io_conn *conn,
if (err)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"rejected disabling channel_update: %s",
tal_hex(trc, err));
tal_hex(tmpctx, err));
fail:
tal_free(tmpctx);
@ -2072,7 +2072,7 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
/* Master shouldn't give bad requests. */
status_failed(STATUS_FAIL_MASTER_IO, "%i: %s",
t, tal_hex(trc, master->msg_in));
t, tal_hex(tmpctx, master->msg_in));
}
#ifndef TESTING

113
gossipd/handshake.c

@ -239,9 +239,9 @@ static void hkdf_two_keys(struct secret *out1, struct secret *out2,
struct secret okm[2];
SUPERVERBOSE("# HKDF(0x%s,%s%s)",
tal_hexstr(trc, in1, sizeof(*in1)),
tal_hexstr(tmpctx, in1, sizeof(*in1)),
in2_size ? "0x" : "zero",
tal_hexstr(trc, in2, in2_size));
tal_hexstr(tmpctx, in2, in2_size));
BUILD_ASSERT(sizeof(okm) == 64);
hkdf_sha256(okm, sizeof(okm), in1, sizeof(*in1), in2, in2_size,
NULL, 0);
@ -285,11 +285,11 @@ static void encrypt_ad(const struct secret *k, u64 nonce,
le64_nonce(npub, nonce);
BUILD_ASSERT(sizeof(*k) == crypto_aead_chacha20poly1305_ietf_KEYBYTES);
SUPERVERBOSE("# encryptWithAD(0x%s, 0x%s, 0x%s, %s%s)",
tal_hexstr(trc, k, sizeof(*k)),
tal_hexstr(trc, npub, sizeof(npub)),
tal_hexstr(trc, additional_data, additional_data_len),
tal_hexstr(tmpctx, k, sizeof(*k)),
tal_hexstr(tmpctx, npub, sizeof(npub)),
tal_hexstr(tmpctx, additional_data, additional_data_len),
plaintext_len ? "0x" : "<empty>",
tal_hexstr(trc, plaintext, plaintext_len));
tal_hexstr(tmpctx, plaintext, plaintext_len));
ret = crypto_aead_chacha20poly1305_ietf_encrypt(output, &clen,
memcheck(plaintext, plaintext_len),
@ -319,10 +319,10 @@ static bool decrypt(const struct secret *k, u64 nonce,
le64_nonce(npub, nonce);
BUILD_ASSERT(sizeof(*k) == crypto_aead_chacha20poly1305_ietf_KEYBYTES);
SUPERVERBOSE("# decryptWithAD(0x%s, 0x%s, 0x%s, 0x%s)",
tal_hexstr(trc, k, sizeof(*k)),
tal_hexstr(trc, npub, sizeof(npub)),
tal_hexstr(trc, additional_data, additional_data_len),
tal_hexstr(trc, ciphertext, ciphertext_len));
tal_hexstr(tmpctx, k, sizeof(*k)),
tal_hexstr(tmpctx, npub, sizeof(npub)),
tal_hexstr(tmpctx, additional_data, additional_data_len),
tal_hexstr(tmpctx, ciphertext, ciphertext_len));
if (crypto_aead_chacha20poly1305_ietf_decrypt(output, &mlen, NULL,
memcheck(ciphertext, ciphertext_len),
ciphertext_len,
@ -412,7 +412,7 @@ static struct handshake *new_handshake(const tal_t *ctx,
BUILD_ASSERT(sizeof(handshake->h) == sizeof(handshake->ck));
memcpy(&handshake->ck, &handshake->h, sizeof(handshake->ck));
SUPERVERBOSE("# ck=%s",
tal_hexstr(trc, &handshake->ck, sizeof(handshake->ck)));
tal_hexstr(tmpctx, &handshake->ck, sizeof(handshake->ck)));
/* BOLT #8:
*
@ -436,7 +436,7 @@ static struct handshake *new_handshake(const tal_t *ctx,
*/
sha_mix_in_key(&handshake->h, responder_id);
SUPERVERBOSE("# h=%s",
tal_hexstr(trc, &handshake->h, sizeof(handshake->h)));
tal_hexstr(tmpctx, &handshake->h, sizeof(handshake->h)));
return handshake;
}
@ -459,13 +459,14 @@ static struct io_plan *act_three_initiator(struct io_conn *conn,
encrypt_ad(&h->temp_k, 1, &h->h, sizeof(h->h), spub, sizeof(spub),
h->act3.ciphertext, sizeof(h->act3.ciphertext));
SUPERVERBOSE("# c=0x%s",
tal_hexstr(trc,h->act3.ciphertext,sizeof(h->act3.ciphertext)));
tal_hexstr(tmpctx,
h->act3.ciphertext, sizeof(h->act3.ciphertext)));
/* BOLT #8:
* * `h = SHA-256(h || c)`
*/
sha_mix_in(&h->h, h->act3.ciphertext, sizeof(h->act3.ciphertext));
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
/* BOLT #8:
*
@ -476,7 +477,7 @@ static struct io_plan *act_three_initiator(struct io_conn *conn,
if (!hsm_do_ecdh(&h->ss, &h->re))
return handshake_failed(conn, h);
SUPERVERBOSE("# ss=0x%s", tal_hexstr(trc, &h->ss, sizeof(h->ss)));
SUPERVERBOSE("# ss=0x%s", tal_hexstr(tmpctx, &h->ss, sizeof(h->ss)));
/* BOLT #8:
*
@ -485,8 +486,8 @@ static struct io_plan *act_three_initiator(struct io_conn *conn,
*/
hkdf_two_keys(&h->ck, &h->temp_k, &h->ck, &h->ss, sizeof(h->ss));
SUPERVERBOSE("# ck,temp_k3=0x%s,0x%s",
tal_hexstr(trc, &h->ck, sizeof(h->ck)),
tal_hexstr(trc, &h->temp_k, sizeof(h->temp_k)));
tal_hexstr(tmpctx, &h->ck, sizeof(h->ck)),
tal_hexstr(tmpctx, &h->temp_k, sizeof(h->temp_k)));
/* BOLT #8:
*
@ -497,7 +498,7 @@ static struct io_plan *act_three_initiator(struct io_conn *conn,
encrypt_ad(&h->temp_k, 0, &h->h, sizeof(h->h), NULL, 0,
h->act3.tag, sizeof(h->act3.tag));
SUPERVERBOSE("# t=0x%s",
tal_hexstr(trc, h->act3.tag, sizeof(h->act3.tag)));
tal_hexstr(tmpctx, h->act3.tag, sizeof(h->act3.tag)));
/* BOLT #8:
*
@ -506,14 +507,14 @@ static struct io_plan *act_three_initiator(struct io_conn *conn,
*/
h->act3.v = 0;
SUPERVERBOSE("output: 0x%s", tal_hexstr(trc, &h->act3, ACT_THREE_SIZE));
SUPERVERBOSE("output: 0x%s", tal_hexstr(tmpctx, &h->act3, ACT_THREE_SIZE));
return io_write(conn, &h->act3, ACT_THREE_SIZE, handshake_succeeded, h);
}
static struct io_plan *act_two_initiator2(struct io_conn *conn,
struct handshake *h)
{
SUPERVERBOSE("input: 0x%s", tal_hexstr(trc, &h->act2, ACT_TWO_SIZE));
SUPERVERBOSE("input: 0x%s", tal_hexstr(tmpctx, &h->act2, ACT_TWO_SIZE));
/* BOLT #8:
*
@ -534,14 +535,14 @@ static struct io_plan *act_two_initiator2(struct io_conn *conn,
h->act2.pubkey, sizeof(h->act2.pubkey)) != 1)
return handshake_failed(conn, h);
SUPERVERBOSE("# re=0x%s", type_to_string(trc, struct pubkey, &h->re));
SUPERVERBOSE("# re=0x%s", type_to_string(tmpctx, struct pubkey, &h->re));
/* BOLT #8:
*
* * `h = SHA-256(h || re.serializeCompressed())`
*/
sha_mix_in_key(&h->h, &h->re);
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
/* BOLT #8:
*
@ -551,7 +552,7 @@ static struct io_plan *act_two_initiator2(struct io_conn *conn,
h->e.priv.secret.data))
return handshake_failed(conn, h);
SUPERVERBOSE("# ss=0x%s", tal_hexstr(trc, &h->ss, sizeof(h->ss)));
SUPERVERBOSE("# ss=0x%s", tal_hexstr(tmpctx, &h->ss, sizeof(h->ss)));
/* BOLT #8:
*
@ -561,8 +562,8 @@ static struct io_plan *act_two_initiator2(struct io_conn *conn,
*/
hkdf_two_keys(&h->ck, &h->temp_k, &h->ck, &h->ss, sizeof(h->ss));
SUPERVERBOSE("# ck,temp_k2=0x%s,0x%s",
tal_hexstr(trc, &h->ck, sizeof(h->ck)),
tal_hexstr(trc, &h->temp_k, sizeof(h->temp_k)));
tal_hexstr(tmpctx, &h->ck, sizeof(h->ck)),
tal_hexstr(tmpctx, &h->temp_k, sizeof(h->temp_k)));
/* BOLT #8:
*
@ -581,7 +582,7 @@ static struct io_plan *act_two_initiator2(struct io_conn *conn,
* step serves to ensure the payload wasn't modified by a MiTM.
*/
sha_mix_in(&h->h, h->act2.tag, sizeof(h->act2.tag));
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
return act_three_initiator(conn, h);
}
@ -619,9 +620,9 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
*/
h->e = generate_key();
SUPERVERBOSE("e.priv: 0x%s",
tal_hexstr(trc, &h->e.priv, sizeof(h->e.priv)));
tal_hexstr(tmpctx, &h->e.priv, sizeof(h->e.priv)));
SUPERVERBOSE("e.pub: 0x%s",
type_to_string(trc, struct pubkey, &h->e.pub));
type_to_string(tmpctx, struct pubkey, &h->e.pub));
/* BOLT #8:
*
@ -630,7 +631,7 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
* running handshake digest.
*/
sha_mix_in_key(&h->h, &h->e.pub);
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
/* BOLT #8:
*
@ -642,7 +643,7 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
&h->their_id.pubkey, h->e.priv.secret.data))
return handshake_failed(conn, h);
SUPERVERBOSE("# ss=0x%s", tal_hexstr(trc, h->ss.data, sizeof(h->ss.data)));
SUPERVERBOSE("# ss=0x%s", tal_hexstr(tmpctx, h->ss.data, sizeof(h->ss.data)));
/* BOLT #8:
*
@ -652,8 +653,8 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
*/
hkdf_two_keys(&h->ck, &h->temp_k, &h->ck, &h->ss, sizeof(h->ss));
SUPERVERBOSE("# ck,temp_k1=0x%s,0x%s",
tal_hexstr(trc, &h->ck, sizeof(h->ck)),
tal_hexstr(trc, &h->temp_k, sizeof(h->temp_k)));
tal_hexstr(tmpctx, &h->ck, sizeof(h->ck)),
tal_hexstr(tmpctx, &h->temp_k, sizeof(h->temp_k)));
/* BOLT #8:
*
@ -663,7 +664,7 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
encrypt_ad(&h->temp_k, 0, &h->h, sizeof(h->h), NULL, 0,
h->act1.tag, sizeof(h->act1.tag));
SUPERVERBOSE("# c=%s",
tal_hexstr(trc, h->act1.tag, sizeof(h->act1.tag)));
tal_hexstr(tmpctx, h->act1.tag, sizeof(h->act1.tag)));
/* BOLT #8:
*
@ -672,7 +673,7 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
* authenticating handshake digest.
*/
sha_mix_in(&h->h, h->act1.tag, sizeof(h->act1.tag));
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
/* BOLT #8:
*
@ -683,7 +684,7 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
secp256k1_ec_pubkey_serialize(secp256k1_ctx, h->act1.pubkey, &len,
&h->e.pub.pubkey,
SECP256K1_EC_COMPRESSED);
SUPERVERBOSE("output: 0x%s", tal_hexstr(trc, &h->act1, ACT_ONE_SIZE));
SUPERVERBOSE("output: 0x%s", tal_hexstr(tmpctx, &h->act1, ACT_ONE_SIZE));
check_act_one(&h->act1);
return io_write(conn, &h->act1, ACT_ONE_SIZE, act_two_initiator, h);
@ -694,7 +695,7 @@ static struct io_plan *act_three_responder2(struct io_conn *conn,
{
u8 der[PUBKEY_DER_LEN];
SUPERVERBOSE("input: 0x%s", tal_hexstr(trc, &h->act3, ACT_THREE_SIZE));
SUPERVERBOSE("input: 0x%s", tal_hexstr(tmpctx, &h->act3, ACT_THREE_SIZE));
/* BOLT #8:
*
@ -720,7 +721,7 @@ static struct io_plan *act_three_responder2(struct io_conn *conn,
der, sizeof(der)))
return handshake_failed(conn, h);
SUPERVERBOSE("# rs=0x%s", tal_hexstr(trc, der, sizeof(der)));
SUPERVERBOSE("# rs=0x%s", tal_hexstr(tmpctx, der, sizeof(der)));
if (secp256k1_ec_pubkey_parse(secp256k1_ctx, &h->their_id.pubkey,
der, sizeof(der)) != 1)
@ -732,7 +733,7 @@ static struct io_plan *act_three_responder2(struct io_conn *conn,
*
*/
sha_mix_in(&h->h, h->act3.ciphertext, sizeof(h->act3.ciphertext));
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
/* BOLT #8:
*
@ -743,15 +744,15 @@ static struct io_plan *act_three_responder2(struct io_conn *conn,
h->e.priv.secret.data))
return handshake_failed(conn, h);
SUPERVERBOSE("# ss=0x%s", tal_hexstr(trc, &h->ss, sizeof(h->ss)));
SUPERVERBOSE("# ss=0x%s", tal_hexstr(tmpctx, &h->ss, sizeof(h->ss)));
/* BOLT #8:
* * `ck, temp_k3 = HKDF(ck, ss)`
*/
hkdf_two_keys(&h->ck, &h->temp_k, &h->ck, &h->ss, sizeof(h->ss));
SUPERVERBOSE("# ck,temp_k3=0x%s,0x%s",
tal_hexstr(trc, &h->ck, sizeof(h->ck)),
tal_hexstr(trc, &h->temp_k, sizeof(h->temp_k)));
tal_hexstr(tmpctx, &h->ck, sizeof(h->ck)),
tal_hexstr(tmpctx, &h->temp_k, sizeof(h->temp_k)));
/* BOLT #8:
* * `p = decryptWithAD(temp_k3, 0, h, t)`
@ -796,8 +797,8 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
*/
h->e = generate_key();
SUPERVERBOSE("# e.pub=0x%s e.priv=0x%s",
type_to_string(trc, struct pubkey, &h->e.pub),
tal_hexstr(trc, &h->e.priv, sizeof(h->e.priv)));
type_to_string(tmpctx, struct pubkey, &h->e.pub),
tal_hexstr(tmpctx, &h->e.priv, sizeof(h->e.priv)));
/* BOLT #8:
*
@ -806,7 +807,7 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
* running handshake digest.
*/
sha_mix_in_key(&h->h, &h->e.pub);
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
/* BOLT #8:
*
@ -817,7 +818,7 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
if (!secp256k1_ecdh(secp256k1_ctx, h->ss.data, &h->re.pubkey,
h->e.priv.secret.data))
return handshake_failed(conn, h);
SUPERVERBOSE("# ss=0x%s", tal_hexstr(trc, &h->ss, sizeof(h->ss)));
SUPERVERBOSE("# ss=0x%s", tal_hexstr(tmpctx, &h->ss, sizeof(h->ss)));
/* BOLT #8:
*
@ -827,8 +828,8 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
*/
hkdf_two_keys(&h->ck, &h->temp_k, &h->ck, &h->ss, sizeof(h->ss));
SUPERVERBOSE("# ck,temp_k2=0x%s,0x%s",
tal_hexstr(trc, &h->ck, sizeof(h->ck)),
tal_hexstr(trc, &h->temp_k, sizeof(h->temp_k)));
tal_hexstr(tmpctx, &h->ck, sizeof(h->ck)),
tal_hexstr(tmpctx, &h->temp_k, sizeof(h->temp_k)));
/* BOLT #8:
*
@ -837,7 +838,7 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
*/
encrypt_ad(&h->temp_k, 0, &h->h, sizeof(h->h), NULL, 0,
h->act2.tag, sizeof(h->act2.tag));
SUPERVERBOSE("# c=0x%s", tal_hexstr(trc, h->act2.tag, sizeof(h->act2.tag)));
SUPERVERBOSE("# c=0x%s", tal_hexstr(tmpctx, h->act2.tag, sizeof(h->act2.tag)));
/* BOLT #8:
*
@ -846,7 +847,7 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
* authenticating handshake digest.
*/
sha_mix_in(&h->h, h->act2.tag, sizeof(h->act2.tag));
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
/* BOLT #8:
*
@ -857,7 +858,7 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
secp256k1_ec_pubkey_serialize(secp256k1_ctx, h->act2.pubkey, &len,
&h->e.pub.pubkey,
SECP256K1_EC_COMPRESSED);
SUPERVERBOSE("output: 0x%s", tal_hexstr(trc, &h->act2, ACT_TWO_SIZE));
SUPERVERBOSE("output: 0x%s", tal_hexstr(tmpctx, &h->act2, ACT_TWO_SIZE));
check_act_two(&h->act2);
return io_write(conn, &h->act2, ACT_TWO_SIZE, act_three_responder, h);
@ -885,7 +886,7 @@ static struct io_plan *act_one_responder2(struct io_conn *conn,
h->act1.pubkey, sizeof(h->act1.pubkey)) != 1)
return handshake_failed(conn, h);
SUPERVERBOSE("# re=0x%s", type_to_string(trc, struct pubkey, &h->re));
SUPERVERBOSE("# re=0x%s", type_to_string(tmpctx, struct pubkey, &h->re));
/* BOLT #8:
*
@ -894,7 +895,7 @@ static struct io_plan *act_one_responder2(struct io_conn *conn,
* authenticating handshake digest.
*/
sha_mix_in_key(&h->h, &h->re);
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
/* BOLT #8:
* * `ss = ECDH(re, s.priv)`
@ -904,7 +905,7 @@ static struct io_plan *act_one_responder2(struct io_conn *conn,
if (!hsm_do_ecdh(&h->ss, &h->re))
return handshake_failed(conn, h);
SUPERVERBOSE("# ss=0x%s", tal_hexstr(trc, &h->ss, sizeof(h->ss)));
SUPERVERBOSE("# ss=0x%s", tal_hexstr(tmpctx, &h->ss, sizeof(h->ss)));
/* BOLT #8:
*
@ -915,8 +916,8 @@ static struct io_plan *act_one_responder2(struct io_conn *conn,
*/
hkdf_two_keys(&h->ck, &h->temp_k, &h->ck, &h->ss, sizeof(h->ss));
SUPERVERBOSE("# ck,temp_k1=0x%s,0x%s",
tal_hexstr(trc, &h->ck, sizeof(h->ck)),
tal_hexstr(trc, &h->temp_k, sizeof(h->temp_k)));
tal_hexstr(tmpctx, &h->ck, sizeof(h->ck)),
tal_hexstr(tmpctx, &h->temp_k, sizeof(h->temp_k)));
/* BOLT #8:
*
@ -937,7 +938,7 @@ static struct io_plan *act_one_responder2(struct io_conn *conn,
* step serves to ensure the payload wasn't modified by a MiTM.
*/
sha_mix_in(&h->h, h->act1.tag, sizeof(h->act1.tag));
SUPERVERBOSE("# h=0x%s", tal_hexstr(trc, &h->h, sizeof(h->h)));
SUPERVERBOSE("# h=0x%s", tal_hexstr(tmpctx, &h->h, sizeof(h->h)));
return act_two_responder(conn, h);
}

38
gossipd/routing.c

@ -366,15 +366,15 @@ find_route(const tal_t *ctx, struct routing_state *rstate,
if (!src) {
status_info("find_route: cannot find %s",
type_to_string(trc, struct pubkey, to));
type_to_string(tmpctx, struct pubkey, to));
return NULL;
} else if (!dst) {
status_info("find_route: cannot find myself (%s)",
type_to_string(trc, struct pubkey, to));
type_to_string(tmpctx, struct pubkey, to));
return NULL;
} else if (dst == src) {
status_info("find_route: this is %s, refusing to create empty route",
type_to_string(trc, struct pubkey, to));
type_to_string(tmpctx, struct pubkey, to));
return NULL;
}
@ -404,7 +404,7 @@ find_route(const tal_t *ctx, struct routing_state *rstate,
int idx = half_chan_to(n, chan);
SUPERVERBOSE("Node %s edge %i/%zu",
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&n->id),
i, num_edges);
@ -428,7 +428,7 @@ find_route(const tal_t *ctx, struct routing_state *rstate,
/* No route? */
if (dst->bfg[best].total >= INFINITE) {
status_trace("find_route: No route to %s",
type_to_string(trc, struct pubkey, to));
type_to_string(tmpctx, struct pubkey, to));
return NULL;
}
@ -565,8 +565,8 @@ static void process_pending_node_announcement(struct routing_state *rstate,
if (err)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"pending node_announcement %s malformed %s?",
tal_hex(trc, pna->node_announcement),
sanitize_error(trc, err, NULL));
tal_hex(tmpctx, pna->node_announcement),
sanitize_error(tmpctx, err, NULL));
}
pending_node_map_del(rstate->pending_node_map, pna);
tal_free(pna);
@ -633,7 +633,7 @@ u8 *handle_channel_announcement(struct routing_state *rstate,
if (chan != NULL && chan->public) {
SUPERVERBOSE("%s: %s already has public channel",
__func__,
type_to_string(trc, struct short_channel_id,
type_to_string(tmpctx, struct short_channel_id,
&pending->short_channel_id));
goto ignored;
}
@ -643,7 +643,7 @@ u8 *handle_channel_announcement(struct routing_state *rstate,
if (find_pending_cannouncement(rstate, &pending->short_channel_id)) {
SUPERVERBOSE("%s: %s already has pending cannouncement",
__func__,
type_to_string(trc, struct short_channel_id,
type_to_string(tmpctx, struct short_channel_id,
&pending->short_channel_id));
goto ignored;
}
@ -738,8 +738,8 @@ static void process_pending_channel_update(struct routing_state *rstate,
err = handle_channel_update(rstate, cupdate);
if (err) {
status_trace("Pending channel_update for %s: %s",
type_to_string(trc, struct short_channel_id, scid),
sanitize_error(trc, err, NULL));
type_to_string(tmpctx, struct short_channel_id, scid),
sanitize_error(tmpctx, err, NULL));
tal_free(err);
}
}
@ -787,7 +787,7 @@ bool handle_pending_cannouncement(struct routing_state *rstate,
status_trace("channel_announcement: txout %s expectes %s, got %s",
type_to_string(pending, struct short_channel_id,
scid),
tal_hex(trc, s), tal_hex(trc, outscript));
tal_hex(tmpctx, s), tal_hex(tmpctx, outscript));
tal_free(pending);
return false;
}
@ -810,7 +810,7 @@ bool handle_pending_cannouncement(struct routing_state *rstate,
take(pending->announce)))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Announcement %s was replaced?",
tal_hex(trc, pending->announce));
tal_hex(tmpctx, pending->announce));
local = pubkey_eq(&pending->node_id_1, &rstate->local_id) ||
pubkey_eq(&pending->node_id_2, &rstate->local_id);
@ -831,7 +831,7 @@ static void update_pending(struct pending_cannouncement *pending,
const u8 direction)
{
SUPERVERBOSE("Deferring update for pending channel %s(%d)",
type_to_string(trc, struct short_channel_id,
type_to_string(tmpctx, struct short_channel_id,
&pending->short_channel_id), direction);
if (pending->update_timestamps[direction] < timestamp) {
@ -867,13 +867,13 @@ void set_connection_values(struct chan *chan,
c->unroutable_until = 0;
SUPERVERBOSE("Channel %s(%d) was updated.",
type_to_string(trc, struct short_channel_id, &chan->scid),
type_to_string(tmpctx, struct short_channel_id, &chan->scid),
idx);
if (c->proportional_fee >= MAX_PROPORTIONAL_FEE) {
status_trace("Channel %s(%d) massive proportional fee %u:"
" disabling.",
type_to_string(trc, struct short_channel_id,
type_to_string(tmpctx, struct short_channel_id,
&chan->scid),
idx,
c->proportional_fee);
@ -943,7 +943,7 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update)
if (!chan) {
SUPERVERBOSE("Ignoring update for unknown channel %s",
type_to_string(trc, struct short_channel_id,
type_to_string(tmpctx, struct short_channel_id,
&short_channel_id));
tal_free(tmpctx);
return NULL;
@ -975,7 +975,7 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update)
}
status_trace("Received channel_update for channel %s(%d) now %s",
type_to_string(trc, struct short_channel_id,
type_to_string(tmpctx, struct short_channel_id,
&short_channel_id),
flags & 0x01,
flags & ROUTING_FLAGS_DISABLED ? "DISABLED" : "ACTIVE");
@ -1398,7 +1398,7 @@ void route_prune(struct routing_state *rstate)
&& chan->half[1].last_timestamp < highwater) {
status_trace(
"Pruning channel %s from network view (ages %"PRIu64" and %"PRIu64"s)",
type_to_string(trc, struct short_channel_id,
type_to_string(tmpctx, struct short_channel_id,
&chan->scid),
now - chan->half[0].last_timestamp,
now - chan->half[1].last_timestamp);

24
hsmd/hsm.c

@ -135,7 +135,7 @@ static struct io_plan *handle_ecdh(struct io_conn *conn, struct daemon_conn *dc)
if (secp256k1_ecdh(secp256k1_ctx, ss.data, &point.pubkey,
privkey.secret.data) != 1) {
status_broken("secp256k1_ecdh fail for client %s",
type_to_string(trc, struct pubkey, &c->id));
type_to_string(tmpctx, struct pubkey, &c->id));
daemon_conn_send(c->master,
take(towire_hsmstatus_client_bad_request(c,
&c->id,
@ -163,7 +163,7 @@ static struct io_plan *handle_cannouncement_sig(struct io_conn *conn,
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));
tal_hex(tmpctx, dc->msg_in));
return io_close(conn);
}
@ -205,7 +205,7 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
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));
tal_hex(tmpctx, dc->msg_in));
return io_close(conn);
}
@ -214,12 +214,12 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
&cltv_expiry_delta, &htlc_minimum_msat,
&fee_base_msat, &fee_proportional_mill)) {
status_broken("Failed to parse inner channel_update: %s",
tal_hex(trc, dc->msg_in));
tal_hex(tmpctx, dc->msg_in));
return io_close(conn);
}
if (tal_len(cu) < offset) {
status_broken("inner channel_update too short: %s",
tal_hex(trc, dc->msg_in));
tal_hex(tmpctx, dc->msg_in));
return io_close(conn);
}
@ -596,7 +596,7 @@ static void hsm_key_for_utxo(struct privkey *privkey, struct pubkey *pubkey,
status_debug("Unilateral close output, deriving secrets");
hsm_unilateral_close_privkey(privkey, utxo->close_info);
pubkey_from_privkey(privkey, pubkey);
status_debug("Derived public key %s from unilateral close", type_to_string(trc, struct pubkey, pubkey));
status_debug("Derived public key %s from unilateral close", type_to_string(tmpctx, struct pubkey, pubkey));
} else {
/* Simple case: just get derive via HD-derivation */
bitcoin_keypair(privkey, pubkey, utxo->keyindex);
@ -691,14 +691,14 @@ static void sign_withdrawal_tx(struct daemon_conn *master, const u8 *msg)
&change_out, &change_keyindex,
&scriptpubkey, &utxos)) {
status_broken("Failed to parse sign_withdrawal: %s",
tal_hex(trc, msg));
tal_hex(tmpctx, msg));
return;
}
if (bip32_key_from_parent(&secretstuff.bip32, change_keyindex,
BIP32_FLAG_KEY_PUBLIC, &ext) != WALLY_OK) {
status_broken("Failed to parse sign_withdrawal: %s",
tal_hex(trc, msg));
tal_hex(tmpctx, msg));
return;
}
@ -760,7 +760,7 @@ static void sign_invoice(struct daemon_conn *master, const u8 *msg)
if (!fromwire_hsm_sign_invoice(tmpctx, msg, &u5bytes, &hrpu8)) {
status_broken("Failed to parse sign_invoice: %s",
tal_hex(trc, msg));
tal_hex(tmpctx, msg));
return;
}
@ -780,7 +780,7 @@ static void sign_invoice(struct daemon_conn *master, const u8 *msg)
NULL, NULL)) {
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Failed to sign invoice: %s",
tal_hex(trc, msg));
tal_hex(tmpctx, msg));
}
daemon_conn_send(master,
@ -801,13 +801,13 @@ static void sign_node_announcement(struct daemon_conn *master, const u8 *msg)
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));
tal_hex(tmpctx, msg));
}
if (tal_len(ann) < offset) {
status_failed(STATUS_FAIL_GOSSIP_IO,
"Node announcement too short: %s",
tal_hex(trc, msg));
tal_hex(tmpctx, msg));
}
/* FIXME(cdecker) Check the node announcement's content */

120
onchaind/onchain.c

@ -279,7 +279,7 @@ static struct tracked_output *
status_trace("Tracking output %u of %s: %s/%s",
outnum,
type_to_string(trc, struct bitcoin_txid, txid),
type_to_string(tmpctx, struct bitcoin_txid, txid),
tx_type_name(tx_type),
output_type_name(output_type));
@ -306,7 +306,7 @@ static void ignore_output(struct tracked_output *out)
{
status_trace("Ignoring output %u of %s: %s/%s",
out->outnum,
type_to_string(trc, struct bitcoin_txid, &out->txid),
type_to_string(tmpctx, struct bitcoin_txid, &out->txid),
tx_type_name(out->tx_type),
output_type_name(out->output_type));
@ -326,7 +326,7 @@ static void proposal_meets_depth(struct tracked_output *out)
status_trace("Broadcasting %s (%s) to resolve %s/%s",
tx_type_name(out->proposal->tx_type),
type_to_string(trc, struct bitcoin_tx, out->proposal->tx),
type_to_string(tmpctx, struct bitcoin_tx, out->proposal->tx),
tx_type_name(out->tx_type),
output_type_name(out->output_type));
@ -345,7 +345,7 @@ static void propose_resolution(struct tracked_output *out,
tx_type_name(out->tx_type),
output_type_name(out->output_type),
tx_type_name(tx_type),
tx ? type_to_string(trc, struct bitcoin_tx, tx):"IGNORING",
tx ? type_to_string(tmpctx, struct bitcoin_tx, tx):"IGNORING",
depth_required);
out->proposal = tal(out, struct proposed_resolution);
@ -444,7 +444,7 @@ static bool resolved_by_proposal(struct tracked_output *out,
tx_type_name(out->tx_type),
output_type_name(out->output_type),
tx_type_name(out->proposal->tx_type),
type_to_string(trc, struct bitcoin_txid,
type_to_string(tmpctx, struct bitcoin_txid,
&out->resolved->txid));
out->resolved->depth = 0;
@ -469,7 +469,7 @@ static void resolved_by_other(struct tracked_output *out,
tx_type_name(out->tx_type),
output_type_name(out->output_type),
tx_type_name(tx_type),
type_to_string(trc, struct bitcoin_txid, txid));
type_to_string(tmpctx, struct bitcoin_txid, txid));
}
static void unknown_spend(struct tracked_output *out,
@ -484,7 +484,7 @@ static void unknown_spend(struct tracked_output *out,
status_trace("Unknown spend of %s/%s by %s",
tx_type_name(out->tx_type),
output_type_name(out->output_type),
type_to_string(trc, struct bitcoin_tx, tx));
type_to_string(tmpctx, struct bitcoin_tx, tx));
}
static u64 unmask_commit_number(const struct bitcoin_tx *tx,
@ -589,7 +589,7 @@ static void billboard_update(struct tracked_output **outs)
"%u outputs unresolved: waiting confirmation that we spent %s (%s:%u) using %s",
num_not_irrevocably_resolved(outs),
output_type_name(best->output_type),
type_to_string(trc, struct bitcoin_txid,
type_to_string(tmpctx, struct bitcoin_txid,
&best->txid),
best->outnum,
tx_type_name(best->proposal->tx_type));
@ -599,7 +599,7 @@ static void billboard_update(struct tracked_output **outs)
num_not_irrevocably_resolved(outs),
best->proposal->depth_required - best->depth,
output_type_name(best->output_type),
type_to_string(trc, struct bitcoin_txid,
type_to_string(tmpctx, struct bitcoin_txid,
&best->txid),
best->outnum,
tx_type_name(best->proposal->tx_type));
@ -705,15 +705,15 @@ static void handle_htlc_onchain_fulfill(struct tracked_output *out,
"%s/%s spent with bad preimage %s (ripemd not %s)",
tx_type_name(out->tx_type),
output_type_name(out->output_type),
type_to_string(trc, struct preimage, &preimage),
type_to_string(trc, struct ripemd160,
type_to_string(tmpctx, struct preimage, &preimage),
type_to_string(tmpctx, struct ripemd160,
&out->htlc->ripemd));
/* Tell master we found a preimage. */
status_trace("%s/%s gave us preimage %s",
tx_type_name(out->tx_type),
output_type_name(out->output_type),
type_to_string(trc, struct preimage, &preimage));
type_to_string(tmpctx, struct preimage, &preimage));
wire_sync_write(REQ_FD,
take(towire_onchain_extracted_preimage(NULL,
&preimage)));
@ -887,7 +887,7 @@ static void output_spent(struct tracked_output ***outs,
/* Not interesting to us, so unwatch the tx and all its outputs */
status_trace("Notified about tx %s output %u spend, but we don't care",
type_to_string(trc, struct bitcoin_txid,
type_to_string(tmpctx, struct bitcoin_txid,
&tx->input[input_num].txid),
tx->input[input_num].index);
unwatch_tx(tx);
@ -1374,17 +1374,17 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
" self_htlc_key: %s"
" other_htlc_key: %s",
commit_num,
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_revocation_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_delayed_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->other_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_htlc_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->other_htlc_key));
if (!derive_simple_privkey(&secrets->delayed_payment_basepoint_secret,
@ -1424,14 +1424,14 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
status_trace("Script to-me: %u: %s (%s)",
to_self_delay[LOCAL],
tal_hex(trc, script[LOCAL]),
tal_hex(trc, local_wscript));
tal_hex(tmpctx, script[LOCAL]),
tal_hex(tmpctx, local_wscript));
status_trace("Script to-them: %s",
tal_hex(trc, script[REMOTE]));
tal_hex(tmpctx, script[REMOTE]));
for (i = 0; i < tal_count(tx->output); i++) {
status_trace("Output %zu: %s",
i, tal_hex(trc, tx->output[i].script));
i, tal_hex(tmpctx, tx->output[i].script));
}
/* BOLT #5:
@ -1663,7 +1663,7 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
if (!pubkey_from_privkey(&per_commitment_privkey, &per_commitment_point))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Failed derive from per_commitment_secret %s",
type_to_string(trc, struct privkey,
type_to_string(tmpctx, struct privkey,
&per_commitment_privkey));
status_trace("Deriving keyset %"PRIu64
@ -1675,19 +1675,19 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
" self_delayed_basepoint=%s"
" other_revocation_basepoint=%s",
commit_num,
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&per_commitment_point),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
remote_payment_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
local_payment_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
remote_htlc_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
local_htlc_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
remote_delayed_payment_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
local_revocation_basepoint));
/* keyset is const, we need a non-const ptr to set it up */
@ -1712,17 +1712,17 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
" self_htlc_key: %s"
" other_htlc_key: %s",
commit_num,
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_revocation_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_delayed_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->other_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_htlc_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->other_htlc_key));
revocation_privkey = tal(tx, struct privkey);
@ -1748,14 +1748,14 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
status_trace("Script to-them: %u: %s (%s)",
to_self_delay[REMOTE],
tal_hex(trc, script[REMOTE]),
tal_hex(trc, remote_wscript));
tal_hex(tmpctx, script[REMOTE]),
tal_hex(tmpctx, remote_wscript));
status_trace("Script to-me: %s",
tal_hex(trc, script[LOCAL]));
tal_hex(tmpctx, script[LOCAL]));
for (i = 0; i < tal_count(tx->output); i++) {
status_trace("Output %zu: %s",
i, tal_hex(trc, tx->output[i].script));
i, tal_hex(tmpctx, tx->output[i].script));
}
/* BOLT #5:
@ -1923,19 +1923,19 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
" self_delayed_basepoint=%s"
" other_revocation_basepoint=%s",
commit_num,
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
remote_per_commitment_point),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
remote_payment_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
local_payment_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
remote_htlc_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
local_htlc_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
remote_delayed_payment_basepoint),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
local_revocation_basepoint));
/* keyset is const, we need a non-const ptr to set it up */
@ -1960,17 +1960,17 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
" self_htlc_key: %s"
" other_htlc_key: %s",
commit_num,
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_revocation_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_delayed_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->other_payment_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->self_htlc_key),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&keyset->other_htlc_key));
if (!derive_simple_privkey(&secrets->payment_basepoint_secret,
@ -2002,14 +2002,14 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
status_trace("Script to-them: %u: %s (%s)",
to_self_delay[REMOTE],
tal_hex(trc, script[REMOTE]),
tal_hex(trc, remote_wscript));
tal_hex(tmpctx, script[REMOTE]),
tal_hex(tmpctx, remote_wscript));
status_trace("Script to-me: %s",
tal_hex(trc, script[LOCAL]));
tal_hex(tmpctx, script[LOCAL]));
for (i = 0; i < tal_count(tx->output); i++) {
status_trace("Output %zu: %s",
i, tal_hex(trc, tx->output[i].script));
i, tal_hex(tmpctx, tx->output[i].script));
}
/* BOLT #5:
@ -2190,10 +2190,10 @@ int main(int argc, char *argv[])
FUNDING_OUTPUT, NULL, NULL, NULL);
status_trace("Remote per-commit point: %s",
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&remote_per_commit_point));
status_trace("Old remote per-commit point: %s",
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&old_remote_per_commit_point));
/* BOLT #5:

24
openingd/opening.c

@ -369,9 +369,9 @@ static u8 *funder_channel(struct state *state,
&state->our_secrets.funding_privkey,
our_funding_pubkey, &sig);
status_trace("signature %s on tx %s using key %s",
type_to_string(trc, secp256k1_ecdsa_signature, &sig),
type_to_string(trc, struct bitcoin_tx, tx),
type_to_string(trc, struct pubkey, our_funding_pubkey));
type_to_string(tmpctx, secp256k1_ecdsa_signature, &sig),
type_to_string(tmpctx, struct bitcoin_tx, tx),
type_to_string(tmpctx, struct pubkey, our_funding_pubkey));
msg = towire_funding_created(state, &state->channel_id,
&state->funding_txid,
@ -427,10 +427,10 @@ static u8 *funder_channel(struct state *state,
peer_failed(&state->cs, state->gossip_index,
&state->channel_id,
"Bad signature %s on tx %s using key %s",
type_to_string(trc, secp256k1_ecdsa_signature,
type_to_string(tmpctx, secp256k1_ecdsa_signature,
&sig),
type_to_string(trc, struct bitcoin_tx, tx),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct bitcoin_tx, tx),
type_to_string(tmpctx, struct pubkey,
&their_funding_pubkey));
}
@ -630,10 +630,10 @@ static u8 *fundee_channel(struct state *state,
peer_failed(&state->cs, state->gossip_index,
&state->channel_id,
"Bad signature %s on tx %s using key %s",
type_to_string(trc, secp256k1_ecdsa_signature,
type_to_string(tmpctx, secp256k1_ecdsa_signature,
&theirsig),
type_to_string(trc, struct bitcoin_tx, their_commit),
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct bitcoin_tx, their_commit),
type_to_string(tmpctx, struct pubkey,
&their_funding_pubkey));
}
@ -729,17 +729,17 @@ int main(int argc, char *argv[])
&state->shaseed))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Secret derivation failed, secret = %s",
type_to_string(trc, struct privkey, &seed));
type_to_string(tmpctx, struct privkey, &seed));
if (!per_commit_point(&state->shaseed, &state->next_per_commit[LOCAL],
0))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"First per_commitment_point derivation failed,"
" secret = %s",
type_to_string(trc, struct privkey, &seed));
type_to_string(tmpctx, struct privkey, &seed));
status_trace("First per_commit_point = %s",
type_to_string(trc, struct pubkey,
type_to_string(tmpctx, struct pubkey,
&state->next_per_commit[LOCAL]));
msg = wire_sync_read(state, REQ_FD);
if (fromwire_opening_funder(state, msg,

Loading…
Cancel
Save