Skip to content

Commit

Permalink
[WIP] Change origin in HTLC messages to be an option
Browse files Browse the repository at this point in the history
I don't want to use DNL's routing types so I had to just make DNL
support None as origin in all commands, which is interesting because
DNL does accept option<HtlcSource> for addHtlc command but if you use
it, receiveFulfill and all other htlc related functions crash or fail.
  • Loading branch information
aarani committed Jun 14, 2021
1 parent 25040ca commit 287b4aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/DotNetLightning.Core/Channel/ChannelTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ type ChannelEvent =
| WeAcceptedUpdateAddHTLC of newCommitments: Commitments

| WeAcceptedOperationFulfillHTLC of msg: UpdateFulfillHTLCMsg * newCommitments: Commitments
| WeAcceptedFulfillHTLC of msg: UpdateFulfillHTLCMsg * origin: HTLCSource * htlc: UpdateAddHTLCMsg * newCommitments: Commitments
| WeAcceptedFulfillHTLC of msg: UpdateFulfillHTLCMsg * origin: Option<HTLCSource> * htlc: UpdateAddHTLCMsg * newCommitments: Commitments

| WeAcceptedOperationFailHTLC of msg: UpdateFailHTLCMsg * newCommitments: Commitments
| WeAcceptedFailHTLC of origin: HTLCSource * msg: UpdateAddHTLCMsg * nextCommitments: Commitments
| WeAcceptedFailHTLC of origin: Option<HTLCSource> * msg: UpdateAddHTLCMsg * nextCommitments: Commitments

| WeAcceptedOperationFailMalformedHTLC of msg: UpdateFailMalformedHTLCMsg * newCommitments: Commitments
| WeAcceptedFailMalformedHTLC of origin: HTLCSource * msg: UpdateAddHTLCMsg * newCommitments: Commitments
| WeAcceptedFailMalformedHTLC of origin: Option<HTLCSource> * msg: UpdateAddHTLCMsg * newCommitments: Commitments

| WeAcceptedOperationUpdateFee of msg: UpdateFeeMsg * nextCommitments: Commitments
| WeAcceptedUpdateFee of msg: UpdateFeeMsg * newCommitments: Commitments
Expand Down
6 changes: 3 additions & 3 deletions src/DotNetLightning.Core/Channel/CommitmentsModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module internal Commitments =
match cm.GetHTLCCrossSigned(Direction.Out, msg.HTLCId) with
| Some htlc when htlc.PaymentHash = msg.PaymentPreimage.Hash ->
let commitments = cm.AddRemoteProposal(msg)
let origin = cm.OriginChannels |> Map.find(msg.HTLCId)
let origin = cm.OriginChannels |> Map.tryFind(msg.HTLCId)
[WeAcceptedFulfillHTLC(msg, origin, htlc, commitments)] |> Ok
| Some htlc ->
(htlc.PaymentHash, msg.PaymentPreimage)
Expand Down Expand Up @@ -178,7 +178,7 @@ module internal Commitments =
| false, _ ->
msg.HTLCId |> htlcOriginNotKnown
let nextC = cm.AddRemoteProposal(msg)
return [WeAcceptedFailHTLC(o, htlc, nextC)]
return [WeAcceptedFailHTLC(Some o, htlc, nextC)]
}
| None ->
msg.HTLCId |> unknownHTLCId
Expand Down Expand Up @@ -216,7 +216,7 @@ module internal Commitments =
| false, _ ->
msg.HTLCId |> htlcOriginNotKnown
let nextC = cm.AddRemoteProposal(msg)
return [WeAcceptedFailMalformedHTLC(o, htlc, nextC)]
return [WeAcceptedFailMalformedHTLC(Some o, htlc, nextC)]
}
| None ->
msg.HTLCId |> unknownHTLCId
Expand Down

0 comments on commit 287b4aa

Please sign in to comment.