Skip to content

Commit d410ae0

Browse files
committed
f: discriminate blinding errors in error codes
1 parent 09ffa57 commit d410ae0

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,15 +1832,36 @@ where
18321832
trampoline_shared_secret,
18331833
),
18341834
}),
1835-
Ok((_, None)) => Err(OnionDecodeErr::Malformed {
1835+
Ok((msgs::InboundTrampolinePayload::BlindedForward(_), None)) => {
1836+
Err(OnionDecodeErr::Malformed {
1837+
err_msg: "Non-final Trampoline onion data provided to us as last hop",
1838+
err_code: INVALID_ONION_BLINDING,
1839+
trampoline_onion_blinding: true,
1840+
})
1841+
},
1842+
Ok((msgs::InboundTrampolinePayload::BlindedReceive(_), Some(_))) => {
1843+
Err(OnionDecodeErr::Malformed {
1844+
err_msg:
1845+
"Final Trampoline onion data provided to us as intermediate hop",
1846+
err_code: INVALID_ONION_BLINDING,
1847+
trampoline_onion_blinding: true,
1848+
})
1849+
},
1850+
Ok((_, None)) => Err(OnionDecodeErr::Relay {
18361851
err_msg: "Non-final Trampoline onion data provided to us as last hop",
1837-
err_code: INVALID_ONION_BLINDING,
1838-
trampoline_onion_blinding: true,
1852+
err_code: 0x4000 | 22,
1853+
shared_secret,
1854+
trampoline_shared_secret: Some(SharedSecret::from_bytes(
1855+
trampoline_shared_secret,
1856+
)),
18391857
}),
1840-
Ok((_, Some(_))) => Err(OnionDecodeErr::Malformed {
1858+
Ok((_, Some(_))) => Err(OnionDecodeErr::Relay {
18411859
err_msg: "Final Trampoline onion data provided to us as intermediate hop",
1842-
err_code: INVALID_ONION_BLINDING,
1843-
trampoline_onion_blinding: true,
1860+
err_code: 0x4000 | 22,
1861+
shared_secret,
1862+
trampoline_shared_secret: Some(SharedSecret::from_bytes(
1863+
trampoline_shared_secret,
1864+
)),
18441865
}),
18451866
Err(e) => Err(e),
18461867
}

0 commit comments

Comments
 (0)