2017-05-01 09:58:08 -07:00
|
|
|
package htlcswitch
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
|
|
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
|
|
|
)
|
|
|
|
|
|
|
|
// htlcPacket is a wrapper around htlc lnwire update, which adds additional
|
|
|
|
// information which is needed by this package.
|
|
|
|
type htlcPacket struct {
|
2017-06-16 14:49:38 -07:00
|
|
|
// destNode is the first-hop destination of a local created HTLC add
|
|
|
|
// message.
|
|
|
|
destNode [33]byte
|
|
|
|
|
|
|
|
// payHash is the payment hash of the HTLC which was modified by either
|
|
|
|
// a settle or fail action.
|
|
|
|
//
|
2017-05-01 09:58:08 -07:00
|
|
|
// NOTE: This fields is initialized only in settle and fail packets.
|
|
|
|
payHash [sha256.Size]byte
|
|
|
|
|
2017-06-16 14:49:38 -07:00
|
|
|
// dest is the destination of this packet identified by the short
|
|
|
|
// channel ID of the target link.
|
|
|
|
dest lnwire.ShortChannelID
|
2017-05-01 09:58:08 -07:00
|
|
|
|
2017-06-16 14:49:38 -07:00
|
|
|
// src is the source of this packet identified by the short channel ID
|
|
|
|
// of the target link.
|
|
|
|
src lnwire.ShortChannelID
|
2017-05-01 09:58:08 -07:00
|
|
|
|
2017-10-23 15:50:26 -07:00
|
|
|
// destID is the ID of the HTLC in the destination channel. This will be set
|
|
|
|
// when forwarding a settle or fail update back to the original source.
|
|
|
|
destID uint64
|
|
|
|
|
|
|
|
// srcID is the ID of the HTLC in the source channel. This will be set when
|
|
|
|
// forwarding any HTLC update message.
|
|
|
|
srcID uint64
|
|
|
|
|
2017-06-16 14:49:38 -07:00
|
|
|
// amount is the value of the HTLC that is being created or modified.
|
2017-08-21 23:36:43 -07:00
|
|
|
amount lnwire.MilliSatoshi
|
2017-06-16 14:49:38 -07:00
|
|
|
|
|
|
|
// htlc lnwire message type of which depends on switch request type.
|
|
|
|
htlc lnwire.Message
|
2017-06-29 06:40:45 -07:00
|
|
|
|
2017-07-14 20:08:29 -07:00
|
|
|
// obfuscator contains the necessary state to allow the switch to wrap
|
|
|
|
// any forwarded errors in an additional layer of encryption.
|
2017-10-10 19:36:52 -07:00
|
|
|
obfuscator ErrorEncrypter
|
2017-06-29 06:40:45 -07:00
|
|
|
|
2017-07-14 20:08:29 -07:00
|
|
|
// isObfuscated is set to true if an error occurs as soon as the switch
|
|
|
|
// forwards a packet to the link. If so, and this is an error packet,
|
|
|
|
// then this allows the switch to avoid doubly encrypting the error.
|
|
|
|
//
|
|
|
|
// TODO(andrew.shvv) revisit after refactoring the way of returning
|
|
|
|
// errors inside the htlcswitch packet.
|
2017-06-29 06:40:45 -07:00
|
|
|
isObfuscated bool
|
2017-05-01 09:58:08 -07:00
|
|
|
}
|