Skip to content

Commit 6a196f2

Browse files
committed
Encode channel_update type in failure messages.
1 parent ce07ed5 commit 6a196f2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,12 +3540,14 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
35403540
fn get_htlc_temp_fail_err_and_data(&self, desired_err_code: u16, scid: u64, chan: &Channel<Signer>) -> (u16, Vec<u8>) {
35413541
debug_assert_eq!(desired_err_code & 0x1000, 0x1000);
35423542
if let Ok(upd) = self.get_channel_update_for_onion(scid, chan) {
3543-
let mut enc = VecWriter(Vec::with_capacity(upd.serialized_length() + 4));
3543+
let mut enc = VecWriter(Vec::with_capacity(upd.serialized_length() + 6));
35443544
if desired_err_code == 0x1000 | 20 {
35453545
// TODO: underspecified, follow https://github.com/lightning/bolts/issues/791
35463546
0u16.write(&mut enc).expect("Writes cannot fail");
35473547
}
3548-
(upd.serialized_length() as u16).write(&mut enc).expect("Writes cannot fail");
3548+
(upd.serialized_length() as u16 + 2).write(&mut enc).expect("Writes cannot fail");
3549+
let chan_update_type = u16::from_be_bytes([0x01, 0x02]);
3550+
chan_update_type.write(&mut enc).expect("Writes cannot fail");
35493551
upd.write(&mut enc).expect("Writes cannot fail");
35503552
(desired_err_code, enc.0)
35513553
} else {

0 commit comments

Comments
 (0)