Skip to content

Commit 4430687

Browse files
authored
Merge pull request #9240 from carlaKC/9166-mergeonly
htlcswitch: merge htlc custom records on modify
2 parents faa4f24 + 151068c commit 4430687

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

docs/release-notes/release-notes-0.19.0.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
* `lncli abandonchannel` (`Lightning.AbandonChannel` RPC)
106106
* `lncli restorechanbackup` (`Lightning.RestoreChannelBackups` RPC)
107107
* `lncli verifychanbackup` (`Lightning.VerifyChanBackup` RPC)
108+
* The `ForwardInterceptor`'s `MODIFY` option will
109+
[merge](https://github.com/lightningnetwork/lnd/pull/9240) any custom
110+
range TLVs provided with the existing set of records on the HTLC,
111+
overwriting any conflicting values with those supplied by the API.
108112

109113
## lncli Updates
110114

@@ -189,4 +193,4 @@ The underlying functionality between those two options remain the same.
189193
* Oliver Gugger
190194
* Pins
191195
* Viktor Tigerström
192-
* Ziggie
196+
* Ziggie

htlcswitch/interceptable_switch.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,12 @@ func (f *interceptedForward) ResumeModified(
715715
htlc.Amount = amount
716716
})
717717

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

722725
case *lnwire.UpdateFulfillHTLC:
723726
if len(validatedRecords) > 0 {

lnrpc/routerrpc/router.pb.go

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/routerrpc/router.proto

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,13 +1064,9 @@ message ForwardHtlcInterceptResponse {
10641064
// the resumed HTLC. This field is ignored if the action is not
10651065
// RESUME_MODIFIED.
10661066
//
1067-
// If this map is populated, it will overwrite any of the wire custom
1068-
// records set by LND. It is the caller's responsibility to copy any desired
1069-
// records across. If the map is empty, no action will be taken and existing
1070-
// custom records will be propagated.
1071-
//
1072-
// The API does not currently support deleting custom records, unless they
1073-
// are overwritten by a new set.
1067+
// This map will merge with the existing set of custom records (if any),
1068+
// replacing any conflicting types. Note that there currently is no support
1069+
// for deleting existing custom records (they can only be replaced).
10741070
map<uint64, bytes> out_wire_custom_records = 8;
10751071
}
10761072

lnrpc/routerrpc/router.swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@
15251525
"type": "string",
15261526
"format": "byte"
15271527
},
1528-
"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."
1528+
"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)."
15291529
}
15301530
},
15311531
"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."

0 commit comments

Comments
 (0)