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

lightningnetwork / lnd / 13481548301

23 Feb 2025 09:06AM UTC coverage: 4.031% (-54.8%) from 58.825%
13481548301

Pull #9521

github

web-flow
Merge 1ffbe99fe into 5fe900d18
Pull Request #9521: unit: remove GOACC, use Go 1.20 native coverage functionality

2852 of 70750 relevant lines covered (4.03%)

0.92 hits per line

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

0.0
/sqldb/sqlc/invoices.sql.go
1
// Code generated by sqlc. DO NOT EDIT.
2
// versions:
3
//   sqlc v1.25.0
4
// source: invoices.sql
5

6
package sqlc
7

8
import (
9
        "context"
10
        "database/sql"
11
        "time"
12
)
13

14
const clearKVInvoiceHashIndex = `-- name: ClearKVInvoiceHashIndex :exec
15
DELETE FROM invoice_payment_hashes
16
`
17

18
func (q *Queries) ClearKVInvoiceHashIndex(ctx context.Context) error {
×
19
        _, err := q.db.ExecContext(ctx, clearKVInvoiceHashIndex)
×
20
        return err
×
21
}
×
22

23
const deleteCanceledInvoices = `-- name: DeleteCanceledInvoices :execresult
24
DELETE
25
FROM invoices
26
WHERE state = 2
27
`
28

29
func (q *Queries) DeleteCanceledInvoices(ctx context.Context) (sql.Result, error) {
×
30
        return q.db.ExecContext(ctx, deleteCanceledInvoices)
×
31
}
×
32

33
const deleteInvoice = `-- name: DeleteInvoice :execresult
34
DELETE 
35
FROM invoices 
36
WHERE (
37
    id = $1 OR 
38
    $1 IS NULL
39
) AND (
40
    hash = $2 OR 
41
    $2 IS NULL
42
) AND (
43
    settle_index = $3 OR 
44
    $3 IS NULL
45
) AND (
46
    payment_addr = $4 OR
47
    $4 IS NULL
48
)
49
`
50

51
type DeleteInvoiceParams struct {
52
        AddIndex    sql.NullInt64
53
        Hash        []byte
54
        SettleIndex sql.NullInt64
55
        PaymentAddr []byte
56
}
57

58
func (q *Queries) DeleteInvoice(ctx context.Context, arg DeleteInvoiceParams) (sql.Result, error) {
×
59
        return q.db.ExecContext(ctx, deleteInvoice,
×
60
                arg.AddIndex,
×
61
                arg.Hash,
×
62
                arg.SettleIndex,
×
63
                arg.PaymentAddr,
×
64
        )
×
65
}
×
66

67
const filterInvoices = `-- name: FilterInvoices :many
68
SELECT
69
    invoices.id, invoices.hash, invoices.preimage, invoices.settle_index, invoices.settled_at, invoices.memo, invoices.amount_msat, invoices.cltv_delta, invoices.expiry, invoices.payment_addr, invoices.payment_request, invoices.payment_request_hash, invoices.state, invoices.amount_paid_msat, invoices.is_amp, invoices.is_hodl, invoices.is_keysend, invoices.created_at
70
FROM invoices
71
WHERE (
72
    id >= $1 OR 
73
    $1 IS NULL
74
) AND (
75
    id <= $2 OR 
76
    $2 IS NULL
77
) AND (
78
    settle_index >= $3 OR
79
    $3 IS NULL
80
) AND (
81
    settle_index <= $4 OR
82
    $4 IS NULL
83
) AND (
84
    state = $5 OR 
85
    $5 IS NULL
86
) AND (
87
    created_at >= $6 OR
88
    $6 IS NULL
89
) AND (
90
    created_at < $7 OR 
91
    $7 IS NULL
92
) AND (
93
    CASE
94
        WHEN $8 = TRUE THEN (state = 0 OR state = 3)
95
        ELSE TRUE 
96
    END
97
)
98
ORDER BY
99
CASE
100
    WHEN $9 = FALSE OR $9 IS NULL THEN id
101
    ELSE NULL
102
    END ASC,
103
CASE
104
    WHEN $9 = TRUE THEN id
105
    ELSE NULL
106
END DESC
107
LIMIT $11 OFFSET $10
108
`
109

