2023-05-17 17:03:32 +00:00
|
|
|
-- name: GetLoopOutSwaps :many
|
2024-05-30 15:39:24 +00:00
|
|
|
SELECT
|
2023-05-17 17:03:32 +00:00
|
|
|
swaps.*,
|
|
|
|
loopout_swaps.*,
|
|
|
|
htlc_keys.*
|
2024-05-30 15:39:24 +00:00
|
|
|
FROM
|
2023-05-17 17:03:32 +00:00
|
|
|
swaps
|
|
|
|
JOIN
|
|
|
|
loopout_swaps ON swaps.swap_hash = loopout_swaps.swap_hash
|
|
|
|
JOIN
|
|
|
|
htlc_keys ON swaps.swap_hash = htlc_keys.swap_hash
|
|
|
|
ORDER BY
|
|
|
|
swaps.id;
|
|
|
|
|
|
|
|
-- name: GetLoopOutSwap :one
|
2024-05-30 15:39:24 +00:00
|
|
|
SELECT
|
2023-05-17 17:03:32 +00:00
|
|
|
swaps.*,
|
|
|
|
loopout_swaps.*,
|
|
|
|
htlc_keys.*
|
|
|
|
FROM
|
|
|
|
swaps
|
|
|
|
JOIN
|
|
|
|
loopout_swaps ON swaps.swap_hash = loopout_swaps.swap_hash
|
|
|
|
JOIN
|
|
|
|
htlc_keys ON swaps.swap_hash = htlc_keys.swap_hash
|
|
|
|
WHERE
|
|
|
|
swaps.swap_hash = $1;
|
|
|
|
|
|
|
|
-- name: GetLoopInSwaps :many
|
2024-05-30 15:39:24 +00:00
|
|
|
SELECT
|
2023-05-17 17:03:32 +00:00
|
|
|
swaps.*,
|
|
|
|
loopin_swaps.*,
|
|
|
|
htlc_keys.*
|
|
|
|
FROM
|
|
|
|
swaps
|
|
|
|
JOIN
|
|
|
|
loopin_swaps ON swaps.swap_hash = loopin_swaps.swap_hash
|
|
|
|
JOIN
|
|
|
|
htlc_keys ON swaps.swap_hash = htlc_keys.swap_hash
|
|
|
|
ORDER BY
|
|
|
|
swaps.id;
|
|
|
|
|
|
|
|
-- name: GetLoopInSwap :one
|
2024-05-30 15:39:24 +00:00
|
|
|
SELECT
|
2023-05-17 17:03:32 +00:00
|
|
|
swaps.*,
|
|
|
|
loopin_swaps.*,
|
|
|
|
htlc_keys.*
|
|
|
|
FROM
|
|
|
|
swaps
|
|
|
|
JOIN
|
|
|
|
loopin_swaps ON swaps.swap_hash = loopin_swaps.swap_hash
|
|
|
|
JOIN
|
|
|
|
htlc_keys ON swaps.swap_hash = htlc_keys.swap_hash
|
|
|
|
WHERE
|
|
|
|
swaps.swap_hash = $1;
|
|
|
|
|
|
|
|
-- name: GetSwapUpdates :many
|
2024-05-30 15:39:24 +00:00
|
|
|
SELECT
|
2023-05-17 17:03:32 +00:00
|
|
|
*
|
|
|
|
FROM
|
|
|
|
swap_updates
|
|
|
|
WHERE
|
|
|
|
swap_hash = $1
|
|
|
|
ORDER BY
|
|
|
|
id ASC;
|
|
|
|
|
|
|
|
-- name: InsertSwap :exec
|
|
|
|
INSERT INTO swaps (
|
|
|
|
swap_hash,
|
|
|
|
preimage,
|
|
|
|
initiation_time,
|
|
|
|
amount_requested,
|
|
|
|
cltv_expiry,
|
|
|
|
max_miner_fee,
|
|
|
|
max_swap_fee,
|
|
|
|
initiation_height,
|
|
|
|
protocol_version,
|
|
|
|
label
|
|
|
|
) VALUES (
|
|
|
|
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10
|
|
|
|
);
|
|
|
|
|
|
|
|
-- name: InsertSwapUpdate :exec
|
|
|
|
INSERT INTO swap_updates (
|
|
|
|
swap_hash,
|
|
|
|
update_timestamp,
|
|
|
|
update_state,
|
|
|
|
htlc_txhash,
|
|
|
|
server_cost,
|
|
|
|
onchain_cost,
|
|
|
|
offchain_cost
|
|
|
|
) VALUES (
|
|
|
|
$1, $2, $3, $4, $5, $6, $7
|
|
|
|
);
|
|
|
|
|
|
|
|
-- name: InsertLoopOut :exec
|
|
|
|
INSERT INTO loopout_swaps (
|
|
|
|
swap_hash,
|
|
|
|
dest_address,
|
|
|
|
swap_invoice,
|
|
|
|
max_swap_routing_fee,
|
|
|
|
sweep_conf_target,
|
|
|
|
htlc_confirmations,
|
|
|
|
outgoing_chan_set,
|
|
|
|
prepay_invoice,
|
|
|
|
max_prepay_routing_fee,
|
2023-09-05 17:48:25 +00:00
|
|
|
publication_deadline,
|
2024-05-09 14:36:10 +00:00
|
|
|
single_sweep,
|
|
|
|
payment_timeout
|
2023-05-17 17:03:32 +00:00
|
|
|
) VALUES (
|
2024-05-09 14:36:10 +00:00
|
|
|
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
|
2023-05-17 17:03:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
-- name: InsertLoopIn :exec
|
|
|
|
INSERT INTO loopin_swaps (
|
|
|
|
swap_hash,
|
|
|
|
htlc_conf_target,
|
|
|
|
last_hop,
|
|
|
|
external_htlc
|
|
|
|
) VALUES (
|
|
|
|
$1, $2, $3, $4
|
|
|
|
);
|
|
|
|
|
|
|
|
-- name: InsertHtlcKeys :exec
|
|
|
|
INSERT INTO htlc_keys(
|
|
|
|
swap_hash,
|
|
|
|
sender_script_pubkey,
|
|
|
|
receiver_script_pubkey,
|
|
|
|
sender_internal_pubkey,
|
|
|
|
receiver_internal_pubkey,
|
|
|
|
client_key_family,
|
|
|
|
client_key_index
|
|
|
|
) VALUES (
|
|
|
|
$1, $2, $3, $4, $5, $6, $7
|
2024-05-09 14:36:10 +00:00
|
|
|
);
|
2024-05-30 20:37:45 +00:00
|
|
|
|
|
|
|
-- name: GetLastUpdateID :one
|
|
|
|
SELECT id
|
|
|
|
FROM swap_updates
|
|
|
|
WHERE swap_hash = $1
|
|
|
|
ORDER BY update_timestamp DESC
|
|
|
|
LIMIT 1;
|
|
|
|
|
|
|
|
-- name: OverrideSwapCosts :exec
|
|
|
|
UPDATE swap_updates
|
|
|
|
SET
|
|
|
|
server_cost = $2,
|
|
|
|
onchain_cost = $3,
|
|
|
|
offchain_cost = $4
|
|
|
|
WHERE id = $1;
|
|
|
|
|