mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 12:44:19 +01:00
Vars and fields renaming (#387)
* Rename asp > server * Rename pool > round * Consolidate naming for pubkey/prvkey vars and types * Fix * Fix * Fix wasm * Rename congestionTree > vtxoTree * Fix wasm * Rename payment > request * Rename congestionTree > vtxoTree after syncing with master * Fix Send API in SDK * Fix wasm * Fix wasm * Fixes * Fixes after review * Fix * Fix naming * Fix * Fix e2e tests
This commit is contained in:
committed by
GitHub
parent
12d666bfdf
commit
7f937e8418
@@ -1,6 +1,6 @@
|
||||
DROP TABLE IF EXISTS round;
|
||||
|
||||
DROP TABLE IF EXISTS payment;
|
||||
DROP TABLE IF EXISTS tx_request;
|
||||
|
||||
DROP TABLE IF EXISTS receiver;
|
||||
|
||||
|
||||
@@ -13,19 +13,19 @@ CREATE TABLE IF NOT EXISTS round (
|
||||
swept BOOLEAN NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS payment (
|
||||
CREATE TABLE IF NOT EXISTS tx_request (
|
||||
id TEXT PRIMARY KEY,
|
||||
round_id TEXT NOT NULL,
|
||||
FOREIGN KEY (round_id) REFERENCES round(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS receiver (
|
||||
payment_id TEXT NOT NULL,
|
||||
request_id TEXT NOT NULL,
|
||||
pubkey TEXT,
|
||||
onchain_address TEXT,
|
||||
amount INTEGER NOT NULL,
|
||||
FOREIGN KEY (payment_id) REFERENCES payment(id),
|
||||
PRIMARY KEY (payment_id, pubkey, onchain_address)
|
||||
FOREIGN KEY (request_id) REFERENCES tx_request(id),
|
||||
PRIMARY KEY (request_id, pubkey, onchain_address)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tx (
|
||||
@@ -46,17 +46,17 @@ CREATE TABLE IF NOT EXISTS vtxo (
|
||||
vout INTEGER NOT NULL,
|
||||
pubkey TEXT NOT NULL,
|
||||
amount INTEGER NOT NULL,
|
||||
pool_tx TEXT NOT NULL,
|
||||
round_tx TEXT NOT NULL,
|
||||
spent_by TEXT NOT NULL,
|
||||
spent BOOLEAN NOT NULL,
|
||||
redeemed BOOLEAN NOT NULL,
|
||||
swept BOOLEAN NOT NULL,
|
||||
expire_at INTEGER NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
payment_id TEXT,
|
||||
request_id TEXT,
|
||||
redeem_tx TEXT,
|
||||
PRIMARY KEY (txid, vout),
|
||||
FOREIGN KEY (payment_id) REFERENCES payment(id)
|
||||
FOREIGN KEY (request_id) REFERENCES tx_request(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS note (
|
||||
@@ -81,22 +81,22 @@ FROM entity
|
||||
LEFT OUTER JOIN entity_vtxo
|
||||
ON entity.id=entity_vtxo.entity_id;
|
||||
|
||||
CREATE VIEW round_payment_vw AS SELECT payment.*
|
||||
CREATE VIEW round_request_vw AS SELECT tx_request.*
|
||||
FROM round
|
||||
LEFT OUTER JOIN payment
|
||||
ON round.id=payment.round_id;
|
||||
LEFT OUTER JOIN tx_request
|
||||
ON round.id=tx_request.round_id;
|
||||
|
||||
CREATE VIEW round_tx_vw AS SELECT tx.*
|
||||
FROM round
|
||||
LEFT OUTER JOIN tx
|
||||
ON round.id=tx.round_id;
|
||||
|
||||
CREATE VIEW payment_receiver_vw AS SELECT receiver.*
|
||||
FROM payment
|
||||
CREATE VIEW request_receiver_vw AS SELECT receiver.*
|
||||
FROM tx_request
|
||||
LEFT OUTER JOIN receiver
|
||||
ON payment.id=receiver.payment_id;
|
||||
ON tx_request.id=receiver.request_id;
|
||||
|
||||
CREATE VIEW payment_vtxo_vw AS SELECT vtxo.*
|
||||
FROM payment
|
||||
CREATE VIEW request_vtxo_vw AS SELECT vtxo.*
|
||||
FROM tx_request
|
||||
LEFT OUTER JOIN vtxo
|
||||
ON payment.id=vtxo.payment_id;
|
||||
ON tx_request.id=vtxo.request_id;
|
||||
@@ -86,7 +86,7 @@ func (r *roundRepository) AddOrUpdateRound(ctx context.Context, round domain.Rou
|
||||
return fmt.Errorf("failed to upsert round: %w", err)
|
||||
}
|
||||
|
||||
if len(round.ForfeitTxs) > 0 || len(round.Connectors) > 0 || len(round.CongestionTree) > 0 {
|
||||
if len(round.ForfeitTxs) > 0 || len(round.Connectors) > 0 || len(round.VtxoTree) > 0 {
|
||||
for pos, tx := range round.ForfeitTxs {
|
||||
if err := querierWithTx.UpsertTransaction(
|
||||
ctx,
|
||||
@@ -115,7 +115,7 @@ func (r *roundRepository) AddOrUpdateRound(ctx context.Context, round domain.Rou
|
||||
}
|
||||
}
|
||||
|
||||
for level, levelTxs := range round.CongestionTree {
|
||||
for level, levelTxs := range round.VtxoTree {
|
||||
for pos, tx := range levelTxs {
|
||||
if err := querierWithTx.UpsertTransaction(
|
||||
ctx,
|
||||
@@ -148,27 +148,27 @@ func (r *roundRepository) AddOrUpdateRound(ctx context.Context, round domain.Rou
|
||||
}
|
||||
}
|
||||
|
||||
if len(round.Payments) > 0 {
|
||||
for _, payment := range round.Payments {
|
||||
if err := querierWithTx.UpsertPayment(
|
||||
if len(round.TxRequests) > 0 {
|
||||
for _, request := range round.TxRequests {
|
||||
if err := querierWithTx.UpsertTxRequest(
|
||||
ctx,
|
||||
queries.UpsertPaymentParams{
|
||||
ID: payment.Id,
|
||||
queries.UpsertTxRequestParams{
|
||||
ID: request.Id,
|
||||
RoundID: round.Id,
|
||||
},
|
||||
); err != nil {
|
||||
return fmt.Errorf("failed to upsert payment: %w", err)
|
||||
return fmt.Errorf("failed to upsert tx request: %w", err)
|
||||
}
|
||||
|
||||
for _, receiver := range payment.Receivers {
|
||||
for _, receiver := range request.Receivers {
|
||||
if err := querierWithTx.UpsertReceiver(
|
||||
ctx,
|
||||
queries.UpsertReceiverParams{
|
||||
PaymentID: payment.Id,
|
||||
RequestID: request.Id,
|
||||
Amount: int64(receiver.Amount),
|
||||
Pubkey: sql.NullString{
|
||||
String: receiver.Pubkey,
|
||||
Valid: len(receiver.Pubkey) > 0,
|
||||
String: receiver.PubKey,
|
||||
Valid: len(receiver.PubKey) > 0,
|
||||
},
|
||||
OnchainAddress: sql.NullString{
|
||||
String: receiver.OnchainAddress,
|
||||
@@ -180,19 +180,19 @@ func (r *roundRepository) AddOrUpdateRound(ctx context.Context, round domain.Rou
|
||||
}
|
||||
}
|
||||
|
||||
for _, input := range payment.Inputs {
|
||||
if err := querierWithTx.UpdateVtxoPaymentId(
|
||||
for _, input := range request.Inputs {
|
||||
if err := querierWithTx.UpdateVtxoRequestId(
|
||||
ctx,
|
||||
queries.UpdateVtxoPaymentIdParams{
|
||||
PaymentID: sql.NullString{
|
||||
String: payment.Id,
|
||||
queries.UpdateVtxoRequestIdParams{
|
||||
RequestID: sql.NullString{
|
||||
String: request.Id,
|
||||
Valid: true,
|
||||
},
|
||||
Txid: input.Txid,
|
||||
Vout: int64(input.VOut),
|
||||
},
|
||||
); err != nil {
|
||||
return fmt.Errorf("failed to update vtxo payment id: %w", err)
|
||||
return fmt.Errorf("failed to update vtxo request id: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,18 +210,18 @@ func (r *roundRepository) GetRoundWithId(ctx context.Context, id string) (*domai
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rvs := make([]roundPaymentTxReceiverVtxoRow, 0, len(rows))
|
||||
rvs := make([]combinedRow, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
rvs = append(rvs, roundPaymentTxReceiverVtxoRow{
|
||||
rvs = append(rvs, combinedRow{
|
||||
round: row.Round,
|
||||
payment: row.RoundPaymentVw,
|
||||
request: row.RoundRequestVw,
|
||||
tx: row.RoundTxVw,
|
||||
receiver: row.PaymentReceiverVw,
|
||||
vtxo: row.PaymentVtxoVw,
|
||||
receiver: row.RequestReceiverVw,
|
||||
vtxo: row.RequestVtxoVw,
|
||||
})
|
||||
}
|
||||
|
||||
rounds, err := readRoundRows(rvs)
|
||||
rounds, err := rowsToRounds(rvs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -239,18 +239,18 @@ func (r *roundRepository) GetRoundWithTxid(ctx context.Context, txid string) (*d
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rvs := make([]roundPaymentTxReceiverVtxoRow, 0, len(rows))
|
||||
rvs := make([]combinedRow, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
rvs = append(rvs, roundPaymentTxReceiverVtxoRow{
|
||||
rvs = append(rvs, combinedRow{
|
||||
round: row.Round,
|
||||
payment: row.RoundPaymentVw,
|
||||
request: row.RoundRequestVw,
|
||||
tx: row.RoundTxVw,
|
||||
receiver: row.PaymentReceiverVw,
|
||||
vtxo: row.PaymentVtxoVw,
|
||||
receiver: row.RequestReceiverVw,
|
||||
vtxo: row.RequestVtxoVw,
|
||||
})
|
||||
}
|
||||
|
||||
rounds, err := readRoundRows(rvs)
|
||||
rounds, err := rowsToRounds(rvs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -268,18 +268,18 @@ func (r *roundRepository) GetSweepableRounds(ctx context.Context) ([]domain.Roun
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rvs := make([]roundPaymentTxReceiverVtxoRow, 0, len(rows))
|
||||
rvs := make([]combinedRow, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
rvs = append(rvs, roundPaymentTxReceiverVtxoRow{
|
||||
rvs = append(rvs, combinedRow{
|
||||
round: row.Round,
|
||||
payment: row.RoundPaymentVw,
|
||||
request: row.RoundRequestVw,
|
||||
tx: row.RoundTxVw,
|
||||
receiver: row.PaymentReceiverVw,
|
||||
vtxo: row.PaymentVtxoVw,
|
||||
receiver: row.RequestReceiverVw,
|
||||
vtxo: row.RequestVtxoVw,
|
||||
})
|
||||
}
|
||||
|
||||
rounds, err := readRoundRows(rvs)
|
||||
rounds, err := rowsToRounds(rvs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -299,18 +299,18 @@ func (r *roundRepository) GetSweptRounds(ctx context.Context) ([]domain.Round, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rvs := make([]roundPaymentTxReceiverVtxoRow, 0, len(rows))
|
||||
rvs := make([]combinedRow, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
rvs = append(rvs, roundPaymentTxReceiverVtxoRow{
|
||||
rvs = append(rvs, combinedRow{
|
||||
round: row.Round,
|
||||
payment: row.RoundPaymentVw,
|
||||
request: row.RoundRequestVw,
|
||||
tx: row.RoundTxVw,
|
||||
receiver: row.PaymentReceiverVw,
|
||||
vtxo: row.PaymentVtxoVw,
|
||||
receiver: row.RequestReceiverVw,
|
||||
vtxo: row.RequestVtxoVw,
|
||||
})
|
||||
}
|
||||
|
||||
rounds, err := readRoundRows(rvs)
|
||||
rounds, err := rowsToRounds(rvs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -324,23 +324,23 @@ func (r *roundRepository) GetSweptRounds(ctx context.Context) ([]domain.Round, e
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func rowToReceiver(row queries.PaymentReceiverVw) domain.Receiver {
|
||||
func rowToReceiver(row queries.RequestReceiverVw) domain.Receiver {
|
||||
return domain.Receiver{
|
||||
Amount: uint64(row.Amount.Int64),
|
||||
Pubkey: row.Pubkey.String,
|
||||
PubKey: row.Pubkey.String,
|
||||
OnchainAddress: row.OnchainAddress.String,
|
||||
}
|
||||
}
|
||||
|
||||
type roundPaymentTxReceiverVtxoRow struct {
|
||||
type combinedRow struct {
|
||||
round queries.Round
|
||||
payment queries.RoundPaymentVw
|
||||
request queries.RoundRequestVw
|
||||
tx queries.RoundTxVw
|
||||
receiver queries.PaymentReceiverVw
|
||||
vtxo queries.PaymentVtxoVw
|
||||
receiver queries.RequestReceiverVw
|
||||
vtxo queries.RequestVtxoVw
|
||||
}
|
||||
|
||||
func readRoundRows(rows []roundPaymentTxReceiverVtxoRow) ([]*domain.Round, error) {
|
||||
func rowsToRounds(rows []combinedRow) ([]*domain.Round, error) {
|
||||
rounds := make(map[string]*domain.Round)
|
||||
|
||||
for _, v := range rows {
|
||||
@@ -364,35 +364,34 @@ func readRoundRows(rows []roundPaymentTxReceiverVtxoRow) ([]*domain.Round, error
|
||||
DustAmount: uint64(v.round.DustAmount),
|
||||
Version: uint(v.round.Version),
|
||||
Swept: v.round.Swept,
|
||||
Payments: make(map[string]domain.Payment),
|
||||
TxRequests: make(map[string]domain.TxRequest),
|
||||
}
|
||||
}
|
||||
|
||||
if v.payment.ID.Valid {
|
||||
payment, ok := round.Payments[v.payment.ID.String]
|
||||
if v.request.ID.Valid {
|
||||
request, ok := round.TxRequests[v.request.ID.String]
|
||||
if !ok {
|
||||
payment = domain.Payment{
|
||||
Id: v.payment.ID.String,
|
||||
request = domain.TxRequest{
|
||||
Id: v.request.ID.String,
|
||||
Inputs: make([]domain.Vtxo, 0),
|
||||
Receivers: make([]domain.Receiver, 0),
|
||||
}
|
||||
round.Payments[v.payment.ID.String] = payment
|
||||
round.TxRequests[v.request.ID.String] = request
|
||||
}
|
||||
|
||||
if v.vtxo.PaymentID.Valid {
|
||||
payment, ok = round.Payments[v.vtxo.PaymentID.String]
|
||||
if v.vtxo.RequestID.Valid {
|
||||
request, ok = round.TxRequests[v.vtxo.RequestID.String]
|
||||
if !ok {
|
||||
payment = domain.Payment{
|
||||
Id: v.vtxo.PaymentID.String,
|
||||
request = domain.TxRequest{
|
||||
Id: v.vtxo.RequestID.String,
|
||||
Inputs: make([]domain.Vtxo, 0),
|
||||
Receivers: make([]domain.Receiver, 0),
|
||||
}
|
||||
}
|
||||
|
||||
vtxo := rowToPaymentVtxoVw(v.vtxo)
|
||||
vtxo := combinedRowToVtxo(v.vtxo)
|
||||
found := false
|
||||
|
||||
for _, v := range payment.Inputs {
|
||||
for _, v := range request.Inputs {
|
||||
if vtxo.Txid == v.Txid && vtxo.VOut == v.VOut {
|
||||
found = true
|
||||
break
|
||||
@@ -400,16 +399,16 @@ func readRoundRows(rows []roundPaymentTxReceiverVtxoRow) ([]*domain.Round, error
|
||||
}
|
||||
|
||||
if !found {
|
||||
payment.Inputs = append(payment.Inputs, rowToPaymentVtxoVw(v.vtxo))
|
||||
round.Payments[v.vtxo.PaymentID.String] = payment
|
||||
request.Inputs = append(request.Inputs, combinedRowToVtxo(v.vtxo))
|
||||
round.TxRequests[v.vtxo.RequestID.String] = request
|
||||
}
|
||||
}
|
||||
|
||||
if v.receiver.PaymentID.Valid {
|
||||
payment, ok = round.Payments[v.receiver.PaymentID.String]
|
||||
if v.receiver.RequestID.Valid {
|
||||
request, ok = round.TxRequests[v.receiver.RequestID.String]
|
||||
if !ok {
|
||||
payment = domain.Payment{
|
||||
Id: v.receiver.PaymentID.String,
|
||||
request = domain.TxRequest{
|
||||
Id: v.receiver.RequestID.String,
|
||||
Inputs: make([]domain.Vtxo, 0),
|
||||
Receivers: make([]domain.Receiver, 0),
|
||||
}
|
||||
@@ -418,17 +417,17 @@ func readRoundRows(rows []roundPaymentTxReceiverVtxoRow) ([]*domain.Round, error
|
||||
rcv := rowToReceiver(v.receiver)
|
||||
|
||||
found := false
|
||||
for _, rcv := range payment.Receivers {
|
||||
for _, rcv := range request.Receivers {
|
||||
if (v.receiver.Pubkey.Valid || v.receiver.OnchainAddress.Valid) && v.receiver.Amount.Valid {
|
||||
if rcv.Pubkey == v.receiver.Pubkey.String && rcv.OnchainAddress == v.receiver.OnchainAddress.String && int64(rcv.Amount) == v.receiver.Amount.Int64 {
|
||||
if rcv.PubKey == v.receiver.Pubkey.String && rcv.OnchainAddress == v.receiver.OnchainAddress.String && int64(rcv.Amount) == v.receiver.Amount.Int64 {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
payment.Receivers = append(payment.Receivers, rcv)
|
||||
round.Payments[v.receiver.PaymentID.String] = payment
|
||||
request.Receivers = append(request.Receivers, rcv)
|
||||
round.TxRequests[v.receiver.RequestID.String] = request
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -444,10 +443,10 @@ func readRoundRows(rows []roundPaymentTxReceiverVtxoRow) ([]*domain.Round, error
|
||||
round.Connectors[position.Int64] = v.tx.Tx.String
|
||||
case "tree":
|
||||
level := v.tx.TreeLevel
|
||||
round.CongestionTree = extendArray(round.CongestionTree, int(level.Int64))
|
||||
round.CongestionTree[int(level.Int64)] = extendArray(round.CongestionTree[int(level.Int64)], int(position.Int64))
|
||||
if round.CongestionTree[int(level.Int64)][position.Int64] == (tree.Node{}) {
|
||||
round.CongestionTree[int(level.Int64)][position.Int64] = tree.Node{
|
||||
round.VtxoTree = extendArray(round.VtxoTree, int(level.Int64))
|
||||
round.VtxoTree[int(level.Int64)] = extendArray(round.VtxoTree[int(level.Int64)], int(position.Int64))
|
||||
if round.VtxoTree[int(level.Int64)][position.Int64] == (tree.Node{}) {
|
||||
round.VtxoTree[int(level.Int64)][position.Int64] = tree.Node{
|
||||
Tx: v.tx.Tx.String,
|
||||
Txid: v.tx.Txid.String,
|
||||
ParentTxid: v.tx.ParentTxid.String,
|
||||
@@ -469,15 +468,15 @@ func readRoundRows(rows []roundPaymentTxReceiverVtxoRow) ([]*domain.Round, error
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func rowToPaymentVtxoVw(row queries.PaymentVtxoVw) domain.Vtxo {
|
||||
func combinedRowToVtxo(row queries.RequestVtxoVw) domain.Vtxo {
|
||||
return domain.Vtxo{
|
||||
VtxoKey: domain.VtxoKey{
|
||||
Txid: row.Txid.String,
|
||||
VOut: uint32(row.Vout.Int64),
|
||||
},
|
||||
Amount: uint64(row.Amount.Int64),
|
||||
Pubkey: row.Pubkey.String,
|
||||
RoundTxid: row.PoolTx.String,
|
||||
PubKey: row.Pubkey.String,
|
||||
RoundTxid: row.RoundTx.String,
|
||||
SpentBy: row.SpentBy.String,
|
||||
Spent: row.Spent.Bool,
|
||||
Redeemed: row.Redeemed.Bool,
|
||||
|
||||
@@ -39,41 +39,36 @@ type Note struct {
|
||||
ID int64
|
||||
}
|
||||
|
||||
type Payment struct {
|
||||
ID string
|
||||
RoundID string
|
||||
type Receiver struct {
|
||||
RequestID string
|
||||
Pubkey sql.NullString
|
||||
OnchainAddress sql.NullString
|
||||
Amount int64
|
||||
}
|
||||
|
||||
type PaymentReceiverVw struct {
|
||||
PaymentID sql.NullString
|
||||
type RequestReceiverVw struct {
|
||||
RequestID sql.NullString
|
||||
Pubkey sql.NullString
|
||||
OnchainAddress sql.NullString
|
||||
Amount sql.NullInt64
|
||||
}
|
||||
|
||||
type PaymentVtxoVw struct {
|
||||
type RequestVtxoVw struct {
|
||||
Txid sql.NullString
|
||||
Vout sql.NullInt64
|
||||
Pubkey sql.NullString
|
||||
Amount sql.NullInt64
|
||||
PoolTx sql.NullString
|
||||
RoundTx sql.NullString
|
||||
SpentBy sql.NullString
|
||||
Spent sql.NullBool
|
||||
Redeemed sql.NullBool
|
||||
Swept sql.NullBool
|
||||
ExpireAt sql.NullInt64
|
||||
CreatedAt sql.NullInt64
|
||||
PaymentID sql.NullString
|
||||
RequestID sql.NullString
|
||||
RedeemTx sql.NullString
|
||||
}
|
||||
|
||||
type Receiver struct {
|
||||
PaymentID string
|
||||
Pubkey sql.NullString
|
||||
OnchainAddress sql.NullString
|
||||
Amount int64
|
||||
}
|
||||
|
||||
type Round struct {
|
||||
ID string
|
||||
StartingTimestamp int64
|
||||
@@ -89,7 +84,7 @@ type Round struct {
|
||||
Swept bool
|
||||
}
|
||||
|
||||
type RoundPaymentVw struct {
|
||||
type RoundRequestVw struct {
|
||||
ID sql.NullString
|
||||
RoundID sql.NullString
|
||||
}
|
||||
@@ -118,18 +113,23 @@ type Tx struct {
|
||||
IsLeaf sql.NullBool
|
||||
}
|
||||
|
||||
type TxRequest struct {
|
||||
ID string
|
||||
RoundID string
|
||||
}
|
||||
|
||||
type Vtxo struct {
|
||||
Txid string
|
||||
Vout int64
|
||||
Pubkey string
|
||||
Amount int64
|
||||
PoolTx string
|
||||
RoundTx string
|
||||
SpentBy string
|
||||
Spent bool
|
||||
Redeemed bool
|
||||
Swept bool
|
||||
ExpireAt int64
|
||||
CreatedAt int64
|
||||
PaymentID sql.NullString
|
||||
RequestID sql.NullString
|
||||
RedeemTx sql.NullString
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ func (q *Queries) SelectEntitiesByVtxo(ctx context.Context, arg SelectEntitiesBy
|
||||
}
|
||||
|
||||
const selectNotRedeemedVtxos = `-- name: SelectNotRedeemedVtxos :many
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.pool_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.payment_id, vtxo.redeem_tx FROM vtxo
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.round_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.request_id, vtxo.redeem_tx FROM vtxo
|
||||
WHERE redeemed = false
|
||||
`
|
||||
|
||||
@@ -213,14 +213,14 @@ func (q *Queries) SelectNotRedeemedVtxos(ctx context.Context) ([]SelectNotRedeem
|
||||
&i.Vtxo.Vout,
|
||||
&i.Vtxo.Pubkey,
|
||||
&i.Vtxo.Amount,
|
||||
&i.Vtxo.PoolTx,
|
||||
&i.Vtxo.RoundTx,
|
||||
&i.Vtxo.SpentBy,
|
||||
&i.Vtxo.Spent,
|
||||
&i.Vtxo.Redeemed,
|
||||
&i.Vtxo.Swept,
|
||||
&i.Vtxo.ExpireAt,
|
||||
&i.Vtxo.CreatedAt,
|
||||
&i.Vtxo.PaymentID,
|
||||
&i.Vtxo.RequestID,
|
||||
&i.Vtxo.RedeemTx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
@@ -237,7 +237,7 @@ func (q *Queries) SelectNotRedeemedVtxos(ctx context.Context) ([]SelectNotRedeem
|
||||
}
|
||||
|
||||
const selectNotRedeemedVtxosWithPubkey = `-- name: SelectNotRedeemedVtxosWithPubkey :many
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.pool_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.payment_id, vtxo.redeem_tx FROM vtxo
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.round_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.request_id, vtxo.redeem_tx FROM vtxo
|
||||
WHERE redeemed = false AND pubkey = ?
|
||||
`
|
||||
|
||||
@@ -259,14 +259,14 @@ func (q *Queries) SelectNotRedeemedVtxosWithPubkey(ctx context.Context, pubkey s
|
||||
&i.Vtxo.Vout,
|
||||
&i.Vtxo.Pubkey,
|
||||
&i.Vtxo.Amount,
|
||||
&i.Vtxo.PoolTx,
|
||||
&i.Vtxo.RoundTx,
|
||||
&i.Vtxo.SpentBy,
|
||||
&i.Vtxo.Spent,
|
||||
&i.Vtxo.Redeemed,
|
||||
&i.Vtxo.Swept,
|
||||
&i.Vtxo.ExpireAt,
|
||||
&i.Vtxo.CreatedAt,
|
||||
&i.Vtxo.PaymentID,
|
||||
&i.Vtxo.RequestID,
|
||||
&i.Vtxo.RedeemTx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
@@ -343,24 +343,24 @@ func (q *Queries) SelectRoundIdsInRange(ctx context.Context, arg SelectRoundIdsI
|
||||
|
||||
const selectRoundWithRoundId = `-- name: SelectRoundWithRoundId :many
|
||||
SELECT round.id, round.starting_timestamp, round.ending_timestamp, round.ended, round.failed, round.stage_code, round.txid, round.unsigned_tx, round.connector_address, round.dust_amount, round.version, round.swept,
|
||||
round_payment_vw.id, round_payment_vw.round_id,
|
||||
round_request_vw.id, round_request_vw.round_id,
|
||||
round_tx_vw.id, round_tx_vw.tx, round_tx_vw.round_id, round_tx_vw.type, round_tx_vw.position, round_tx_vw.txid, round_tx_vw.tree_level, round_tx_vw.parent_txid, round_tx_vw.is_leaf,
|
||||
payment_receiver_vw.payment_id, payment_receiver_vw.pubkey, payment_receiver_vw.onchain_address, payment_receiver_vw.amount,
|
||||
payment_vtxo_vw.txid, payment_vtxo_vw.vout, payment_vtxo_vw.pubkey, payment_vtxo_vw.amount, payment_vtxo_vw.pool_tx, payment_vtxo_vw.spent_by, payment_vtxo_vw.spent, payment_vtxo_vw.redeemed, payment_vtxo_vw.swept, payment_vtxo_vw.expire_at, payment_vtxo_vw.created_at, payment_vtxo_vw.payment_id, payment_vtxo_vw.redeem_tx
|
||||
request_receiver_vw.request_id, request_receiver_vw.pubkey, request_receiver_vw.onchain_address, request_receiver_vw.amount,
|
||||
request_vtxo_vw.txid, request_vtxo_vw.vout, request_vtxo_vw.pubkey, request_vtxo_vw.amount, request_vtxo_vw.round_tx, request_vtxo_vw.spent_by, request_vtxo_vw.spent, request_vtxo_vw.redeemed, request_vtxo_vw.swept, request_vtxo_vw.expire_at, request_vtxo_vw.created_at, request_vtxo_vw.request_id, request_vtxo_vw.redeem_tx
|
||||
FROM round
|
||||
LEFT OUTER JOIN round_payment_vw ON round.id=round_payment_vw.round_id
|
||||
LEFT OUTER JOIN round_request_vw ON round.id=round_request_vw.round_id
|
||||
LEFT OUTER JOIN round_tx_vw ON round.id=round_tx_vw.round_id
|
||||
LEFT OUTER JOIN payment_receiver_vw ON round_payment_vw.id=payment_receiver_vw.payment_id
|
||||
LEFT OUTER JOIN payment_vtxo_vw ON round_payment_vw.id=payment_vtxo_vw.payment_id
|
||||
LEFT OUTER JOIN request_receiver_vw ON round_request_vw.id=request_receiver_vw.request_id
|
||||
LEFT OUTER JOIN request_vtxo_vw ON round_request_vw.id=request_vtxo_vw.request_id
|
||||
WHERE round.id = ?
|
||||
`
|
||||
|
||||
type SelectRoundWithRoundIdRow struct {
|
||||
Round Round
|
||||
RoundPaymentVw RoundPaymentVw
|
||||
RoundRequestVw RoundRequestVw
|
||||
RoundTxVw RoundTxVw
|
||||
PaymentReceiverVw PaymentReceiverVw
|
||||
PaymentVtxoVw PaymentVtxoVw
|
||||
RequestReceiverVw RequestReceiverVw
|
||||
RequestVtxoVw RequestVtxoVw
|
||||
}
|
||||
|
||||
func (q *Queries) SelectRoundWithRoundId(ctx context.Context, id string) ([]SelectRoundWithRoundIdRow, error) {
|
||||
@@ -385,8 +385,8 @@ func (q *Queries) SelectRoundWithRoundId(ctx context.Context, id string) ([]Sele
|
||||
&i.Round.DustAmount,
|
||||
&i.Round.Version,
|
||||
&i.Round.Swept,
|
||||
&i.RoundPaymentVw.ID,
|
||||
&i.RoundPaymentVw.RoundID,
|
||||
&i.RoundRequestVw.ID,
|
||||
&i.RoundRequestVw.RoundID,
|
||||
&i.RoundTxVw.ID,
|
||||
&i.RoundTxVw.Tx,
|
||||
&i.RoundTxVw.RoundID,
|
||||
@@ -396,23 +396,23 @@ func (q *Queries) SelectRoundWithRoundId(ctx context.Context, id string) ([]Sele
|
||||
&i.RoundTxVw.TreeLevel,
|
||||
&i.RoundTxVw.ParentTxid,
|
||||
&i.RoundTxVw.IsLeaf,
|
||||
&i.PaymentReceiverVw.PaymentID,
|
||||
&i.PaymentReceiverVw.Pubkey,
|
||||
&i.PaymentReceiverVw.OnchainAddress,
|
||||
&i.PaymentReceiverVw.Amount,
|
||||
&i.PaymentVtxoVw.Txid,
|
||||
&i.PaymentVtxoVw.Vout,
|
||||
&i.PaymentVtxoVw.Pubkey,
|
||||
&i.PaymentVtxoVw.Amount,
|
||||
&i.PaymentVtxoVw.PoolTx,
|
||||
&i.PaymentVtxoVw.SpentBy,
|
||||
&i.PaymentVtxoVw.Spent,
|
||||
&i.PaymentVtxoVw.Redeemed,
|
||||
&i.PaymentVtxoVw.Swept,
|
||||
&i.PaymentVtxoVw.ExpireAt,
|
||||
&i.PaymentVtxoVw.CreatedAt,
|
||||
&i.PaymentVtxoVw.PaymentID,
|
||||
&i.PaymentVtxoVw.RedeemTx,
|
||||
&i.RequestReceiverVw.RequestID,
|
||||
&i.RequestReceiverVw.Pubkey,
|
||||
&i.RequestReceiverVw.OnchainAddress,
|
||||
&i.RequestReceiverVw.Amount,
|
||||
&i.RequestVtxoVw.Txid,
|
||||
&i.RequestVtxoVw.Vout,
|
||||
&i.RequestVtxoVw.Pubkey,
|
||||
&i.RequestVtxoVw.Amount,
|
||||
&i.RequestVtxoVw.RoundTx,
|
||||
&i.RequestVtxoVw.SpentBy,
|
||||
&i.RequestVtxoVw.Spent,
|
||||
&i.RequestVtxoVw.Redeemed,
|
||||
&i.RequestVtxoVw.Swept,
|
||||
&i.RequestVtxoVw.ExpireAt,
|
||||
&i.RequestVtxoVw.CreatedAt,
|
||||
&i.RequestVtxoVw.RequestID,
|
||||
&i.RequestVtxoVw.RedeemTx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -429,24 +429,24 @@ func (q *Queries) SelectRoundWithRoundId(ctx context.Context, id string) ([]Sele
|
||||
|
||||
const selectRoundWithRoundTxId = `-- name: SelectRoundWithRoundTxId :many
|
||||
SELECT round.id, round.starting_timestamp, round.ending_timestamp, round.ended, round.failed, round.stage_code, round.txid, round.unsigned_tx, round.connector_address, round.dust_amount, round.version, round.swept,
|
||||
round_payment_vw.id, round_payment_vw.round_id,
|
||||
round_request_vw.id, round_request_vw.round_id,
|
||||
round_tx_vw.id, round_tx_vw.tx, round_tx_vw.round_id, round_tx_vw.type, round_tx_vw.position, round_tx_vw.txid, round_tx_vw.tree_level, round_tx_vw.parent_txid, round_tx_vw.is_leaf,
|
||||
payment_receiver_vw.payment_id, payment_receiver_vw.pubkey, payment_receiver_vw.onchain_address, payment_receiver_vw.amount,
|
||||
payment_vtxo_vw.txid, payment_vtxo_vw.vout, payment_vtxo_vw.pubkey, payment_vtxo_vw.amount, payment_vtxo_vw.pool_tx, payment_vtxo_vw.spent_by, payment_vtxo_vw.spent, payment_vtxo_vw.redeemed, payment_vtxo_vw.swept, payment_vtxo_vw.expire_at, payment_vtxo_vw.created_at, payment_vtxo_vw.payment_id, payment_vtxo_vw.redeem_tx
|
||||
request_receiver_vw.request_id, request_receiver_vw.pubkey, request_receiver_vw.onchain_address, request_receiver_vw.amount,
|
||||
request_vtxo_vw.txid, request_vtxo_vw.vout, request_vtxo_vw.pubkey, request_vtxo_vw.amount, request_vtxo_vw.round_tx, request_vtxo_vw.spent_by, request_vtxo_vw.spent, request_vtxo_vw.redeemed, request_vtxo_vw.swept, request_vtxo_vw.expire_at, request_vtxo_vw.created_at, request_vtxo_vw.request_id, request_vtxo_vw.redeem_tx
|
||||
FROM round
|
||||
LEFT OUTER JOIN round_payment_vw ON round.id=round_payment_vw.round_id
|
||||
LEFT OUTER JOIN round_request_vw ON round.id=round_request_vw.round_id
|
||||
LEFT OUTER JOIN round_tx_vw ON round.id=round_tx_vw.round_id
|
||||
LEFT OUTER JOIN payment_receiver_vw ON round_payment_vw.id=payment_receiver_vw.payment_id
|
||||
LEFT OUTER JOIN payment_vtxo_vw ON round_payment_vw.id=payment_vtxo_vw.payment_id
|
||||
LEFT OUTER JOIN request_receiver_vw ON round_request_vw.id=request_receiver_vw.request_id
|
||||
LEFT OUTER JOIN request_vtxo_vw ON round_request_vw.id=request_vtxo_vw.request_id
|
||||
WHERE round.txid = ?
|
||||
`
|
||||
|
||||
type SelectRoundWithRoundTxIdRow struct {
|
||||
Round Round
|
||||
RoundPaymentVw RoundPaymentVw
|
||||
RoundRequestVw RoundRequestVw
|
||||
RoundTxVw RoundTxVw
|
||||
PaymentReceiverVw PaymentReceiverVw
|
||||
PaymentVtxoVw PaymentVtxoVw
|
||||
RequestReceiverVw RequestReceiverVw
|
||||
RequestVtxoVw RequestVtxoVw
|
||||
}
|
||||
|
||||
func (q *Queries) SelectRoundWithRoundTxId(ctx context.Context, txid string) ([]SelectRoundWithRoundTxIdRow, error) {
|
||||
@@ -471,8 +471,8 @@ func (q *Queries) SelectRoundWithRoundTxId(ctx context.Context, txid string) ([]
|
||||
&i.Round.DustAmount,
|
||||
&i.Round.Version,
|
||||
&i.Round.Swept,
|
||||
&i.RoundPaymentVw.ID,
|
||||
&i.RoundPaymentVw.RoundID,
|
||||
&i.RoundRequestVw.ID,
|
||||
&i.RoundRequestVw.RoundID,
|
||||
&i.RoundTxVw.ID,
|
||||
&i.RoundTxVw.Tx,
|
||||
&i.RoundTxVw.RoundID,
|
||||
@@ -482,23 +482,23 @@ func (q *Queries) SelectRoundWithRoundTxId(ctx context.Context, txid string) ([]
|
||||
&i.RoundTxVw.TreeLevel,
|
||||
&i.RoundTxVw.ParentTxid,
|
||||
&i.RoundTxVw.IsLeaf,
|
||||
&i.PaymentReceiverVw.PaymentID,
|
||||
&i.PaymentReceiverVw.Pubkey,
|
||||
&i.PaymentReceiverVw.OnchainAddress,
|
||||
&i.PaymentReceiverVw.Amount,
|
||||
&i.PaymentVtxoVw.Txid,
|
||||
&i.PaymentVtxoVw.Vout,
|
||||
&i.PaymentVtxoVw.Pubkey,
|
||||
&i.PaymentVtxoVw.Amount,
|
||||
&i.PaymentVtxoVw.PoolTx,
|
||||
&i.PaymentVtxoVw.SpentBy,
|
||||
&i.PaymentVtxoVw.Spent,
|
||||
&i.PaymentVtxoVw.Redeemed,
|
||||
&i.PaymentVtxoVw.Swept,
|
||||
&i.PaymentVtxoVw.ExpireAt,
|
||||
&i.PaymentVtxoVw.CreatedAt,
|
||||
&i.PaymentVtxoVw.PaymentID,
|
||||
&i.PaymentVtxoVw.RedeemTx,
|
||||
&i.RequestReceiverVw.RequestID,
|
||||
&i.RequestReceiverVw.Pubkey,
|
||||
&i.RequestReceiverVw.OnchainAddress,
|
||||
&i.RequestReceiverVw.Amount,
|
||||
&i.RequestVtxoVw.Txid,
|
||||
&i.RequestVtxoVw.Vout,
|
||||
&i.RequestVtxoVw.Pubkey,
|
||||
&i.RequestVtxoVw.Amount,
|
||||
&i.RequestVtxoVw.RoundTx,
|
||||
&i.RequestVtxoVw.SpentBy,
|
||||
&i.RequestVtxoVw.Spent,
|
||||
&i.RequestVtxoVw.Redeemed,
|
||||
&i.RequestVtxoVw.Swept,
|
||||
&i.RequestVtxoVw.ExpireAt,
|
||||
&i.RequestVtxoVw.CreatedAt,
|
||||
&i.RequestVtxoVw.RequestID,
|
||||
&i.RequestVtxoVw.RedeemTx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -515,24 +515,24 @@ func (q *Queries) SelectRoundWithRoundTxId(ctx context.Context, txid string) ([]
|
||||
|
||||
const selectSweepableRounds = `-- name: SelectSweepableRounds :many
|
||||
SELECT round.id, round.starting_timestamp, round.ending_timestamp, round.ended, round.failed, round.stage_code, round.txid, round.unsigned_tx, round.connector_address, round.dust_amount, round.version, round.swept,
|
||||
round_payment_vw.id, round_payment_vw.round_id,
|
||||
round_request_vw.id, round_request_vw.round_id,
|
||||
round_tx_vw.id, round_tx_vw.tx, round_tx_vw.round_id, round_tx_vw.type, round_tx_vw.position, round_tx_vw.txid, round_tx_vw.tree_level, round_tx_vw.parent_txid, round_tx_vw.is_leaf,
|
||||
payment_receiver_vw.payment_id, payment_receiver_vw.pubkey, payment_receiver_vw.onchain_address, payment_receiver_vw.amount,
|
||||
payment_vtxo_vw.txid, payment_vtxo_vw.vout, payment_vtxo_vw.pubkey, payment_vtxo_vw.amount, payment_vtxo_vw.pool_tx, payment_vtxo_vw.spent_by, payment_vtxo_vw.spent, payment_vtxo_vw.redeemed, payment_vtxo_vw.swept, payment_vtxo_vw.expire_at, payment_vtxo_vw.created_at, payment_vtxo_vw.payment_id, payment_vtxo_vw.redeem_tx
|
||||
request_receiver_vw.request_id, request_receiver_vw.pubkey, request_receiver_vw.onchain_address, request_receiver_vw.amount,
|
||||
request_vtxo_vw.txid, request_vtxo_vw.vout, request_vtxo_vw.pubkey, request_vtxo_vw.amount, request_vtxo_vw.round_tx, request_vtxo_vw.spent_by, request_vtxo_vw.spent, request_vtxo_vw.redeemed, request_vtxo_vw.swept, request_vtxo_vw.expire_at, request_vtxo_vw.created_at, request_vtxo_vw.request_id, request_vtxo_vw.redeem_tx
|
||||
FROM round
|
||||
LEFT OUTER JOIN round_payment_vw ON round.id=round_payment_vw.round_id
|
||||
LEFT OUTER JOIN round_request_vw ON round.id=round_request_vw.round_id
|
||||
LEFT OUTER JOIN round_tx_vw ON round.id=round_tx_vw.round_id
|
||||
LEFT OUTER JOIN payment_receiver_vw ON round_payment_vw.id=payment_receiver_vw.payment_id
|
||||
LEFT OUTER JOIN payment_vtxo_vw ON round_payment_vw.id=payment_vtxo_vw.payment_id
|
||||
LEFT OUTER JOIN request_receiver_vw ON round_request_vw.id=request_receiver_vw.request_id
|
||||
LEFT OUTER JOIN request_vtxo_vw ON round_request_vw.id=request_vtxo_vw.request_id
|
||||
WHERE round.swept = false AND round.ended = true AND round.failed = false
|
||||
`
|
||||
|
||||
type SelectSweepableRoundsRow struct {
|
||||
Round Round
|
||||
RoundPaymentVw RoundPaymentVw
|
||||
RoundRequestVw RoundRequestVw
|
||||
RoundTxVw RoundTxVw
|
||||
PaymentReceiverVw PaymentReceiverVw
|
||||
PaymentVtxoVw PaymentVtxoVw
|
||||
RequestReceiverVw RequestReceiverVw
|
||||
RequestVtxoVw RequestVtxoVw
|
||||
}
|
||||
|
||||
func (q *Queries) SelectSweepableRounds(ctx context.Context) ([]SelectSweepableRoundsRow, error) {
|
||||
@@ -557,8 +557,8 @@ func (q *Queries) SelectSweepableRounds(ctx context.Context) ([]SelectSweepableR
|
||||
&i.Round.DustAmount,
|
||||
&i.Round.Version,
|
||||
&i.Round.Swept,
|
||||
&i.RoundPaymentVw.ID,
|
||||
&i.RoundPaymentVw.RoundID,
|
||||
&i.RoundRequestVw.ID,
|
||||
&i.RoundRequestVw.RoundID,
|
||||
&i.RoundTxVw.ID,
|
||||
&i.RoundTxVw.Tx,
|
||||
&i.RoundTxVw.RoundID,
|
||||
@@ -568,23 +568,23 @@ func (q *Queries) SelectSweepableRounds(ctx context.Context) ([]SelectSweepableR
|
||||
&i.RoundTxVw.TreeLevel,
|
||||
&i.RoundTxVw.ParentTxid,
|
||||
&i.RoundTxVw.IsLeaf,
|
||||
&i.PaymentReceiverVw.PaymentID,
|
||||
&i.PaymentReceiverVw.Pubkey,
|
||||
&i.PaymentReceiverVw.OnchainAddress,
|
||||
&i.PaymentReceiverVw.Amount,
|
||||
&i.PaymentVtxoVw.Txid,
|
||||
&i.PaymentVtxoVw.Vout,
|
||||
&i.PaymentVtxoVw.Pubkey,
|
||||
&i.PaymentVtxoVw.Amount,
|
||||
&i.PaymentVtxoVw.PoolTx,
|
||||
&i.PaymentVtxoVw.SpentBy,
|
||||
&i.PaymentVtxoVw.Spent,
|
||||
&i.PaymentVtxoVw.Redeemed,
|
||||
&i.PaymentVtxoVw.Swept,
|
||||
&i.PaymentVtxoVw.ExpireAt,
|
||||
&i.PaymentVtxoVw.CreatedAt,
|
||||
&i.PaymentVtxoVw.PaymentID,
|
||||
&i.PaymentVtxoVw.RedeemTx,
|
||||
&i.RequestReceiverVw.RequestID,
|
||||
&i.RequestReceiverVw.Pubkey,
|
||||
&i.RequestReceiverVw.OnchainAddress,
|
||||
&i.RequestReceiverVw.Amount,
|
||||
&i.RequestVtxoVw.Txid,
|
||||
&i.RequestVtxoVw.Vout,
|
||||
&i.RequestVtxoVw.Pubkey,
|
||||
&i.RequestVtxoVw.Amount,
|
||||
&i.RequestVtxoVw.RoundTx,
|
||||
&i.RequestVtxoVw.SpentBy,
|
||||
&i.RequestVtxoVw.Spent,
|
||||
&i.RequestVtxoVw.Redeemed,
|
||||
&i.RequestVtxoVw.Swept,
|
||||
&i.RequestVtxoVw.ExpireAt,
|
||||
&i.RequestVtxoVw.CreatedAt,
|
||||
&i.RequestVtxoVw.RequestID,
|
||||
&i.RequestVtxoVw.RedeemTx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -600,7 +600,7 @@ func (q *Queries) SelectSweepableRounds(ctx context.Context) ([]SelectSweepableR
|
||||
}
|
||||
|
||||
const selectSweepableVtxos = `-- name: SelectSweepableVtxos :many
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.pool_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.payment_id, vtxo.redeem_tx FROM vtxo
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.round_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.request_id, vtxo.redeem_tx FROM vtxo
|
||||
WHERE redeemed = false AND swept = false
|
||||
`
|
||||
|
||||
@@ -622,14 +622,14 @@ func (q *Queries) SelectSweepableVtxos(ctx context.Context) ([]SelectSweepableVt
|
||||
&i.Vtxo.Vout,
|
||||
&i.Vtxo.Pubkey,
|
||||
&i.Vtxo.Amount,
|
||||
&i.Vtxo.PoolTx,
|
||||
&i.Vtxo.RoundTx,
|
||||
&i.Vtxo.SpentBy,
|
||||
&i.Vtxo.Spent,
|
||||
&i.Vtxo.Redeemed,
|
||||
&i.Vtxo.Swept,
|
||||
&i.Vtxo.ExpireAt,
|
||||
&i.Vtxo.CreatedAt,
|
||||
&i.Vtxo.PaymentID,
|
||||
&i.Vtxo.RequestID,
|
||||
&i.Vtxo.RedeemTx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
@@ -647,24 +647,24 @@ func (q *Queries) SelectSweepableVtxos(ctx context.Context) ([]SelectSweepableVt
|
||||
|
||||
const selectSweptRounds = `-- name: SelectSweptRounds :many
|
||||
SELECT round.id, round.starting_timestamp, round.ending_timestamp, round.ended, round.failed, round.stage_code, round.txid, round.unsigned_tx, round.connector_address, round.dust_amount, round.version, round.swept,
|
||||
round_payment_vw.id, round_payment_vw.round_id,
|
||||
round_request_vw.id, round_request_vw.round_id,
|
||||
round_tx_vw.id, round_tx_vw.tx, round_tx_vw.round_id, round_tx_vw.type, round_tx_vw.position, round_tx_vw.txid, round_tx_vw.tree_level, round_tx_vw.parent_txid, round_tx_vw.is_leaf,
|
||||
payment_receiver_vw.payment_id, payment_receiver_vw.pubkey, payment_receiver_vw.onchain_address, payment_receiver_vw.amount,
|
||||
payment_vtxo_vw.txid, payment_vtxo_vw.vout, payment_vtxo_vw.pubkey, payment_vtxo_vw.amount, payment_vtxo_vw.pool_tx, payment_vtxo_vw.spent_by, payment_vtxo_vw.spent, payment_vtxo_vw.redeemed, payment_vtxo_vw.swept, payment_vtxo_vw.expire_at, payment_vtxo_vw.created_at, payment_vtxo_vw.payment_id, payment_vtxo_vw.redeem_tx
|
||||
request_receiver_vw.request_id, request_receiver_vw.pubkey, request_receiver_vw.onchain_address, request_receiver_vw.amount,
|
||||
request_vtxo_vw.txid, request_vtxo_vw.vout, request_vtxo_vw.pubkey, request_vtxo_vw.amount, request_vtxo_vw.round_tx, request_vtxo_vw.spent_by, request_vtxo_vw.spent, request_vtxo_vw.redeemed, request_vtxo_vw.swept, request_vtxo_vw.expire_at, request_vtxo_vw.created_at, request_vtxo_vw.request_id, request_vtxo_vw.redeem_tx
|
||||
FROM round
|
||||
LEFT OUTER JOIN round_payment_vw ON round.id=round_payment_vw.round_id
|
||||
LEFT OUTER JOIN round_request_vw ON round.id=round_request_vw.round_id
|
||||
LEFT OUTER JOIN round_tx_vw ON round.id=round_tx_vw.round_id
|
||||
LEFT OUTER JOIN payment_receiver_vw ON round_payment_vw.id=payment_receiver_vw.payment_id
|
||||
LEFT OUTER JOIN payment_vtxo_vw ON round_payment_vw.id=payment_vtxo_vw.payment_id
|
||||
LEFT OUTER JOIN request_receiver_vw ON round_request_vw.id=request_receiver_vw.request_id
|
||||
LEFT OUTER JOIN request_vtxo_vw ON round_request_vw.id=request_vtxo_vw.request_id
|
||||
WHERE round.swept = true AND round.failed = false AND round.ended = true AND round.connector_address <> ''
|
||||
`
|
||||
|
||||
type SelectSweptRoundsRow struct {
|
||||
Round Round
|
||||
RoundPaymentVw RoundPaymentVw
|
||||
RoundRequestVw RoundRequestVw
|
||||
RoundTxVw RoundTxVw
|
||||
PaymentReceiverVw PaymentReceiverVw
|
||||
PaymentVtxoVw PaymentVtxoVw
|
||||
RequestReceiverVw RequestReceiverVw
|
||||
RequestVtxoVw RequestVtxoVw
|
||||
}
|
||||
|
||||
func (q *Queries) SelectSweptRounds(ctx context.Context) ([]SelectSweptRoundsRow, error) {
|
||||
@@ -689,8 +689,8 @@ func (q *Queries) SelectSweptRounds(ctx context.Context) ([]SelectSweptRoundsRow
|
||||
&i.Round.DustAmount,
|
||||
&i.Round.Version,
|
||||
&i.Round.Swept,
|
||||
&i.RoundPaymentVw.ID,
|
||||
&i.RoundPaymentVw.RoundID,
|
||||
&i.RoundRequestVw.ID,
|
||||
&i.RoundRequestVw.RoundID,
|
||||
&i.RoundTxVw.ID,
|
||||
&i.RoundTxVw.Tx,
|
||||
&i.RoundTxVw.RoundID,
|
||||
@@ -700,23 +700,23 @@ func (q *Queries) SelectSweptRounds(ctx context.Context) ([]SelectSweptRoundsRow
|
||||
&i.RoundTxVw.TreeLevel,
|
||||
&i.RoundTxVw.ParentTxid,
|
||||
&i.RoundTxVw.IsLeaf,
|
||||
&i.PaymentReceiverVw.PaymentID,
|
||||
&i.PaymentReceiverVw.Pubkey,
|
||||
&i.PaymentReceiverVw.OnchainAddress,
|
||||
&i.PaymentReceiverVw.Amount,
|
||||
&i.PaymentVtxoVw.Txid,
|
||||
&i.PaymentVtxoVw.Vout,
|
||||
&i.PaymentVtxoVw.Pubkey,
|
||||
&i.PaymentVtxoVw.Amount,
|
||||
&i.PaymentVtxoVw.PoolTx,
|
||||
&i.PaymentVtxoVw.SpentBy,
|
||||
&i.PaymentVtxoVw.Spent,
|
||||
&i.PaymentVtxoVw.Redeemed,
|
||||
&i.PaymentVtxoVw.Swept,
|
||||
&i.PaymentVtxoVw.ExpireAt,
|
||||
&i.PaymentVtxoVw.CreatedAt,
|
||||
&i.PaymentVtxoVw.PaymentID,
|
||||
&i.PaymentVtxoVw.RedeemTx,
|
||||
&i.RequestReceiverVw.RequestID,
|
||||
&i.RequestReceiverVw.Pubkey,
|
||||
&i.RequestReceiverVw.OnchainAddress,
|
||||
&i.RequestReceiverVw.Amount,
|
||||
&i.RequestVtxoVw.Txid,
|
||||
&i.RequestVtxoVw.Vout,
|
||||
&i.RequestVtxoVw.Pubkey,
|
||||
&i.RequestVtxoVw.Amount,
|
||||
&i.RequestVtxoVw.RoundTx,
|
||||
&i.RequestVtxoVw.SpentBy,
|
||||
&i.RequestVtxoVw.Spent,
|
||||
&i.RequestVtxoVw.Redeemed,
|
||||
&i.RequestVtxoVw.Swept,
|
||||
&i.RequestVtxoVw.ExpireAt,
|
||||
&i.RequestVtxoVw.CreatedAt,
|
||||
&i.RequestVtxoVw.RequestID,
|
||||
&i.RequestVtxoVw.RedeemTx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -732,7 +732,7 @@ func (q *Queries) SelectSweptRounds(ctx context.Context) ([]SelectSweptRoundsRow
|
||||
}
|
||||
|
||||
const selectVtxoByOutpoint = `-- name: SelectVtxoByOutpoint :one
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.pool_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.payment_id, vtxo.redeem_tx FROM vtxo
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.round_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.request_id, vtxo.redeem_tx FROM vtxo
|
||||
WHERE txid = ? AND vout = ?
|
||||
`
|
||||
|
||||
@@ -753,50 +753,50 @@ func (q *Queries) SelectVtxoByOutpoint(ctx context.Context, arg SelectVtxoByOutp
|
||||
&i.Vtxo.Vout,
|
||||
&i.Vtxo.Pubkey,
|
||||
&i.Vtxo.Amount,
|
||||
&i.Vtxo.PoolTx,
|
||||
&i.Vtxo.RoundTx,
|
||||
&i.Vtxo.SpentBy,
|
||||
&i.Vtxo.Spent,
|
||||
&i.Vtxo.Redeemed,
|
||||
&i.Vtxo.Swept,
|
||||
&i.Vtxo.ExpireAt,
|
||||
&i.Vtxo.CreatedAt,
|
||||
&i.Vtxo.PaymentID,
|
||||
&i.Vtxo.RequestID,
|
||||
&i.Vtxo.RedeemTx,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const selectVtxosByPoolTxid = `-- name: SelectVtxosByPoolTxid :many
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.pool_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.payment_id, vtxo.redeem_tx FROM vtxo
|
||||
WHERE pool_tx = ?
|
||||
const selectVtxosByRoundTxid = `-- name: SelectVtxosByRoundTxid :many
|
||||
SELECT vtxo.txid, vtxo.vout, vtxo.pubkey, vtxo.amount, vtxo.round_tx, vtxo.spent_by, vtxo.spent, vtxo.redeemed, vtxo.swept, vtxo.expire_at, vtxo.created_at, vtxo.request_id, vtxo.redeem_tx FROM vtxo
|
||||
WHERE round_tx = ?
|
||||
`
|
||||
|
||||
type SelectVtxosByPoolTxidRow struct {
|
||||
type SelectVtxosByRoundTxidRow struct {
|
||||
Vtxo Vtxo
|
||||
}
|
||||
|
||||
func (q *Queries) SelectVtxosByPoolTxid(ctx context.Context, poolTx string) ([]SelectVtxosByPoolTxidRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, selectVtxosByPoolTxid, poolTx)
|
||||
func (q *Queries) SelectVtxosByRoundTxid(ctx context.Context, roundTx string) ([]SelectVtxosByRoundTxidRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, selectVtxosByRoundTxid, roundTx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []SelectVtxosByPoolTxidRow
|
||||
var items []SelectVtxosByRoundTxidRow
|
||||
for rows.Next() {
|
||||
var i SelectVtxosByPoolTxidRow
|
||||
var i SelectVtxosByRoundTxidRow
|
||||
if err := rows.Scan(
|
||||
&i.Vtxo.Txid,
|
||||
&i.Vtxo.Vout,
|
||||
&i.Vtxo.Pubkey,
|
||||
&i.Vtxo.Amount,
|
||||
&i.Vtxo.PoolTx,
|
||||
&i.Vtxo.RoundTx,
|
||||
&i.Vtxo.SpentBy,
|
||||
&i.Vtxo.Spent,
|
||||
&i.Vtxo.Redeemed,
|
||||
&i.Vtxo.Swept,
|
||||
&i.Vtxo.ExpireAt,
|
||||
&i.Vtxo.CreatedAt,
|
||||
&i.Vtxo.PaymentID,
|
||||
&i.Vtxo.RequestID,
|
||||
&i.Vtxo.RedeemTx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
@@ -868,18 +868,18 @@ func (q *Queries) UpdateVtxoExpireAt(ctx context.Context, arg UpdateVtxoExpireAt
|
||||
return err
|
||||
}
|
||||
|
||||
const updateVtxoPaymentId = `-- name: UpdateVtxoPaymentId :exec
|
||||
UPDATE vtxo SET payment_id = ? WHERE txid = ? AND vout = ?
|
||||
const updateVtxoRequestId = `-- name: UpdateVtxoRequestId :exec
|
||||
UPDATE vtxo SET request_id = ? WHERE txid = ? AND vout = ?
|
||||
`
|
||||
|
||||
type UpdateVtxoPaymentIdParams struct {
|
||||
PaymentID sql.NullString
|
||||
type UpdateVtxoRequestIdParams struct {
|
||||
RequestID sql.NullString
|
||||
Txid string
|
||||
Vout int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateVtxoPaymentId(ctx context.Context, arg UpdateVtxoPaymentIdParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateVtxoPaymentId, arg.PaymentID, arg.Txid, arg.Vout)
|
||||
func (q *Queries) UpdateVtxoRequestId(ctx context.Context, arg UpdateVtxoRequestIdParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateVtxoRequestId, arg.RequestID, arg.Txid, arg.Vout)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -916,31 +916,16 @@ func (q *Queries) UpsertEntityVtxo(ctx context.Context, arg UpsertEntityVtxoPara
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertPayment = `-- name: UpsertPayment :exec
|
||||
INSERT INTO payment (id, round_id) VALUES (?, ?)
|
||||
ON CONFLICT(id) DO UPDATE SET round_id = EXCLUDED.round_id
|
||||
`
|
||||
|
||||
type UpsertPaymentParams struct {
|
||||
ID string
|
||||
RoundID string
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertPayment(ctx context.Context, arg UpsertPaymentParams) error {
|
||||
_, err := q.db.ExecContext(ctx, upsertPayment, arg.ID, arg.RoundID)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertReceiver = `-- name: UpsertReceiver :exec
|
||||
INSERT INTO receiver (payment_id, pubkey, onchain_address, amount) VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT(payment_id, pubkey, onchain_address) DO UPDATE SET
|
||||
INSERT INTO receiver (request_id, pubkey, onchain_address, amount) VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT(request_id, pubkey, onchain_address) DO UPDATE SET
|
||||
amount = EXCLUDED.amount,
|
||||
pubkey = EXCLUDED.pubkey,
|
||||
onchain_address = EXCLUDED.onchain_address
|
||||
`
|
||||
|
||||
type UpsertReceiverParams struct {
|
||||
PaymentID string
|
||||
RequestID string
|
||||
Pubkey sql.NullString
|
||||
OnchainAddress sql.NullString
|
||||
Amount int64
|
||||
@@ -948,7 +933,7 @@ type UpsertReceiverParams struct {
|
||||
|
||||
func (q *Queries) UpsertReceiver(ctx context.Context, arg UpsertReceiverParams) error {
|
||||
_, err := q.db.ExecContext(ctx, upsertReceiver,
|
||||
arg.PaymentID,
|
||||
arg.RequestID,
|
||||
arg.Pubkey,
|
||||
arg.OnchainAddress,
|
||||
arg.Amount,
|
||||
@@ -1057,12 +1042,27 @@ func (q *Queries) UpsertTransaction(ctx context.Context, arg UpsertTransactionPa
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertTxRequest = `-- name: UpsertTxRequest :exec
|
||||
INSERT INTO tx_request (id, round_id) VALUES (?, ?)
|
||||
ON CONFLICT(id) DO UPDATE SET round_id = EXCLUDED.round_id
|
||||
`
|
||||
|
||||
type UpsertTxRequestParams struct {
|
||||
ID string
|
||||
RoundID string
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertTxRequest(ctx context.Context, arg UpsertTxRequestParams) error {
|
||||
_, err := q.db.ExecContext(ctx, upsertTxRequest, arg.ID, arg.RoundID)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertVtxo = `-- name: UpsertVtxo :exec
|
||||
INSERT INTO vtxo (txid, vout, pubkey, amount, pool_tx, spent_by, spent, redeemed, swept, expire_at, created_at, redeem_tx)
|
||||
INSERT INTO vtxo (txid, vout, pubkey, amount, round_tx, spent_by, spent, redeemed, swept, expire_at, created_at, redeem_tx)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(txid, vout) DO UPDATE SET
|
||||
pubkey = EXCLUDED.pubkey,
|
||||
amount = EXCLUDED.amount,
|
||||
pool_tx = EXCLUDED.pool_tx,
|
||||
round_tx = EXCLUDED.round_tx,
|
||||
spent_by = EXCLUDED.spent_by,
|
||||
spent = EXCLUDED.spent,
|
||||
redeemed = EXCLUDED.redeemed,
|
||||
@@ -1077,7 +1077,7 @@ type UpsertVtxoParams struct {
|
||||
Vout int64
|
||||
Pubkey string
|
||||
Amount int64
|
||||
PoolTx string
|
||||
RoundTx string
|
||||
SpentBy string
|
||||
Spent bool
|
||||
Redeemed bool
|
||||
@@ -1093,7 +1093,7 @@ func (q *Queries) UpsertVtxo(ctx context.Context, arg UpsertVtxoParams) error {
|
||||
arg.Vout,
|
||||
arg.Pubkey,
|
||||
arg.Amount,
|
||||
arg.PoolTx,
|
||||
arg.RoundTx,
|
||||
arg.SpentBy,
|
||||
arg.Spent,
|
||||
arg.Redeemed,
|
||||
|
||||
@@ -39,70 +39,70 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
version = EXCLUDED.version,
|
||||
swept = EXCLUDED.swept;
|
||||
|
||||
-- name: UpsertPayment :exec
|
||||
INSERT INTO payment (id, round_id) VALUES (?, ?)
|
||||
-- name: UpsertTxRequest :exec
|
||||
INSERT INTO tx_request (id, round_id) VALUES (?, ?)
|
||||
ON CONFLICT(id) DO UPDATE SET round_id = EXCLUDED.round_id;
|
||||
|
||||
-- name: UpsertReceiver :exec
|
||||
INSERT INTO receiver (payment_id, pubkey, onchain_address, amount) VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT(payment_id, pubkey, onchain_address) DO UPDATE SET
|
||||
INSERT INTO receiver (request_id, pubkey, onchain_address, amount) VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT(request_id, pubkey, onchain_address) DO UPDATE SET
|
||||
amount = EXCLUDED.amount,
|
||||
pubkey = EXCLUDED.pubkey,
|
||||
onchain_address = EXCLUDED.onchain_address;
|
||||
|
||||
-- name: UpdateVtxoPaymentId :exec
|
||||
UPDATE vtxo SET payment_id = ? WHERE txid = ? AND vout = ?;
|
||||
-- name: UpdateVtxoRequestId :exec
|
||||
UPDATE vtxo SET request_id = ? WHERE txid = ? AND vout = ?;
|
||||
|
||||
-- name: SelectRoundWithRoundId :many
|
||||
SELECT sqlc.embed(round),
|
||||
sqlc.embed(round_payment_vw),
|
||||
sqlc.embed(round_request_vw),
|
||||
sqlc.embed(round_tx_vw),
|
||||
sqlc.embed(payment_receiver_vw),
|
||||
sqlc.embed(payment_vtxo_vw)
|
||||
sqlc.embed(request_receiver_vw),
|
||||
sqlc.embed(request_vtxo_vw)
|
||||
FROM round
|
||||
LEFT OUTER JOIN round_payment_vw ON round.id=round_payment_vw.round_id
|
||||
LEFT OUTER JOIN round_request_vw ON round.id=round_request_vw.round_id
|
||||
LEFT OUTER JOIN round_tx_vw ON round.id=round_tx_vw.round_id
|
||||
LEFT OUTER JOIN payment_receiver_vw ON round_payment_vw.id=payment_receiver_vw.payment_id
|
||||
LEFT OUTER JOIN payment_vtxo_vw ON round_payment_vw.id=payment_vtxo_vw.payment_id
|
||||
LEFT OUTER JOIN request_receiver_vw ON round_request_vw.id=request_receiver_vw.request_id
|
||||
LEFT OUTER JOIN request_vtxo_vw ON round_request_vw.id=request_vtxo_vw.request_id
|
||||
WHERE round.id = ?;
|
||||
|
||||
-- name: SelectRoundWithRoundTxId :many
|
||||
SELECT sqlc.embed(round),
|
||||
sqlc.embed(round_payment_vw),
|
||||
sqlc.embed(round_request_vw),
|
||||
sqlc.embed(round_tx_vw),
|
||||
sqlc.embed(payment_receiver_vw),
|
||||
sqlc.embed(payment_vtxo_vw)
|
||||
sqlc.embed(request_receiver_vw),
|
||||
sqlc.embed(request_vtxo_vw)
|
||||
FROM round
|
||||
LEFT OUTER JOIN round_payment_vw ON round.id=round_payment_vw.round_id
|
||||
LEFT OUTER JOIN round_request_vw ON round.id=round_request_vw.round_id
|
||||
LEFT OUTER JOIN round_tx_vw ON round.id=round_tx_vw.round_id
|
||||
LEFT OUTER JOIN payment_receiver_vw ON round_payment_vw.id=payment_receiver_vw.payment_id
|
||||
LEFT OUTER JOIN payment_vtxo_vw ON round_payment_vw.id=payment_vtxo_vw.payment_id
|
||||
LEFT OUTER JOIN request_receiver_vw ON round_request_vw.id=request_receiver_vw.request_id
|
||||
LEFT OUTER JOIN request_vtxo_vw ON round_request_vw.id=request_vtxo_vw.request_id
|
||||
WHERE round.txid = ?;
|
||||
|
||||
-- name: SelectSweepableRounds :many
|
||||
SELECT sqlc.embed(round),
|
||||
sqlc.embed(round_payment_vw),
|
||||
sqlc.embed(round_request_vw),
|
||||
sqlc.embed(round_tx_vw),
|
||||
sqlc.embed(payment_receiver_vw),
|
||||
sqlc.embed(payment_vtxo_vw)
|
||||
sqlc.embed(request_receiver_vw),
|
||||
sqlc.embed(request_vtxo_vw)
|
||||
FROM round
|
||||
LEFT OUTER JOIN round_payment_vw ON round.id=round_payment_vw.round_id
|
||||
LEFT OUTER JOIN round_request_vw ON round.id=round_request_vw.round_id
|
||||
LEFT OUTER JOIN round_tx_vw ON round.id=round_tx_vw.round_id
|
||||
LEFT OUTER JOIN payment_receiver_vw ON round_payment_vw.id=payment_receiver_vw.payment_id
|
||||
LEFT OUTER JOIN payment_vtxo_vw ON round_payment_vw.id=payment_vtxo_vw.payment_id
|
||||
LEFT OUTER JOIN request_receiver_vw ON round_request_vw.id=request_receiver_vw.request_id
|
||||
LEFT OUTER JOIN request_vtxo_vw ON round_request_vw.id=request_vtxo_vw.request_id
|
||||
WHERE round.swept = false AND round.ended = true AND round.failed = false;
|
||||
|
||||
-- name: SelectSweptRounds :many
|
||||
SELECT sqlc.embed(round),
|
||||
sqlc.embed(round_payment_vw),
|
||||
sqlc.embed(round_request_vw),
|
||||
sqlc.embed(round_tx_vw),
|
||||
sqlc.embed(payment_receiver_vw),
|
||||
sqlc.embed(payment_vtxo_vw)
|
||||
sqlc.embed(request_receiver_vw),
|
||||
sqlc.embed(request_vtxo_vw)
|
||||
FROM round
|
||||
LEFT OUTER JOIN round_payment_vw ON round.id=round_payment_vw.round_id
|
||||
LEFT OUTER JOIN round_request_vw ON round.id=round_request_vw.round_id
|
||||
LEFT OUTER JOIN round_tx_vw ON round.id=round_tx_vw.round_id
|
||||
LEFT OUTER JOIN payment_receiver_vw ON round_payment_vw.id=payment_receiver_vw.payment_id
|
||||
LEFT OUTER JOIN payment_vtxo_vw ON round_payment_vw.id=payment_vtxo_vw.payment_id
|
||||
LEFT OUTER JOIN request_receiver_vw ON round_request_vw.id=request_receiver_vw.request_id
|
||||
LEFT OUTER JOIN request_vtxo_vw ON round_request_vw.id=request_vtxo_vw.request_id
|
||||
WHERE round.swept = true AND round.failed = false AND round.ended = true AND round.connector_address <> '';
|
||||
|
||||
-- name: SelectRoundIdsInRange :many
|
||||
@@ -112,11 +112,11 @@ SELECT id FROM round WHERE starting_timestamp > ? AND starting_timestamp < ?;
|
||||
SELECT id FROM round;
|
||||
|
||||
-- name: UpsertVtxo :exec
|
||||
INSERT INTO vtxo (txid, vout, pubkey, amount, pool_tx, spent_by, spent, redeemed, swept, expire_at, created_at, redeem_tx)
|
||||
INSERT INTO vtxo (txid, vout, pubkey, amount, round_tx, spent_by, spent, redeemed, swept, expire_at, created_at, redeem_tx)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(txid, vout) DO UPDATE SET
|
||||
pubkey = EXCLUDED.pubkey,
|
||||
amount = EXCLUDED.amount,
|
||||
pool_tx = EXCLUDED.pool_tx,
|
||||
round_tx = EXCLUDED.round_tx,
|
||||
spent_by = EXCLUDED.spent_by,
|
||||
spent = EXCLUDED.spent,
|
||||
redeemed = EXCLUDED.redeemed,
|
||||
@@ -141,9 +141,9 @@ WHERE redeemed = false AND pubkey = ?;
|
||||
SELECT sqlc.embed(vtxo) FROM vtxo
|
||||
WHERE txid = ? AND vout = ?;
|
||||
|
||||
-- name: SelectVtxosByPoolTxid :many
|
||||
-- name: SelectVtxosByRoundTxid :many
|
||||
SELECT sqlc.embed(vtxo) FROM vtxo
|
||||
WHERE pool_tx = ?;
|
||||
WHERE round_tx = ?;
|
||||
|
||||
-- name: MarkVtxoAsRedeemed :exec
|
||||
UPDATE vtxo SET redeemed = true WHERE txid = ? AND vout = ?;
|
||||
|
||||
@@ -42,9 +42,9 @@ func (v *vxtoRepository) AddVtxos(ctx context.Context, vtxos []domain.Vtxo) erro
|
||||
ctx, queries.UpsertVtxoParams{
|
||||
Txid: vtxo.Txid,
|
||||
Vout: int64(vtxo.VOut),
|
||||
Pubkey: vtxo.Pubkey,
|
||||
Pubkey: vtxo.PubKey,
|
||||
Amount: int64(vtxo.Amount),
|
||||
PoolTx: vtxo.RoundTxid,
|
||||
RoundTx: vtxo.RoundTxid,
|
||||
SpentBy: vtxo.SpentBy,
|
||||
Spent: vtxo.Spent,
|
||||
Redeemed: vtxo.Redeemed,
|
||||
@@ -150,7 +150,7 @@ func (v *vxtoRepository) GetVtxos(ctx context.Context, outpoints []domain.VtxoKe
|
||||
}
|
||||
|
||||
func (v *vxtoRepository) GetVtxosForRound(ctx context.Context, txid string) ([]domain.Vtxo, error) {
|
||||
res, err := v.querier.SelectVtxosByPoolTxid(ctx, txid)
|
||||
res, err := v.querier.SelectVtxosByRoundTxid(ctx, txid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -251,8 +251,8 @@ func rowToVtxo(row queries.Vtxo) domain.Vtxo {
|
||||
VOut: uint32(row.Vout),
|
||||
},
|
||||
Amount: uint64(row.Amount),
|
||||
Pubkey: row.Pubkey,
|
||||
RoundTxid: row.PoolTx,
|
||||
PubKey: row.Pubkey,
|
||||
RoundTxid: row.RoundTx,
|
||||
SpentBy: row.SpentBy,
|
||||
Spent: row.Spent,
|
||||
Redeemed: row.Redeemed,
|
||||
|
||||
Reference in New Issue
Block a user