-fix schema use
This commit is contained in:
parent
fb5037b8e3
commit
8800d0df9b
@ -239,7 +239,7 @@ CREATE OR REPLACE FUNCTION reserves_out_by_reserve_insert_trigger()
|
|||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO reserves_out_by_reserve
|
INSERT INTO exchange.reserves_out_by_reserve
|
||||||
(reserve_uuid
|
(reserve_uuid
|
||||||
,h_blind_ev)
|
,h_blind_ev)
|
||||||
VALUES
|
VALUES
|
||||||
@ -260,7 +260,7 @@ CREATE OR REPLACE FUNCTION reserves_out_by_reserve_delete_trigger()
|
|||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
DELETE FROM reserves_out_by_reserve
|
DELETE FROM exchange.reserves_out_by_reserve
|
||||||
WHERE reserve_uuid = OLD.reserve_uuid;
|
WHERE reserve_uuid = OLD.reserve_uuid;
|
||||||
RETURN OLD;
|
RETURN OLD;
|
||||||
END $$;
|
END $$;
|
||||||
@ -533,7 +533,7 @@ BEGIN
|
|||||||
|
|
||||||
IF (is_ready)
|
IF (is_ready)
|
||||||
THEN
|
THEN
|
||||||
INSERT INTO deposits_by_ready
|
INSERT INTO exchange.deposits_by_ready
|
||||||
(wire_deadline
|
(wire_deadline
|
||||||
,shard
|
,shard
|
||||||
,coin_pub
|
,coin_pub
|
||||||
@ -543,7 +543,7 @@ BEGIN
|
|||||||
,NEW.shard
|
,NEW.shard
|
||||||
,NEW.coin_pub
|
,NEW.coin_pub
|
||||||
,NEW.deposit_serial_id);
|
,NEW.deposit_serial_id);
|
||||||
INSERT INTO deposits_for_matching
|
INSERT INTO exchange.deposits_for_matching
|
||||||
(refund_deadline
|
(refund_deadline
|
||||||
,merchant_pub
|
,merchant_pub
|
||||||
,coin_pub
|
,coin_pub
|
||||||
@ -577,12 +577,12 @@ BEGIN
|
|||||||
is_ready = NOT (NEW.done OR NEW.extension_blocked);
|
is_ready = NOT (NEW.done OR NEW.extension_blocked);
|
||||||
IF (was_ready AND NOT is_ready)
|
IF (was_ready AND NOT is_ready)
|
||||||
THEN
|
THEN
|
||||||
DELETE FROM deposits_by_ready
|
DELETE FROM exchange.deposits_by_ready
|
||||||
WHERE wire_deadline = OLD.wire_deadline
|
WHERE wire_deadline = OLD.wire_deadline
|
||||||
AND shard = OLD.shard
|
AND shard = OLD.shard
|
||||||
AND coin_pub = OLD.coin_pub
|
AND coin_pub = OLD.coin_pub
|
||||||
AND deposit_serial_id = OLD.deposit_serial_id;
|
AND deposit_serial_id = OLD.deposit_serial_id;
|
||||||
DELETE FROM deposits_for_matching
|
DELETE FROM exchange.deposits_for_matching
|
||||||
WHERE refund_deadline = OLD.refund_deadline
|
WHERE refund_deadline = OLD.refund_deadline
|
||||||
AND merchant_pub = OLD.merchant_pub
|
AND merchant_pub = OLD.merchant_pub
|
||||||
AND coin_pub = OLD.coin_pub
|
AND coin_pub = OLD.coin_pub
|
||||||
@ -590,7 +590,7 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
IF (is_ready AND NOT was_ready)
|
IF (is_ready AND NOT was_ready)
|
||||||
THEN
|
THEN
|
||||||
INSERT INTO deposits_by_ready
|
INSERT INTO exchange.deposits_by_ready
|
||||||
(wire_deadline
|
(wire_deadline
|
||||||
,shard
|
,shard
|
||||||
,coin_pub
|
,coin_pub
|
||||||
@ -600,7 +600,7 @@ BEGIN
|
|||||||
,NEW.shard
|
,NEW.shard
|
||||||
,NEW.coin_pub
|
,NEW.coin_pub
|
||||||
,NEW.deposit_serial_id);
|
,NEW.deposit_serial_id);
|
||||||
INSERT INTO deposits_for_matching
|
INSERT INTO exchange.deposits_for_matching
|
||||||
(refund_deadline
|
(refund_deadline
|
||||||
,merchant_pub
|
,merchant_pub
|
||||||
,coin_pub
|
,coin_pub
|
||||||
@ -632,12 +632,12 @@ BEGIN
|
|||||||
|
|
||||||
IF (was_ready)
|
IF (was_ready)
|
||||||
THEN
|
THEN
|
||||||
DELETE FROM deposits_by_ready
|
DELETE FROM exchange.deposits_by_ready
|
||||||
WHERE wire_deadline = OLD.wire_deadline
|
WHERE wire_deadline = OLD.wire_deadline
|
||||||
AND shard = OLD.shard
|
AND shard = OLD.shard
|
||||||
AND coin_pub = OLD.coin_pub
|
AND coin_pub = OLD.coin_pub
|
||||||
AND deposit_serial_id = OLD.deposit_serial_id;
|
AND deposit_serial_id = OLD.deposit_serial_id;
|
||||||
DELETE FROM deposits_for_matching
|
DELETE FROM exchange.deposits_for_matching
|
||||||
WHERE refund_deadline = OLD.refund_deadline
|
WHERE refund_deadline = OLD.refund_deadline
|
||||||
AND merchant_pub = OLD.merchant_pub
|
AND merchant_pub = OLD.merchant_pub
|
||||||
AND coin_pub = OLD.coin_pub
|
AND coin_pub = OLD.coin_pub
|
||||||
@ -694,7 +694,7 @@ CREATE OR REPLACE FUNCTION wire_out_delete_trigger()
|
|||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
DELETE FROM aggregation_tracking
|
DELETE FROM exchange.aggregation_tracking
|
||||||
WHERE wtid_raw = OLD.wtid_raw;
|
WHERE wtid_raw = OLD.wtid_raw;
|
||||||
RETURN OLD;
|
RETURN OLD;
|
||||||
END $$;
|
END $$;
|
||||||
@ -833,7 +833,7 @@ CREATE OR REPLACE FUNCTION recoup_insert_trigger()
|
|||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO recoup_by_reserve
|
INSERT INTO exchange.recoup_by_reserve
|
||||||
(reserve_out_serial_id
|
(reserve_out_serial_id
|
||||||
,coin_pub)
|
,coin_pub)
|
||||||
VALUES
|
VALUES
|
||||||
@ -854,7 +854,7 @@ CREATE OR REPLACE FUNCTION recoup_delete_trigger()
|
|||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
DELETE FROM recoup_by_reserve
|
DELETE FROM exchange.recoup_by_reserve
|
||||||
WHERE reserve_out_serial_id = OLD.reserve_out_serial_id
|
WHERE reserve_out_serial_id = OLD.reserve_out_serial_id
|
||||||
AND coin_pub = OLD.coin_pub;
|
AND coin_pub = OLD.coin_pub;
|
||||||
RETURN OLD;
|
RETURN OLD;
|
||||||
@ -1434,14 +1434,14 @@ BEGIN
|
|||||||
SET purses_active=purses_active-1
|
SET purses_active=purses_active-1
|
||||||
WHERE reserve_pub IN
|
WHERE reserve_pub IN
|
||||||
(SELECT reserve_pub
|
(SELECT reserve_pub
|
||||||
FROM purse_merges
|
FROM exchange.purse_merges
|
||||||
WHERE purse_pub=NEW.purse_pub
|
WHERE purse_pub=NEW.purse_pub
|
||||||
LIMIT 1);
|
LIMIT 1);
|
||||||
NEW.in_reserve_quota=FALSE;
|
NEW.in_reserve_quota=FALSE;
|
||||||
END IF;
|
END IF;
|
||||||
-- Delete from the purse_actions table, we are done
|
-- Delete from the purse_actions table, we are done
|
||||||
-- with this purse for good.
|
-- with this purse for good.
|
||||||
DELETE FROM purse_actions
|
DELETE FROM exchange.purse_actions
|
||||||
WHERE purse_pub=NEW.purse_pub;
|
WHERE purse_pub=NEW.purse_pub;
|
||||||
RETURN NEW;
|
RETURN NEW;
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -59,7 +59,7 @@ BEGIN
|
|||||||
|
|
||||||
SELECT denominations_serial
|
SELECT denominations_serial
|
||||||
INTO denom_serial
|
INTO denom_serial
|
||||||
FROM denominations
|
FROM exchange.denominations
|
||||||
WHERE denom_pub_hash=h_denom_pub;
|
WHERE denom_pub_hash=h_denom_pub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -85,7 +85,7 @@ SELECT
|
|||||||
,reserve_frac
|
,reserve_frac
|
||||||
,reserve_gc
|
,reserve_gc
|
||||||
,ruuid
|
,ruuid
|
||||||
FROM reserves
|
FROM exchange.reserves
|
||||||
WHERE reserves.reserve_pub=rpub;
|
WHERE reserves.reserve_pub=rpub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -102,7 +102,7 @@ END IF;
|
|||||||
|
|
||||||
-- We optimistically insert, and then on conflict declare
|
-- We optimistically insert, and then on conflict declare
|
||||||
-- the query successful due to idempotency.
|
-- the query successful due to idempotency.
|
||||||
INSERT INTO reserves_out
|
INSERT INTO exchange.reserves_out
|
||||||
(h_blind_ev
|
(h_blind_ev
|
||||||
,denominations_serial
|
,denominations_serial
|
||||||
,denom_sig
|
,denom_sig
|
||||||
@ -180,7 +180,7 @@ IF NOT NULL cs_nonce
|
|||||||
THEN
|
THEN
|
||||||
-- Cache CS signature to prevent replays in the future
|
-- Cache CS signature to prevent replays in the future
|
||||||
-- (and check if cached signature exists at the same time).
|
-- (and check if cached signature exists at the same time).
|
||||||
INSERT INTO cs_nonce_locks
|
INSERT INTO exchange.cs_nonce_locks
|
||||||
(nonce
|
(nonce
|
||||||
,max_denomination_serial
|
,max_denomination_serial
|
||||||
,op_hash)
|
,op_hash)
|
||||||
@ -194,7 +194,7 @@ THEN
|
|||||||
THEN
|
THEN
|
||||||
-- See if the existing entry is identical.
|
-- See if the existing entry is identical.
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM cs_nonce_locks
|
FROM exchange.cs_nonce_locks
|
||||||
WHERE nonce=cs_nonce
|
WHERE nonce=cs_nonce
|
||||||
AND op_hash=h_coin_envelope;
|
AND op_hash=h_coin_envelope;
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -221,15 +221,15 @@ END IF;
|
|||||||
-- INTO
|
-- INTO
|
||||||
-- kycok
|
-- kycok
|
||||||
-- ,account_uuid
|
-- ,account_uuid
|
||||||
-- FROM reserves_in
|
-- FROM exchange.reserves_in
|
||||||
-- JOIN wire_targets ON (wire_source_h_payto = wire_target_h_payto)
|
-- JOIN wire_targets ON (wire_source_h_payto = wire_target_h_payto)
|
||||||
-- WHERE reserve_pub=rpub
|
-- WHERE reserve_pub=rpub
|
||||||
-- LIMIT 1; -- limit 1 should not be required (without p2p transfers)
|
-- LIMIT 1; -- limit 1 should not be required (without p2p transfers)
|
||||||
|
|
||||||
WITH reserves_in AS materialized (
|
WITH my_reserves_in AS materialized (
|
||||||
SELECT wire_source_h_payto
|
SELECT wire_source_h_payto
|
||||||
FROM reserves_in WHERE
|
FROM exchange.reserves_in
|
||||||
reserve_pub=rpub
|
WHERE reserve_pub=rpub
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
kyc_ok
|
kyc_ok
|
||||||
@ -237,10 +237,10 @@ SELECT
|
|||||||
INTO
|
INTO
|
||||||
kycok
|
kycok
|
||||||
,account_uuid
|
,account_uuid
|
||||||
FROM wire_targets
|
FROM exchange.wire_targets
|
||||||
WHERE wire_target_h_payto = (
|
WHERE wire_target_h_payto = (
|
||||||
SELECT wire_source_h_payto
|
SELECT wire_source_h_payto
|
||||||
FROM reserves_in
|
FROM my_reserves_in
|
||||||
);
|
);
|
||||||
|
|
||||||
END $$;
|
END $$;
|
||||||
@ -287,7 +287,7 @@ SELECT
|
|||||||
,reserve_frac
|
,reserve_frac
|
||||||
,reserve_gc
|
,reserve_gc
|
||||||
,ruuid
|
,ruuid
|
||||||
FROM reserves
|
FROM exchange.reserves
|
||||||
WHERE reserves.reserve_pub=rpub;
|
WHERE reserves.reserve_pub=rpub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -349,15 +349,15 @@ balance_ok=TRUE;
|
|||||||
-- INTO
|
-- INTO
|
||||||
-- kycok
|
-- kycok
|
||||||
-- ,account_uuid
|
-- ,account_uuid
|
||||||
-- FROM reserves_in
|
-- FROM exchange.reserves_in
|
||||||
-- JOIN wire_targets ON (wire_source_h_payto = wire_target_h_payto)
|
-- JOIN wire_targets ON (wire_source_h_payto = wire_target_h_payto)
|
||||||
-- WHERE reserve_pub=rpub
|
-- WHERE reserve_pub=rpub
|
||||||
-- LIMIT 1; -- limit 1 should not be required (without p2p transfers)
|
-- LIMIT 1; -- limit 1 should not be required (without p2p transfers)
|
||||||
|
|
||||||
WITH reserves_in AS materialized (
|
WITH my_reserves_in AS materialized (
|
||||||
SELECT wire_source_h_payto
|
SELECT wire_source_h_payto
|
||||||
FROM reserves_in WHERE
|
FROM exchange.reserves_in
|
||||||
reserve_pub=rpub
|
WHERE reserve_pub=rpub
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
kyc_ok
|
kyc_ok
|
||||||
@ -365,10 +365,10 @@ SELECT
|
|||||||
INTO
|
INTO
|
||||||
kycok
|
kycok
|
||||||
,account_uuid
|
,account_uuid
|
||||||
FROM wire_targets
|
FROM exchange.wire_targets
|
||||||
WHERE wire_target_h_payto = (
|
WHERE wire_target_h_payto = (
|
||||||
SELECT wire_source_h_payto
|
SELECT wire_source_h_payto
|
||||||
FROM reserves_in
|
FROM my_reserves_in
|
||||||
);
|
);
|
||||||
|
|
||||||
END $$;
|
END $$;
|
||||||
@ -410,7 +410,7 @@ out_nonce_reuse=TRUE;
|
|||||||
|
|
||||||
SELECT denominations_serial
|
SELECT denominations_serial
|
||||||
INTO denom_serial
|
INTO denom_serial
|
||||||
FROM denominations
|
FROM exchange.denominations
|
||||||
WHERE denom_pub_hash=h_denom_pub;
|
WHERE denom_pub_hash=h_denom_pub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -422,7 +422,7 @@ THEN
|
|||||||
END IF;
|
END IF;
|
||||||
out_denom_unknown=FALSE;
|
out_denom_unknown=FALSE;
|
||||||
|
|
||||||
INSERT INTO reserves_out
|
INSERT INTO exchange.reserves_out
|
||||||
(h_blind_ev
|
(h_blind_ev
|
||||||
,denominations_serial
|
,denominations_serial
|
||||||
,denom_sig
|
,denom_sig
|
||||||
@ -455,7 +455,7 @@ IF NOT NULL cs_nonce
|
|||||||
THEN
|
THEN
|
||||||
-- Cache CS signature to prevent replays in the future
|
-- Cache CS signature to prevent replays in the future
|
||||||
-- (and check if cached signature exists at the same time).
|
-- (and check if cached signature exists at the same time).
|
||||||
INSERT INTO cs_nonce_locks
|
INSERT INTO exchange.cs_nonce_locks
|
||||||
(nonce
|
(nonce
|
||||||
,max_denomination_serial
|
,max_denomination_serial
|
||||||
,op_hash)
|
,op_hash)
|
||||||
@ -469,7 +469,7 @@ THEN
|
|||||||
THEN
|
THEN
|
||||||
-- See if the existing entry is identical.
|
-- See if the existing entry is identical.
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM cs_nonce_locks
|
FROM exchange.cs_nonce_locks
|
||||||
WHERE nonce=cs_nonce
|
WHERE nonce=cs_nonce
|
||||||
AND op_hash=h_coin_envelope;
|
AND op_hash=h_coin_envelope;
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -513,7 +513,7 @@ SELECT
|
|||||||
INTO
|
INTO
|
||||||
total_val
|
total_val
|
||||||
,total_frac
|
,total_frac
|
||||||
FROM reserves_out
|
FROM exchange.reserves_out
|
||||||
WHERE reserve_uuid=ruuid
|
WHERE reserve_uuid=ruuid
|
||||||
AND execution_date > start_time;
|
AND execution_date > start_time;
|
||||||
|
|
||||||
@ -540,7 +540,7 @@ BEGIN
|
|||||||
|
|
||||||
IF EXISTS (
|
IF EXISTS (
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM information_Schema.constraint_column_usage
|
FROM exchange.information_Schema.constraint_column_usage
|
||||||
WHERE table_name='wire_out'
|
WHERE table_name='wire_out'
|
||||||
AND constraint_name='wire_out_ref')
|
AND constraint_name='wire_out_ref')
|
||||||
THEN
|
THEN
|
||||||
@ -573,20 +573,20 @@ DECLARE
|
|||||||
BEGIN
|
BEGIN
|
||||||
SELECT reserve_uuid
|
SELECT reserve_uuid
|
||||||
INTO res_uuid
|
INTO res_uuid
|
||||||
FROM reserves
|
FROM exchange.reserves
|
||||||
WHERE reserves.reserve_pub = res_pub;
|
WHERE reserves.reserve_pub = res_pub;
|
||||||
|
|
||||||
FOR blind_ev IN
|
FOR blind_ev IN
|
||||||
SELECT h_blind_ev
|
SELECT h_blind_ev
|
||||||
FROM reserves_out_by_reserve
|
FROM exchange.reserves_out_by_reserve
|
||||||
WHERE reserves_out_by_reserve.reserve_uuid = res_uuid
|
WHERE reserves_out_by_reserve.reserve_uuid = res_uuid
|
||||||
LOOP
|
LOOP
|
||||||
SELECT robr.coin_pub
|
SELECT robr.coin_pub
|
||||||
INTO c_pub
|
INTO c_pub
|
||||||
FROM recoup_by_reserve robr
|
FROM exchange.recoup_by_reserve robr
|
||||||
WHERE robr.reserve_out_serial_id = (
|
WHERE robr.reserve_out_serial_id = (
|
||||||
SELECT reserves_out.reserve_out_serial_id
|
SELECT reserves_out.reserve_out_serial_id
|
||||||
FROM reserves_out
|
FROM exchange.reserves_out
|
||||||
WHERE reserves_out.h_blind_ev = blind_ev
|
WHERE reserves_out.h_blind_ev = blind_ev
|
||||||
);
|
);
|
||||||
RETURN QUERY
|
RETURN QUERY
|
||||||
@ -600,12 +600,12 @@ BEGIN
|
|||||||
rc.recoup_timestamp
|
rc.recoup_timestamp
|
||||||
FROM (
|
FROM (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM known_coins
|
FROM exchange.known_coins
|
||||||
WHERE known_coins.coin_pub = c_pub
|
WHERE known_coins.coin_pub = c_pub
|
||||||
) kc
|
) kc
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM recoup
|
FROM exchange.recoup
|
||||||
WHERE recoup.coin_pub = c_pub
|
WHERE recoup.coin_pub = c_pub
|
||||||
) rc USING (coin_pub);
|
) rc USING (coin_pub);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
@ -651,7 +651,7 @@ BEGIN
|
|||||||
|
|
||||||
IF NOT NULL in_extension_details
|
IF NOT NULL in_extension_details
|
||||||
THEN
|
THEN
|
||||||
INSERT INTO extension_details
|
INSERT INTO exchange.extension_details
|
||||||
(extension_options)
|
(extension_options)
|
||||||
VALUES
|
VALUES
|
||||||
(in_extension_details)
|
(in_extension_details)
|
||||||
@ -661,7 +661,7 @@ ELSE
|
|||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO wire_targets
|
INSERT INTO exchange.wire_targets
|
||||||
(wire_target_h_payto
|
(wire_target_h_payto
|
||||||
,payto_uri)
|
,payto_uri)
|
||||||
VALUES
|
VALUES
|
||||||
@ -674,12 +674,12 @@ IF NOT FOUND
|
|||||||
THEN
|
THEN
|
||||||
SELECT wire_target_serial_id
|
SELECT wire_target_serial_id
|
||||||
INTO wtsi
|
INTO wtsi
|
||||||
FROM wire_targets
|
FROM exchange.wire_targets
|
||||||
WHERE wire_target_h_payto=in_h_payto;
|
WHERE wire_target_h_payto=in_h_payto;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO deposits
|
INSERT INTO exchange.deposits
|
||||||
(shard
|
(shard
|
||||||
,coin_pub
|
,coin_pub
|
||||||
,known_coin_id
|
,known_coin_id
|
||||||
@ -727,7 +727,7 @@ THEN
|
|||||||
exchange_timestamp
|
exchange_timestamp
|
||||||
INTO
|
INTO
|
||||||
out_exchange_timestamp
|
out_exchange_timestamp
|
||||||
FROM deposits
|
FROM exchange.deposits
|
||||||
WHERE shard=in_shard
|
WHERE shard=in_shard
|
||||||
AND merchant_pub=in_merchant_pub
|
AND merchant_pub=in_merchant_pub
|
||||||
AND wire_target_h_payto=in_h_payto
|
AND wire_target_h_payto=in_h_payto
|
||||||
@ -812,7 +812,7 @@ BEGIN
|
|||||||
-- (rare:) PERFORM recoup_refresh (by rrc_serial) -- crosses shards!
|
-- (rare:) PERFORM recoup_refresh (by rrc_serial) -- crosses shards!
|
||||||
-- UPDATE known_coins (by coin_pub)
|
-- UPDATE known_coins (by coin_pub)
|
||||||
|
|
||||||
INSERT INTO refresh_commitments
|
INSERT INTO exchange.refresh_commitments
|
||||||
(rc
|
(rc
|
||||||
,old_coin_pub
|
,old_coin_pub
|
||||||
,old_coin_sig
|
,old_coin_sig
|
||||||
@ -837,7 +837,7 @@ THEN
|
|||||||
noreveal_index
|
noreveal_index
|
||||||
INTO
|
INTO
|
||||||
out_noreveal_index
|
out_noreveal_index
|
||||||
FROM refresh_commitments
|
FROM exchange.refresh_commitments
|
||||||
WHERE rc=in_rc;
|
WHERE rc=in_rc;
|
||||||
out_balance_ok=FOUND;
|
out_balance_ok=FOUND;
|
||||||
out_zombie_bad=FALSE; -- zombie is OK
|
out_zombie_bad=FALSE; -- zombie is OK
|
||||||
@ -855,13 +855,13 @@ THEN
|
|||||||
-- operations, and then see if any of these
|
-- operations, and then see if any of these
|
||||||
-- reveal operations was involved in a recoup.
|
-- reveal operations was involved in a recoup.
|
||||||
PERFORM
|
PERFORM
|
||||||
FROM recoup_refresh
|
FROM exchange.recoup_refresh
|
||||||
WHERE rrc_serial IN
|
WHERE rrc_serial IN
|
||||||
(SELECT rrc_serial
|
(SELECT rrc_serial
|
||||||
FROM refresh_revealed_coins
|
FROM exchange.refresh_revealed_coins
|
||||||
WHERE melt_serial_id IN
|
WHERE melt_serial_id IN
|
||||||
(SELECT melt_serial_id
|
(SELECT melt_serial_id
|
||||||
FROM refresh_commitments
|
FROM exchange.refresh_commitments
|
||||||
WHERE old_coin_pub=in_old_coin_pub));
|
WHERE old_coin_pub=in_old_coin_pub));
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
THEN
|
THEN
|
||||||
@ -914,13 +914,13 @@ THEN
|
|||||||
denominations_serial
|
denominations_serial
|
||||||
INTO
|
INTO
|
||||||
denom_max
|
denom_max
|
||||||
FROM denominations
|
FROM exchange.denominations
|
||||||
ORDER BY denominations_serial DESC
|
ORDER BY denominations_serial DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
-- Cache CS signature to prevent replays in the future
|
-- Cache CS signature to prevent replays in the future
|
||||||
-- (and check if cached signature exists at the same time).
|
-- (and check if cached signature exists at the same time).
|
||||||
INSERT INTO cs_nonce_locks
|
INSERT INTO exchange.cs_nonce_locks
|
||||||
(nonce
|
(nonce
|
||||||
,max_denomination_serial
|
,max_denomination_serial
|
||||||
,op_hash)
|
,op_hash)
|
||||||
@ -934,7 +934,7 @@ THEN
|
|||||||
THEN
|
THEN
|
||||||
-- Record exists, make sure it is the same
|
-- Record exists, make sure it is the same
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM cs_nonce_locks
|
FROM exchange.cs_nonce_locks
|
||||||
WHERE nonce=cs_rms
|
WHERE nonce=cs_rms
|
||||||
AND op_hash=in_rc;
|
AND op_hash=in_rc;
|
||||||
|
|
||||||
@ -1003,7 +1003,7 @@ INTO
|
|||||||
,deposit_val
|
,deposit_val
|
||||||
,deposit_frac
|
,deposit_frac
|
||||||
,out_gone
|
,out_gone
|
||||||
FROM deposits
|
FROM exchange.deposits
|
||||||
WHERE coin_pub=in_coin_pub
|
WHERE coin_pub=in_coin_pub
|
||||||
AND shard=in_deposit_shard
|
AND shard=in_deposit_shard
|
||||||
AND merchant_pub=in_merchant_pub
|
AND merchant_pub=in_merchant_pub
|
||||||
@ -1019,7 +1019,7 @@ THEN
|
|||||||
RETURN;
|
RETURN;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO refunds
|
INSERT INTO exchange.refunds
|
||||||
(deposit_serial_id
|
(deposit_serial_id
|
||||||
,coin_pub
|
,coin_pub
|
||||||
,merchant_sig
|
,merchant_sig
|
||||||
@ -1044,7 +1044,7 @@ THEN
|
|||||||
-- We do select over merchant_pub and h_contract_terms
|
-- We do select over merchant_pub and h_contract_terms
|
||||||
-- primarily here to maximally use the existing index.
|
-- primarily here to maximally use the existing index.
|
||||||
PERFORM
|
PERFORM
|
||||||
FROM refunds
|
FROM exchange.refunds
|
||||||
WHERE coin_pub=in_coin_pub
|
WHERE coin_pub=in_coin_pub
|
||||||
AND deposit_serial_id=dsi
|
AND deposit_serial_id=dsi
|
||||||
AND rtransaction_id=in_rtransaction_id
|
AND rtransaction_id=in_rtransaction_id
|
||||||
@ -1084,7 +1084,7 @@ SELECT
|
|||||||
INTO
|
INTO
|
||||||
tmp_val
|
tmp_val
|
||||||
,tmp_frac
|
,tmp_frac
|
||||||
FROM refunds
|
FROM exchange.refunds
|
||||||
WHERE coin_pub=in_coin_pub
|
WHERE coin_pub=in_coin_pub
|
||||||
AND deposit_serial_id=dsi;
|
AND deposit_serial_id=dsi;
|
||||||
IF tmp_val IS NULL
|
IF tmp_val IS NULL
|
||||||
@ -1190,7 +1190,7 @@ SELECT
|
|||||||
INTO
|
INTO
|
||||||
tmp_frac
|
tmp_frac
|
||||||
,tmp_val
|
,tmp_val
|
||||||
FROM known_coins
|
FROM exchange.known_coins
|
||||||
WHERE coin_pub=in_coin_pub;
|
WHERE coin_pub=in_coin_pub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -1207,7 +1207,7 @@ THEN
|
|||||||
recoup_timestamp
|
recoup_timestamp
|
||||||
INTO
|
INTO
|
||||||
out_recoup_timestamp
|
out_recoup_timestamp
|
||||||
FROM recoup
|
FROM exchange.recoup
|
||||||
WHERE coin_pub=in_coin_pub;
|
WHERE coin_pub=in_coin_pub;
|
||||||
|
|
||||||
out_recoup_ok=FOUND;
|
out_recoup_ok=FOUND;
|
||||||
@ -1252,7 +1252,7 @@ THEN
|
|||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO recoup
|
INSERT INTO exchange.recoup
|
||||||
(coin_pub
|
(coin_pub
|
||||||
,coin_sig
|
,coin_sig
|
||||||
,coin_blind
|
,coin_blind
|
||||||
@ -1319,7 +1319,7 @@ SELECT
|
|||||||
INTO
|
INTO
|
||||||
tmp_frac
|
tmp_frac
|
||||||
,tmp_val
|
,tmp_val
|
||||||
FROM known_coins
|
FROM exchange.known_coins
|
||||||
WHERE coin_pub=in_coin_pub;
|
WHERE coin_pub=in_coin_pub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -1336,7 +1336,7 @@ THEN
|
|||||||
recoup_timestamp
|
recoup_timestamp
|
||||||
INTO
|
INTO
|
||||||
out_recoup_timestamp
|
out_recoup_timestamp
|
||||||
FROM recoup_refresh
|
FROM exchange.recoup_refresh
|
||||||
WHERE coin_pub=in_coin_pub;
|
WHERE coin_pub=in_coin_pub;
|
||||||
out_recoup_ok=FOUND;
|
out_recoup_ok=FOUND;
|
||||||
RETURN;
|
RETURN;
|
||||||
@ -1377,7 +1377,7 @@ THEN
|
|||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO recoup_refresh
|
INSERT INTO exchange.recoup_refresh
|
||||||
(coin_pub
|
(coin_pub
|
||||||
,known_coin_id
|
,known_coin_id
|
||||||
,coin_sig
|
,coin_sig
|
||||||
@ -1430,14 +1430,14 @@ DECLARE
|
|||||||
denom_min INT8; -- minimum denomination still alive
|
denom_min INT8; -- minimum denomination still alive
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
DELETE FROM prewire
|
DELETE FROM exchange.prewire
|
||||||
WHERE finished=TRUE;
|
WHERE finished=TRUE;
|
||||||
|
|
||||||
DELETE FROM wire_fee
|
DELETE FROM exchange.wire_fee
|
||||||
WHERE end_date < in_ancient_date;
|
WHERE end_date < in_ancient_date;
|
||||||
|
|
||||||
-- TODO: use closing fee as threshold?
|
-- TODO: use closing fee as threshold?
|
||||||
DELETE FROM reserves
|
DELETE FROM exchange.reserves
|
||||||
WHERE gc_date < in_now
|
WHERE gc_date < in_now
|
||||||
AND current_balance_val = 0
|
AND current_balance_val = 0
|
||||||
AND current_balance_frac = 0;
|
AND current_balance_frac = 0;
|
||||||
@ -1446,11 +1446,11 @@ SELECT
|
|||||||
reserve_out_serial_id
|
reserve_out_serial_id
|
||||||
INTO
|
INTO
|
||||||
reserve_out_min
|
reserve_out_min
|
||||||
FROM reserves_out
|
FROM exchange.reserves_out
|
||||||
ORDER BY reserve_out_serial_id ASC
|
ORDER BY reserve_out_serial_id ASC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
DELETE FROM recoup
|
DELETE FROM exchange.recoup
|
||||||
WHERE reserve_out_serial_id < reserve_out_min;
|
WHERE reserve_out_serial_id < reserve_out_min;
|
||||||
-- FIXME: recoup_refresh lacks GC!
|
-- FIXME: recoup_refresh lacks GC!
|
||||||
|
|
||||||
@ -1458,81 +1458,81 @@ SELECT
|
|||||||
reserve_uuid
|
reserve_uuid
|
||||||
INTO
|
INTO
|
||||||
reserve_uuid_min
|
reserve_uuid_min
|
||||||
FROM reserves
|
FROM exchange.reserves
|
||||||
ORDER BY reserve_uuid ASC
|
ORDER BY reserve_uuid ASC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
DELETE FROM reserves_out
|
DELETE FROM exchange.reserves_out
|
||||||
WHERE reserve_uuid < reserve_uuid_min;
|
WHERE reserve_uuid < reserve_uuid_min;
|
||||||
|
|
||||||
-- FIXME: this query will be horribly slow;
|
-- FIXME: this query will be horribly slow;
|
||||||
-- need to find another way to formulate it...
|
-- need to find another way to formulate it...
|
||||||
DELETE FROM denominations
|
DELETE FROM exchange.denominations
|
||||||
WHERE expire_legal < in_now
|
WHERE expire_legal < in_now
|
||||||
AND denominations_serial NOT IN
|
AND denominations_serial NOT IN
|
||||||
(SELECT DISTINCT denominations_serial
|
(SELECT DISTINCT denominations_serial
|
||||||
FROM reserves_out)
|
FROM exchange.reserves_out)
|
||||||
AND denominations_serial NOT IN
|
AND denominations_serial NOT IN
|
||||||
(SELECT DISTINCT denominations_serial
|
(SELECT DISTINCT denominations_serial
|
||||||
FROM known_coins
|
FROM exchange.known_coins
|
||||||
WHERE coin_pub IN
|
WHERE coin_pub IN
|
||||||
(SELECT DISTINCT coin_pub
|
(SELECT DISTINCT coin_pub
|
||||||
FROM recoup))
|
FROM exchange.recoup))
|
||||||
AND denominations_serial NOT IN
|
AND denominations_serial NOT IN
|
||||||
(SELECT DISTINCT denominations_serial
|
(SELECT DISTINCT denominations_serial
|
||||||
FROM known_coins
|
FROM exchange.known_coins
|
||||||
WHERE coin_pub IN
|
WHERE coin_pub IN
|
||||||
(SELECT DISTINCT coin_pub
|
(SELECT DISTINCT coin_pub
|
||||||
FROM recoup_refresh));
|
FROM exchange.recoup_refresh));
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
melt_serial_id
|
melt_serial_id
|
||||||
INTO
|
INTO
|
||||||
melt_min
|
melt_min
|
||||||
FROM refresh_commitments
|
FROM exchange.refresh_commitments
|
||||||
ORDER BY melt_serial_id ASC
|
ORDER BY melt_serial_id ASC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
DELETE FROM refresh_revealed_coins
|
DELETE FROM exchange.refresh_revealed_coins
|
||||||
WHERE melt_serial_id < melt_min;
|
WHERE melt_serial_id < melt_min;
|
||||||
|
|
||||||
DELETE FROM refresh_transfer_keys
|
DELETE FROM exchange.refresh_transfer_keys
|
||||||
WHERE melt_serial_id < melt_min;
|
WHERE melt_serial_id < melt_min;
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
known_coin_id
|
known_coin_id
|
||||||
INTO
|
INTO
|
||||||
coin_min
|
coin_min
|
||||||
FROM known_coins
|
FROM exchange.known_coins
|
||||||
ORDER BY known_coin_id ASC
|
ORDER BY known_coin_id ASC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
DELETE FROM deposits
|
DELETE FROM exchange.deposits
|
||||||
WHERE known_coin_id < coin_min;
|
WHERE known_coin_id < coin_min;
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
deposit_serial_id
|
deposit_serial_id
|
||||||
INTO
|
INTO
|
||||||
deposit_min
|
deposit_min
|
||||||
FROM deposits
|
FROM exchange.deposits
|
||||||
ORDER BY deposit_serial_id ASC
|
ORDER BY deposit_serial_id ASC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
DELETE FROM refunds
|
DELETE FROM exchange.refunds
|
||||||
WHERE deposit_serial_id < deposit_min;
|
WHERE deposit_serial_id < deposit_min;
|
||||||
|
|
||||||
DELETE FROM aggregation_tracking
|
DELETE FROM exchange.aggregation_tracking
|
||||||
WHERE deposit_serial_id < deposit_min;
|
WHERE deposit_serial_id < deposit_min;
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
denominations_serial
|
denominations_serial
|
||||||
INTO
|
INTO
|
||||||
denom_min
|
denom_min
|
||||||
FROM denominations
|
FROM exchange.denominations
|
||||||
ORDER BY denominations_serial ASC
|
ORDER BY denominations_serial ASC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
DELETE FROM cs_nonce_locks
|
DELETE FROM exchange.cs_nonce_locks
|
||||||
WHERE max_denomination_serial <= denom_min;
|
WHERE max_denomination_serial <= denom_min;
|
||||||
|
|
||||||
END $$;
|
END $$;
|
||||||
@ -1568,7 +1568,7 @@ DECLARE
|
|||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Store the deposit request.
|
-- Store the deposit request.
|
||||||
INSERT INTO purse_deposits
|
INSERT INTO exchange.purse_deposits
|
||||||
(partner_serial_id
|
(partner_serial_id
|
||||||
,purse_pub
|
,purse_pub
|
||||||
,coin_pub
|
,coin_pub
|
||||||
@ -1589,7 +1589,7 @@ THEN
|
|||||||
-- Idempotency check: check if coin_sig is the same,
|
-- Idempotency check: check if coin_sig is the same,
|
||||||
-- if so, success, otherwise conflict!
|
-- if so, success, otherwise conflict!
|
||||||
PERFORM
|
PERFORM
|
||||||
FROM purse_deposits
|
FROM exchange.purse_deposits
|
||||||
WHERE coin_pub = in_coin_pub
|
WHERE coin_pub = in_coin_pub
|
||||||
AND purse_pub = in_purse_pub
|
AND purse_pub = in_purse_pub
|
||||||
AND coin_sig = in_cion_sig;
|
AND coin_sig = in_cion_sig;
|
||||||
@ -1658,7 +1658,7 @@ SELECT partner_serial_id
|
|||||||
,reserve_pub
|
,reserve_pub
|
||||||
INTO psi
|
INTO psi
|
||||||
,my_reserve_pub
|
,my_reserve_pub
|
||||||
FROM purse_merges
|
FROM exchange.purse_merges
|
||||||
WHERE purse_pub=in_purse_pub;
|
WHERE purse_pub=in_purse_pub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -1672,7 +1672,7 @@ SELECT
|
|||||||
INTO
|
INTO
|
||||||
my_amount_val
|
my_amount_val
|
||||||
,my_amount_frac
|
,my_amount_frac
|
||||||
FROM purse_requests
|
FROM exchange.purse_requests
|
||||||
WHERE (purse_pub=in_purse_pub)
|
WHERE (purse_pub=in_purse_pub)
|
||||||
AND ( ( ( (amount_with_fee_val <= balance_val)
|
AND ( ( ( (amount_with_fee_val <= balance_val)
|
||||||
AND (amount_with_fee_frac <= balance_frac) )
|
AND (amount_with_fee_frac <= balance_frac) )
|
||||||
@ -1758,7 +1758,7 @@ ELSE
|
|||||||
partner_serial_id
|
partner_serial_id
|
||||||
INTO
|
INTO
|
||||||
my_partner_serial_id
|
my_partner_serial_id
|
||||||
FROM partners
|
FROM exchange.partners
|
||||||
WHERE partner_base_url=in_partner_url
|
WHERE partner_base_url=in_partner_url
|
||||||
AND start_date <= in_merge_timestamp
|
AND start_date <= in_merge_timestamp
|
||||||
AND end_date > in_merge_timestamp;
|
AND end_date > in_merge_timestamp;
|
||||||
@ -1786,7 +1786,7 @@ SELECT amount_with_fee_val
|
|||||||
,my_purse_fee_val
|
,my_purse_fee_val
|
||||||
,my_purse_fee_frac
|
,my_purse_fee_frac
|
||||||
,my_finished
|
,my_finished
|
||||||
FROM purse_requests
|
FROM exchange.purse_requests
|
||||||
WHERE purse_pub=in_purse_pub
|
WHERE purse_pub=in_purse_pub
|
||||||
AND balance_val >= amount_with_fee_val
|
AND balance_val >= amount_with_fee_val
|
||||||
AND ( (balance_frac >= amount_with_fee_frac) OR
|
AND ( (balance_frac >= amount_with_fee_frac) OR
|
||||||
@ -1802,7 +1802,7 @@ END IF;
|
|||||||
out_no_balance=FALSE;
|
out_no_balance=FALSE;
|
||||||
|
|
||||||
-- Store purse merge signature, checks for purse_pub uniqueness
|
-- Store purse merge signature, checks for purse_pub uniqueness
|
||||||
INSERT INTO purse_merges
|
INSERT INTO exchange.purse_merges
|
||||||
(partner_serial_id
|
(partner_serial_id
|
||||||
,reserve_pub
|
,reserve_pub
|
||||||
,purse_pub
|
,purse_pub
|
||||||
@ -1822,7 +1822,7 @@ THEN
|
|||||||
-- Note that by checking 'merge_sig', we implicitly check
|
-- Note that by checking 'merge_sig', we implicitly check
|
||||||
-- identity over everything that the signature covers.
|
-- identity over everything that the signature covers.
|
||||||
PERFORM
|
PERFORM
|
||||||
FROM purse_merges
|
FROM exchange.purse_merges
|
||||||
WHERE purse_pub=in_purse_pub
|
WHERE purse_pub=in_purse_pub
|
||||||
AND merge_sig=in_merge_sig;
|
AND merge_sig=in_merge_sig;
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -1850,7 +1850,7 @@ THEN
|
|||||||
-- Need to do KYC check.
|
-- Need to do KYC check.
|
||||||
SELECT NOT kyc_passed
|
SELECT NOT kyc_passed
|
||||||
INTO out_no_kyc
|
INTO out_no_kyc
|
||||||
FROM reserves
|
FROM exchange.reserves
|
||||||
WHERE reserve_pub=in_reserve_pub;
|
WHERE reserve_pub=in_reserve_pub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -1874,7 +1874,7 @@ END IF;
|
|||||||
|
|
||||||
|
|
||||||
-- Store account merge signature.
|
-- Store account merge signature.
|
||||||
INSERT INTO account_merges
|
INSERT INTO exchange.account_merges
|
||||||
(reserve_pub
|
(reserve_pub
|
||||||
,reserve_sig
|
,reserve_sig
|
||||||
,purse_pub
|
,purse_pub
|
||||||
@ -1954,7 +1954,7 @@ AS $$
|
|||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Store purse merge signature, checks for purse_pub uniqueness
|
-- Store purse merge signature, checks for purse_pub uniqueness
|
||||||
INSERT INTO purse_merges
|
INSERT INTO exchange.purse_merges
|
||||||
(partner_serial_id
|
(partner_serial_id
|
||||||
,reserve_pub
|
,reserve_pub
|
||||||
,purse_pub
|
,purse_pub
|
||||||
@ -1974,7 +1974,7 @@ THEN
|
|||||||
-- Note that by checking 'merge_sig', we implicitly check
|
-- Note that by checking 'merge_sig', we implicitly check
|
||||||
-- identity over everything that the signature covers.
|
-- identity over everything that the signature covers.
|
||||||
PERFORM
|
PERFORM
|
||||||
FROM purse_merges
|
FROM exchange.purse_merges
|
||||||
WHERE purse_pub=in_purse_pub
|
WHERE purse_pub=in_purse_pub
|
||||||
AND merge_sig=in_merge_sig;
|
AND merge_sig=in_merge_sig;
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -1998,7 +1998,7 @@ out_conflict=FALSE;
|
|||||||
|
|
||||||
SELECT NOT kyc_passed
|
SELECT NOT kyc_passed
|
||||||
INTO out_no_kyc
|
INTO out_no_kyc
|
||||||
FROM reserves
|
FROM exchange.reserves
|
||||||
WHERE reserve_pub=in_reserve_pub;
|
WHERE reserve_pub=in_reserve_pub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -2061,7 +2061,7 @@ out_no_funds=FALSE;
|
|||||||
|
|
||||||
|
|
||||||
-- Store account merge signature.
|
-- Store account merge signature.
|
||||||
INSERT INTO account_merges
|
INSERT INTO exchange.account_merges
|
||||||
(reserve_pub
|
(reserve_pub
|
||||||
,reserve_sig
|
,reserve_sig
|
||||||
,purse_pub
|
,purse_pub
|
||||||
@ -2110,7 +2110,7 @@ BEGIN
|
|||||||
|
|
||||||
SELECT purse_pub
|
SELECT purse_pub
|
||||||
INTO my_purse_pub
|
INTO my_purse_pub
|
||||||
FROM purse_requests
|
FROM exchange.purse_requests
|
||||||
WHERE (purse_expiration >= in_start_time) AND
|
WHERE (purse_expiration >= in_start_time) AND
|
||||||
(purse_expiration < in_end_time) AND
|
(purse_expiration < in_end_time) AND
|
||||||
(NOT finished) AND
|
(NOT finished) AND
|
||||||
@ -2128,7 +2128,7 @@ UPDATE purse_requests
|
|||||||
finished=TRUE
|
finished=TRUE
|
||||||
WHERE purse_pub=my_purse_pub;
|
WHERE purse_pub=my_purse_pub;
|
||||||
|
|
||||||
INSERT INTO purse_refunds
|
INSERT INTO exchange.purse_refunds
|
||||||
(purse_pub)
|
(purse_pub)
|
||||||
VALUES
|
VALUES
|
||||||
(my_purse_pub);
|
(my_purse_pub);
|
||||||
@ -2138,7 +2138,7 @@ FOR my_deposit IN
|
|||||||
SELECT coin_pub
|
SELECT coin_pub
|
||||||
,amount_with_fee_val
|
,amount_with_fee_val
|
||||||
,amount_with_fee_frac
|
,amount_with_fee_frac
|
||||||
FROM purse_deposits
|
FROM exchange.purse_deposits
|
||||||
WHERE purse_pub = my_purse_pub
|
WHERE purse_pub = my_purse_pub
|
||||||
LOOP
|
LOOP
|
||||||
UPDATE known_coins SET
|
UPDATE known_coins SET
|
||||||
@ -2177,7 +2177,7 @@ AS $$
|
|||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Insert and check for idempotency.
|
-- Insert and check for idempotency.
|
||||||
INSERT INTO history_requests
|
INSERT INTO exchange.history_requests
|
||||||
(reserve_pub
|
(reserve_pub
|
||||||
,request_timestamp
|
,request_timestamp
|
||||||
,reserve_sig
|
,reserve_sig
|
||||||
@ -2251,7 +2251,7 @@ BEGIN
|
|||||||
INTO
|
INTO
|
||||||
out_final_balance_val
|
out_final_balance_val
|
||||||
,out_final_balance_frac
|
,out_final_balance_frac
|
||||||
FROM reserves
|
FROM exchange.reserves
|
||||||
WHERE reserve_pub=in_reserve_pub;
|
WHERE reserve_pub=in_reserve_pub;
|
||||||
|
|
||||||
IF NOT FOUND
|
IF NOT FOUND
|
||||||
@ -2262,7 +2262,7 @@ BEGIN
|
|||||||
out_conflict = FALSE;
|
out_conflict = FALSE;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO close_requests
|
INSERT INTO exchange.close_requests
|
||||||
(reserve_pub
|
(reserve_pub
|
||||||
,close_timestamp
|
,close_timestamp
|
||||||
,reserve_sig
|
,reserve_sig
|
||||||
|
@ -95,6 +95,11 @@ enum TALER_KYCLOGIC_KycStatus
|
|||||||
= TALER_KYCLOGIC_STATUS_PROVIDER
|
= TALER_KYCLOGIC_STATUS_PROVIDER
|
||||||
| TALER_KYCLOGIC_STATUS_ABORTED,
|
| TALER_KYCLOGIC_STATUS_ABORTED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return code set to not update the KYC status
|
||||||
|
* at all.
|
||||||
|
*/
|
||||||
|
TALER_KYCLOGIC_STATUS_KEEP = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -333,7 +338,7 @@ struct TALER_KYCLOGIC_Plugin
|
|||||||
* @param cb_cls closure for @a cb
|
* @param cb_cls closure for @a cb
|
||||||
* @return handle to cancel operation early
|
* @return handle to cancel operation early
|
||||||
*/
|
*/
|
||||||
struct TALER_KYCLOGIC_InitiateHandle *
|
struct TALER_KYCLOGIC_WebhookHandle *
|
||||||
(*webhook)(void *cls,
|
(*webhook)(void *cls,
|
||||||
const struct TALER_KYCLOGIC_ProviderDetails *pd,
|
const struct TALER_KYCLOGIC_ProviderDetails *pd,
|
||||||
TALER_KYCLOGIC_ProviderLookupCallback plc,
|
TALER_KYCLOGIC_ProviderLookupCallback plc,
|
||||||
|
@ -236,6 +236,21 @@ struct TALER_KYCLOGIC_ProofHandle
|
|||||||
struct TALER_KYCLOGIC_WebhookHandle
|
struct TALER_KYCLOGIC_WebhookHandle
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continuation to call when done.
|
||||||
|
*/
|
||||||
|
TALER_KYCLOGIC_WebhookCallback cb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for @a cb.
|
||||||
|
*/
|
||||||
|
void *cb_cls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task for asynchronous execution.
|
||||||
|
*/
|
||||||
|
struct GNUNET_SCHEDULER_Task *task;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overall plugin state.
|
* Overall plugin state.
|
||||||
*/
|
*/
|
||||||
@ -900,6 +915,34 @@ oauth2_proof_cancel (struct TALER_KYCLOGIC_ProofHandle *ph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to asynchronously return the 404 not found
|
||||||
|
* page for the webhook.
|
||||||
|
*
|
||||||
|
* @param cls the `struct TALER_KYCLOGIC_WebhookHandle *`
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
wh_return_not_found (void *cls)
|
||||||
|
{
|
||||||
|
struct TALER_KYCLOGIC_WebhookHandle *wh = cls;
|
||||||
|
struct MHD_Response *response;
|
||||||
|
|
||||||
|
wh->task = NULL;
|
||||||
|
response = MHD_create_response_from_buffer (0,
|
||||||
|
"",
|
||||||
|
MHD_RESPMEM_PERSISTENT);
|
||||||
|
wh->cb (wh->cb_cls,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
TALER_KYCLOGIC_STATUS_KEEP,
|
||||||
|
GNUNET_TIME_UNIT_ZERO_ABS,
|
||||||
|
MHD_HTTP_NOT_FOUND,
|
||||||
|
response);
|
||||||
|
GNUNET_free (wh);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check KYC status and return result for Webhook.
|
* Check KYC status and return result for Webhook.
|
||||||
*
|
*
|
||||||
@ -916,7 +959,7 @@ oauth2_proof_cancel (struct TALER_KYCLOGIC_ProofHandle *ph)
|
|||||||
* @param cb_cls closure for @a cb
|
* @param cb_cls closure for @a cb
|
||||||
* @return handle to cancel operation early
|
* @return handle to cancel operation early
|
||||||
*/
|
*/
|
||||||
static struct TALER_KYCLOGIC_InitiateHandle *
|
static struct TALER_KYCLOGIC_WebhookHandle *
|
||||||
oauth2_webhook (void *cls,
|
oauth2_webhook (void *cls,
|
||||||
const struct TALER_KYCLOGIC_ProviderDetails *pd,
|
const struct TALER_KYCLOGIC_ProviderDetails *pd,
|
||||||
TALER_KYCLOGIC_ProviderLookupCallback plc,
|
TALER_KYCLOGIC_ProviderLookupCallback plc,
|
||||||
@ -929,9 +972,16 @@ oauth2_webhook (void *cls,
|
|||||||
TALER_KYCLOGIC_WebhookCallback cb,
|
TALER_KYCLOGIC_WebhookCallback cb,
|
||||||
void *cb_cls)
|
void *cb_cls)
|
||||||
{
|
{
|
||||||
// FIXME: add logic to asynchronously return an error (404)
|
struct PluginState *ps = cls;
|
||||||
GNUNET_break_op (0);
|
struct TALER_KYCLOGIC_WebhookHandle *wh;
|
||||||
return NULL;
|
|
||||||
|
wh = GNUNET_new (struct TALER_KYCLOGIC_WebhookHandle);
|
||||||
|
wh->cb = cb;
|
||||||
|
wh->cb_cls = cb_cls;
|
||||||
|
wh->ps = ps;
|
||||||
|
wh->task = GNUNET_SCHEDULER_add_now (&wh_return_not_found,
|
||||||
|
wh);
|
||||||
|
return wh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -943,6 +993,8 @@ oauth2_webhook (void *cls,
|
|||||||
static void
|
static void
|
||||||
oauth2_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
|
oauth2_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
|
||||||
{
|
{
|
||||||
|
GNUNET_SCHEDULER_cancel (wh->task);
|
||||||
|
GNUNET_free (wh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,6 +139,21 @@ struct TALER_KYCLOGIC_ProofHandle
|
|||||||
struct TALER_KYCLOGIC_WebhookHandle
|
struct TALER_KYCLOGIC_WebhookHandle
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continuation to call when done.
|
||||||
|
*/
|
||||||
|
TALER_KYCLOGIC_WebhookCallback cb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closure for @a cb.
|
||||||
|
*/
|
||||||
|
void *cb_cls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task for asynchronous execution.
|
||||||
|
*/
|
||||||
|
struct GNUNET_SCHEDULER_Task *task;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overall plugin state.
|
* Overall plugin state.
|
||||||
*/
|
*/
|
||||||
@ -300,7 +315,7 @@ template_proof_cancel (struct TALER_KYCLOGIC_ProofHandle *ph)
|
|||||||
* @param cb_cls closure for @a cb
|
* @param cb_cls closure for @a cb
|
||||||
* @return handle to cancel operation early
|
* @return handle to cancel operation early
|
||||||
*/
|
*/
|
||||||
static struct TALER_KYCLOGIC_InitiateHandle *
|
static struct TALER_KYCLOGIC_WebhookHandle *
|
||||||
template_webhook (void *cls,
|
template_webhook (void *cls,
|
||||||
const struct TALER_KYCLOGIC_ProviderDetails *pd,
|
const struct TALER_KYCLOGIC_ProviderDetails *pd,
|
||||||
TALER_KYCLOGIC_ProviderLookupCallback plc,
|
TALER_KYCLOGIC_ProviderLookupCallback plc,
|
||||||
@ -313,8 +328,16 @@ template_webhook (void *cls,
|
|||||||
TALER_KYCLOGIC_WebhookCallback cb,
|
TALER_KYCLOGIC_WebhookCallback cb,
|
||||||
void *cb_cls)
|
void *cb_cls)
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
struct PluginState *ps = cls;
|
||||||
return NULL;
|
struct TALER_KYCLOGIC_WebhookHandle *wh;
|
||||||
|
|
||||||
|
wh = GNUNET_new (struct TALER_KYCLOGIC_WebhookHandle);
|
||||||
|
wh->cb = cb;
|
||||||
|
wh->cb_cls = cb_cls;
|
||||||
|
wh->ps = ps;
|
||||||
|
wh->pd = pd;
|
||||||
|
GNUNET_break (0); /* FIXME: start activity */
|
||||||
|
return wh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -326,6 +349,8 @@ template_webhook (void *cls,
|
|||||||
static void
|
static void
|
||||||
template_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
|
template_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
|
||||||
{
|
{
|
||||||
|
GNUNET_break (0); /* FIXME: stop activity */
|
||||||
|
GNUNET_free (wh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user