mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
billboard: add in billboard updates from dualopend
Uses shared messaging now!
This commit is contained in:
parent
fc49874e32
commit
d47992a46d
@ -24,13 +24,18 @@ char *billboard_message(const tal_t *ctx,
|
||||
else if (!funding_locked[LOCAL] && funding_locked[REMOTE])
|
||||
funding_status = "They've confirmed funding, we haven't yet.";
|
||||
|
||||
if (have_sigs[LOCAL] && have_sigs[REMOTE])
|
||||
announce_status = " Channel announced.";
|
||||
else if (have_sigs[LOCAL] && !have_sigs[REMOTE])
|
||||
announce_status = " Waiting for their announcement signatures.";
|
||||
else if (!have_sigs[LOCAL] && have_sigs[REMOTE])
|
||||
announce_status = " They need our announcement signatures.";
|
||||
else if (!have_sigs[LOCAL] && !have_sigs[REMOTE])
|
||||
if (have_sigs) {
|
||||
if (have_sigs[LOCAL] && have_sigs[REMOTE])
|
||||
announce_status = " Channel announced.";
|
||||
else if (have_sigs[LOCAL] && !have_sigs[REMOTE])
|
||||
announce_status = " Waiting for their"
|
||||
" announcement signatures.";
|
||||
else if (!have_sigs[LOCAL] && have_sigs[REMOTE])
|
||||
announce_status = " They need our announcement"
|
||||
" signatures.";
|
||||
else if (!have_sigs[LOCAL] && !have_sigs[REMOTE])
|
||||
announce_status = "";
|
||||
} else
|
||||
announce_status = "";
|
||||
|
||||
if (!shutdown_sent[LOCAL] && !shutdown_sent[REMOTE])
|
||||
|
@ -1148,9 +1148,11 @@ void dualopen_tell_depth(struct subd *dualopend,
|
||||
assert(channel->scid);
|
||||
msg = towire_dualopend_depth_reached(NULL, depth);
|
||||
subd_send_msg(dualopend, take(msg));
|
||||
}
|
||||
|
||||
// FIXME: update billboard. needs to_go counter!
|
||||
} else
|
||||
channel_set_billboard(channel, false,
|
||||
tal_fmt(tmpctx, "Funding needs %d more"
|
||||
" confirmations for lockin.",
|
||||
to_go));
|
||||
}
|
||||
|
||||
static void accepter_psbt_changed(struct subd *dualopend,
|
||||
|
@ -39,6 +39,7 @@ OPENINGD_COMMON_OBJS := \
|
||||
common/amount.o \
|
||||
common/base32.o \
|
||||
common/bigsize.o \
|
||||
common/billboard.o \
|
||||
common/bip32.o \
|
||||
common/channel_config.o \
|
||||
common/channel_id.o \
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <ccan/fdpass/fdpass.h>
|
||||
#include <ccan/short_types/short_types.h>
|
||||
#include <common/amount.h>
|
||||
#include <common/billboard.h>
|
||||
#include <common/channel_config.h>
|
||||
#include <common/channel_id.h>
|
||||
#include <common/crypto_sync.h>
|
||||
@ -153,8 +154,8 @@ struct state {
|
||||
/* Peer sends this to us in the funding_locked msg */
|
||||
struct pubkey remote_per_commit;
|
||||
|
||||
/* Are we shutting this channel down? */
|
||||
bool shutting_down;
|
||||
/* Are we shutting down? */
|
||||
bool shutdown_sent[NUM_SIDES];
|
||||
};
|
||||
|
||||
/* psbt_changeset_get_next - Get next message to send
|
||||
@ -297,6 +298,16 @@ static void negotiation_failed(struct state *state, bool am_opener,
|
||||
negotiation_aborted(state, am_opener, errmsg);
|
||||
}
|
||||
|
||||
static void billboard_update(struct state *state)
|
||||
{
|
||||
const char *update = billboard_message(tmpctx, state->funding_locked,
|
||||
NULL,
|
||||
state->shutdown_sent,
|
||||
0, /* Always zero? */
|
||||
0);
|
||||
peer_billboard(false, update);
|
||||
}
|
||||
|
||||
static void check_channel_id(struct state *state,
|
||||
struct channel_id *id_in,
|
||||
struct channel_id *orig_id)
|
||||
@ -2187,7 +2198,7 @@ static u8 *handle_funding_locked(struct state *state, u8 *msg)
|
||||
type_to_string(msg, struct channel_id, &cid));
|
||||
|
||||
state->funding_locked[REMOTE] = true;
|
||||
// FIXME: update billboard!
|
||||
billboard_update(state);
|
||||
if (state->funding_locked[LOCAL])
|
||||
return towire_dualopend_channel_locked(state, state->pps,
|
||||
&state->remote_per_commit);
|
||||
@ -2220,7 +2231,7 @@ static u8 *handle_funding_depth(struct state *state, u8 *msg)
|
||||
master_badmsg(WIRE_DUALOPEND_DEPTH_REACHED, msg);
|
||||
|
||||
/* Too late, shutting down already */
|
||||
if (state->shutting_down)
|
||||
if (state->shutdown_sent[LOCAL])
|
||||
return NULL;
|
||||
|
||||
/* We check this before we arrive here, but for sanity */
|
||||
@ -2235,7 +2246,7 @@ static u8 *handle_funding_depth(struct state *state, u8 *msg)
|
||||
sync_crypto_write(state->pps, take(msg));
|
||||
|
||||
state->funding_locked[LOCAL] = true;
|
||||
// FIXME: update billboard!
|
||||
billboard_update(state);
|
||||
if (state->funding_locked[REMOTE])
|
||||
return towire_dualopend_channel_locked(state,
|
||||
state->pps,
|
||||
@ -2438,7 +2449,7 @@ int main(int argc, char *argv[])
|
||||
memset(&state->channel_id, 0, sizeof(state->channel_id));
|
||||
state->channel = NULL;
|
||||
state->funding_locked[LOCAL] = state->funding_locked[REMOTE] = false;
|
||||
state->shutting_down = false;
|
||||
state->shutdown_sent[LOCAL]= state->shutdown_sent[REMOTE] = false;
|
||||
|
||||
for (size_t i = 0; i < NUM_TX_MSGS; i++)
|
||||
state->tx_msg_count[i] = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user