mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
Channeld: Add new wire type:channel_got_announcement
Channeld sends announcement signatures to Master by this message. When Channeld receive a new channel announcement msg, (After channel locking)it will sends announcement signatures to Master by this message.
This commit is contained in:
parent
a645fbdecd
commit
d93f61407a
@ -185,3 +185,8 @@ channel_fail_fallen_behind,,remote_per_commitment_point,struct pubkey
|
||||
channel_specific_feerates,1029
|
||||
channel_specific_feerates,,feerate_base,u32
|
||||
channel_specific_feerates,,feerate_ppm,u32
|
||||
|
||||
# When we receive announcement_signatures for channel announce
|
||||
channel_got_announcement,1017
|
||||
channel_got_announcement,,remote_ann_node_sig,secp256k1_ecdsa_signature
|
||||
channel_got_announcement,,remote_ann_bitcoin_sig,secp256k1_ecdsa_signature
|
|
@ -451,8 +451,6 @@ static void announce_channel(struct peer *peer)
|
||||
{
|
||||
u8 *cannounce;
|
||||
|
||||
check_short_ids_match(peer);
|
||||
|
||||
cannounce = create_channel_announcement(tmpctx, peer);
|
||||
|
||||
wire_sync_write(GOSSIP_FD, cannounce);
|
||||
@ -493,6 +491,10 @@ static void channel_announcement_negotiate(struct peer *peer)
|
||||
* has been sent and received AND the funding transaction has at least six confirmations.
|
||||
*/
|
||||
if (peer->announce_depth_reached && !peer->have_sigs[LOCAL]) {
|
||||
/* When we reenable the channel, we will also send the announcement to remote peer, and
|
||||
* receive the remote announcement reply. But we will rebuild the channel with announcement
|
||||
* from the DB directly, other than waiting for the remote announcement reply.
|
||||
*/
|
||||
send_announcement_signatures(peer);
|
||||
peer->have_sigs[LOCAL] = true;
|
||||
billboard_update(peer);
|
||||
@ -500,8 +502,18 @@ static void channel_announcement_negotiate(struct peer *peer)
|
||||
|
||||
/* If we've completed the signature exchange, we can send a real
|
||||
* announcement, otherwise we send a temporary one */
|
||||
if (peer->have_sigs[LOCAL] && peer->have_sigs[REMOTE])
|
||||
if (peer->have_sigs[LOCAL] && peer->have_sigs[REMOTE]) {
|
||||
check_short_ids_match(peer);
|
||||
|
||||
/* After making sure short_channel_ids match, we can send remote
|
||||
* announcement to MASTER. */
|
||||
wire_sync_write(MASTER_FD,
|
||||
take(towire_channel_got_announcement(NULL,
|
||||
&peer->announcement_node_sigs[REMOTE],
|
||||
&peer->announcement_bitcoin_sigs[REMOTE])));
|
||||
|
||||
announce_channel(peer);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
|
||||
@ -2778,6 +2790,7 @@ static void req_in(struct peer *peer, const u8 *msg)
|
||||
case WIRE_CHANNEL_GOT_COMMITSIG_REPLY:
|
||||
case WIRE_CHANNEL_GOT_REVOKE_REPLY:
|
||||
case WIRE_CHANNEL_GOT_FUNDING_LOCKED:
|
||||
case WIRE_CHANNEL_GOT_ANNOUNCEMENT:
|
||||
case WIRE_CHANNEL_GOT_SHUTDOWN:
|
||||
case WIRE_CHANNEL_SHUTDOWN_COMPLETE:
|
||||
case WIRE_CHANNEL_DEV_REENABLE_COMMIT_REPLY:
|
||||
|
@ -117,6 +117,25 @@ static void peer_got_funding_locked(struct channel *channel, const u8 *msg)
|
||||
lockin_complete(channel);
|
||||
}
|
||||
|
||||
static void peer_got_announcement(struct channel *channel, const u8 *msg)
|
||||
{
|
||||
secp256k1_ecdsa_signature remote_ann_node_sig;
|
||||
secp256k1_ecdsa_signature remote_ann_bitcoin_sig;
|
||||
|
||||
if (!fromwire_channel_got_announcement(msg,
|
||||
&remote_ann_node_sig,
|
||||
&remote_ann_bitcoin_sig)) {
|
||||
channel_internal_error(channel,
|
||||
"bad channel_got_funding_locked %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
return;
|
||||
}
|
||||
|
||||
wallet_announcement_save(channel->peer->ld->wallet, channel->dbid,
|
||||
&remote_ann_node_sig,
|
||||
&remote_ann_bitcoin_sig);
|
||||
}
|
||||
|
||||
static void peer_got_shutdown(struct channel *channel, const u8 *msg)
|
||||
{
|
||||
u8 *scriptpubkey;
|
||||
@ -219,6 +238,9 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds)
|
||||
case WIRE_CHANNEL_GOT_FUNDING_LOCKED:
|
||||
peer_got_funding_locked(sd->channel, msg);
|
||||
break;
|
||||
case WIRE_CHANNEL_GOT_ANNOUNCEMENT:
|
||||
peer_got_announcement(sd->channel, msg);
|
||||
break;
|
||||
case WIRE_CHANNEL_GOT_SHUTDOWN:
|
||||
peer_got_shutdown(sd->channel, msg);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user