110
type FilterInvoicesParams struct {
111
        AddIndexGet    sql.NullInt64
112
        AddIndexLet    sql.NullInt64
113
        SettleIndexGet sql.NullInt64
114
        SettleIndexLet sql.NullInt64
115
        State          sql.NullInt16
116
        CreatedAfter   sql.NullTime
117
        CreatedBefore  sql.NullTime
118
        PendingOnly    interface{}
119
        Reverse        interface{}
120
        NumOffset      int32
121
        NumLimit       int32
122
}
123

124
func (q *Queries) FilterInvoices(ctx context.Context, arg FilterInvoicesParams) ([]Invoice, error) {
×
125
        rows, err := q.db.QueryContext(ctx, filterInvoices,
×
126
                arg.AddIndexGet,
×
127
                arg.AddIndexLet,
×
128
                arg.SettleIndexGet,
×
129
                arg.SettleIndexLet,
×
130
                arg.State,
×
131
                arg.CreatedAfter,
×
132
                arg.CreatedBefore,
×
133
                arg.PendingOnly,
×
134
                arg.Reverse,
×
135
                arg.NumOffset,
×
136
                arg.NumLimit,
×
137
        )
×
138
        if err != nil {
×
139
                return nil, err
×
140
        }
×
141
        defer rows.Close()
×
142
        var items []Invoice
×
143
        for rows.Next() {
×
144
                var i Invoice
×
145
                if err := rows.Scan(
×
146
                        &i.ID,
×
147
                        &i.Hash,
×
148
                        &i.Preimage,
×
149
                        &i.SettleIndex,
×
150
                        &i.SettledAt,
×
151
                        &i.Memo,
×
152
                        &i.AmountMsat,
×
153
                        &i.CltvDelta,
×
154
                        &i.Expiry,
×
155
                        &i.PaymentAddr,
×
156
                        &i.PaymentRequest,
×
157
                        &i.PaymentRequestHash,
×
158
                        &i.State,
×
159
                        &i.AmountPaidMsat,
×
160
                        &i.IsAmp,
×
161
                        &i.IsHodl,
×
162
                        &i.IsKeysend,
×
163
                        &i.CreatedAt,
×
164
                ); err != nil {
×
165
                        return nil, err
×
166
                }
×
167
                items = append(items, i)
×
168
        }
169
        if err := rows.Close(); err != nil {
×
170
                return nil, err
×
171
        }
×
172
        if err := rows.Err(); err != nil {
×
173
                return nil, err
×
174
        }
×
175
        return items, nil
×
176
}
177

178
const getInvoice = `-- name: GetInvoice :many
179

180
SELECT i.id, i.hash, i.preimage, i.settle_index, i.settled_at, i.memo, i.amount_msat, i.cltv_delta, i.expiry, i.payment_addr, i.payment_request, i.payment_request_hash, i.state, i.amount_paid_msat, i.is_amp, i.is_hodl, i.is_keysend, i.created_at
181
FROM invoices i
182
LEFT JOIN amp_sub_invoices a 
183
ON i.id = a.invoice_id
184
AND (
185
    a.set_id = $1 OR $1 IS NULL
186
)
187
WHERE (
188
    i.id = $2 OR 
189
    $2 IS NULL
190
) AND (
191
    i.hash = $3 OR 
192
    $3 IS NULL
193
) AND (
194
    i.payment_addr = $4 OR 
195
    $4 IS NULL
196
)
197
GROUP BY i.id
198
LIMIT 2
199
`
200

