mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 17:47:01 +02:00
multi: use wire records on payment and intercept flows
This commit is contained in:
committed by
Oliver Gugger
parent
aa86020b84
commit
878f964a33
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch/hop"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnutils"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
@@ -645,15 +646,16 @@ func (f *interceptedForward) Packet() InterceptedPacket {
|
||||
ChanID: f.packet.incomingChanID,
|
||||
HtlcID: f.packet.incomingHTLCID,
|
||||
},
|
||||
OutgoingChanID: f.packet.outgoingChanID,
|
||||
Hash: f.htlc.PaymentHash,
|
||||
OutgoingExpiry: f.htlc.Expiry,
|
||||
OutgoingAmount: f.htlc.Amount,
|
||||
IncomingAmount: f.packet.incomingAmount,
|
||||
IncomingExpiry: f.packet.incomingTimeout,
|
||||
CustomRecords: f.packet.customRecords,
|
||||
OnionBlob: f.htlc.OnionBlob,
|
||||
AutoFailHeight: f.autoFailHeight,
|
||||
OutgoingChanID: f.packet.outgoingChanID,
|
||||
Hash: f.htlc.PaymentHash,
|
||||
OutgoingExpiry: f.htlc.Expiry,
|
||||
OutgoingAmount: f.htlc.Amount,
|
||||
IncomingAmount: f.packet.incomingAmount,
|
||||
IncomingExpiry: f.packet.incomingTimeout,
|
||||
InOnionCustomRecords: f.packet.inOnionCustomRecords,
|
||||
OnionBlob: f.htlc.OnionBlob,
|
||||
AutoFailHeight: f.autoFailHeight,
|
||||
InWireCustomRecords: f.packet.inWireCustomRecords,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,6 +725,8 @@ func (f *interceptedForward) ResumeModified(
|
||||
}
|
||||
}
|
||||
|
||||
log.Tracef("Forwarding packet %v", lnutils.SpewLogClosure(f.packet))
|
||||
|
||||
// Forward to the switch. A link quit channel isn't needed, because we
|
||||
// are on a different thread now.
|
||||
return f.htlcSwitch.ForwardPackets(nil, f.packet)
|
||||
|
@@ -357,13 +357,17 @@ type InterceptedPacket struct {
|
||||
// IncomingAmount is the amount of the accepted htlc.
|
||||
IncomingAmount lnwire.MilliSatoshi
|
||||
|
||||
// CustomRecords are user-defined records in the custom type range that
|
||||
// were included in the payload.
|
||||
CustomRecords record.CustomSet
|
||||
// InOnionCustomRecords are user-defined records in the custom type
|
||||
// range that were included in the payload.
|
||||
InOnionCustomRecords record.CustomSet
|
||||
|
||||
// OnionBlob is the onion packet for the next hop
|
||||
OnionBlob [lnwire.OnionPacketSize]byte
|
||||
|
||||
// InWireCustomRecords are user-defined p2p wire message records that
|
||||
// were defined by the peer that forwarded this HTLC to us.
|
||||
InWireCustomRecords lnwire.CustomRecords
|
||||
|
||||
// AutoFailHeight is the block height at which this intercept will be
|
||||
// failed back automatically.
|
||||
AutoFailHeight int32
|
||||
|
@@ -3630,7 +3630,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
|
||||
}
|
||||
|
||||
// Otherwise, it was already processed, we can
|
||||
// can collect it and continue.
|
||||
// collect it and continue.
|
||||
addMsg := &lnwire.UpdateAddHTLC{
|
||||
Expiry: fwdInfo.OutgoingCTLV,
|
||||
Amount: fwdInfo.AmountToForward,
|
||||
@@ -3650,19 +3650,21 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
|
||||
|
||||
inboundFee := l.cfg.FwrdingPolicy.InboundFee
|
||||
|
||||
//nolint:lll
|
||||
updatePacket := &htlcPacket{
|
||||
incomingChanID: l.ShortChanID(),
|
||||
incomingHTLCID: pd.HtlcIndex,
|
||||
outgoingChanID: fwdInfo.NextHop,
|
||||
sourceRef: pd.SourceRef,
|
||||
incomingAmount: pd.Amount,
|
||||
amount: addMsg.Amount,
|
||||
htlc: addMsg,
|
||||
obfuscator: obfuscator,
|
||||
incomingTimeout: pd.Timeout,
|
||||
outgoingTimeout: fwdInfo.OutgoingCTLV,
|
||||
customRecords: pld.CustomRecords(),
|
||||
inboundFee: inboundFee,
|
||||
incomingChanID: l.ShortChanID(),
|
||||
incomingHTLCID: pd.HtlcIndex,
|
||||
outgoingChanID: fwdInfo.NextHop,
|
||||
sourceRef: pd.SourceRef,
|
||||
incomingAmount: pd.Amount,
|
||||
amount: addMsg.Amount,
|
||||
htlc: addMsg,
|
||||
obfuscator: obfuscator,
|
||||
incomingTimeout: pd.Timeout,
|
||||
outgoingTimeout: fwdInfo.OutgoingCTLV,
|
||||
inOnionCustomRecords: pld.CustomRecords(),
|
||||
inboundFee: inboundFee,
|
||||
inWireCustomRecords: pd.CustomRecords.Copy(),
|
||||
}
|
||||
switchPackets = append(
|
||||
switchPackets, updatePacket,
|
||||
@@ -3718,19 +3720,21 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
|
||||
if fwdPkg.State == channeldb.FwdStateLockedIn {
|
||||
inboundFee := l.cfg.FwrdingPolicy.InboundFee
|
||||
|
||||
//nolint:lll
|
||||
updatePacket := &htlcPacket{
|
||||
incomingChanID: l.ShortChanID(),
|
||||
incomingHTLCID: pd.HtlcIndex,
|
||||
outgoingChanID: fwdInfo.NextHop,
|
||||
sourceRef: pd.SourceRef,
|
||||
incomingAmount: pd.Amount,
|
||||
amount: addMsg.Amount,
|
||||
htlc: addMsg,
|
||||
obfuscator: obfuscator,
|
||||
incomingTimeout: pd.Timeout,
|
||||
outgoingTimeout: fwdInfo.OutgoingCTLV,
|
||||
customRecords: pld.CustomRecords(),
|
||||
inboundFee: inboundFee,
|
||||
incomingChanID: l.ShortChanID(),
|
||||
incomingHTLCID: pd.HtlcIndex,
|
||||
outgoingChanID: fwdInfo.NextHop,
|
||||
sourceRef: pd.SourceRef,
|
||||
incomingAmount: pd.Amount,
|
||||
amount: addMsg.Amount,
|
||||
htlc: addMsg,
|
||||
obfuscator: obfuscator,
|
||||
incomingTimeout: pd.Timeout,
|
||||
outgoingTimeout: fwdInfo.OutgoingCTLV,
|
||||
inOnionCustomRecords: pld.CustomRecords(),
|
||||
inboundFee: inboundFee,
|
||||
inWireCustomRecords: pd.CustomRecords.Copy(),
|
||||
}
|
||||
|
||||
fwdPkg.FwdFilter.Set(idx)
|
||||
|
@@ -94,9 +94,13 @@ type htlcPacket struct {
|
||||
// link.
|
||||
outgoingTimeout uint32
|
||||
|
||||
// customRecords are user-defined records in the custom type range that
|
||||
// were included in the payload.
|
||||
customRecords record.CustomSet
|
||||
// inOnionCustomRecords are user-defined records in the custom type
|
||||
// range that were included in the onion payload.
|
||||
inOnionCustomRecords record.CustomSet
|
||||
|
||||
// inWireCustomRecords are custom type range TLVs that are included
|
||||
// in the incoming update_add_htlc wire message.
|
||||
inWireCustomRecords lnwire.CustomRecords
|
||||
|
||||
// originalOutgoingChanID is used when sending back failure messages.
|
||||
// It is only used for forwarded Adds on option_scid_alias channels.
|
||||
|
Reference in New Issue
Block a user