Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Sep 14, 2024
2 parents c26755b + 5bd3d51 commit 4e2aab5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
5 changes: 5 additions & 0 deletions lightningd/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
channel->remote_channel_ready = remote_channel_ready;
channel->scid = tal_steal(channel, scid);
channel->alias[LOCAL] = tal_dup_or_null(channel, struct short_channel_id, alias_local);
/* We always make sure this is set (historical channels from db might not) */
if (!channel->alias[LOCAL]) {
channel->alias[LOCAL] = tal(channel, struct short_channel_id);
randombytes_buf(channel->alias[LOCAL], sizeof(struct short_channel_id));
}
channel->alias[REMOTE] = tal_steal(channel, alias_remote); /* Haven't gotten one yet. */
channel->cid = *cid;
channel->our_msat = our_msat;
Expand Down
7 changes: 1 addition & 6 deletions lightningd/opening_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <lightningd/plugin_hook.h>
#include <lightningd/subd.h>
#include <openingd/openingd_wiregen.h>
#include <sodium/randombytes.h>
#include <wally_psbt.h>

void json_add_uncommitted_channel(struct command *cmd,
Expand Down Expand Up @@ -108,7 +107,6 @@ wallet_commit_channel(struct lightningd *ld,
s64 final_key_idx;
u64 static_remotekey_start;
u32 lease_start_blockheight = 0; /* No leases on v1 */
struct short_channel_id local_alias;
struct timeabs timestamp;
bool any_active = peer_any_channel(uc->peer, channel_state_wants_peercomms, NULL);

Expand Down Expand Up @@ -158,9 +156,6 @@ wallet_commit_channel(struct lightningd *ld,
else
static_remotekey_start = 0x7FFFFFFFFFFFFFFF;

/* This won't clash, we don't even bother checking */
randombytes_buf(&local_alias, sizeof(local_alias));

channel = new_channel(uc->peer, uc->dbid,
NULL, /* No shachain yet */
CHANNELD_AWAITING_LOCKIN,
Expand All @@ -178,7 +173,7 @@ wallet_commit_channel(struct lightningd *ld,
local_funding,
false, /* !remote_channel_ready */
NULL, /* no scid yet */
&local_alias,
NULL, /* assign random local alias */
NULL, /* They haven't told us an alias yet */
cid,
/* The three arguments below are msatoshi_to_us,
Expand Down
21 changes: 13 additions & 8 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2536,14 +2536,19 @@ void plugins_set_builtin_plugins_dir(struct plugins *plugins,
const char *dir)
{
/*~ Load the builtin plugins as important. */
for (size_t i = 0; list_of_builtin_plugins[i]; ++i)
plugin_register(plugins,
take(path_join(NULL, dir,
list_of_builtin_plugins[i])),
NULL,
/* important = */
!streq(list_of_builtin_plugins[i], "cln-renepay"),
NULL, NULL);
for (size_t i = 0; list_of_builtin_plugins[i]; ++i) {
struct plugin *p = plugin_register(
plugins,
take(path_join(NULL, dir, list_of_builtin_plugins[i])),
NULL,
/* important = */
!streq(list_of_builtin_plugins[i], "cln-renepay"), NULL,
NULL);
if (!p)
log_unusual(
plugins->log, "failed to register plugin %s",
path_join(tmpctx, dir, list_of_builtin_plugins[i]));
}
}

void shutdown_plugins(struct lightningd *ld)
Expand Down
12 changes: 10 additions & 2 deletions wire/wire_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ static int do_read_wire_header(int fd, struct io_plan_arg *arg)
u8 *p = *(u8 **)arg->u1.vp;

ret = read(fd, p + len, HEADER_LEN - len);
if (ret <= 0)
if (ret <= 0) {
/* Errno isn't set if we hit EOF, so set it to distinct value */
if (ret == 0)
errno = 0;
return -1;
}
arg->u2.s += ret;

/* Length bytes read? Set up for normal read of data. */
Expand Down Expand Up @@ -61,8 +65,12 @@ static int do_read_wire(int fd, struct io_plan_arg *arg)

/* Normal read */
ret = read(fd, arg->u1.cp, arg->u2.s);
if (ret <= 0)
if (ret <= 0) {
/* Errno isn't set if we hit EOF, so set it to distinct value */
if (ret == 0)
errno = 0;
return -1;
}

arg->u1.cp += ret;
arg->u2.s -= ret;
Expand Down

0 comments on commit 4e2aab5

Please sign in to comment.