201
type GetInvoiceParams struct {
202
        SetID       []byte
203
        AddIndex    sql.NullInt64
204
        Hash        []byte
205
        PaymentAddr []byte
206
}
207

208
// This method may return more than one invoice if filter using multiple fields
209
// from different invoices. It is the caller's responsibility to ensure that
210
// we bubble up an error in those cases.
211
func (q *Queries) GetInvoice(ctx context.Context, arg GetInvoiceParams) ([]Invoice, error) {
×
212
        rows, err := q.db.QueryContext(ctx, getInvoice,
×
213
                arg.SetID,
×
214
                arg.AddIndex,
×
215
                arg.Hash,
×
216
                arg.PaymentAddr,
×
217
        )
×
218
        if err != nil {
×
219
                return nil, err
×
220
        }
×
221
        defer rows.Close()
×
222
        var items []Invoice
×
223
        for rows.Next() {
×
224
                var i Invoice
×
225
                if err := rows.Scan(
×
226
                        &i.ID,
×
227
                        &i.Hash,
×
228
                        &i.Preimage,
×
229
                        &i.SettleIndex,
×
230
                        &i.SettledAt,
×
231
                        &i.Memo,
×
232
                        &i.AmountMsat,
×
233
                        &i.CltvDelta,
×
234
                        &i.Expiry,
×
235
                        &i.PaymentAddr,
×
236
                        &i.PaymentRequest,
×
237
                        &i.PaymentRequestHash,
×
238
                        &i.State,
×
239
                        &i.AmountPaidMsat,
×
240
                        &i.IsAmp,
×
241
                        &i.IsHodl,
×
242
                        &i.IsKeysend,
×
243
                        &i.CreatedAt,
×
244
                ); err != nil {
×
245
                        return nil, err
×
246
                }
×
247
                items = append(items, i)
×
248
        }
249
        if err := rows.Close(); err != nil {
×
250
                return nil, err
×
251
        }
×
252
        if err := rows.Err(); err != nil {
×
253
                return nil, err
×
254
        }
×
255
        return items, nil
×
256
}
257

258
const getInvoiceByHash = `-- name: GetInvoiceByHash :one
259
SELECT i.id, i.hash, i.preimage, i.settle_index, i.settled_at, i.memo, i.amount_msat, i.cltv_delta, i.expiry, i.payment_addr, i.payment_request, i.payment_request_hash, i.state, i.amount_paid_msat, i.is_amp, i.is_hodl, i.is_keysend, i.created_at
260
FROM invoices i
261
WHERE i.hash = $1
262
`
263

264
func (q *Queries) GetInvoiceByHash(ctx context.Context, hash []byte) (Invoice, error) {
×
265
        row := q.db.QueryRowContext(ctx, getInvoiceByHash, hash)
×
266
        var i Invoice
×
267
        err := row.Scan(
×
268
                &i.ID,
×
269
                &i.Hash,
×
270
                &i.Preimage,
×
271
                &i.SettleIndex,
×
272
                &i.SettledAt,
×
273
                &i.Memo,
×
274
                &i.AmountMsat,
×
275
                &i.CltvDelta,
×
276
                &i.Expiry,
×
277
                &i.PaymentAddr,
×
278
                &i.PaymentRequest,
×
279
                &i.PaymentRequestHash,
×
280
                &i.State,
×
281
                &i.AmountPaidMsat,
×
282
                &i.IsAmp,
×
283
                &i.IsHodl,
×
284
                &i.IsKeysend,
×
285
                &i.CreatedAt,
×
286
        )
×
287
        return i, err
×
288
}
×
289

290
const getInvoiceBySetID = `-- name: GetInvoiceBySetID :many
291
SELECT i.id, i.hash, i.preimage, i.settle_index, i.settled_at, i.memo, i.amount_msat, i.cltv_delta, i.expiry, i.payment_addr, i.payment_request, i.payment_request_hash, i.state, i.amount_paid_msat, i.is_amp, i.is_hodl, i.is_keysend, i.created_at
292
FROM invoices i
293
INNER JOIN amp_sub_invoices a 
294
ON i.id = a.invoice_id AND a.set_id = $1
295
`
296

