exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

0003-auditor_aml_holds.sql (3088B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2026 Taler Systems SA
      4 --
      5 -- TALER is free software; you can redistribute it and/or modify it under the
      6 -- terms of the GNU General Public License as published by the Free Software
      7 -- Foundation; either version 3, or (at your option) any later version.
      8 --
      9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11 -- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 --
     13 -- You should have received a copy of the GNU General Public License along with
     14 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 --
     16 
     17 CREATE TABLE IF NOT EXISTS auditor_aml_holds
     18 (
     19     row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
     20     wtid BYTEA NOT NULL UNIQUE CHECK (LENGTH(wtid)=32),
     21     wire_target_h_payto BYTEA NOT NULL CHECK (LENGTH(wire_target_h_payto)=32),
     22     account TEXT NOT NULL,
     23     amount taler_amount NOT NULL,
     24     deferral_reason INT4 NOT NULL,
     25     legitimization_measure_serial_id BIGINT NOT NULL DEFAULT (0),
     26     suppressed BOOLEAN NOT NULL DEFAULT FALSE,
     27     creation_date INT8 NOT NULL
     28       DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT
     29 );
     30 
     31 -- Deliberately not garbage collected: a row here is not a finding that ages
     32 -- out, it is money the exchange is still sitting on.  It disappears when the
     33 -- wire transfer is executed, and not before.
     34 
     35 COMMENT ON TABLE auditor_aml_holds
     36   IS 'Wire transfers the exchange aggregated but did not execute: it wrote the aggregation_tracking rows and marked the deposits done, but there is no wire_out row. One row per wire transfer identifier, deleted once the transfer is made.';
     37 
     38 COMMENT ON COLUMN auditor_aml_holds.row_id
     39   IS 'Unique identifier of the report in the auditor database';
     40 COMMENT ON COLUMN auditor_aml_holds.wtid
     41   IS 'Wire transfer identifier the deposits were aggregated into';
     42 COMMENT ON COLUMN auditor_aml_holds.wire_target_h_payto
     43   IS 'Hash of the bank account the transfer should be made to';
     44 COMMENT ON COLUMN auditor_aml_holds.account
     45   IS 'Payto URI of that bank account, for the benefit of the reader';
     46 COMMENT ON COLUMN auditor_aml_holds.amount
     47   IS 'What the exchange still owes on this transfer: deposits minus refunds minus deposit fees, before the wire fee';
     48 COMMENT ON COLUMN auditor_aml_holds.deferral_reason
     49   IS 'Why the exchange says it has not made the transfer, taken from its aggregation_deferrals row: 1 for an aggregate too small to cover the wire fee, 2 for an open KYC/AML requirement, 0 if the exchange gave no reason at all';
     50 COMMENT ON COLUMN auditor_aml_holds.legitimization_measure_serial_id
     51   IS 'The measure the exchange named as blocking the payout, or 0 if it named none';
     52 COMMENT ON COLUMN auditor_aml_holds.suppressed
     53   IS 'True if the report was suppressed by an administrator; the amount still counts towards the balances, as the funds are held either way';
     54 COMMENT ON COLUMN auditor_aml_holds.creation_date
     55   IS 'When the auditor first saw this transfer being held';