diff --git a/loopdb/sqlc/migrations/000019_static_selected_amount.down.sql b/loopdb/sqlc/migrations/000019_static_selected_amount.down.sql new file mode 100644 index 00000000..ae6852fc --- /dev/null +++ b/loopdb/sqlc/migrations/000019_static_selected_amount.down.sql @@ -0,0 +1,3 @@ +-- selected_amount is a fractional amount amongst selected deposits of a static +-- address loop-in swap. +ALTER TABLE static_address_swaps DROP COLUMN selected_amount; diff --git a/loopdb/sqlc/migrations/000019_static_selected_amount.up.sql b/loopdb/sqlc/migrations/000019_static_selected_amount.up.sql new file mode 100644 index 00000000..52027e30 --- /dev/null +++ b/loopdb/sqlc/migrations/000019_static_selected_amount.up.sql @@ -0,0 +1,4 @@ +-- selected_amount is a fractional amount amongst selected deposits of a static +-- address loop-in swap. A selected amount of 0 indicates that the total amount +-- of deposits is selected for the swap. +ALTER TABLE static_address_swaps ADD selected_amount BIGINT NOT NULL DEFAULT 0; diff --git a/loopdb/sqlc/models.go b/loopdb/sqlc/models.go index 46766aca..432cf8d0 100644 --- a/loopdb/sqlc/models.go +++ b/loopdb/sqlc/models.go @@ -147,6 +147,7 @@ type StaticAddressSwap struct { HtlcTxFeeRateSatKw int64 HtlcTimeoutSweepTxID sql.NullString HtlcTimeoutSweepAddress string + SelectedAmount int64 } type StaticAddressSwapUpdate struct { diff --git a/loopdb/sqlc/queries/static_address_loopin.sql b/loopdb/sqlc/queries/static_address_loopin.sql index 36a6cfdc..2d35b906 100644 --- a/loopdb/sqlc/queries/static_address_loopin.sql +++ b/loopdb/sqlc/queries/static_address_loopin.sql @@ -6,6 +6,7 @@ INSERT INTO static_address_swaps ( payment_timeout_seconds, quoted_swap_fee_satoshis, deposit_outpoints, + selected_amount, htlc_tx_fee_rate_sat_kw, htlc_timeout_sweep_tx_id, htlc_timeout_sweep_address @@ -18,7 +19,8 @@ INSERT INTO static_address_swaps ( $6, $7, $8, - $9 + $9, + $10 ); -- name: UpdateStaticAddressLoopIn :exec diff --git a/loopdb/sqlc/static_address_loopin.sql.go b/loopdb/sqlc/static_address_loopin.sql.go index 3d582dea..69e868ae 100644 --- a/loopdb/sqlc/static_address_loopin.sql.go +++ b/loopdb/sqlc/static_address_loopin.sql.go @@ -153,7 +153,7 @@ func (q *Queries) GetLoopInSwapUpdates(ctx context.Context, swapHash []byte) ([] const getStaticAddressLoopInSwap = `-- name: GetStaticAddressLoopInSwap :one SELECT swaps.id, swaps.swap_hash, swaps.preimage, swaps.initiation_time, swaps.amount_requested, swaps.cltv_expiry, swaps.max_miner_fee, swaps.max_swap_fee, swaps.initiation_height, swaps.protocol_version, swaps.label, - static_address_swaps.id, static_address_swaps.swap_hash, static_address_swaps.swap_invoice, static_address_swaps.last_hop, static_address_swaps.payment_timeout_seconds, static_address_swaps.quoted_swap_fee_satoshis, static_address_swaps.deposit_outpoints, static_address_swaps.htlc_tx_fee_rate_sat_kw, static_address_swaps.htlc_timeout_sweep_tx_id, static_address_swaps.htlc_timeout_sweep_address, + static_address_swaps.id, static_address_swaps.swap_hash, static_address_swaps.swap_invoice, static_address_swaps.last_hop, static_address_swaps.payment_timeout_seconds, static_address_swaps.quoted_swap_fee_satoshis, static_address_swaps.deposit_outpoints, static_address_swaps.htlc_tx_fee_rate_sat_kw, static_address_swaps.htlc_timeout_sweep_tx_id, static_address_swaps.htlc_timeout_sweep_address, static_address_swaps.selected_amount, htlc_keys.swap_hash, htlc_keys.sender_script_pubkey, htlc_keys.receiver_script_pubkey, htlc_keys.sender_internal_pubkey, htlc_keys.receiver_internal_pubkey, htlc_keys.client_key_family, htlc_keys.client_key_index FROM swaps @@ -187,6 +187,7 @@ type GetStaticAddressLoopInSwapRow struct { HtlcTxFeeRateSatKw int64 HtlcTimeoutSweepTxID sql.NullString HtlcTimeoutSweepAddress string + SelectedAmount int64 SwapHash_3 []byte SenderScriptPubkey []byte ReceiverScriptPubkey []byte @@ -221,6 +222,7 @@ func (q *Queries) GetStaticAddressLoopInSwap(ctx context.Context, swapHash []byt &i.HtlcTxFeeRateSatKw, &i.HtlcTimeoutSweepTxID, &i.HtlcTimeoutSweepAddress, + &i.SelectedAmount, &i.SwapHash_3, &i.SenderScriptPubkey, &i.ReceiverScriptPubkey, @@ -235,7 +237,7 @@ func (q *Queries) GetStaticAddressLoopInSwap(ctx context.Context, swapHash []byt const getStaticAddressLoopInSwapsByStates = `-- name: GetStaticAddressLoopInSwapsByStates :many SELECT swaps.id, swaps.swap_hash, swaps.preimage, swaps.initiation_time, swaps.amount_requested, swaps.cltv_expiry, swaps.max_miner_fee, swaps.max_swap_fee, swaps.initiation_height, swaps.protocol_version, swaps.label, - static_address_swaps.id, static_address_swaps.swap_hash, static_address_swaps.swap_invoice, static_address_swaps.last_hop, static_address_swaps.payment_timeout_seconds, static_address_swaps.quoted_swap_fee_satoshis, static_address_swaps.deposit_outpoints, static_address_swaps.htlc_tx_fee_rate_sat_kw, static_address_swaps.htlc_timeout_sweep_tx_id, static_address_swaps.htlc_timeout_sweep_address, + static_address_swaps.id, static_address_swaps.swap_hash, static_address_swaps.swap_invoice, static_address_swaps.last_hop, static_address_swaps.payment_timeout_seconds, static_address_swaps.quoted_swap_fee_satoshis, static_address_swaps.deposit_outpoints, static_address_swaps.htlc_tx_fee_rate_sat_kw, static_address_swaps.htlc_timeout_sweep_tx_id, static_address_swaps.htlc_timeout_sweep_address, static_address_swaps.selected_amount, htlc_keys.swap_hash, htlc_keys.sender_script_pubkey, htlc_keys.receiver_script_pubkey, htlc_keys.sender_internal_pubkey, htlc_keys.receiver_internal_pubkey, htlc_keys.client_key_family, htlc_keys.client_key_index FROM swaps @@ -280,6 +282,7 @@ type GetStaticAddressLoopInSwapsByStatesRow struct { HtlcTxFeeRateSatKw int64 HtlcTimeoutSweepTxID sql.NullString HtlcTimeoutSweepAddress string + SelectedAmount int64 SwapHash_3 []byte SenderScriptPubkey []byte ReceiverScriptPubkey []byte @@ -320,6 +323,7 @@ func (q *Queries) GetStaticAddressLoopInSwapsByStates(ctx context.Context, dolla &i.HtlcTxFeeRateSatKw, &i.HtlcTimeoutSweepTxID, &i.HtlcTimeoutSweepAddress, + &i.SelectedAmount, &i.SwapHash_3, &i.SenderScriptPubkey, &i.ReceiverScriptPubkey, @@ -349,6 +353,7 @@ INSERT INTO static_address_swaps ( payment_timeout_seconds, quoted_swap_fee_satoshis, deposit_outpoints, + selected_amount, htlc_tx_fee_rate_sat_kw, htlc_timeout_sweep_tx_id, htlc_timeout_sweep_address @@ -361,7 +366,8 @@ INSERT INTO static_address_swaps ( $6, $7, $8, - $9 + $9, + $10 ) ` @@ -372,6 +378,7 @@ type InsertStaticAddressLoopInParams struct { PaymentTimeoutSeconds int32 QuotedSwapFeeSatoshis int64 DepositOutpoints string + SelectedAmount int64 HtlcTxFeeRateSatKw int64 HtlcTimeoutSweepTxID sql.NullString HtlcTimeoutSweepAddress string @@ -385,6 +392,7 @@ func (q *Queries) InsertStaticAddressLoopIn(ctx context.Context, arg InsertStati arg.PaymentTimeoutSeconds, arg.QuotedSwapFeeSatoshis, arg.DepositOutpoints, + arg.SelectedAmount, arg.HtlcTxFeeRateSatKw, arg.HtlcTimeoutSweepTxID, arg.HtlcTimeoutSweepAddress,