297
func (q *Queries) GetInvoiceBySetID(ctx context.Context, setID []byte) ([]Invoice, error) {
×
298
        rows, err := q.db.QueryContext(ctx, getInvoiceBySetID, setID)
×
299
        if err != nil {
×
300
                return nil, err
×
301
        }
×
302
        defer rows.Close()
×
303
        var items []Invoice
×
304
        for rows.Next() {
×
305
                var i Invoice
×
306
                if err := rows.Scan(
×
307
                        &i.ID,
×
308
                        &i.Hash,
×
309
                        &i.Preimage,
×
310
                        &i.SettleIndex,
×
311
                        &i.SettledAt,
×
312
                        &i.Memo,
×
313
                        &i.AmountMsat,
×
314
                        &i.CltvDelta,
×
315
                        &i.Expiry,
×
316
                        &i.PaymentAddr,
×
317
                        &i.PaymentRequest,
×
318
                        &i.PaymentRequestHash,
×
319
                        &i.State,
×
320
                        &i.AmountPaidMsat,
×
321
                        &i.IsAmp,
×
322
                        &i.IsHodl,
×
323
                        &i.IsKeysend,
×
324
                        &i.CreatedAt,
×
325
                ); err != nil {
×
326
                        return nil, err
×
327
                }
×
328
                items = append(items, i)
×
329
        }
330
        if err := rows.Close(); err != nil {
×
331
                return nil, err
×
332
        }
×
333
        if err := rows.Err(); err != nil {
×
334
                return nil, err
×
335
        }
×
336
        return items, nil
×
337
}
338

339
const getInvoiceFeatures = `-- name: GetInvoiceFeatures :many
340
SELECT feature, invoice_id
341
FROM invoice_features
342
WHERE invoice_id = $1
343
`
344

345
func (q *Queries) GetInvoiceFeatures(ctx context.Context, invoiceID int64) ([]InvoiceFeature, error) {
×
346
        rows, err := q.db.QueryContext(ctx, getInvoiceFeatures, invoiceID)
×
347
        if err != nil {
×
348
                return nil, err
×
349
        }
×
350
        defer rows.Close()
×
351
        var items []InvoiceFeature
×
352
        for rows.Next() {
×
353
                var i InvoiceFeature
×
354
                if err := rows.Scan(&i.Feature, &i.InvoiceID); err != nil {
×
355
                        return nil, err
×
356
                }
×
357
                items = append(items, i)
×
358
        }
359
        if err := rows.Close(); err != nil {
×
360
                return nil, err
×
361
        }
×
362
        if err := rows.Err(); err != nil {
×
363
                return nil, err
×
364
        }
×
365
        return items, nil
×
366
}
367

368
const getInvoiceHTLCCustomRecords = `-- name: GetInvoiceHTLCCustomRecords :many
369
SELECT ihcr.htlc_id, key, value
370
FROM invoice_htlcs ih JOIN invoice_htlc_custom_records ihcr ON ih.id=ihcr.htlc_id 
371
WHERE ih.invoice_id = $1
372
`
373

374
type GetInvoiceHTLCCustomRecordsRow struct {
375
        HtlcID int64
376
        Key    int64
377
        Value  []byte
378
}
379

