use util::ser::{Readable, ReadableArgs, Writeable, Writer, VecWriter};
use util::logger::Logger;
use util::errors::APIError;
-use util::config::{UserConfig,ChannelConfig,ChannelHandshakeConfig};
+use util::config::{UserConfig,ChannelConfig};
use util::scid_utils::scid_from_parts;
use io;
self.config.forwarding_fee_proportional_millionths.write(writer)?;
self.config.cltv_expiry_delta.write(writer)?;
self.config.announced_channel.write(writer)?;
- // self.config.commit_upfront_shutdown_pubkey.write(writer)?;
self.commit_upfront_shutdown_pubkey.write(writer)?;
self.channel_id.write(writer)?;
(9, self.target_closing_feerate_sats_per_kw, option),
(11, self.monitor_pending_finalized_fulfills, vec_type),
(13, self.channel_creation_height, required),
+ (15, self.commit_upfront_shutdown_pubkey, required),
});
Ok(())
config.as_mut().unwrap().forwarding_fee_proportional_millionths = Readable::read(reader)?;
config.as_mut().unwrap().cltv_expiry_delta = Readable::read(reader)?;
config.as_mut().unwrap().announced_channel = Readable::read(reader)?;
- // config.as_mut().unwrap().commit_upfront_shutdown_pubkey = Readable::read(reader)?;
+ config.as_mut().unwrap().commit_upfront_shutdown_pubkey = Some(Readable::read(reader)?);
} else {
// Read the 8 bytes of backwards-compatibility ChannelConfig data.
let mut _val: u64 = Readable::read(reader)?;
}
- let handshake_config = Some(ChannelHandshakeConfig::default()); let channel_id = Readable::read(reader)?;
+ let channel_id = Readable::read(reader)?;
let channel_state = Readable::read(reader)?;
let channel_value_satoshis = Readable::read(reader)?;
// only, so we default to that if none was written.
let mut channel_type = Some(ChannelTypeFeatures::only_static_remote_key());
let mut channel_creation_height = Some(serialized_height);
+ let mut commit_upfront_shutdown_pubkey = None;
read_tlv_fields!(reader, {
(0, announcement_sigs, option),
(1, minimum_depth, option),
(9, target_closing_feerate_sats_per_kw, option),
(11, monitor_pending_finalized_fulfills, vec_type),
(13, channel_creation_height, option),
+ (15, commit_upfront_shutdown_pubkey, option),
});
let chan_features = channel_type.as_ref().unwrap();
return Err(DecodeError::InvalidValue);
}
+ if commit_upfront_shutdown_pubkey.is_none() {
+ // commit_upfront_shutdown_pubkey has moved around a good bit, in version 1
+ // serialization, it was written out as a part of the explicit field list of the
+ // `ChannelConfig`. Then, it was written out as a field in the `ChannelConfig` itself.
+ // Now, it is written out explicitly as its own TLV (as the field has moved to
+ // `ChannelHandshakeConfig`).
+ // Thus, if its not in a TLV, we here pull it from the `ChannelConfig`, and if we can't
+ // find it at all, fail.
+ let legacy_commit_upfront_shutdown_pubkey = config.as_ref().unwrap().commit_upfront_shutdown_pubkey;
+ if let Some(val) = legacy_commit_upfront_shutdown_pubkey {
+ commit_upfront_shutdown_pubkey = Some(val);
+ } else {
+ return Err(DecodeError::InvalidValue);
+ }
+ }
+
let mut secp_ctx = Secp256k1::new();
secp_ctx.seeded_randomize(&keys_source.get_secure_random_bytes());
Ok(Channel {
user_id,
- commit_upfront_shutdown_pubkey: handshake_config.unwrap().commit_upfront_shutdown_pubkey,
+ commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey.unwrap(),
config: config.unwrap(),
channel_id,
channel_state,