Versions in this module Expand all Collapse all v3 v3.0.0 Oct 12, 2020 Changes in this version + const AddressSize + const AmtForwardSize + const ExitNode + const Failure + const HMACSize + const HashPrefixSize + const LegacyHopDataSize + const MaxPayloadSize + const MoreHops + const NumMaxHops + const NumPaddingBytes + const OutgoingCLTVSize + const RealmByteSize + var ErrAlreadyCommitted = errors.New("cannot add to batch after committing") + var ErrInvalidOnionHMAC = fmt.Errorf("invalid mismatched mac") + var ErrInvalidOnionKey = fmt.Errorf(...) + var ErrInvalidOnionVersion = fmt.Errorf("invalid onion packet version") + var ErrLogEntryNotFound = fmt.Errorf("sphinx packet is not in log") + var ErrMaxRoutingInfoSizeExceeded = fmt.Errorf("max routing info size of %v bytes exceeded", routingInfoSize) + var ErrReplayedPacket = fmt.Errorf("sphinx packet replay attempted") + var ErrVarIntNotCanonical = errors.New("decoded varint is not canonical") + func BlankPacketFiller(_ *secp256k1.PrivateKey, _ *[routingInfoSize]byte) error + func DeterministicPacketFiller(sessionKey *secp256k1.PrivateKey, mixHeader *[routingInfoSize]byte) error + func RandPacketFiller(_ *secp256k1.PrivateKey, mixHeader *[routingInfoSize]byte) error + func ReadVarInt(r io.Reader, buf *[8]byte) (uint64, error) + func UseLogger(logger slog.Logger) + func WriteVarInt(w io.Writer, val uint64, buf *[8]byte) error + type Batch struct + ID []byte + IsCommitted bool + ReplaySet *ReplaySet + func NewBatch(id []byte) *Batch + func (b *Batch) ForEach(fn func(seqNum uint16, hashPrefix *HashPrefix, cltv uint32) error) error + func (b *Batch) Put(seqNum uint16, hashPrefix *HashPrefix, cltv uint32) error + type Circuit struct + PaymentPath []*secp256k1.PublicKey + SessionKey *secp256k1.PrivateKey + func (c *Circuit) Decode(r io.Reader) error + func (c *Circuit) Encode(w io.Writer) error + type DecryptedError struct + Message []byte + Sender *secp256k1.PublicKey + SenderIdx int + type Hash256 [sha256.Size]byte + type HashPrefix [HashPrefixSize]byte + type HopData struct + ExtraBytes [NumPaddingBytes]byte + ForwardAmount uint64 + NextAddress [AddressSize]byte + OutgoingCltv uint32 + Realm [RealmByteSize]byte + func (hd *HopData) Decode(r io.Reader) error + func (hd *HopData) Encode(w io.Writer) error + type HopPayload struct + HMAC [HMACSize]byte + Payload []byte + Type PayloadType + func NewHopPayload(hopData *HopData, eob []byte) (HopPayload, error) + func (hp *HopPayload) Decode(r io.Reader) error + func (hp *HopPayload) Encode(w io.Writer) error + func (hp *HopPayload) HopData() (*HopData, error) + func (hp *HopPayload) NumBytes() int + type MemoryReplayLog struct + func NewMemoryReplayLog() *MemoryReplayLog + func (rl *MemoryReplayLog) Delete(hash *HashPrefix) error + func (rl *MemoryReplayLog) Get(hash *HashPrefix) (uint32, error) + func (rl *MemoryReplayLog) Put(hash *HashPrefix, cltv uint32) error + func (rl *MemoryReplayLog) PutBatch(batch *Batch) (*ReplaySet, error) + func (rl *MemoryReplayLog) Start() error + func (rl *MemoryReplayLog) Stop() error + type OnionErrorDecrypter struct + func NewOnionErrorDecrypter(circuit *Circuit) *OnionErrorDecrypter + func (o *OnionErrorDecrypter) DecryptError(encryptedData []byte) (*DecryptedError, error) + type OnionErrorEncrypter struct + func NewOnionErrorEncrypter(router *Router, ephemeralKey *secp256k1.PublicKey) (*OnionErrorEncrypter, error) + func (o *OnionErrorEncrypter) Decode(r io.Reader) error + func (o *OnionErrorEncrypter) Encode(w io.Writer) error + func (o *OnionErrorEncrypter) EncryptError(initial bool, data []byte) []byte + type OnionHop struct + HopPayload HopPayload + NodePub secp256k1.PublicKey + func (o OnionHop) IsEmpty() bool + type OnionPacket struct + EphemeralKey *secp256k1.PublicKey + HeaderMAC [HMACSize]byte + RoutingInfo [routingInfoSize]byte + Version byte + func NewOnionPacket(paymentPath *PaymentPath, sessionKey *secp256k1.PrivateKey, assocData []byte, ...) (*OnionPacket, error) + func (f *OnionPacket) Decode(r io.Reader) error + func (f *OnionPacket) Encode(w io.Writer) error + type PacketFiller func(*secp256k1.PrivateKey, *[routingInfoSize]byte) error + type PayloadType uint8 + const PayloadLegacy + const PayloadTLV + type PaymentPath [NumMaxHops]OnionHop + func (p *PaymentPath) NodeKeys() []*secp256k1.PublicKey + func (p *PaymentPath) TotalPayloadSize() int + func (p *PaymentPath) TrueRouteLength() int + type PrivKeyECDH struct + PrivKey *secp256k1.PrivateKey + func (p *PrivKeyECDH) ECDH(pub *secp256k1.PublicKey) ([32]byte, error) + func (p *PrivKeyECDH) PubKey() *secp256k1.PublicKey + type ProcessCode int + func (p ProcessCode) String() string + type ProcessedPacket struct + Action ProcessCode + ForwardingInstructions *HopData + NextPacket *OnionPacket + Payload HopPayload + type ReplayLog interface + Delete func(*HashPrefix) error + Get func(*HashPrefix) (uint32, error) + Put func(*HashPrefix, uint32) error + PutBatch func(*Batch) (*ReplaySet, error) + Start func() error + Stop func() error + type ReplaySet struct + func NewReplaySet() *ReplaySet + func (rs *ReplaySet) Add(idx uint16) + func (rs *ReplaySet) Contains(idx uint16) bool + func (rs *ReplaySet) Decode(r io.Reader) error + func (rs *ReplaySet) Encode(w io.Writer) error + func (rs *ReplaySet) Merge(rs2 *ReplaySet) + func (rs *ReplaySet) Size() int + type Router struct + func NewRouter(nodeKey SingleKeyECDH, net dcrutil.AddressParams, log ReplayLog) *Router + func (r *Router) BeginTxn(id []byte, nels int) *Tx + func (r *Router) ProcessOnionPacket(onionPkt *OnionPacket, assocData []byte, incomingCltv uint32) (*ProcessedPacket, error) + func (r *Router) ReconstructOnionPacket(onionPkt *OnionPacket, assocData []byte) (*ProcessedPacket, error) + func (r *Router) Start() error + func (r *Router) Stop() + type SingleKeyECDH interface + ECDH func(pubKey *secp256k1.PublicKey) ([32]byte, error) + PubKey func() *secp256k1.PublicKey + type Tx struct + func (t *Tx) Commit() ([]ProcessedPacket, *ReplaySet, error) + func (t *Tx) ProcessOnionPacket(seqNum uint16, onionPkt *OnionPacket, assocData []byte, incomingCltv uint32) error Other modules containing this package github.com/decred/lightning-onion github.com/decred/lightning-onion/v2 github.com/decred/lightning-onion/v4