380
func (q *Queries) GetInvoiceHTLCCustomRecords(ctx context.Context, invoiceID int64) ([]GetInvoiceHTLCCustomRecordsRow, error) {
×
381
        rows, err := q.db.QueryContext(ctx, getInvoiceHTLCCustomRecords, invoiceID)
×
382
        if err != nil {
×
383
                return nil, err
×
384
        }
×
385
        defer rows.Close()
×
386
        var items []GetInvoiceHTLCCustomRecordsRow
×
387
        for rows.Next() {
×
388
                var i GetInvoiceHTLCCustomRecordsRow
×
389
                if err := rows.Scan(&i.HtlcID, &i.Key, &i.Value); err != nil {
×
390
                        return nil, err
×
391
                }
×
392
                items = append(items, i)
×
393
        }
394
        if err := rows.Close(); err != nil {
×
395
                return nil, err
×
396
        }
×
397
        if err := rows.Err(); err != nil {
×
398
                return nil, err
×
399
        }
×
400
        return items, nil
×
401
}
402

403
const getInvoiceHTLCs = `-- name: GetInvoiceHTLCs :many
404
SELECT id, chan_id, htlc_id, amount_msat, total_mpp_msat, accept_height, accept_time, expiry_height, state, resolve_time, invoice_id
405
FROM invoice_htlcs
406
WHERE invoice_id = $1
407
`
408

409
func (q *Queries) GetInvoiceHTLCs(ctx context.Context, invoiceID int64) ([]InvoiceHtlc, error) {
×
410
        rows, err := q.db.QueryContext(ctx, getInvoiceHTLCs, invoiceID)
×
411
        if err != nil {
×
412
                return nil, err
×
413
        }
×
414
        defer rows.Close()
×
415
        var items []InvoiceHtlc
×
416
        for rows.Next() {
×
417
                var i InvoiceHtlc
×
418
                if err := rows.Scan(
×
419
                        &i.ID,
×
420
                        &i.ChanID,
×
421
                        &i.HtlcID,
×
422
                        &i.AmountMsat,
×
423
                        &i.TotalMppMsat,
×
424
                        &i.AcceptHeight,
×
425
                        &i.AcceptTime,
×
426
                        &i.ExpiryHeight,
×
427
                        &i.State,
×
428
                        &i.ResolveTime,
×
429
                        &i.InvoiceID,
×
430
                ); err != nil {
×
431
                        return nil, err
×
432
                }
×
433
                items = append(items, i)
×
434
        }
435
        if err := rows.Close(); err != nil {
×
436
                return nil, err
×
437
        }
×
438
        if err := rows.Err(); err != nil {
×
439
                return nil, err
×
440
        }
×
441
        return items, nil
×
442
}
443

444
const getKVInvoicePaymentHashByAddIndex = `-- name: GetKVInvoicePaymentHashByAddIndex :one
445
SELECT hash
446
FROM invoice_payment_hashes
447
WHERE add_index = $1
448
`
449

450
func (q *Queries) GetKVInvoicePaymentHashByAddIndex(ctx context.Context, addIndex int64) ([]byte, error) {
×
451
        row := q.db.QueryRowContext(ctx, getKVInvoicePaymentHashByAddIndex, addIndex)
×
452
        var hash []byte
×
453
        err := row.Scan(&hash)
×
454
        return hash, err
×
455
}
×
456

457
const insertInvoice = `-- name: InsertInvoice :one
458
INSERT INTO invoices (
459
    hash, preimage, memo, amount_msat, cltv_delta, expiry, payment_addr, 
460
    payment_request, payment_request_hash, state, amount_paid_msat, is_amp,
461
    is_hodl, is_keysend, created_at
462
) VALUES (
463
    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15
464
) RETURNING id
465
`
466

467
type InsertInvoiceParams struct {
468
        Hash               []byte
469
        Preimage           []byte
470
        Memo               sql.NullString
471
        AmountMsat         int64
472
        CltvDelta          sql.NullInt32
473
        Expiry             int32
474
        PaymentAddr        []byte
475
        PaymentRequest     sql.NullString
476
        PaymentRequestHash []byte
477
        State              int16
478
        AmountPaidMsat     int64
479
        IsAmp              bool
480
        IsHodl             bool
481
        IsKeysend          bool
482
        CreatedAt          time.Time
483
}
484

