diff --git a/instantout/reservation/store.go b/instantout/reservation/store.go index 72613f9c..dabade50 100644 --- a/instantout/reservation/store.go +++ b/instantout/reservation/store.go @@ -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 } diff --git a/loopdb/sqlc/migrations/000015_reservation_prepay_invoice.down.sql b/loopdb/sqlc/migrations/000015_reservation_prepay_invoice.down.sql new file mode 100644 index 00000000..61ae44c6 --- /dev/null +++ b/loopdb/sqlc/migrations/000015_reservation_prepay_invoice.down.sql @@ -0,0 +1 @@ +ALTER TABLE reservations DROP COLUMN prepay_invoice; diff --git a/loopdb/sqlc/migrations/000015_reservation_prepay_invoice.up.sql b/loopdb/sqlc/migrations/000015_reservation_prepay_invoice.up.sql new file mode 100644 index 00000000..37075170 --- /dev/null +++ b/loopdb/sqlc/migrations/000015_reservation_prepay_invoice.up.sql @@ -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 ''; diff --git a/loopdb/sqlc/models.go b/loopdb/sqlc/models.go index 78a75d04..62bf5a66 100644 --- a/loopdb/sqlc/models.go +++ b/loopdb/sqlc/models.go @@ -115,6 +115,7 @@ type Reservation struct { OutIndex sql.NullInt32 ConfirmationHeight sql.NullInt32 ProtocolVersion int32 + PrepayInvoice string } type ReservationUpdate struct { diff --git a/loopdb/sqlc/queries/reservations.sql b/loopdb/sqlc/queries/reservations.sql index ba95f53a..f9592326 100644 --- a/loopdb/sqlc/queries/reservations.sql +++ b/loopdb/sqlc/queries/reservations.sql @@ -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 diff --git a/loopdb/sqlc/reservations.sql.go b/loopdb/sqlc/reservations.sql.go index 3a1ba898..275f45b8 100644 --- a/loopdb/sqlc/reservations.sql.go +++ b/loopdb/sqlc/reservations.sql.go @@ -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 }