• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 16170852573

09 Jul 2025 01:36PM UTC coverage: 68.199% (+10.6%) from 57.62%
16170852573

Pull #9868

github

web-flow
Merge e5726a7be into ea32aac77
Pull Request #9868: PoC Onion messaging using `msgmux`

169 of 228 new or added lines in 10 files covered. (74.12%)

17 existing lines in 3 files now uncovered.

137361 of 201411 relevant lines covered (68.2%)

21720.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.71
/lnwire/onion_message.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "io"
6

7
        "github.com/btcsuite/btcd/btcec/v2"
8
)
9

10
// OnionMessage is a message that carries an onion-encrypted payload.
11
// This is used for BOLT12 messages.
12
type OnionMessage struct {
13
        // BlindingPoint is the route blinding ephemeral pubkey to be used for
14
        // the onion message.
15
        BlindingPoint *btcec.PublicKey
16

17
        // OnionBlob is the raw serialized mix header used to relay messages in
18
        // a privacy-preserving manner. This blob should be handled in the same
19
        // manner as onions used to route HTLCs, with the exception that it uses
20
        // blinded routes by default.
21
        OnionBlob []byte
22
}
23

24
// NewOnionMessage creates a new OnionMessage.
25
func NewOnionMessage(blindingPoint *btcec.PublicKey,
26
        onion []byte) *OnionMessage {
103✔
27

103✔
28
        return &OnionMessage{
103✔
29
                BlindingPoint: blindingPoint,
103✔
30
                OnionBlob:     onion,
103✔
31
        }
103✔
32
}
103✔
33

34
// A compile-time check to ensure OnionMessage implements the Message interface.
35
var _ Message = (*OnionMessage)(nil)
36

37
// Decode reads the bytes stream and converts it to the object.
38
func (o *OnionMessage) Decode(r io.Reader, pver uint32) error {
103✔
39
        if err := ReadElement(r, &o.BlindingPoint); err != nil {
103✔
NEW
40
                return err
×
NEW
41
        }
×
42

43
        var onionLen uint16
103✔
44
        if err := ReadElement(r, &onionLen); err != nil {
103✔
NEW
45
                return err
×
NEW
46
        }
×
47

48
        o.OnionBlob = make([]byte, onionLen)
103✔
49
        if err := ReadElement(r, o.OnionBlob); err != nil {
103✔
NEW
50
                return err
×
NEW
51
        }
×
52

53
        return nil
103✔
54
}
55

56
// Encode converts object to the bytes stream and write it into the
57
// write buffer.
58
func (o *OnionMessage) Encode(w *bytes.Buffer, _ uint32) error {
103✔
59
        if err := WritePublicKey(w, o.BlindingPoint); err != nil {
103✔
NEW
60
                return err
×
NEW
61
        }
×
62

63
        onionLen := len(o.OnionBlob)
103✔
64
        if err := WriteUint16(w, uint16(onionLen)); err != nil {
103✔
NEW
65
                return err
×
NEW
66
        }
×
67

68
        if err := WriteBytes(w, o.OnionBlob); err != nil {
103✔
NEW
69
                return err
×
NEW
70
        }
×
71

72
        return nil
103✔
73
}
74

75
// MsgType returns the integer uniquely identifying this message type on the
76
// wire.
77
func (o *OnionMessage) MsgType() MessageType {
103✔
78
        return MsgOnionMessage
103✔
79
}
103✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc