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

lightningnetwork / lnd / 13408822928

19 Feb 2025 08:59AM UTC coverage: 41.123% (-17.7%) from 58.794%
13408822928

Pull #9521

github

web-flow
Merge d2f397b3c into 0e8786348
Pull Request #9521: unit: remove GOACC, use Go 1.20 native coverage functionality

92496 of 224923 relevant lines covered (41.12%)

18825.83 hits per line

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

65.38
/lnwire/musig2.go
1
package lnwire
2

3
import (
4
        "io"
5

6
        "github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
7
        "github.com/lightningnetwork/lnd/tlv"
8
)
9

10
// NonceRecordTypeT is the TLV type used to encode a local musig2 nonce.
11
type NonceRecordTypeT = tlv.TlvType4
12

13
// nonceRecordType is the TLV (integer) type used to encode a local musig2
14
// nonce.
15
var nonceRecordType tlv.Type = (NonceRecordTypeT)(nil).TypeVal()
16

17
type (
18
        // Musig2Nonce represents a musig2 public nonce, which is the
19
        // concatenation of two EC points serialized in compressed format.
20
        Musig2Nonce [musig2.PubNonceSize]byte
21

22
        // Musig2NonceTLV is a TLV type that can be used to encode/decode a
23
        // musig2 nonce. This is an optional TLV.
24
        Musig2NonceTLV = tlv.RecordT[NonceRecordTypeT, Musig2Nonce]
25

26
        // OptMusig2NonceTLV is a TLV type that can be used to encode/decode a
27
        // musig2 nonce.
28
        OptMusig2NonceTLV = tlv.OptionalRecordT[NonceRecordTypeT, Musig2Nonce]
29
)
30

31
// Record returns a TLV record that can be used to encode/decode the musig2
32
// nonce from a given TLV stream.
33
func (m *Musig2Nonce) Record() tlv.Record {
2,005✔
34
        return tlv.MakeStaticRecord(
2,005✔
35
                nonceRecordType, m, musig2.PubNonceSize,
2,005✔
36
                nonceTypeEncoder, nonceTypeDecoder,
2,005✔
37
        )
2,005✔
38
}
2,005✔
39

40
// nonceTypeEncoder is a custom TLV encoder for the Musig2Nonce type.
41
func nonceTypeEncoder(w io.Writer, val interface{}, _ *[8]byte) error {
475✔
42
        if v, ok := val.(*Musig2Nonce); ok {
950✔
43
                _, err := w.Write(v[:])
475✔
44
                return err
475✔
45
        }
475✔
46

47
        return tlv.NewTypeForEncodingErr(val, "lnwire.Musig2Nonce")
×
48
}
49

50
// nonceTypeDecoder is a custom TLV decoder for the Musig2Nonce record.
51
func nonceTypeDecoder(r io.Reader, val interface{}, _ *[8]byte,
52
        l uint64) error {
523✔
53

523✔
54
        if v, ok := val.(*Musig2Nonce); ok {
1,046✔
55
                _, err := io.ReadFull(r, v[:])
523✔
56
                return err
523✔
57
        }
523✔
58

59
        return tlv.NewTypeForDecodingErr(
×
60
                val, "lnwire.Musig2Nonce", l, musig2.PubNonceSize,
×
61
        )
×
62
}
63

64
// SomeMusig2Nonce is a helper function that creates a musig2 nonce TLV.
65
func SomeMusig2Nonce(nonce Musig2Nonce) OptMusig2NonceTLV {
×
66
        return tlv.SomeRecordT(
×
67
                tlv.NewRecordT[NonceRecordTypeT, Musig2Nonce](nonce),
×
68
        )
×
69
}
×
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