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

lightningnetwork / lnd / 19263483187

11 Nov 2025 11:01AM UTC coverage: 66.351%. First build
19263483187

Pull #10287

github

web-flow
Merge 6488a57e2 into a0044baa8
Pull Request #10287: [Part 2|*] Implement First Part for SQL Backend functions

0 of 958 new or added lines in 4 files covered. (0.0%)

137264 of 206874 relevant lines covered (66.35%)

21157.83 hits per line

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

21.05
/sqldb/sqlc/db_custom.go
1
package sqlc
2

3
import (
4
        "fmt"
5
        "strings"
6
)
7

8
// makeQueryParams generates a string of query parameters for a SQL query. It is
9
// meant to replace the `?` placeholders in a SQL query with numbered parameters
10
// like `$1`, `$2`, etc. This is required for the sqlc /*SLICE:<field_name>*/
11
// workaround. See scripts/gen_sqlc_docker.sh for more details.
12
func makeQueryParams(numTotalArgs, numListArgs int) string {
5✔
13
        if numListArgs == 0 {
6✔
14
                return ""
1✔
15
        }
1✔
16

17
        var b strings.Builder
4✔
18

4✔
19
        // Pre-allocate a rough estimation of the buffer size to avoid
4✔
20
        // re-allocations. A parameter like $1000, takes 6 bytes.
4✔
21
        b.Grow(numListArgs * 6)
4✔
22

4✔
23
        diff := numTotalArgs - numListArgs
4✔
24
        for i := 0; i < numListArgs; i++ {
14✔
25
                if i > 0 {
16✔
26
                        // We don't need to check the error here because the
6✔
27
                        // WriteString method of strings.Builder always returns
6✔
28
                        // nil.
6✔
29
                        _, _ = b.WriteString(",")
6✔
30
                }
6✔
31

32
                // We don't need to check the error here because the
33
                // Write method (called by fmt.Fprintf) of strings.Builder
34
                // always returns nil.
35
                _, _ = fmt.Fprintf(&b, "$%d", i+diff+1)
10✔
36
        }
37

38
        return b.String()
4✔
39
}
40

41
// ChannelAndNodes is an interface that provides access to a channel and its
42
// two nodes.
43
type ChannelAndNodes interface {
44
        // Channel returns the GraphChannel associated with this interface.
45
        Channel() GraphChannel
46

47
        // Node1 returns the first GraphNode associated with this channel.
48
        Node1() GraphNode
49

50
        // Node2 returns the second GraphNode associated with this channel.
51
        Node2() GraphNode
52
}
53

54
// Channel returns the GraphChannel associated with this interface.
55
//
56
// NOTE: This method is part of the ChannelAndNodes interface.
57
func (r GetChannelsByPolicyLastUpdateRangeRow) Channel() GraphChannel {
×
58
        return r.GraphChannel
×
59
}
×
60

61
// Node1 returns the first GraphNode associated with this channel.
62
//
63
// NOTE: This method is part of the ChannelAndNodes interface.
64
func (r GetChannelsByPolicyLastUpdateRangeRow) Node1() GraphNode {
×
65
        return r.GraphNode
×
66
}
×
67

68
// Node2 returns the second GraphNode associated with this channel.
69
//
70
// NOTE: This method is part of the ChannelAndNodes interface.
71
func (r GetChannelsByPolicyLastUpdateRangeRow) Node2() GraphNode {
×
72
        return r.GraphNode_2
×
73
}
×
74

75
// ChannelAndNodeIDs is an interface that provides access to a channel and its
76
// two node public keys.
77
type ChannelAndNodeIDs interface {
78
        // Channel returns the GraphChannel associated with this interface.
79
        Channel() GraphChannel
80

81
        // Node1Pub returns the public key of the first node as a byte slice.
82
        Node1Pub() []byte
83

84
        // Node2Pub returns the public key of the second node as a byte slice.
85
        Node2Pub() []byte
86
}
87

88
// Channel returns the GraphChannel associated with this interface.
89
//
90
// NOTE: This method is part of the ChannelAndNodeIDs interface.
91
func (r GetChannelsBySCIDWithPoliciesRow) Channel() GraphChannel {
×
92
        return r.GraphChannel
×
93
}
×
94

95
// Node1Pub returns the public key of the first node as a byte slice.
96
//
97
// NOTE: This method is part of the ChannelAndNodeIDs interface.
98
func (r GetChannelsBySCIDWithPoliciesRow) Node1Pub() []byte {
×
99
        return r.GraphNode.PubKey
×
100
}
×
101

102
// Node2Pub returns the public key of the second node as a byte slice.
103
//
104
// NOTE: This method is part of the ChannelAndNodeIDs interface.
105
func (r GetChannelsBySCIDWithPoliciesRow) Node2Pub() []byte {
×
106
        return r.GraphNode_2.PubKey
×
107
}
×
108

109
// Node1 returns the first GraphNode associated with this channel.
110
//
111
// NOTE: This method is part of the ChannelAndNodes interface.
112
func (r GetChannelsBySCIDWithPoliciesRow) Node1() GraphNode {
×
113
        return r.GraphNode
×
114
}
×
115

116
// Node2 returns the second GraphNode associated with this channel.
117
//
118
// NOTE: This method is part of the ChannelAndNodes interface.
119
func (r GetChannelsBySCIDWithPoliciesRow) Node2() GraphNode {
×
120
        return r.GraphNode_2
×
121
}
×
122

