Skip to content

Commit 50e9525

Browse files
committed
Correct Channel outbound HTLC serialization
Channel serialization should happen "as if remove_uncommitted_htlcs_and_mark_paused had just been called". This is true for the most part, but outbound RemoteRemoved HTLCs were being serialized as normal, even though `remote_uncommitted_htlcs_and_mark_paused` resets them to `Committed`. This led to a bug identified by the `chanmon_consistency_target` fuzzer wherein, if we receive a update_*_htlc message bug not the corresponding commitment_signed prior to a serialization roundtrip, we'd force-close the channel due to the peer "attempting to fail/claim an HTLC which was already failed/claimed".
1 parent 681c72f commit 50e9525

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4451,9 +4451,10 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
44514451
&OutboundHTLCState::Committed => {
44524452
1u8.write(writer)?;
44534453
},
4454-
&OutboundHTLCState::RemoteRemoved(ref fail_reason) => {
4455-
2u8.write(writer)?;
4456-
fail_reason.write(writer)?;
4454+
&OutboundHTLCState::RemoteRemoved(_) => {
4455+
// Treat this as a Committed because we haven't received the CS - they'll
4456+
// resend the claim/fail on reconnect as we all (hopefully) the missing CS.
4457+
1u8.write(writer)?;
44574458
},
44584459
&OutboundHTLCState::AwaitingRemoteRevokeToRemove(ref fail_reason) => {
44594460
3u8.write(writer)?;

0 commit comments

Comments
 (0)