mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: method to fetch deposits by outpoints
This commit is contained in:
parent
bce9b5d45d
commit
e948c94b95
8 changed files with 135 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ type Querier interface {
|
|||
CreateStaticAddress(ctx context.Context, arg CreateStaticAddressParams) error
|
||||
CreateWithdrawal(ctx context.Context, arg CreateWithdrawalParams) error
|
||||
CreateWithdrawalDeposit(ctx context.Context, arg CreateWithdrawalDepositParams) error
|
||||
DepositForOutpoint(ctx context.Context, arg DepositForOutpointParams) (Deposit, error)
|
||||
FetchLiquidityParams(ctx context.Context) ([]byte, error)
|
||||
GetAllWithdrawals(ctx context.Context) ([]Withdrawal, error)
|
||||
GetBatchSweeps(ctx context.Context, batchID int32) ([]Sweep, error)
|
||||
|
|
|
|||
|
|
@ -49,6 +49,16 @@ FROM
|
|||
WHERE
|
||||
deposit_id = $1;
|
||||
|
||||
-- name: DepositForOutpoint :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
deposits
|
||||
WHERE
|
||||
tx_hash = $1
|
||||
AND
|
||||
out_index = $2;
|
||||
|
||||
-- name: AllDeposits :many
|
||||
SELECT
|
||||
*
|
||||
|
|
|
|||
|
|
@ -100,6 +100,39 @@ func (q *Queries) CreateDeposit(ctx context.Context, arg CreateDepositParams) er
|
|||
return err
|
||||
}
|
||||
|
||||
const depositForOutpoint = `-- name: DepositForOutpoint :one
|
||||
SELECT
|
||||
id, deposit_id, tx_hash, out_index, amount, confirmation_height, timeout_sweep_pk_script, expiry_sweep_txid, finalized_withdrawal_tx
|
||||
FROM
|
||||
deposits
|
||||
WHERE
|
||||
tx_hash = $1
|
||||
AND
|
||||
out_index = $2
|
||||
`
|
||||
|
||||
type DepositForOutpointParams struct {
|
||||
TxHash []byte
|
||||
OutIndex int32
|
||||
}
|
||||
|
||||
func (q *Queries) DepositForOutpoint(ctx context.Context, arg DepositForOutpointParams) (Deposit, error) {
|
||||
row := q.db.QueryRowContext(ctx, depositForOutpoint, arg.TxHash, arg.OutIndex)
|
||||
var i Deposit
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.DepositID,
|
||||
&i.TxHash,
|
||||
&i.OutIndex,
|
||||
&i.Amount,
|
||||
&i.ConfirmationHeight,
|
||||
&i.TimeoutSweepPkScript,
|
||||
&i.ExpirySweepTxid,
|
||||
&i.FinalizedWithdrawalTx,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getDeposit = `-- name: GetDeposit :one
|
||||
SELECT
|
||||
id, deposit_id, tx_hash, out_index, amount, confirmation_height, timeout_sweep_pk_script, expiry_sweep_txid, finalized_withdrawal_tx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue