X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fmsgs.rs;h=fab396e3c7112af934021041abfcf2e1f4d609af;hb=952cee4a168d266d7bdd43d21ac71a3e3de46a53;hp=ffca10dbb6de009ed2b5bfa53f1a88f2324ce453;hpb=e43cfe135a5b68620cd51b9b982362c272b4ef77;p=rust-lightning diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index ffca10db..fab396e3 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -241,6 +241,9 @@ pub struct FundingLocked { pub channel_id: [u8; 32], /// The per-commitment point of the second commitment transaction pub next_per_commitment_point: PublicKey, + /// If set, provides a short_channel_id alias for this channel. The sender will accept payments + /// to be forwarded over this SCID and forward them to this messages' recipient. + pub short_channel_id_alias: Option, } /// A shutdown message to be sent or received from a peer @@ -1155,7 +1158,9 @@ impl_writeable_msg!(FundingSigned, { impl_writeable_msg!(FundingLocked, { channel_id, next_per_commitment_point, -}, {}); +}, { + (1, short_channel_id_alias, option), +}); impl Writeable for Init { fn write(&self, w: &mut W) -> Result<(), io::Error> { @@ -1299,10 +1304,6 @@ impl Readable for FinalOnionHopData { impl Writeable for OnionHopData { fn write(&self, w: &mut W) -> Result<(), io::Error> { - // Note that this should never be reachable if Rust-Lightning generated the message, as we - // check values are sane long before we get here, though its possible in the future - // user-generated messages may hit this. - if self.amt_to_forward > MAX_VALUE_MSAT { panic!("We should never be sending infinite/overflow onion payments"); } match self.format { OnionHopDataFormat::Legacy { short_channel_id } => { 0u8.write(w)?; @@ -1319,9 +1320,6 @@ impl Writeable for OnionHopData { }); }, OnionHopDataFormat::FinalNode { ref payment_data, ref keysend_preimage } => { - if let Some(final_data) = payment_data { - if final_data.total_msat > MAX_VALUE_MSAT { panic!("We should never be sending infinite/overflow onion payments"); } - } encode_varint_length_prefixed_tlv!(w, { (2, HighZeroBytesDroppedVarInt(self.amt_to_forward), required), (4, HighZeroBytesDroppedVarInt(self.outgoing_cltv_value), required), @@ -2253,6 +2251,7 @@ mod tests { let funding_locked = msgs::FundingLocked { channel_id: [2; 32], next_per_commitment_point: pubkey_1, + short_channel_id_alias: None, }; let encoded_value = funding_locked.encode(); let target_value = hex::decode("0202020202020202020202020202020202020202020202020202020202020202031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f").unwrap();