485
func (q *Queries) InsertInvoice(ctx context.Context, arg InsertInvoiceParams) (int64, error) {
×
486
        row := q.db.QueryRowContext(ctx, insertInvoice,
×
487
                arg.Hash,
×
488
                arg.Preimage,
×
489
                arg.Memo,
×
490
                arg.AmountMsat,
×
491
                arg.CltvDelta,
×
492
                arg.Expiry,
×
493
                arg.PaymentAddr,
×
494
                arg.PaymentRequest,
×
495
                arg.PaymentRequestHash,
×
496
                arg.State,
×
497
                arg.AmountPaidMsat,
×
498
                arg.IsAmp,
×
499
                arg.IsHodl,
×
500
                arg.IsKeysend,
×
501
                arg.CreatedAt,
×
502
        )
×
503
        var id int64
×
504
        err := row.Scan(&id)
×
505
        return id, err
×
506
}
×
507

508
const insertInvoiceFeature = `-- name: InsertInvoiceFeature :exec
509
INSERT INTO invoice_features (
510
    invoice_id, feature
511
) VALUES (
512
    $1, $2
513
)
514
`
515

516
type InsertInvoiceFeatureParams struct {
517
        InvoiceID int64
518
        Feature   int32
519
}
520

521
func (q *Queries) InsertInvoiceFeature(ctx context.Context, arg InsertInvoiceFeatureParams) error {
×
522
        _, err := q.db.ExecContext(ctx, insertInvoiceFeature, arg.InvoiceID, arg.Feature)
×
523
        return err
×
524
}
×
525

526
const insertInvoiceHTLC = `-- name: InsertInvoiceHTLC :one
527
INSERT INTO invoice_htlcs (
528
    htlc_id, chan_id, amount_msat, total_mpp_msat, accept_height, accept_time,
529
    expiry_height, state, resolve_time, invoice_id
530
) VALUES (
531
    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10
532
) RETURNING id
533
`
534

535
type InsertInvoiceHTLCParams struct {
536
        HtlcID       int64
537
        ChanID       string
538
        AmountMsat   int64
539
        TotalMppMsat sql.NullInt64
540
        AcceptHeight int32
541
        AcceptTime   time.Time
542
        ExpiryHeight int32
543
        State        int16
544
        ResolveTime  sql.NullTime
545
        InvoiceID    int64
546
}
547

548
func (q *Queries) InsertInvoiceHTLC(ctx context.Context, arg InsertInvoiceHTLCParams) (int64, error) {
×
549
        row := q.db.QueryRowContext(ctx, insertInvoiceHTLC,
×
550
                arg.HtlcID,
×
551
                arg.ChanID,
×
552
                arg.AmountMsat,
×
553
                arg.TotalMppMsat,
×
554
                arg.AcceptHeight,
×
555
                arg.AcceptTime,
×
556
                arg.ExpiryHeight,
×
557
                arg.State,
×
558
                arg.ResolveTime,
×
559
                arg.InvoiceID,
×
560
        )
×
561
        var id int64
×
562
        err := row.Scan(&id)
×
563
        return id, err
×
564
}
×
565

566
const insertInvoiceHTLCCustomRecord = `-- name: InsertInvoiceHTLCCustomRecord :exec
567
INSERT INTO invoice_htlc_custom_records (
568
    key, value, htlc_id 
569
) VALUES (
570
    $1, $2, $3
571
)
572
`
573

574
type InsertInvoiceHTLCCustomRecordParams struct {
575
        Key    int64
576
        Value  []byte
577
        HtlcID int64
578
}
579

580
func (q *Queries) InsertInvoiceHTLCCustomRecord(ctx context.Context, arg InsertInvoiceHTLCCustomRecordParams) error {
×
581
        _, err := q.db.ExecContext(ctx, insertInvoiceHTLCCustomRecord, arg.Key, arg.Value, arg.HtlcID)
×
582
        return err
×
583
}
×
584

