staticbackup: don't use wireaddr_internal.

This is an internal type: it has no API guarantees (indeed, I'm about
to change it, which is how I discovered scb was using it).

Fortunately for every case we care about, it is actually a wireaddr
(in theory the peer can connect locally using a local socket, but this
is mostly for testing and is a very strange setup, and so simply don't
do scb for those).

In this case, the wire encoding is a single byte followed by the
wireaddr, so open-code that in scb_wire.csv for compatibility.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-05-30 13:57:56 +09:30
parent 5ccdab71e5
commit 1b6ff0b2fc
4 changed files with 34 additions and 18 deletions

View File

@@ -1261,13 +1261,17 @@ wallet_commit_channel(struct lightningd *ld,
&commitment_feerate);
channel->min_possible_feerate = commitment_feerate;
channel->max_possible_feerate = commitment_feerate;
channel->scb = tal(channel, struct scb_chan);
channel->scb->id = channel->dbid;
channel->scb->addr = channel->peer->addr;
channel->scb->node_id = channel->peer->id;
channel->scb->funding = *funding;
channel->scb->cid = channel->cid;
channel->scb->funding_sats = total_funding;
if (channel->peer->addr.itype == ADDR_INTERNAL_WIREADDR) {
channel->scb = tal(channel, struct scb_chan);
channel->scb->id = channel->dbid;
channel->scb->unused = 0;
channel->scb->addr = channel->peer->addr.u.wireaddr;
channel->scb->node_id = channel->peer->id;
channel->scb->funding = *funding;
channel->scb->cid = channel->cid;
channel->scb->funding_sats = total_funding;
} else
channel->scb = NULL;
channel->type = channel_type_dup(channel, type);
channel->scb->type = channel_type_dup(channel->scb, type);