htlcswitch/packet: adds serialization to htlcPacket
This commit is contained in:
parent
3048dfd4be
commit
e4fb420665
@ -1,6 +1,7 @@
|
|||||||
package htlcswitch
|
package htlcswitch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,6 +36,20 @@ type htlcPacket struct {
|
|||||||
// outgoing channel.
|
// outgoing channel.
|
||||||
outgoingHTLCID uint64
|
outgoingHTLCID uint64
|
||||||
|
|
||||||
|
// sourceRef is used by forwarded htlcPackets to locate incoming Add
|
||||||
|
// entry in a fwdpkg owned by the incoming link. This value can be nil
|
||||||
|
// if there is no such entry, e.g. switch initiated payments.
|
||||||
|
sourceRef *channeldb.AddRef
|
||||||
|
|
||||||
|
// destRef is used to locate a settle/fail entry in the outgoing link's
|
||||||
|
// fwdpkg. If sourceRef is non-nil, this reference should be to a
|
||||||
|
// settle/fail in response to the sourceRef.
|
||||||
|
destRef *channeldb.SettleFailRef
|
||||||
|
|
||||||
|
// incomingAmount is the value in milli-satoshis that arrived on an
|
||||||
|
// incoming link.
|
||||||
|
incomingAmount lnwire.MilliSatoshi
|
||||||
|
|
||||||
// amount is the value of the HTLC that is being created or modified.
|
// amount is the value of the HTLC that is being created or modified.
|
||||||
amount lnwire.MilliSatoshi
|
amount lnwire.MilliSatoshi
|
||||||
|
|
||||||
@ -50,10 +65,10 @@ type htlcPacket struct {
|
|||||||
// encrypted with any shared secret.
|
// encrypted with any shared secret.
|
||||||
localFailure bool
|
localFailure bool
|
||||||
|
|
||||||
// isRouted is set to true if the incomingChanID and incomingHTLCID fields
|
// hasSource is set to true if the incomingChanID and incomingHTLCID
|
||||||
// of a forwarded fail packet are already set and do not need to be looked
|
// fields of a forwarded fail packet are already set and do not need to
|
||||||
// up in the circuit map.
|
// be looked up in the circuit map.
|
||||||
isRouted bool
|
hasSource bool
|
||||||
|
|
||||||
// isResolution is set to true if this packet was actually an incoming
|
// isResolution is set to true if this packet was actually an incoming
|
||||||
// resolution message from an outside sub-system. We'll treat these as
|
// resolution message from an outside sub-system. We'll treat these as
|
||||||
@ -61,4 +76,32 @@ type htlcPacket struct {
|
|||||||
// encrypt all errors related to this packet as if we were the first
|
// encrypt all errors related to this packet as if we were the first
|
||||||
// hop.
|
// hop.
|
||||||
isResolution bool
|
isResolution bool
|
||||||
|
|
||||||
|
// circuit holds a reference to an Add's circuit which is persisted in
|
||||||
|
// the switch during successful forwarding.
|
||||||
|
circuit *PaymentCircuit
|
||||||
|
}
|
||||||
|
|
||||||
|
// inKey returns the circuit key used to identify the incoming htlc.
|
||||||
|
func (p *htlcPacket) inKey() CircuitKey {
|
||||||
|
return CircuitKey{
|
||||||
|
ChanID: p.incomingChanID,
|
||||||
|
HtlcID: p.incomingHTLCID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// outKey returns the circuit key used to identify the outgoing, forwarded htlc.
|
||||||
|
func (p *htlcPacket) outKey() CircuitKey {
|
||||||
|
return CircuitKey{
|
||||||
|
ChanID: p.outgoingChanID,
|
||||||
|
HtlcID: p.outgoingHTLCID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// keystone returns a tuple containing the incoming and outgoing circuit keys.
|
||||||
|
func (p *htlcPacket) keystone() Keystone {
|
||||||
|
return Keystone{
|
||||||
|
InKey: p.inKey(),
|
||||||
|
OutKey: p.outKey(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user