585
const insertKVInvoiceKeyAndAddIndex = `-- name: InsertKVInvoiceKeyAndAddIndex :exec
586
INSERT INTO invoice_payment_hashes (
587
    id, add_index
588
) VALUES (
589
    $1, $2
590
)
591
`
592

593
type InsertKVInvoiceKeyAndAddIndexParams struct {
594
        ID       int64
595
        AddIndex int64
596
}
597

598
func (q *Queries) InsertKVInvoiceKeyAndAddIndex(ctx context.Context, arg InsertKVInvoiceKeyAndAddIndexParams) error {
×
599
        _, err := q.db.ExecContext(ctx, insertKVInvoiceKeyAndAddIndex, arg.ID, arg.AddIndex)
×
600
        return err
×
601
}
×
602

603
const insertMigratedInvoice = `-- name: InsertMigratedInvoice :one
604
INSERT INTO invoices (
605
    hash, preimage, settle_index, settled_at, memo, amount_msat, cltv_delta, 
606
    expiry, payment_addr, payment_request, payment_request_hash, state, 
607
    amount_paid_msat, is_amp, is_hodl, is_keysend, created_at
608
) VALUES (
609
    $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17
610
) RETURNING id
611
`
612

613
type InsertMigratedInvoiceParams struct {
614
        Hash               []byte
615
        Preimage           []byte
616
        SettleIndex        sql.NullInt64
617
        SettledAt          sql.NullTime
618
        Memo               sql.NullString
619
        AmountMsat         int64
620
        CltvDelta          sql.NullInt32
621
        Expiry             int32
622
        PaymentAddr        []byte
623
        PaymentRequest     sql.NullString
624
        PaymentRequestHash []byte
625
        State              int16
626
        AmountPaidMsat     int64
627
        IsAmp              bool
628
        IsHodl             bool
629
        IsKeysend          bool
630
        CreatedAt          time.Time
631
}
632

633
func (q *Queries) InsertMigratedInvoice(ctx context.Context, arg InsertMigratedInvoiceParams) (int64, error) {
×
634
        row := q.db.QueryRowContext(ctx, insertMigratedInvoice,
×
635
                arg.Hash,
×
636
                arg.Preimage,
×
637
                arg.SettleIndex,
×
638
                arg.SettledAt,
×
639
                arg.Memo,
×
640
                arg.AmountMsat,
×
641
                arg.CltvDelta,
×
642
                arg.Expiry,
×
643
                arg.PaymentAddr,
×
644
                arg.PaymentRequest,
×
645
                arg.PaymentRequestHash,
×
646
                arg.State,
×
647
                arg.AmountPaidMsat,
×
648
                arg.IsAmp,
×
649
                arg.IsHodl,
×
650
                arg.IsKeysend,
×
651
                arg.CreatedAt,
×
652
        )
×
653
        var id int64
×
654
        err := row.Scan(&id)
×
655
        return id, err
×
656
}
×
657

658
const nextInvoiceSettleIndex = `-- name: NextInvoiceSettleIndex :one
659
UPDATE invoice_sequences SET current_value = current_value + 1
660
WHERE name = 'settle_index'
661
RETURNING current_value
662
`
663

664
func (q *Queries) NextInvoiceSettleIndex(ctx context.Context) (int64, error) {
×
665
        row := q.db.QueryRowContext(ctx, nextInvoiceSettleIndex)
×
666
        var current_value int64
×
667
        err := row.Scan(&current_value)
×
668
        return current_value, err
×
669
}
×
670

671
const setKVInvoicePaymentHash = `-- name: SetKVInvoicePaymentHash :exec
672
UPDATE invoice_payment_hashes
673
SET hash = $2
674
WHERE id = $1
675
`
676

