mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopdb: store reservation prepay invoice
This commit is contained in:
parent
4f121287d6
commit
327d4b42d0
6 changed files with 21 additions and 6 deletions
|
|
@ -84,6 +84,7 @@ func (r *SQLStore) CreateReservation(ctx context.Context,
|
|||
ClientKeyIndex: int32(reservation.KeyLocator.Index),
|
||||
InitiationHeight: reservation.InitiationHeight,
|
||||
ProtocolVersion: int32(reservation.ProtocolVersion),
|
||||
PrepayInvoice: reservation.PrepayInvoice,
|
||||
}
|
||||
|
||||
updateArgs := sqlc.InsertReservationUpdateParams{
|
||||
|
|
@ -293,6 +294,7 @@ func sqlReservationToReservation(row sqlc.Reservation,
|
|||
InitiationHeight: row.InitiationHeight,
|
||||
State: fsm.StateType(lastUpdate.UpdateState),
|
||||
ProtocolVersion: ProtocolVersion(row.ProtocolVersion),
|
||||
PrepayInvoice: row.PrepayInvoice,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE reservations DROP COLUMN prepay_invoice;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
-- prepay_invoice is a field that will store the invoice of the prepay payment
|
||||
-- that pays for the reservation.
|
||||
ALTER TABLE reservations ADD COLUMN prepay_invoice TEXT NOT NULL DEFAULT '';
|
||||
|
|
@ -115,6 +115,7 @@ type Reservation struct {
|
|||
OutIndex sql.NullInt32
|
||||
ConfirmationHeight sql.NullInt32
|
||||
ProtocolVersion int32
|
||||
PrepayInvoice string
|
||||
}
|
||||
|
||||
type ReservationUpdate struct {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ INSERT INTO reservations (
|
|||
client_key_family,
|
||||
client_key_index,
|
||||
initiation_height,
|
||||
protocol_version
|
||||
protocol_version,
|
||||
prepay_invoice
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
|
|
@ -18,7 +19,8 @@ INSERT INTO reservations (
|
|||
$6,
|
||||
$7,
|
||||
$8,
|
||||
$9
|
||||
$9,
|
||||
$10
|
||||
);
|
||||
|
||||
-- name: UpdateReservation :exec
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ INSERT INTO reservations (
|
|||
client_key_family,
|
||||
client_key_index,
|
||||
initiation_height,
|
||||
protocol_version
|
||||
protocol_version,
|
||||
prepay_invoice
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
|
|
@ -31,7 +32,8 @@ INSERT INTO reservations (
|
|||
$6,
|
||||
$7,
|
||||
$8,
|
||||
$9
|
||||
$9,
|
||||
$10
|
||||
)
|
||||
`
|
||||
|
||||
|
|
@ -45,6 +47,7 @@ type CreateReservationParams struct {
|
|||
ClientKeyIndex int32
|
||||
InitiationHeight int32
|
||||
ProtocolVersion int32
|
||||
PrepayInvoice string
|
||||
}
|
||||
|
||||
func (q *Queries) CreateReservation(ctx context.Context, arg CreateReservationParams) error {
|
||||
|
|
@ -58,13 +61,14 @@ func (q *Queries) CreateReservation(ctx context.Context, arg CreateReservationPa
|
|||
arg.ClientKeyIndex,
|
||||
arg.InitiationHeight,
|
||||
arg.ProtocolVersion,
|
||||
arg.PrepayInvoice,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const getReservation = `-- name: GetReservation :one
|
||||
SELECT
|
||||
id, reservation_id, client_pubkey, server_pubkey, expiry, value, client_key_family, client_key_index, initiation_height, tx_hash, out_index, confirmation_height, protocol_version
|
||||
id, reservation_id, client_pubkey, server_pubkey, expiry, value, client_key_family, client_key_index, initiation_height, tx_hash, out_index, confirmation_height, protocol_version, prepay_invoice
|
||||
FROM
|
||||
reservations
|
||||
WHERE
|
||||
|
|
@ -88,6 +92,7 @@ func (q *Queries) GetReservation(ctx context.Context, reservationID []byte) (Res
|
|||
&i.OutIndex,
|
||||
&i.ConfirmationHeight,
|
||||
&i.ProtocolVersion,
|
||||
&i.PrepayInvoice,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
|
@ -133,7 +138,7 @@ func (q *Queries) GetReservationUpdates(ctx context.Context, reservationID []byt
|
|||
|
||||
const getReservations = `-- name: GetReservations :many
|
||||
SELECT
|
||||
id, reservation_id, client_pubkey, server_pubkey, expiry, value, client_key_family, client_key_index, initiation_height, tx_hash, out_index, confirmation_height, protocol_version
|
||||
id, reservation_id, client_pubkey, server_pubkey, expiry, value, client_key_family, client_key_index, initiation_height, tx_hash, out_index, confirmation_height, protocol_version, prepay_invoice
|
||||
FROM
|
||||
reservations
|
||||
ORDER BY
|
||||
|
|
@ -163,6 +168,7 @@ func (q *Queries) GetReservations(ctx context.Context) ([]Reservation, error) {
|
|||
&i.OutIndex,
|
||||
&i.ConfirmationHeight,
|
||||
&i.ProtocolVersion,
|
||||
&i.PrepayInvoice,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue