mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-03 08:20:30 +02:00
multi: add call to directly insert an AMP sub-invoice
This commit is contained in:
parent
91c3e1496f
commit
115f96c29a
@ -79,6 +79,10 @@ type SQLInvoiceQueries interface { //nolint:interfacebloat
|
||||
UpsertAMPSubInvoice(ctx context.Context,
|
||||
arg sqlc.UpsertAMPSubInvoiceParams) (sql.Result, error)
|
||||
|
||||
// TODO(bhandras): remove this once migrations have been separated out.
|
||||
InsertAMPSubInvoice(ctx context.Context,
|
||||
arg sqlc.InsertAMPSubInvoiceParams) error
|
||||
|
||||
UpdateAMPSubInvoiceState(ctx context.Context,
|
||||
arg sqlc.UpdateAMPSubInvoiceStateParams) error
|
||||
|
||||
|
@ -235,6 +235,35 @@ func (q *Queries) GetAMPInvoiceID(ctx context.Context, setID []byte) (int64, err
|
||||
return invoice_id, err
|
||||
}
|
||||
|
||||
const insertAMPSubInvoice = `-- name: InsertAMPSubInvoice :exec
|
||||
INSERT INTO amp_sub_invoices (
|
||||
set_id, state, created_at, settled_at, settle_index, invoice_id
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6
|
||||
)
|
||||
`
|
||||
|
||||
type InsertAMPSubInvoiceParams struct {
|
||||
SetID []byte
|
||||
State int16
|
||||
CreatedAt time.Time
|
||||
SettledAt sql.NullTime
|
||||
SettleIndex sql.NullInt64
|
||||
InvoiceID int64
|
||||
}
|
||||
|
||||
func (q *Queries) InsertAMPSubInvoice(ctx context.Context, arg InsertAMPSubInvoiceParams) error {
|
||||
_, err := q.db.ExecContext(ctx, insertAMPSubInvoice,
|
||||
arg.SetID,
|
||||
arg.State,
|
||||
arg.CreatedAt,
|
||||
arg.SettledAt,
|
||||
arg.SettleIndex,
|
||||
arg.InvoiceID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertAMPSubInvoiceHTLC = `-- name: InsertAMPSubInvoiceHTLC :exec
|
||||
INSERT INTO amp_sub_invoice_htlcs (
|
||||
invoice_id, set_id, htlc_id, root_share, child_index, hash, preimage
|
||||
|
@ -28,6 +28,7 @@ type Querier interface {
|
||||
GetInvoiceHTLCCustomRecords(ctx context.Context, invoiceID int64) ([]GetInvoiceHTLCCustomRecordsRow, error)
|
||||
GetInvoiceHTLCs(ctx context.Context, invoiceID int64) ([]InvoiceHtlc, error)
|
||||
GetMigration(ctx context.Context, version int32) (time.Time, error)
|
||||
InsertAMPSubInvoice(ctx context.Context, arg InsertAMPSubInvoiceParams) error
|
||||
InsertAMPSubInvoiceHTLC(ctx context.Context, arg InsertAMPSubInvoiceHTLCParams) error
|
||||
InsertInvoice(ctx context.Context, arg InsertInvoiceParams) (int64, error)
|
||||
InsertInvoiceFeature(ctx context.Context, arg InsertInvoiceFeatureParams) error
|
||||
|
@ -65,3 +65,11 @@ SET preimage = $5
|
||||
WHERE a.invoice_id = $1 AND a.set_id = $2 AND a.htlc_id = (
|
||||
SELECT id FROM invoice_htlcs AS i WHERE i.chan_id = $3 AND i.htlc_id = $4
|
||||
);
|
||||
|
||||
-- name: InsertAMPSubInvoice :exec
|
||||
INSERT INTO amp_sub_invoices (
|
||||
set_id, state, created_at, settled_at, settle_index, invoice_id
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user