/// channel_id in ChannelManager.
pub(super) enum ChannelError {
Ignore(String),
+ Warn(String),
Close(String),
CloseDelayBroadcast(String),
}
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&ChannelError::Ignore(ref e) => write!(f, "Ignore : {}", e),
+ &ChannelError::Warn(ref e) => write!(f, "Warn : {}", e),
&ChannelError::Close(ref e) => write!(f, "Close : {}", e),
&ChannelError::CloseDelayBroadcast(ref e) => write!(f, "CloseDelayBroadcast : {}", e)
}
// now!
match self.free_holding_cell_htlcs(logger) {
Err(ChannelError::Close(msg)) => return Err(ChannelError::Close(msg)),
- Err(ChannelError::Ignore(_)) | Err(ChannelError::CloseDelayBroadcast(_)) => panic!("Got non-channel-failing result from free_holding_cell_htlcs"),
+ Err(ChannelError::Warn(_)) | Err(ChannelError::Ignore(_)) | Err(ChannelError::CloseDelayBroadcast(_)) =>
+ panic!("Got non-channel-failing result from free_holding_cell_htlcs"),
Ok((Some((commitment_update, monitor_update)), htlcs_to_fail)) => {
return Ok((resend_funding_locked, required_revoke, Some(commitment_update), Some(monitor_update), self.resend_order.clone(), htlcs_to_fail, shutdown_msg));
},
channel_id: self.channel_id,
fee_satoshis: total_fee_satoshis,
signature: sig.unwrap(),
+ fee_range: None,
})
}
channel_id: self.channel_id,
fee_satoshis: used_total_fee,
signature: sig,
+ fee_range: None,
}), None))
}
}
channel_id: self.channel_id,
fee_satoshis: msg.fee_satoshis,
signature: sig,
+ fee_range: None,
}), Some(closing_tx)))
}
self.channel_state >= ChannelState::FundingSent as u32
}
+ /// Returns true if our peer has either initiated or agreed to shut down the channel.
+ pub fn received_shutdown(&self) -> bool {
+ (self.channel_state & ChannelState::RemoteShutdownSent as u32) != 0
+ }
+
+ /// Returns true if we either initiated or agreed to shut down the channel.
+ pub fn sent_shutdown(&self) -> bool {
+ (self.channel_state & ChannelState::LocalShutdownSent as u32) != 0
+ }
+
/// Returns true if this channel is fully shut down. True here implies that no further actions
/// may/will be taken on this channel, and thus this object should be freed. Any future changes
/// will be handled appropriately by the chain monitor.
self.update_time_counter.write(writer)?;
self.feerate_per_kw.write(writer)?;
- match self.last_sent_closing_fee {
- Some((feerate, fee, sig)) => {
- 1u8.write(writer)?;
- feerate.write(writer)?;
- fee.write(writer)?;
- sig.write(writer)?;
- },
- None => 0u8.write(writer)?,
- }
+ // Versions prior to 0.0.100 expected to read the fields of `last_sent_closing_fee` here,
+ // however we are supposed to restart shutdown fee negotiation on reconnect (and wipe
+ // `last_send_closing_fee` in `remove_uncommitted_htlcs_and_mark_paused`) so we should never
+ // consider the stale state on reload.
+ 0u8.write(writer)?;
self.funding_tx_confirmed_in.write(writer)?;
self.funding_tx_confirmation_height.write(writer)?;
let update_time_counter = Readable::read(reader)?;
let feerate_per_kw = Readable::read(reader)?;
- let last_sent_closing_fee = match <u8 as Readable>::read(reader)? {
- 0 => None,
- 1 => Some((Readable::read(reader)?, Readable::read(reader)?, Readable::read(reader)?)),
+ // Versions prior to 0.0.100 expected to read the fields of `last_sent_closing_fee` here,
+ // however we are supposed to restart shutdown fee negotiation on reconnect (and wipe
+ // `last_send_closing_fee` in `remove_uncommitted_htlcs_and_mark_paused`) so we should never
+ // consider the stale state on reload.
+ match <u8 as Readable>::read(reader)? {
+ 0 => {},
+ 1 => {
+ let _: u32 = Readable::read(reader)?;
+ let _: u64 = Readable::read(reader)?;
+ let _: Signature = Readable::read(reader)?;
+ },
_ => return Err(DecodeError::InvalidValue),
- };
+ }
let funding_tx_confirmed_in = Readable::read(reader)?;
let funding_tx_confirmation_height = Readable::read(reader)?;
#[cfg(debug_assertions)]
counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
- last_sent_closing_fee,
+ last_sent_closing_fee: None,
funding_tx_confirmed_in,
funding_tx_confirmation_height,