677
type SetKVInvoicePaymentHashParams struct {
678
        ID   int64
679
        Hash []byte
680
}
681

682
func (q *Queries) SetKVInvoicePaymentHash(ctx context.Context, arg SetKVInvoicePaymentHashParams) error {
×
683
        _, err := q.db.ExecContext(ctx, setKVInvoicePaymentHash, arg.ID, arg.Hash)
×
684
        return err
×
685
}
×
686

687
const updateInvoiceAmountPaid = `-- name: UpdateInvoiceAmountPaid :execresult
688
UPDATE invoices
689
SET amount_paid_msat = $2
690
WHERE id = $1
691
`
692

693
type UpdateInvoiceAmountPaidParams struct {
694
        ID             int64
695
        AmountPaidMsat int64
696
}
697

698
func (q *Queries) UpdateInvoiceAmountPaid(ctx context.Context, arg UpdateInvoiceAmountPaidParams) (sql.Result, error) {
×
699
        return q.db.ExecContext(ctx, updateInvoiceAmountPaid, arg.ID, arg.AmountPaidMsat)
×
700
}
×
701

702
const updateInvoiceHTLC = `-- name: UpdateInvoiceHTLC :exec
703
UPDATE invoice_htlcs 
704
SET state=$4, resolve_time=$5
705
WHERE htlc_id = $1 AND chan_id = $2 AND invoice_id = $3
706
`
707

708
type UpdateInvoiceHTLCParams struct {
709
        HtlcID      int64
710
        ChanID      string
711
        InvoiceID   int64
712
        State       int16
713
        ResolveTime sql.NullTime
714
}
715

716
func (q *Queries) UpdateInvoiceHTLC(ctx context.Context, arg UpdateInvoiceHTLCParams) error {
×
717
        _, err := q.db.ExecContext(ctx, updateInvoiceHTLC,
×
718
                arg.HtlcID,
×
719
                arg.ChanID,
×
720
                arg.InvoiceID,
×
721
                arg.State,
×
722
                arg.ResolveTime,
×
723
        )
×
724
        return err
×
725
}
×
726

727
const updateInvoiceHTLCs = `-- name: UpdateInvoiceHTLCs :exec
728
UPDATE invoice_htlcs 
729
SET state=$2, resolve_time=$3
730
WHERE invoice_id = $1 AND resolve_time IS NULL
731
`
732

733
type UpdateInvoiceHTLCsParams struct {
734
        InvoiceID   int64
735
        State       int16
736
        ResolveTime sql.NullTime
737
}
738

739
func (q *Queries) UpdateInvoiceHTLCs(ctx context.Context, arg UpdateInvoiceHTLCsParams) error {
×
740
        _, err := q.db.ExecContext(ctx, updateInvoiceHTLCs, arg.InvoiceID, arg.State, arg.ResolveTime)
×
741
        return err
×
742
}
×
743

744
const updateInvoiceState = `-- name: UpdateInvoiceState :execresult
745
UPDATE invoices
746
SET state = $2,
747
    preimage = COALESCE(preimage, $3),
748
    settle_index = COALESCE(settle_index, $4),
749
    settled_at = COALESCE(settled_at, $5)
750
WHERE id = $1
751
`
752

753
type UpdateInvoiceStateParams struct {
754
        ID          int64
755
        State       int16
756
        Preimage    []byte
757
        SettleIndex sql.NullInt64
758
        SettledAt   sql.NullTime
759
}
760

761
func (q *Queries) UpdateInvoiceState(ctx context.Context, arg UpdateInvoiceStateParams) (sql.Result, error) {
×
762
        return q.db.ExecContext(ctx, updateInvoiceState,
×
763
                arg.ID,
×
764
                arg.State,
×
765
                arg.Preimage,
×
766
                arg.SettleIndex,
×
767
                arg.SettledAt,
×
768
        )
×
769
}
×
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

© 2026 Coveralls, Inc