+impl_writeable!(ClosingSigned, 32+8+64, {
+ channel_id,
+ fee_satoshis,
+ signature
+});
+
+impl_writeable_len_match!(CommitmentSigned, {
+ { CommitmentSigned { ref htlc_signatures, .. }, 32+64+2+htlc_signatures.len()*64 }
+ }, {
+ channel_id,
+ signature,
+ htlc_signatures
+});
+
+impl_writeable_len_match!(DecodedOnionErrorPacket, {
+ { DecodedOnionErrorPacket { ref failuremsg, ref pad, .. }, 32 + 4 + failuremsg.len() + pad.len() }
+ }, {
+ hmac,
+ failuremsg,
+ pad
+});
+
+impl_writeable!(FundingCreated, 32+32+2+64, {
+ temporary_channel_id,
+ funding_txid,
+ funding_output_index,
+ signature
+});
+
+impl_writeable!(FundingSigned, 32+64, {
+ channel_id,
+ signature
+});
+
+impl_writeable!(FundingLocked, 32+33, {
+ channel_id,
+ next_per_commitment_point
+});
+
+impl_writeable_len_match!(GlobalFeatures, {
+ { GlobalFeatures { ref flags }, flags.len() + 2 }
+ }, {
+ flags
+});
+
+impl_writeable_len_match!(LocalFeatures, {
+ { LocalFeatures { ref flags }, flags.len() + 2 }
+ }, {
+ flags
+});
+
+impl_writeable_len_match!(Init, {
+ { Init { ref global_features, ref local_features }, global_features.flags.len() + local_features.flags.len() + 4 }
+ }, {
+ global_features,
+ local_features
+});
+
+impl_writeable_len_match!(OpenChannel, {
+ { OpenChannel { shutdown_scriptpubkey: Some(ref script), .. }, 319 + 2 + script.len() },
+ { OpenChannel { shutdown_scriptpubkey: None, .. }, 319 }
+ }, {
+ chain_hash,
+ temporary_channel_id,
+ funding_satoshis,
+ push_msat,
+ dust_limit_satoshis,
+ max_htlc_value_in_flight_msat,
+ channel_reserve_satoshis,
+ htlc_minimum_msat,
+ feerate_per_kw,
+ to_self_delay,
+ max_accepted_htlcs,
+ funding_pubkey,
+ revocation_basepoint,
+ payment_basepoint,
+ delayed_payment_basepoint,
+ htlc_basepoint,
+ first_per_commitment_point,
+ channel_flags,
+ shutdown_scriptpubkey
+});
+
+impl_writeable!(RevokeAndACK, 32+32+33, {
+ channel_id,
+ per_commitment_secret,
+ next_per_commitment_point
+});
+
+impl_writeable_len_match!(Shutdown, {
+ { Shutdown { ref scriptpubkey, .. }, 32 + 2 + scriptpubkey.len() }
+ }, {
+ channel_id,
+ scriptpubkey
+});
+
+impl_writeable_len_match!(UpdateFailHTLC, {
+ { UpdateFailHTLC { ref reason, .. }, 32 + 10 + reason.data.len() }
+ }, {
+ channel_id,
+ htlc_id,
+ reason
+});
+
+impl_writeable!(UpdateFailMalformedHTLC, 32+8+32+2, {
+ channel_id,
+ htlc_id,
+ sha256_of_onion,
+ failure_code
+});
+
+impl_writeable!(UpdateFee, 32+4, {
+ channel_id,
+ feerate_per_kw
+});
+
+impl_writeable!(UpdateFulfillHTLC, 32+8+32, {
+ channel_id,
+ htlc_id,
+ payment_preimage
+});
+
+impl_writeable_len_match!(OnionErrorPacket, {
+ { OnionErrorPacket { ref data, .. }, 2 + data.len() }
+ }, {
+ data
+});
+
+impl Writeable for OnionPacket {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ w.size_hint(1 + 33 + 20*65 + 32);
+ self.version.write(w)?;
+ match self.public_key {
+ Ok(pubkey) => pubkey.write(w)?,
+ Err(_) => [0u8;33].write(w)?,