mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 17:51:33 +02:00
routerrpc: extend HTLC forward interceptor resp with modification fields
This commit extends the forward HTLC intercept response with fields that can be used in conjunction with a `ResumeModified` action to modify the intercepted HTLC p2p message.
This commit is contained in:
@@ -128,6 +128,10 @@ type FwdResolution struct {
|
||||
// FwdActionSettle.
|
||||
Preimage lntypes.Preimage
|
||||
|
||||
// InAmountMsat is the amount that is to be used for validating if
|
||||
// Action is FwdActionResumeModified.
|
||||
InAmountMsat fn.Option[lnwire.MilliSatoshi]
|
||||
|
||||
// OutAmountMsat is the amount that is to be used for forwarding if
|
||||
// Action is FwdActionResumeModified.
|
||||
OutAmountMsat fn.Option[lnwire.MilliSatoshi]
|
||||
@@ -414,7 +418,8 @@ func (s *InterceptableSwitch) resolve(res *FwdResolution) error {
|
||||
|
||||
case FwdActionResumeModified:
|
||||
return intercepted.ResumeModified(
|
||||
res.OutAmountMsat, res.OutWireCustomRecords,
|
||||
res.InAmountMsat, res.OutAmountMsat,
|
||||
res.OutWireCustomRecords,
|
||||
)
|
||||
|
||||
case FwdActionSettle:
|
||||
@@ -665,6 +670,7 @@ func (f *interceptedForward) Resume() error {
|
||||
// validation. The presence of an output amount and/or custom records indicates
|
||||
// that those values should be modified on the outgoing HTLC.
|
||||
func (f *interceptedForward) ResumeModified(
|
||||
inAmountMsat fn.Option[lnwire.MilliSatoshi],
|
||||
outAmountMsat fn.Option[lnwire.MilliSatoshi],
|
||||
outWireCustomRecords fn.Option[lnwire.CustomRecords]) error {
|
||||
|
||||
@@ -694,6 +700,11 @@ func (f *interceptedForward) ResumeModified(
|
||||
err)
|
||||
}
|
||||
|
||||
// Set the incoming amount, if it is provided, on the packet.
|
||||
inAmountMsat.WhenSome(func(amount lnwire.MilliSatoshi) {
|
||||
f.packet.incomingAmount = amount
|
||||
})
|
||||
|
||||
// Modify the wire message contained in the packet.
|
||||
switch htlc := f.packet.htlc.(type) {
|
||||
case *lnwire.UpdateAddHTLC:
|
||||
|
@@ -385,8 +385,9 @@ type InterceptedForward interface {
|
||||
|
||||
// ResumeModified notifies the intention to resume an existing hold
|
||||
// forward with modified fields.
|
||||
ResumeModified(outgoingAmountMsat fn.Option[lnwire.MilliSatoshi],
|
||||
customRecords fn.Option[lnwire.CustomRecords]) error
|
||||
ResumeModified(inAmountMsat,
|
||||
outAmountMsat fn.Option[lnwire.MilliSatoshi],
|
||||
outWireCustomRecords fn.Option[lnwire.CustomRecords]) error
|
||||
|
||||
// Settle notifies the intention to settle an existing hold
|
||||
// forward with a given preimage.
|
||||
|
Reference in New Issue
Block a user