Skip to content

Commit

Permalink
Merge pull request #9240 from carlaKC/9166-mergeonly
Browse files Browse the repository at this point in the history
htlcswitch: merge htlc custom records on modify
  • Loading branch information
ellemouton authored Nov 8, 2024
2 parents faa4f24 + 151068c commit 4430687
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
6 changes: 5 additions & 1 deletion docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
* `lncli abandonchannel` (`Lightning.AbandonChannel` RPC)
* `lncli restorechanbackup` (`Lightning.RestoreChannelBackups` RPC)
* `lncli verifychanbackup` (`Lightning.VerifyChanBackup` RPC)
* The `ForwardInterceptor`'s `MODIFY` option will
[merge](https://github.com/lightningnetwork/lnd/pull/9240) any custom
range TLVs provided with the existing set of records on the HTLC,
overwriting any conflicting values with those supplied by the API.

## lncli Updates

Expand Down Expand Up @@ -189,4 +193,4 @@ The underlying functionality between those two options remain the same.
* Oliver Gugger
* Pins
* Viktor Tigerström
* Ziggie
* Ziggie
9 changes: 6 additions & 3 deletions htlcswitch/interceptable_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,12 @@ func (f *interceptedForward) ResumeModified(
htlc.Amount = amount
})

if len(validatedRecords) > 0 {
htlc.CustomRecords = validatedRecords
}
// Merge custom records with any validated records that were
// added in the modify request, overwriting any existing values
// with those supplied in the modifier API.
htlc.CustomRecords = htlc.CustomRecords.MergedCopy(
validatedRecords,
)

case *lnwire.UpdateFulfillHTLC:
if len(validatedRecords) > 0 {
Expand Down
10 changes: 3 additions & 7 deletions lnrpc/routerrpc/router.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions lnrpc/routerrpc/router.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1064,13 +1064,9 @@ message ForwardHtlcInterceptResponse {
// the resumed HTLC. This field is ignored if the action is not
// RESUME_MODIFIED.
//
// If this map is populated, it will overwrite any of the wire custom
// records set by LND. It is the caller's responsibility to copy any desired
// records across. If the map is empty, no action will be taken and existing
// custom records will be propagated.
//
// The API does not currently support deleting custom records, unless they
// are overwritten by a new set.
// This map will merge with the existing set of custom records (if any),
// replacing any conflicting types. Note that there currently is no support
// for deleting existing custom records (they can only be replaced).
map<uint64, bytes> out_wire_custom_records = 8;
}

Expand Down
2 changes: 1 addition & 1 deletion lnrpc/routerrpc/router.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@
"type": "string",
"format": "byte"
},
"description": "Any custom records that should be set on the p2p wire message message of\nthe resumed HTLC. This field is ignored if the action is not\nRESUME_MODIFIED.\n\nIf this map is populated, it will overwrite any of the wire custom\nrecords set by LND. It is the caller's responsibility to copy any desired\nrecords across. If the map is empty, no action will be taken and existing\ncustom records will be propagated.\n\nThe API does not currently support deleting custom records, unless they\nare overwritten by a new set."
"description": "Any custom records that should be set on the p2p wire message message of\nthe resumed HTLC. This field is ignored if the action is not\nRESUME_MODIFIED.\n\nThis map will merge with the existing set of custom records (if any),\nreplacing any conflicting types. Note that there currently is no support\nfor deleting existing custom records (they can only be replaced)."
}
},
"description": "*\nForwardHtlcInterceptResponse enables the caller to resolve a previously hold\nforward. The caller can choose either to:\n- `Resume`: Execute the default behavior (usually forward).\n- `ResumeModified`: Execute the default behavior (usually forward) with HTLC\nfield modifications.\n- `Reject`: Fail the htlc backwards.\n- `Settle`: Settle this htlc with a given preimage."
Expand Down

0 comments on commit 4430687

Please sign in to comment.