X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchannel.rs;h=c9c9e41430d014ba6d6d62ee9d21c4a1a6bde230;hb=f7dd69240afcd3a0087f7796824a9e2697ed85cf;hp=aa33b88b9e0f8c9eefd859f3d9cae0eafb66a2df;hpb=d923717216c964fcc77cafcb05db80692c42e75f;p=rust-lightning diff --git a/src/ln/channel.rs b/src/ln/channel.rs index aa33b88b..c9c9e414 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -149,7 +149,20 @@ enum ChannelState { /// later. /// Flag is set on ChannelFunded. AwaitingRemoteRevoke = (1 << 7), + /// Flag which is set on ChannelFunded or FundingSent after receiving a shutdown message from + /// the remote end. If set, they may not add any new HTLCs to the channel, and we are expected + /// to respond with our own shutdown message when possible. + RemoteShutdownSent = (1 << 8), + /// Flag which is set on ChannelFunded or FundingSent after sending a shutdown message. At this + /// point, we may not add any new HTLCs to the channel. + /// TODO: Investigate some kind of timeout mechanism by which point the remote end must provide + /// us their shutdown. + LocalShutdownSent = (1 << 9), + /// We've successfully negotiated a closing_signed dance. At this point ChannelManager is about + /// to drop us, but we store this anyway. + ShutdownComplete = (1 << 10), } +const BOTH_SIDES_SHUTDOWN_MASK: u32 = (ChannelState::LocalShutdownSent as u32 | ChannelState::RemoteShutdownSent as u32); // TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking // has been completed, and then turn into a Channel to get compiler-time enforcement of things like @@ -177,6 +190,8 @@ pub struct Channel { channel_update_count: u32, feerate_per_kw: u64, + last_sent_closing_fee: Option<(u64, u64)>, // (feerate, fee) + /// The hash of the block in which the funding transaction reached our CONF_TARGET. We use this /// to detect unconfirmation after a serialize-unserialize roudtrip where we may not see a full /// series of block_connected/block_disconnected calls. Obviously this is not a guarantee as we @@ -208,6 +223,8 @@ pub struct Channel { their_cur_commitment_point: PublicKey, their_node_id: PublicKey, + their_shutdown_scriptpubkey: Option