-fix type defs
This commit is contained in:
parent
571d43cef3
commit
c93ce9ea2e
@ -29,7 +29,7 @@ BEGIN
|
|||||||
'(age_withdraw_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
|
'(age_withdraw_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
|
||||||
',h_commitment BYTEA NOT NULL CONSTRAINT h_commitment_length CHECK(LENGTH(h_commitment)=64)'
|
',h_commitment BYTEA NOT NULL CONSTRAINT h_commitment_length CHECK(LENGTH(h_commitment)=64)'
|
||||||
',max_age SMALLINT NOT NULL CONSTRAINT max_age_positive CHECK(max_age>=0)'
|
',max_age SMALLINT NOT NULL CONSTRAINT max_age_positive CHECK(max_age>=0)'
|
||||||
',amount_with_fee TALER_AMOUNT NOT NULL'
|
',amount_with_fee taler_amount NOT NULL'
|
||||||
',reserve_pub BYTEA NOT NULL CONSTRAINT reserve_pub_length CHECK(LENGTH(reserve_pub)=32)'
|
',reserve_pub BYTEA NOT NULL CONSTRAINT reserve_pub_length CHECK(LENGTH(reserve_pub)=32)'
|
||||||
',reserve_sig BYTEA NOT NULL CONSTRAINT reserve_sig_length CHECK(LENGTH(reserve_sig)=64)'
|
',reserve_sig BYTEA NOT NULL CONSTRAINT reserve_sig_length CHECK(LENGTH(reserve_sig)=64)'
|
||||||
',noreveal_index SMALLINT NOT NULL CONSTRAINT noreveal_index_positive CHECK(noreveal_index>=0)'
|
',noreveal_index SMALLINT NOT NULL CONSTRAINT noreveal_index_positive CHECK(noreveal_index>=0)'
|
||||||
|
@ -141,22 +141,10 @@ COMMENT ON FUNCTION comment_partitioned_column
|
|||||||
-- Taler amounts and helper functiosn
|
-- Taler amounts and helper functiosn
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
|
|
||||||
DO $$
|
|
||||||
BEGIN
|
|
||||||
CREATE TYPE TALER_AMOUNT
|
|
||||||
AS (val INT8
|
|
||||||
,frac INT4);
|
|
||||||
|
|
||||||
COMMENT ON TYPE TALER_AMOUNT
|
|
||||||
IS 'Type to store a TALER-amount as (val, frac) pair.';
|
|
||||||
EXCEPTION
|
|
||||||
WHEN duplicate_object THEN null;
|
|
||||||
END
|
|
||||||
$$;
|
|
||||||
|
|
||||||
CREATE PROCEDURE amount_normalize(
|
CREATE PROCEDURE amount_normalize(
|
||||||
IN amount TALER_AMOUNT
|
IN amount taler_amount
|
||||||
,OUT normalized TALER_AMOUNT
|
,OUT normalized taler_amount
|
||||||
)
|
)
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
@ -169,9 +157,9 @@ COMMENT ON PROCEDURE amount_normalize
|
|||||||
IS 'Returns the normalized amount by adding to the .val the value of (.frac / 100000000) and removing the modulus 100000000 from .frac.';
|
IS 'Returns the normalized amount by adding to the .val the value of (.frac / 100000000) and removing the modulus 100000000 from .frac.';
|
||||||
|
|
||||||
CREATE PROCEDURE amount_add(
|
CREATE PROCEDURE amount_add(
|
||||||
IN a TALER_AMOUNT
|
IN a taler_amount
|
||||||
,IN b TALER_AMOUNT
|
,IN b taler_amount
|
||||||
,OUT sum TALER_AMOUNT
|
,OUT sum taler_amount
|
||||||
)
|
)
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
@ -189,9 +177,9 @@ COMMENT ON PROCEDURE amount_add
|
|||||||
IS 'Returns the normalized sum of two amounts. It raises an exception when the resulting .val is larger than 2^52';
|
IS 'Returns the normalized sum of two amounts. It raises an exception when the resulting .val is larger than 2^52';
|
||||||
|
|
||||||
CREATE FUNCTION amount_left_minus_right(
|
CREATE FUNCTION amount_left_minus_right(
|
||||||
IN l TALER_AMOUNT
|
IN l taler_amount
|
||||||
,IN r TALER_AMOUNT
|
,IN r taler_amount
|
||||||
,OUT diff TALER_AMOUNT
|
,OUT diff taler_amount
|
||||||
,OUT ok BOOLEAN
|
,OUT ok BOOLEAN
|
||||||
)
|
)
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
|
@ -19,6 +19,21 @@ BEGIN;
|
|||||||
SELECT _v.register_patch('exchange-0002', NULL, NULL);
|
SELECT _v.register_patch('exchange-0002', NULL, NULL);
|
||||||
SET search_path TO exchange;
|
SET search_path TO exchange;
|
||||||
|
|
||||||
|
CREATE TYPE taler_amount
|
||||||
|
AS
|
||||||
|
(val INT8
|
||||||
|
,frac INT4);
|
||||||
|
COMMENT ON TYPE taler_amount
|
||||||
|
IS 'Stores an amount, fraction is in units of 1/100000000 of the base value';
|
||||||
|
|
||||||
|
CREATE TYPE exchange_do_array_reserve_insert_return_type
|
||||||
|
AS
|
||||||
|
(transaction_duplicate BOOLEAN
|
||||||
|
,ruuid INT8
|
||||||
|
);
|
||||||
|
COMMENT ON TYPE exchange_do_array_reserve_insert_return_type
|
||||||
|
IS 'Return type for exchange_do_array_reserves_insert() stored procedure';
|
||||||
|
|
||||||
#include "0002-denominations.sql"
|
#include "0002-denominations.sql"
|
||||||
#include "0002-denomination_revocations.sql"
|
#include "0002-denomination_revocations.sql"
|
||||||
#include "0002-wire_targets.sql"
|
#include "0002-wire_targets.sql"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
-- @author Özgür Kesim
|
-- @author Özgür Kesim
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION exchange_do_age_withdraw(
|
CREATE OR REPLACE FUNCTION exchange_do_age_withdraw(
|
||||||
IN amount_with_fee TALER_AMOUNT,
|
IN amount_with_fee taler_amount,
|
||||||
IN rpub BYTEA,
|
IN rpub BYTEA,
|
||||||
IN rsig BYTEA,
|
IN rsig BYTEA,
|
||||||
IN now INT8,
|
IN now INT8,
|
||||||
@ -38,8 +38,8 @@ AS $$
|
|||||||
DECLARE
|
DECLARE
|
||||||
reserve_gc INT8;
|
reserve_gc INT8;
|
||||||
difference RECORD;
|
difference RECORD;
|
||||||
balance TALER_AMOUNT;
|
balance taler_amount;
|
||||||
new_balance TALER_AMOUNT;
|
new_balance taler_amount;
|
||||||
not_before date;
|
not_before date;
|
||||||
earliest_date date;
|
earliest_date date;
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -104,9 +104,9 @@ required_age=0;
|
|||||||
|
|
||||||
-- Check reserve balance is sufficient.
|
-- Check reserve balance is sufficient.
|
||||||
SELECT *
|
SELECT *
|
||||||
INTO
|
INTO
|
||||||
difference
|
difference
|
||||||
FROM
|
FROM
|
||||||
amount_left_minus_right(
|
amount_left_minus_right(
|
||||||
balance
|
balance
|
||||||
,amount_with_fee);
|
,amount_with_fee);
|
||||||
@ -114,7 +114,7 @@ FROM
|
|||||||
balance_ok = difference.ok;
|
balance_ok = difference.ok;
|
||||||
|
|
||||||
IF NOT balance_ok
|
IF NOT balance_ok
|
||||||
THEN
|
THEN
|
||||||
RETURN;
|
RETURN;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
@ -166,6 +166,5 @@ END IF;
|
|||||||
|
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
COMMENT ON FUNCTION exchange_do_age_withdraw(TALER_AMOUNT, BYTEA, BYTEA, INT8, INT8, BYTEA, INT2, INT2, BYTEA[], INT8[], BYTEA[])
|
COMMENT ON FUNCTION exchange_do_age_withdraw(taler_amount, BYTEA, BYTEA, INT8, INT8, BYTEA, INT2, INT2, BYTEA[], INT8[], BYTEA[])
|
||||||
IS 'Checks whether the reserve has sufficient balance for an age-withdraw operation (or the request is repeated and was previously approved) and that age requirements are met. If so updates the database with the result. Includes storing the blinded planchets and denomination signatures, or signaling conflict';
|
IS 'Checks whether the reserve has sufficient balance for an age-withdraw operation (or the request is repeated and was previously approved) and that age requirements are met. If so updates the database with the result. Includes storing the blinded planchets and denomination signatures, or signaling conflict';
|
||||||
|
|
||||||
|
@ -966,21 +966,6 @@ END $$;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DO $$
|
|
||||||
BEGIN
|
|
||||||
CREATE TYPE exchange_do_array_reserve_insert_return_type
|
|
||||||
AS
|
|
||||||
(transaction_duplicate BOOLEAN
|
|
||||||
,ruuid INT8);
|
|
||||||
EXCEPTION
|
|
||||||
WHEN duplicate_object THEN null;
|
|
||||||
END
|
|
||||||
$$;
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION exchange_do_array_reserves_insert(
|
CREATE OR REPLACE FUNCTION exchange_do_array_reserves_insert(
|
||||||
IN in_gc_date INT8,
|
IN in_gc_date INT8,
|
||||||
IN in_reserve_expiration INT8,
|
IN in_reserve_expiration INT8,
|
||||||
@ -1019,7 +1004,7 @@ BEGIN
|
|||||||
,UNNEST (ina_payto_uri) AS payto_uri
|
,UNNEST (ina_payto_uri) AS payto_uri
|
||||||
ON CONFLICT DO NOTHING;
|
ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
FOR i IN
|
FOR i IN
|
||||||
SELECT
|
SELECT
|
||||||
reserve_pub
|
reserve_pub
|
||||||
,wire_ref
|
,wire_ref
|
||||||
|
Loading…
Reference in New Issue
Block a user