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

lightningnetwork / lnd / 15260961044

26 May 2025 07:40PM UTC coverage: 58.586% (+0.6%) from 57.977%
15260961044

Pull #9868

github

web-flow
Merge 68fbe502c into 93a6ab875
Pull Request #9868: PoC Onion messaging using `msgmux`

138 of 202 new or added lines in 7 files covered. (68.32%)

49 existing lines in 9 files now uncovered.

97608 of 166605 relevant lines covered (58.59%)

1.82 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 {
3✔
27

3✔
28
        return &OnionMessage{
3✔
29
                BlindingPoint: blindingPoint,
3✔
30
                OnionBlob:     onion,
3✔
31
        }
3✔
32
}
3✔
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 {
3✔
39
        if err := ReadElement(r, &o.BlindingPoint); err != nil {
3✔
NEW
40
                return err
×
NEW
41
        }
×
42

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

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

53
        return nil
3✔
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, pver uint32) error {
3✔
59
        if err := WriteElement(w, o.BlindingPoint); err != nil {
3✔
NEW
60
                return err
×
NEW
61
        }
×
62

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

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

72
        return nil
3✔
73
}
74

75
// MsgType returns the integer uniquely identifying this message type on the
76
// wire.
77
func (o *OnionMessage) MsgType() MessageType {
3✔
78
        return MsgOnionMessage
3✔
79
}
3✔
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