Skip to content

Commit 31d22c7

Browse files
committed
f: catch invalid Trampoline onion match arms explicitly
1 parent fd51e59 commit 31d22c7

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,22 +1861,27 @@ where
18611861
err_code: INVALID_ONION_BLINDING,
18621862
})
18631863
},
1864-
Ok((_, None)) => Err(OnionDecodeErr::Relay {
1865-
err_msg: "Non-final Trampoline onion data provided to us as last hop",
1866-
err_code: 0x4000 | 22,
1867-
shared_secret,
1868-
trampoline_shared_secret: Some(SharedSecret::from_bytes(
1869-
trampoline_shared_secret,
1870-
)),
1871-
}),
1872-
Ok((_, Some(_))) => Err(OnionDecodeErr::Relay {
1873-
err_msg: "Final Trampoline onion data provided to us as intermediate hop",
1874-
err_code: 0x4000 | 22,
1875-
shared_secret,
1876-
trampoline_shared_secret: Some(SharedSecret::from_bytes(
1877-
trampoline_shared_secret,
1878-
)),
1879-
}),
1864+
Ok((msgs::InboundTrampolinePayload::Forward(_), None)) => {
1865+
Err(OnionDecodeErr::Relay {
1866+
err_msg: "Non-final Trampoline onion data provided to us as last hop",
1867+
err_code: 0x4000 | 22,
1868+
shared_secret,
1869+
trampoline_shared_secret: Some(SharedSecret::from_bytes(
1870+
trampoline_shared_secret,
1871+
)),
1872+
})
1873+
},
1874+
Ok((msgs::InboundTrampolinePayload::Receive(_), Some(_))) => {
1875+
Err(OnionDecodeErr::Relay {
1876+
err_msg:
1877+
"Final Trampoline onion data provided to us as intermediate hop",
1878+
err_code: 0x4000 | 22,
1879+
shared_secret,
1880+
trampoline_shared_secret: Some(SharedSecret::from_bytes(
1881+
trampoline_shared_secret,
1882+
)),
1883+
})
1884+
},
18801885
Err(e) => Err(e),
18811886
}
18821887
},

0 commit comments

Comments
 (0)