123
// Channel returns the GraphChannel associated with this interface.
124
//
125
// NOTE: This method is part of the ChannelAndNodeIDs interface.
126
func (r GetChannelsByOutpointsRow) Channel() GraphChannel {
×
127
        return r.GraphChannel
×
128
}
×
129

130
// Node1Pub returns the public key of the first node as a byte slice.
131
//
132
// NOTE: This method is part of the ChannelAndNodeIDs interface.
133
func (r GetChannelsByOutpointsRow) Node1Pub() []byte {
×
134
        return r.Node1Pubkey
×
135
}
×
136

137
// Node2Pub returns the public key of the second node as a byte slice.
138
//
139
// NOTE: This method is part of the ChannelAndNodeIDs interface.
140
func (r GetChannelsByOutpointsRow) Node2Pub() []byte {
×
141
        return r.Node2Pubkey
×
142
}
×
143

144
// Channel returns the GraphChannel associated with this interface.
145
//
146
// NOTE: This method is part of the ChannelAndNodeIDs interface.
147
func (r GetChannelsBySCIDRangeRow) Channel() GraphChannel {
×
148
        return r.GraphChannel
×
149
}
×
150

151
// Node1Pub returns the public key of the first node as a byte slice.
152
//
153
// NOTE: This method is part of the ChannelAndNodeIDs interface.
154
func (r GetChannelsBySCIDRangeRow) Node1Pub() []byte {
×
155
        return r.Node1PubKey
×
156
}
×
157

158
// Node2Pub returns the public key of the second node as a byte slice.
159
//
160
// NOTE: This method is part of the ChannelAndNodeIDs interface.
161
func (r GetChannelsBySCIDRangeRow) Node2Pub() []byte {
×
162
        return r.Node2PubKey
×
163
}
×
164

165
// PaymentAndIntent is an interface that provides access to a payment and its
166
// associated payment intent.
167
type PaymentAndIntent interface {
168
        // GetPayment returns the Payment associated with this interface.
169
        GetPayment() Payment
170

171
        // GetPaymentIntent returns the PaymentIntent associated with this payment.
172
        GetPaymentIntent() PaymentIntent
173
}
174

175
// GetPayment returns the Payment associated with this interface.
176
//
177
// NOTE: This method is part of the PaymentAndIntent interface.
NEW
178
func (r FilterPaymentsRow) GetPayment() Payment {
×
NEW
179
        return r.Payment
×
NEW
180
}
×
181

182
// GetPaymentIntent returns the PaymentIntent associated with this payment.
183
// If the payment has no intent (IntentType is NULL), this returns a zero-value
184
// PaymentIntent.
185
//
186
// NOTE: This method is part of the PaymentAndIntent interface.
NEW
187
func (r FilterPaymentsRow) GetPaymentIntent() PaymentIntent {
×
NEW
188
        if !r.IntentType.Valid {
×
NEW
189
                return PaymentIntent{}
×
NEW
190
        }
×
NEW
191
        return PaymentIntent{
×
NEW
192
                IntentType:    r.IntentType.Int16,
×
NEW
193
                IntentPayload: r.IntentPayload,
×
NEW
194
        }
×
195
}
196

197
// GetPayment returns the Payment associated with this interface.
198
//
199
// NOTE: This method is part of the PaymentAndIntent interface.
NEW
200
func (r FetchPaymentRow) GetPayment() Payment {
×
NEW
201
        return r.Payment
×
NEW
202
}
×
203

204
// GetPaymentIntent returns the PaymentIntent associated with this payment.
205
// If the payment has no intent (IntentType is NULL), this returns a zero-value
206
// PaymentIntent.
207
//
208
// NOTE: This method is part of the PaymentAndIntent interface.
NEW
209
func (r FetchPaymentRow) GetPaymentIntent() PaymentIntent {
×
NEW
210
        if !r.IntentType.Valid {
×
NEW
211
                return PaymentIntent{}
×
NEW
212
        }
×
NEW
213
        return PaymentIntent{
×
NEW
214
                IntentType:    r.IntentType.Int16,
×
NEW
215
                IntentPayload: r.IntentPayload,
×
NEW
216
        }
×
217
}
218

219
// GetPayment returns the Payment associated with this interface.
220
//
221
// NOTE: This method is part of the PaymentAndIntent interface.
NEW
222
func (r FetchPaymentsByIDsRow) GetPayment() Payment {
×
NEW
223
        return r.Payment
×
NEW
224
}
×
225

226
// GetPaymentIntent returns the PaymentIntent associated with this payment.
227
// If the payment has no intent (IntentType is NULL), this returns a zero-value
228
// PaymentIntent.
229
//
230
// NOTE: This method is part of the PaymentAndIntent interface.
NEW
231
func (r FetchPaymentsByIDsRow) GetPaymentIntent() PaymentIntent {
×
NEW
232
        if !r.IntentType.Valid {
×
NEW
233
                return PaymentIntent{}
×
NEW
234
        }
×
NEW
235
        return PaymentIntent{
×
NEW
236
                IntentType:    r.IntentType.Int16,
×
NEW
237
                IntentPayload: r.IntentPayload,
×
NEW
238
        }
×
239
}
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