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

lightningnetwork / lnd / 19699489477

26 Nov 2025 09:50AM UTC coverage: 65.173%. First build
19699489477

Pull #10379

github

web-flow
Merge 88a1a8566 into a5f300683
Pull Request #10379: [g175:3] graph/db: continue prepping `models` for V2 data

245 of 435 new or added lines in 11 files covered. (56.32%)

137805 of 211444 relevant lines covered (65.17%)

20804.44 hits per line

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

70.27
/graph/db/models/channel_auth_proof.go
1
package models
2

3
import (
4
        "github.com/lightningnetwork/lnd/fn/v2"
5
        "github.com/lightningnetwork/lnd/lnwire"
6
)
7

8
// ChannelAuthProof is the authentication proof (the signature portion) for a
9
// channel.
10
//
11
// For v1 channels:
12
// Using the four node and bitcoin signatures contained in the struct, and some
13
// auxiliary knowledge (the funding script, node identities, and outpoint) nodes
14
// on the network are able to validate the authenticity and existence of a
15
// channel. Each of these signatures signs the following digest: chanID ||
16
// nodeID1 || nodeID2 || bitcoinKey1|| bitcoinKey2 || 2-byte-feature-len ||
17
// features.
18
//
19
// For v2 channels:
20
// The single schnorr signature signs the tlv fields of the v2 channel
21
// announcement message which are in the signed range.
22
type ChannelAuthProof struct {
23
        // Version is the version of the channel announcement.
24
        Version lnwire.GossipVersion
25

26
        // NodeSig1Bytes are the raw bytes of the first node signature encoded
27
        // in DER format.
28
        //
29
        // NOTE: v1 channel announcements only.
30
        NodeSig1Bytes fn.Option[[]byte]
31

32
        // NodeSig2Bytes are the raw bytes of the second node signature
33
        // encoded in DER format.
34
        //
35
        // NOTE: v1 channel announcements only.
36
        NodeSig2Bytes fn.Option[[]byte]
37

38
        // BitcoinSig1Bytes are the raw bytes of the first bitcoin signature
39
        // encoded in DER format.
40
        //
41
        // NOTE: v1 channel announcements only.
42
        BitcoinSig1Bytes fn.Option[[]byte]
43

44
        // BitcoinSig2Bytes are the raw bytes of the second bitcoin signature
45
        // encoded in DER format.
46
        //
47
        // NOTE: v1 channel announcements only.
48
        BitcoinSig2Bytes fn.Option[[]byte]
49

50
        // Signature is the raw bytes of the single schnorr signature for v2
51
        // channel announcements.
52
        //
53
        // NOTE: v2 channel announcements only.
54
        Signature fn.Option[[]byte]
55
}
56

57
// IsEmpty check is the authentication proof is empty Proof is empty.
58
func (c *ChannelAuthProof) IsEmpty() bool {
7,585✔
59
        // For v2 channel announcements, we only have a single signature.
7,585✔
60
        if c.Signature.IsSome() {
7,585✔
NEW
61
                return len(c.Signature.UnwrapOr([]byte{})) == 0
×
NEW
62
        }
×
63

64
        // For v1 channel announcements, we either have all four signatures or
65
        // none.
66
        return len(c.NodeSig1Bytes.UnwrapOr([]byte{})) == 0
7,585✔
67
}
68

69
// NewV1ChannelAuthProof creates a new ChannelAuthProof for a v1 channel
70
// announcement.
71
func NewV1ChannelAuthProof(nodeSig1, nodeSig2, bitcoinSig1,
72
        bitcoinSig2 []byte) *ChannelAuthProof {
1,196✔
73

1,196✔
74
        return &ChannelAuthProof{
1,196✔
75
                Version:          lnwire.GossipVersion1,
1,196✔
76
                NodeSig1Bytes:    fn.Some(nodeSig1),
1,196✔
77
                NodeSig2Bytes:    fn.Some(nodeSig2),
1,196✔
78
                BitcoinSig1Bytes: fn.Some(bitcoinSig1),
1,196✔
79
                BitcoinSig2Bytes: fn.Some(bitcoinSig2),
1,196✔
80
        }
1,196✔
81
}
1,196✔
82

83
// NewV2ChannelAuthProof creates a new ChannelAuthProof for a v2 channel
84
// announcement.
NEW
85
func NewV2ChannelAuthProof(signature []byte) *ChannelAuthProof {
×
NEW
86
        return &ChannelAuthProof{
×
NEW
87
                Version:   lnwire.GossipVersion2,
×
NEW
88
                Signature: fn.Some(signature),
×
NEW
89
        }
×
NEW
90
}
×
91

92
// NodeSig1 returns the first node signature bytes, or an empty slice if not
93
// present.
94
func (c *ChannelAuthProof) NodeSig1() []byte {
1,577✔
95
        return c.NodeSig1Bytes.UnwrapOr([]byte{})
1,577✔
96
}
1,577✔
97

98
// NodeSig2 returns the second node signature bytes, or an empty slice if not
99
// present.
100
func (c *ChannelAuthProof) NodeSig2() []byte {
1,577✔
101
        return c.NodeSig2Bytes.UnwrapOr([]byte{})
1,577✔
102
}
1,577✔
103

104
// BitcoinSig1 returns the first bitcoin signature bytes, or an empty slice if
105
// not present.
106
func (c *ChannelAuthProof) BitcoinSig1() []byte {
1,577✔
107
        return c.BitcoinSig1Bytes.UnwrapOr([]byte{})
1,577✔
108
}
1,577✔
109

110
// BitcoinSig2 returns the second bitcoin signature bytes, or an empty slice if
111
// not present.
112
func (c *ChannelAuthProof) BitcoinSig2() []byte {
1,577✔
113
        return c.BitcoinSig2Bytes.UnwrapOr([]byte{})
1,577✔
114
}
1,577✔
115

116
// Sig returns the v2 signature bytes, or an empty slice if not present.
NEW
117
func (c *ChannelAuthProof) Sig() []byte {
×
NEW
118
        return c.Signature.UnwrapOr([]byte{})
×
119
}
×
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