diff options
510 files changed, 8910 insertions, 13385 deletions
@@ -8,6 +8,10 @@ if ! git --version >/dev/null; then exit 1 fi +# Make sure that "git pull" et al. also update +# submodules to avoid accidental rollbacks. +git config --local submodule.recurse true + echo "$0: Updating submodules" # Caution: We do NOT want to fetch the latest version with --remote, # but instead always the one that's recorded in the repository. diff --git a/contrib/Makefile.am.in b/contrib/Makefile.am.in index c6c59357c..bc7115a8d 100644 --- a/contrib/Makefile.am.in +++ b/contrib/Makefile.am.in @@ -44,7 +44,8 @@ bin_SCRIPTS = \ EXTRA_DIST = \ - locale/de/LC_MESSAGES/exchange-tos-v0.po \ + locale/de/LC_MESSAGES/exchange-tos-tops-v0.po \ + locale/fr/LC_MESSAGES/exchange-tos-tops-v0.po \ $(bin_SCRIPTS) \ gana-generate.sh \ gana/gnu-taler-error-codes/registry.rec \ diff --git a/contrib/aml-spa.lock b/contrib/aml-spa.lock index 6da9323bb..a03d9e9db 100644 --- a/contrib/aml-spa.lock +++ b/contrib/aml-spa.lock @@ -1 +1 @@ -0.13.2-dev.1 +0.13.7-dev.1 diff --git a/contrib/exchange-tos-tops-v0-de.rst b/contrib/exchange-tos-tops-v0-de.rst new file mode 100644 index 000000000..fd0c2db0b --- /dev/null +++ b/contrib/exchange-tos-tops-v0-de.rst @@ -0,0 +1,286 @@ +Allgemeine Geschäftsbedingungen der Taler Operations AG +========================================================== + +Diese Allgemeinen Geschäftsbedingungen (nachfolgend **AGB**) der Taler +Operations AG regeln die Rechte und Pflichten von Nutzern und +Zahlungsempfängern (Begünstigten) des angebotenen Zahlungsdiensts. +Mit der Nutzung des Zahlungsdiensts akzeptieren die Nutzer automatisch diese AGB. + + +Dienstleistung; Geltungsbereich +-------------------------------- + +GNU Taler ist ein technisches System, das bargeldlose Zahlungen ermöglicht. +Taler Operations AG (nachfolgend **TOPS**) mit Sitz in Biel/Bienne, Schweiz, +bietet einen **Zahlungsdienst** auf Basis von GNU Taler für Nutzer in der +Schweiz an. TOPS ist Mitglied im VQF, einer FINMA-akkreditierten +Selbstregulierungsorganisation. TOPS wird daher nicht direkt von der FINMA +beaufsichtigt, sondern betreibt eine Finanzdienstleistung nach Art. 6 Abs. 2 +BankV ohne gewerbsmässige Bankeneigenschaft (Nichtbank) und somit ohne +Kundeneinlagensicherung. + +**Nutzer** sind Eigentümer von durch TOPS signierten und in CHF denominierten +Wertmarken (e-Geld), welche in Taler-Wallets in Eigenverantwortung der Nutzer +gespeichert werden und mit denen die Nutzer bezahlen können. + +**Taler-Wallets** sind Produkte, die digitales Bargeld (e-Geld) nach dem GNU +Taler-Protokoll verwalten, welches ein Zahlungsdienst emittiert und zur +Zahlung an Begünstigte wieder einlöst. Die von TOPS emittierten Wertmarken +(e-CHF) können als Zahlungsmittel im stationären Handel, an Automaten, online +und in Apps bei autorisierten Händlern oder Dienstleistungsanbietern, die +dieses Zahlungsmittel akzeptieren (nachfolgend **Begünstigte**), eingesetzt +werden. Nutzer können auch Zahlungen an andere Nutzer durchführen oder +das e-Geld auf ein Schweizer Bankkonto zurückübertragen. + + +Technische Voraussetzungen +-------------------------- + +Um die angebotenen Dienste wahrnehmen zu können, müssen Nutzer ein Taler-Wallet +(elektronische Geldbörse) als Taler-App auf ihrem Smartphone oder als +Erweiterung in einem Browser auf dem PC installieren. Die Nutzer sind frei in +der Wahl ihrer Taler-Wallet-Anwendung. Begünstigte sind ebenfalls frei in der +Wahl ihrer Taler-Wallet-Anwendung bzw. ihres Taler-Backends. Verschiedene +Lösungen werden von diversen Anbietern bereitgestellt. TOPS macht hier keine +Einschränkungen und übernimmt keine Gewährleistung für die gewählte Lösung. Die +Nutzer sind eigenverantwortlich für die Sicherheit ihrer Taler-Wallets bzw. +Taler-Backends und der darin gespeicherten Wertmarken bzw. Transaktionsdaten. + +Das Taler-Wallet wird von den Nutzern über die hierfür vorgesehenen +Mechanismen aufgeladen. Zum Aufbuchen der gewünschten Geldmenge wählt man im +Taler-Wallet den von TOPS betriebenen Zahlungsdienst, an den man diese +Geldmenge vom Girokonto überweist und von dem schliesslich das Taler-Wallet die +elektronischen Repräsentanten der Geldmenge abhebt. TOPS kann weitere +Aufladeoptionen einführen oder auch bestehende Mechanismen nicht mehr anbieten. +Allfällige mit der Aufladung verbundene Transaktionsgebühren oder sonstige Gebühren +sind durch die Nutzer zu tragen. Das Guthaben der Nutzer wird nicht verzinst. +Die Nutzer nehmen zur Kenntnis, dass das Guthaben nicht von der Einlagensicherung gedeckt ist. + +Das Entladen des Taler-Wallet muss auf ein Schweizer Bankkonto +erfolgen. Internationale Zahlungen sind nicht erlaubt. Die Nutzer können mit +dem im Smartphone oder Webbrowser installierten Taler-Wallet innerhalb der +geltenden Limiten bei natürlichen und juristischen Personen bezahlen, die +diese Bezahloption akzeptieren und ein Schweizer Bankkonto zum Geldempfang +führen (z.B. Ladengeschäfte, Webshops, Apps und sonstige Begünstigte). Bei +einer Bezahlung wird der entsprechende Betrag direkt vom Taler-Wallet +abgebucht. Es muss im Taler-Wallet mindestens der Transaktionsbetrag verfügbar +sein. Die Nutzer anerkennen sämtliche getätigten Zahlungen, welche mit dem +Taler-Wallet von ihrem digitalen Endgerät erfolgten, selbst wenn diese +Zahlungen ohne ihre Zustimmung erfolgt sind. Wer ein Guthaben im Taler-Wallet +einlöst, hat den Wert des Guthabens zur Zahlung verwendet. + +Der Verarbeitungsprozess für das Erhöhen und Verringern des Guthabens im +Taler-Wallet kann je nach Mechanismus mehrere Tage in Anspruch nehmen. + + +Preise, Gebühren und Limiten +---------------------------- + +TOPS kann die Gebühren jederzeit ändern. Änderungen haben nur Wirkung auf nach +der Änderung bezogene Wertmarken. Mit dem GNU Taler-Protokoll konforme Taler-Wallets +informieren Nutzer über Gebührenänderungen vor dem Bezug von neuen Wertmarken. +Der Bezug von Wertmarken der TOPS nach Änderung der Gebühren gilt als Zustimmung zu den +geänderten Bedingungen. + +Es bestehen Limiten von CHF 3.000 pro Monat und CHF 15.000 pro Kalenderjahr +für das Abheben von e-Geld von einem Girokonto bzw. für den Empfang von +Peer-to-Peer-Zahlungen zwischen Taler-Wallets mit bestätigter Schweizer +Mobilfunknummer. + + +Allgemeine Mitwirkungspflichten +------------------------------- + +Zur Nutzung des Zahlungsdiensts sind Nutzer und Begünstigte verpflichtet, TOPS +bei der Erfüllung regulatorischer und gesetzlicher Vorgaben zu unterstützen. +TOPS hält sich an alle geltenden Gesetze zur Bekämpfung der Geldwäsche (AML) +und zur Feststellung wirtschaftlich Berechtigter. +TOPS stellt sicher, dass alle privaten Daten im Einklang mit den Schweizerischen +Datenschutzbestimmungen, insbesondere dem Schweizer Datenschutzgesetz (DSG) +und der Verordnung über den Datenschutz (DSV), behandelt werden. +Insbesondere kann TOPS über die Identität von wirtschaftlich Berechtigten +Auskunft verlangen. TOPS hat das Recht und ggf. die gesetzliche Pflicht, +Nutzer und Begünstigte von der Nutzung des Zahlungsdiensts auszuschliessen, +sollten diese die erforderlichen Auskünfte verweigern oder unwahre Angaben +machen. + +Zur Nutzung des Zahlungsdiensts gehen *Begünstigte* eine Geschäftsbeziehung +mit TOPS ein und können ggf. verpflichtet sein, sich bei TOPS zu registrieren +und die dabei verlangten Informationen zur Verfügung zu stellen. +Die Begünstigten können aufgefordert werden, Dokumente zur ihrer Identitätsprüfung vorzulegen. +Für KYC-Anfragen haben sie 30 Tage Zeit, auf diese zu antworten. +TOPS behält sich vor, zur Erfüllung regulatorischer Vorgaben jederzeit weitere Informationen zu verlangen. + +Es erfolgt keine Kontenanlage der *Nutzer* bei TOPS. Erfasst werden jedoch +die IBAN-Konten von Nutzern, die CHF an TOPS überweisen, um Wertmarken zu +kaufen. Die Nutzer brauchen zum Empfang von Peer-to-Peer-Zahlungen mindestens +eine Schweizer Mobiltelefonnummer zum Empfang von SMS zur Identifizierung. + + +Sorgfaltspflichten und andere Pflichten der Nutzer +--------------------------------------------------------------------- + +1. +Beim Umgang mit dem Zahlungsdienst sind insbesondere folgende Sorgfaltspflichten von Nutzern einzuhalten: + +* Das Smartphone, PC, Notebook etc. ist vor unbefugter Benutzung oder Manipulation zu schützen (z.B. mittels Geräte- bzw. Displaysperre). + +* Im Schadenfall haben die Nutzer nach bestem Wissen zur Aufklärung des Falls und zur Schadensminderung beizutragen. Bei strafbaren Handlungen ist Anzeige bei der Polizei zu erstatten. + +* Vor jeder Ausführung einer Zahlung sind die Angaben zum Zahlungsempfänger zu überprüfen, um Fehltransaktionen zu verhindern. + +* Die Nutzer sind für die Nutzung verantwortlich und tragen sämtliche Folgen, die sich aus der Verwendung ergeben. + +* Insbesondere werden Handlungen, die eine Drittperson unberechtigt mit dem Taler-Wallet vornimmt, dem Eigentümer des Wallet zugerechnet. + +2. Die Nutzer müssen sich darüber im klaren sein, **elektronisches Geld wie Bargeld zu behandeln** und ebenso zu +sichern, d.h. ein Backup der Wallet-Daten anzulegen. +Die Nutzer der Taler-App sind daher verpflichtet, den Zugang zum digitalen Endgerät zu sichern und vor unbefugtem Zugriff zu bewahren. +Sie müssen die Wallet-Daten mit einer Sicherungskopie auf einem anderen Gerät speichern. +Die Exportfunktion des Wallet hilft dabei, ein Backup der Wallet-Daten anzulegen und zu speichern. +Ein verlorenes Nutzergerät mit einem Wallet darauf ohne Backup auf einem anderen Gerät oder Datenträger bedeutet einen Totalverlust des Guthabens. + +3. Es ist dafür zu sorgen, dass sich das Endgerät mit einem darauf installierten Taler-Wallet **innerhalb eines Jahres** +nach der letzten Transaktion **mit dem Zahlungsdienst über das Internet verbindet**, ansonsten kann das Guthaben im +Wallet verloren werden. Ein Erneuern des Guthabens erfolgt regulär einen Monat vor dem Ende der Gültigkeit des +elektronischen Bargelds, die zum Abhebezeitpunkt ca. ein Jahr beträgt. + +4. Die Kommunikation von TOPS zu Nutzern erfolgt grundsätzlich über Benachrichtigungen im Protokoll von GNU Taler. +Die Nutzer sind dafür verantwortlich, auf entsprechende Benachrichtigungen zu reagieren. +TOPS hat das Recht, Transaktionen solange nicht auszuführen, bis die Nutzer auf diesem Weg angeforderte rechtlich notwendige Daten bereitstellen. + + +Haftung +------- + +TOPS haftet nicht für entstandene Verluste oder Schäden der Nutzer aufgrund +der Verwendung von GNU Taler, insbesondere nicht für Verluste oder Schäden + +* aufgrund von Übermittlungsfehlern, technischen Störungen oder Defekten, Ausfällen und unberechtigten Zugriffen oder Eingriffen auf das digitale Endgerät, + +* die ganz oder teilweise auf einen Verstoss der Nutzer gegen diese AGB oder anwendbare Gesetze zurückzuführen sind, + +* aufgrund einer Störung oder eines Fehlers der Software oder der verwendeten Hardware, + +* aufgrund von Störungen, Unterbrechungen (einschliesslich Systemwartungsarbeiten) oder Überlastungen der relevanten Informatiksysteme bzw. Netze, + +* aufgrund von Zahlungen, die nicht oder verzögert verarbeitet werden, + +* die auf Handlungen oder Unterlassungen von Dritten (inkl. Hilfspersonen der TOPS) zurückzuführen sind, + +es sei denn, diese Verluste oder Schäden sind auf grobe Fahrlässigkeit oder +vorsätzliches Verschulden von TOPS zurückzuführen. TOPS ersetzt Sach- und +Vermögensschäden je Schadenereignis bis höchstens CHF 1.000. Die Haftung für +Folgeschäden, entgangenen Gewinn oder Datenverluste ist - soweit gesetzlich +zulässig - in jedem Fall ausgeschlossen. + + +Nutzung; Missbräuche +-------------------- + +Nutzer halten TOPS schadlos für Schäden oder Verluste, die TOPS aufgrund der +Nichteinhaltung dieser AGB oder gesetzlicher Vorgaben, aufgrund fehlerhafter +oder unvollständiger Angaben der Nutzer oder der fehlerhaften Ausführung von +Anweisungen entstehen. + +Weicht die Nutzung erheblich vom üblichen Gebrauch ab oder bestehen Anzeichen +eines rechts- oder vertragswidrigen Verhaltens, kann TOPS die Nutzer zur +rechts- und vertragskonformen Nutzung anhalten, die Leistungserbringung ohne +Vorankündigung entschädigungslos ändern, einschränken oder einstellen, die +Geschäftsbeziehung fristlos und entschädigungslos auflösen und gegebenenfalls +Schadenersatz sowie die Freistellung von Ansprüchen Dritter verlangen. TOPS +behält sich vor, bei Verletzung von Regeln oder Missbrauch Zahlungen an +Begünstigte zurückzuhalten. + + +Vorbehalte zu Änderungen an diesen AGB +-------------------------------------- + +TOPS kann die AGB jederzeit ändern. Änderungen haben nur Wirkung auf nach der +Änderung bezogene Wertmarken. Mit dem GNU Taler-Protokoll konforme Taler-Wallets +informieren Nutzer über Änderungen vor dem Bezug von neuen Wertmarken. +Der Bezug von Wertmarken der TOPS nach Änderung der AGB gilt als Zustimmung +zu den geänderten Bedingungen. + +Allfällige Gesetzesbestimmungen, die den Betrieb und die Nutzung von digitalen +Endgeräten, Zahlungsdiensten, des Internets und sonstiger Infrastruktur +regeln, bleiben vorbehalten und gelten ab ihrer Inkraftsetzung auch für die +TOPS-Dienstleistungen. + +TOPS behält sich vor, das Angebot von Dienstleistungen jederzeit und ohne +vorherige Ankündigung zu ändern, zu beschränken oder vollständig einzustellen, +insbesondere aufgrund rechtlicher Anforderungen, technischer Probleme, zur +Verhinderung von Missbräuchen, auf behördliche Anordnung oder aus +Sicherheitsgründen. + +TOPS kann die Vertragsbeziehungen (einschliesslich eines Guthabens) jederzeit +und ohne vorherige Information auf eine andere Gesellschaft übertragen. + + +Geheimhaltung und Datenschutz +----------------------------- + +Personenbezogene Daten werden von TOPS nur im Rahmen der Erfüllung +gesetzlicher Verpflichtungen erhoben, verarbeitet, aufbewahrt oder +weitergegeben. Beim Bezahlvorgang mit e-Geld werden keine Daten zur Identität +der Nutzer erfasst. + +TOPS stellt Nutzern auf Anfrage technischen Support zur Verfügung. An der +Erbringung dieses Supports können Dritte beteiligt sein. Diese erhalten +hierfür Zugriff auf notwendige personenbezogene Daten zur Kommunikation mit +den Nutzern. + +TOPS verpflichtet sich hinsichtlich der Beschaffung, Bearbeitung und Nutzung +personenbezogener Daten von Nutzern die Bestimmungen der schweizerischen +Datenschutzgesetzgebung, insbesondere des Bundesgesetzes über den Datenschutz +und der Verordnung über den Datenschutz, einzuhalten. + +Alle Systemdaten werden primär in der Schweiz gehostet. + +KYC-Prozesse werden ggf. durch Dienstleister gesteuert. Diese sind ebenfalls +verpflichtet, die Daten nach Recht und Gesetz der Schweiz zu sichern. Die +eigentlichen Daten des Kernsystems werden auf verschlüsselten Festplatten +redundant (d.h. mit Backup) gespeichert und sind nur autorisiertem Personal +zugänglich. Autorisiertes Personal wird von TOPS einer Sicherheitsprüfung +unterzogen. Das gesamte Design des Zahlungsdiensts GNU Taler wurde strikt nach +den Grundsätzen "Privacy-by-Design" und "Privacy-by-Default" umgesetzt. + +Weitere Informationen zu den Datenverarbeitungen finden sich in der +Datenschutzerklärung auf der Webseite der TOPS (www.taler-ops.ch). + + +Dauer und Kündigung +------------------- + +Die Geschäftsbeziehung zwischen TOPS und Begünstigten (Händler, Betriebe, +Verkäufer und sonstige regelmässige Empfänger von Überweisungen des +Zahlungsdiensts an die begünstigten IBAN-Konten) wird auf eine unbestimmte +Dauer abgeschlossen. TOPS kann die Geschäftsbeziehung mit den Begünstigten +jederzeit - insbesondere in Missbrauchsfällen mit sofortiger Wirkung - +kündigen. Eine schriftliche Kündigung durch TOPS erfolgt an eine der zuletzt +bekanntgegebenen Adressen der Geschäftspartner (z.B. per E-Mail oder +Brief). Sollten für über 12 Monate keine Transaktionen an die Begünstigen +erfolgen, gilt die Geschäftsbeziehung automatisch als beendet. + +Die Nutzer von Taler-Wallets können das Guthaben in diesen jederzeit an +Bankkonten in der Schweiz zurücküberweisen lassen und so das Guthaben +saldieren. Bei einer +Betriebsaufgabe des Zahlungsdiensts der TOPS werden die Nutzer über die +bevorstehende Einstellung des Zahlungsdiensts durch das Taler-Protokoll +informiert und von den Taler-Wallets aufgefordert, das bestehende Guthaben zu +saldieren. Nutzer, die diese Saldierung unterlassen, verlieren nach 3 Monaten +den Anspruch auf das danach noch bestehende Guthaben, welches in das Eigentum +der TOPS übergeht. + + +Anwendbares Recht und Gerichtsstand +----------------------------------- + +Soweit gesetzlich zulässig unterstehen alle Rechtsbeziehungen zwischen TOPS +und Nutzern ausschliesslich dem materiellen schweizerischen Recht, unter +Ausschluss von Kollisionsrecht und unter Ausschluss von Staatsverträgen. + +Unter dem Vorbehalt von entgegenstehenden zwingenden gesetzlichen +Bestimmungen ist Biel ausschliesslicher Gerichtsstand und Erfüllungsort. Für +Nutzer und Begünstigte mit einem Wohnsitz ausserhalb der Schweiz ist Biel +sodann auch Betreibungsort. diff --git a/contrib/exchange-tos-tops-v0-en.rst b/contrib/exchange-tos-tops-v0-en.rst deleted file mode 100644 index 4eeca11fc..000000000 --- a/contrib/exchange-tos-tops-v0-en.rst +++ /dev/null @@ -1,226 +0,0 @@ -Terms of Service of Taler Operations AG -============================================ - -These Terms of Service (hereinafter **ToS**) of Taler Operations AG regulate the rights and obligations of users and -recipients (beneficiaries) of the payment service offered. By using the payment service, users automatically accept these ToS. - - -Service; scope of application ----------------------------------------------- - -GNU Taler is a technical system that enables cashless payments. Taler Operations AG (hereinafter **TOPS**), -headquartered in Biel/Bienne, Switzerland, provides a **payment system** based on GNU Taler for users in Switzerland. -TOPS is a member of VQF, a FINMA-accredited self-regulating organisation. Consequently, TOPS will therefore not be -directly supervised by the Swiss financial services regulation authority FINMA, but operates a financial service in -accordance with Art. 6 para. 2 Banking Ordinance without commercial banking status (non-bank) and therefore without -customer deposit protection. - -**Users** are the owners of tokens signed by TOPS, denominated in CHF (e-money), which they store in their Taler -wallets under their own responsibility. These tokens can be used by the users to make payments. - -**Taler-Wallets** are products that, in accordance with the GNU Taler protocol, manage digital cash (e-money) , which a -payment service issues and redeems for payments to beneficiaries. The tokens issued by TOPS (e-CHF) can be used as a -means of payment in bricks-and-mortar shops, at vending machines, in online shops, and in apps at authorized merchants -or service providers that accept this means of payment (hereinafter **beneficiaries**). Users can also make payments to -other users or transfer the e-money back to a Swiss bank account. - - -Technical requirements --------------------------------------- - -In order to use the services offered, users must have a Taler wallet (an electronic wallet) as a Taler application on -their smartphone or as an extension in a browser on the PC. Users are free to choose their Taler wallet application. -Beneficiaries are also free to choose their Taler wallet application or Taler backend. Various solutions are provided -by various providers. TOPS does not impose any restrictions and does not provide any guarantee for the chosen solution. -The users are responsible for the security of their Taler wallets or Taler backends and the tokens or transaction data -stored in them. - -The Taler wallet is topped up by users through mechanisms foreseen for the purpose of withdrawals. In order to let the -wallet withdraw the desired amount of money, users select from within the Taler wallet the payment service provider -operated by TOPS and wire this amount of money to the bank account of the payment service provider. TOPS may introduce -further withdrawal options or cease to offer existing mechanisms. Any transaction fees or other fees associated with -wiring or with withdrawals shall be borne by the users. The users' funds do not receive interest and no interest rates -are given for balances in Taler wallets. Users acknowledge that their credit balance is not covered by customer deposit -protection. - -To unload a Taler wallet, users must transfer their funds to a Swiss bank account. International payments -are not permitted. With the Taler wallet installed in the smartphone or web browser, users can make payments -(within applicable limits) to natural persons and legal entities that accept this payment method and have a -Swiss bank account to receive the funds (e.g., stores, web shops, apps, and other beneficiaries). -When users make payments, the corresponding amount of e-money is debited directly from the Taler wallet. -At least the transaction amount must be available in the Taler wallet's balance. Users consent to all payments made -with the Taler wallet from their digital end device, even if these payments were made without their agreement. -Anyone who redeems a token in the Taler wallet has used its represented value of the credit for payment. - -The procedure for increasing and decreasing the credit balance in the Taler wallet can take several days, depending on -the mechanism. - - -Prices, fees and limits ------------------------------------ - -TOPS may change the fees at any time. Fee changes only apply to tokens withdrawn after the change takes effect. -Taler wallets compliant to the GNU Taler protocol will inform users about fee changes before they withdraw new tokens. -Withdrawing tokens issued by TOPS after a fee change is considered the user’s consent to the updated conditions. - -There are limits of CHF 3,000 per month and CHF 15,000 per calendar year for withdrawing e-money from a bank account -or receiving peer-to-peer payments between Taler wallets with a confirmed Swiss mobile number. - - -Legal and regulatory requirements -------------------------------------------------------- - -In order to use the payment service, users and beneficiaries are obliged to support TOPS in fulfilling legal and regulatory requirements. -TOPS complies with all applicable anti-money laundering (AML) and know-your-customer (KYC) regulations. -TOPS will ensure that all personal data is processed in accordance with Swiss privacy laws, including the -Federal Act on Data Protection and the Ordinance on Data Protection. -TOPS has the right and, where applicable, the legal obligation to exclude users and beneficiaries from using the payment service, -if they refuse to provide the required information or provide false information. - -*Beneficiaries* may be required to provide identity verification documents. They will be notified of any KYC information requests -and will have 30 days to respond. In order to use the payment service, beneficiaries enter into a business relationship with TOPS -and, where applicable, may be required to register with TOPS and provide the requested information for this purpose. -TOPS reserves the right to request further information at any time to fulfill regulatory compliance. - -No accounts are created for *users* at TOPS. However, the bank accounts of users who transfer CHF to TOPS in order to -purchase tokens are recorded. To accept peer-to-peer payments, users must have a Swiss cell phone number to receive -SMS for identification purposes. - - -Duty of care and other obligations of users --------------------------------------------------------------------- - -1. -Users must comply with the following duties of care when using the payment service: - -* The smartphone, PC, notebook, etc. must be protected against unauthorized use or manipulation (e.g. by means of a device lock or display lock). - -* In the event of damage, users must contribute to the best of their knowledge to help clarify the case and minimizing the damage. Criminal acts must be reported to the police. - -* Before each payment is made, the details of the payee must be double-checked in order to prevent incorrect transactions. - -* Users are responsible for their use of the system and bear all consequences arising from such use. - -* In particular, any unauthorized use of the Taler wallet by a third party shall be attributed to the owner of the wallet. - -2. Users must be aware of the need to **treat electronic money like cash** and to secure it in the same way, i.e. to create a backup of the wallet data. -The users of the Taler app are therefore obliged to secure access to the digital end device and protect it from unauthorized access. -They must save the wallet's data with a backup copy on another device. The wallet's export function helps to create and save a backup of the wallet data. -A lost user device with a wallet on it without a backup on another device or data carrier means a total loss of the credit. - -3. It must be ensured that the end device with a Taler wallet installed on it connects to the payment service via the Internet **within one year** -after the last transaction, otherwise the credit balance in the wallet may be lost. -The credit balance is usually renewed one month before the end of the validity of the electronic cash, -which is approximately one year after its withdrawal. - -4. Communication from TOPS to users is generally carried out via notifications in the GNU Taler protocol. -Users are responsible for responding to such notifications. -TOPS has the right not to execute transactions until the users provide legally required data. - - -Liability ------------- - -TOPS is not liable for any loss or damage incurred by users as a result of -the use of GNU Taler, in particular not for loss or damage - -* due to transmission errors, technical malfunctions or defects, failures and unauthorized access to or interference with the digital end device, - -* which are due in whole or in part to a breach by the user of these ToS or applicable laws, - -* due to a malfunction or error in the software or hardware used, - -* due to malfunctions, interruptions (including system maintenance work) or overloads of the relevant IT systems or networks, - -* due to payments that are not processed or are delayed, - -* due to acts or omissions of third parties (including auxiliary persons of TOPS), - -unless these losses or damages are attributable to gross negligence or willful misconduct on the part of TOPS. -Liability caps are set at CHF 1,000 for certain loss events. -Liability for consequential damages, loss of profit or loss of data is - to the extent permitted by law - excluded in any case. - - -Use; misuse --------------------- - -Users shall indemnify TOPS for any damages or losses incurred by TOPS due to non-compliance with these ToS -or legal requirements, due to incorrect or incomplete information provided by users or the incorrect execution of -instructions. - -If the use deviates significantly from normal use or if there are signs of illegal or non-contractual behavior, TOPS -may require users to act in accordance with the law and the contract, to suspend, restrict or discontinue the provision -of services without prior notice and without compensation, terminate the business relationship without prior notice -and without compensation and, if necessary, demand compensation for damages and indemnification from third-party claims. -TOPS reserves the right to withhold payments to beneficiaries in the event of a breach of rules or abuse. - - -Reservations regarding changes to these ToS -------------------------------------------------------------------------- - -TOPS may amend the ToS at any time. Amendments only have effect on tokens withdrawn after the change. -Taler wallets compliant to the GNU Taler protocol inform users about changes before new tokens are withdrawn. The withdrawal of tokens -issued by TOPS after the ToS have been amended shall be deemed to constitute acceptance of the amended conditions. - -Any legal provisions governing the operation and use of digital devices, payment services, the Internet and other -infrastructure remain reserved and shall also apply to the TOPS services. - -TOPS reserves the right to change, restrict, modify or completely discontinue its range of services at any time -and without prior notice, in particular due to legal requirements, technical problems, prevention of misuse, -by order of the authorities or for security reasons. - -TOPS may transfer the contractual relationship (including a credit balance) to another company -at any time and without prior notification. - - -Confidentiality and data protection -------------------------------------------------------- - -Personal data is only collected, processed, stored or used by TOPS within the scope of legal obligations. -When paying with e-money, no data on the identity of the user is recorded. - -TOPS provides users with technical support on request. In the provision of this support third parties may be involved. -They will receive access to the personal data required for communication with users. - -TOPS undertakes to comply with the provisions of Swiss law with regard to the personal data of users, in particular -the Federal Act on Data Protection and the Ordinance on Data Protection. - -All system data is primarily hosted in Switzerland. - -KYC processes may be controlled by service providers. These are also obliged to secure the data in accordance with Swiss law. -The core system’s data is stored on encrypted hard disks with redundancy (including backups) and is accessible only to authorized personnel. -Authorized personnel are subjected to security checks by TOPS. -The entire design of the GNU Taler payment service has been strictly developed according to the principles of -“Privacy-by-Design” and “Privacy-by-Default”. - -Further information on data processing can be found in the privacy policy on the TOPS website (www.taler-ops.ch). - - -Duration and termination ----------------------------------------- - -The business relationship between TOPS and beneficiaries (merchants, businesses, and other regular recipients -of transfers from the payment service to the beneficiary IBAN accounts) is concluded for an indefinite period. -TOPS may terminate the business relationship with the beneficiaries at any time - in particular in cases of abuse -with immediate effect. -Written notice of termination by TOPS shall be sent to one of the last addresses provided by the business partners -(e.g. by e-mail or letter). -If no transactions are made to the beneficiaries for more than 12 months, the business relationship shall be automatically -deemed terminated. - -Users of Taler wallets can return the existing credit in these wallets to bank accounts in Switzerland at any time, -thereby balancing the credit. -If the TOPS payment service is discontinued, users will be notified through the GNU Taler protocol and prompted -by their Taler wallets to balance any remaining credit. -Users who fail to balance the credit within 3 months will lose their entitlement to the remaining amount, -which will become the property of TOPS. - - -Applicable law and place of jurisdiction ---------------------------------------------------------------- - -To the extent permitted by law, all legal relationships between TOPS and users shall be governed exclusively by -substantive Swiss law, excluding conflict of laws and international treaties. - -Subject to any mandatory statutory provisions to the contrary, Biel is the exclusive place of jurisdiction and the place of performance. -For users and beneficiaries domiciled outside Switzerland, Biel/Bienne is also the place of debt collection. diff --git a/contrib/exchange-tos-tops-v0-fr.rst b/contrib/exchange-tos-tops-v0-fr.rst index 8a0119156..215f4e9ec 100644 --- a/contrib/exchange-tos-tops-v0-fr.rst +++ b/contrib/exchange-tos-tops-v0-fr.rst @@ -43,7 +43,7 @@ d'argent souhaitée, on choisit dans le portefeuille Taler le service de paiemen cette quantité d'argent sur le compte courant du service de paiement et duquel le portefeuille Taler retire finalement les jetons électroniques correspondant à la quantité d'argent envoyée. TOPS peut introduire d'autres options de rechargement ou ne plus proposer les mécanismes existants. Les éventuels frais de transaction ou autres frais liés à la -recharge sont à la charge des utilisateurs. L'avoir des utilisateurs dans les portefeuilles électroniques ne porte pas d'intérêts. +recharge sont à la charge des utilisateurs. L'avoir des utilisateurs ne porte pas d'intérêts. Les utilisateurs prennent connaissance du fait que l'avoir n'est pas couvert par la garantie des dépôts des clients. Le débit du portefeuille Taler doit être effectué sur un compte bancaire suisse. Les paiements internationaux ne sont @@ -64,9 +64,9 @@ Tarifs, frais, commissions et limites --------------------------------------------------------- TOPS peut modifier les frais à tout moment. Les modifications n'ont d'effet que sur les jetons achetés après la -modification. Les portefeuilles Taler corrects informent les utilisateurs des changements de frais avant l'achat de -nouveaux jetons. Le retrait de jetons de TOPS après une modification des frais vaut acceptation par l'utilisateur des -conditions modifiées. +modification. Les portefeuilles Taler conformes au protocole GNU Taler informent les utilisateurs des changements +de frais avant que de nouveaux jetons ne soient retirés. +Le retrait de jetons de TOPS après une modification des frais vaut acceptation par l'utilisateur des conditions modifiées. Des limites de 3 000 CHF par mois et de 15 000 CHF par année civile sont définies pour le retrait de la monnaie électronique d'un compte courant ou pour la réception de paiements peer-to-peer (d'égal à égal) entre les portefeuilles Taler ayant @@ -77,15 +77,20 @@ Obligations générales de coopération ------------------------------------------------------------ Pour utiliser le service de paiement, l'utilisateur et le bénéficiaire sont tenus d'aider TOPS à satisfaire aux -exigences réglementaires et légales. En particulier, TOPS peut demander des informations sur l'identité des -bénéficiaires effectifs. TOPS a le droit et, le cas échéant, l'obligation légale d'exclure les utilisateurs et les -bénéficiaires de l'utilisation du service de paiement s'ils refusent de fournir les informations requises ou s'ils -fournissent des informations fausses. +exigences réglementaires et légales. TOPS se conforme à toutes les réglementations applicables en matière de +lutte contre le blanchiment d'argent (AML) et de connaissance des bénéficiaires effectifs. +TOPS veillera à ce que toutes les données personnelles soient traitées conformément aux lois suisses sur +la protection des données, y compris la nouvelle loi suisse sur la protection des données (nLPD) et +l'ordonnance sur la protection des données (OPDo). +En particulier, TOPS peut demander des informations sur l'identité des bénéficiaires effectifs. +TOPS a le droit et, le cas échéant, l'obligation légale d'exclure les utilisateurs et les bénéficiaires de l'utilisation +du service de paiement s'ils refusent de fournir les informations requises ou s'ils fournissent des informations fausses. Pour utiliser le service de paiement, les *bénéficiaires* établissent une relation commerciale avec TOPS et peuvent être -tenus, le cas échéant, de s'enregistrer auprès de TOPS et de fournir les informations demandées à cette occasion. TOPS -se réserve le droit de demander à tout moment des informations supplémentaires pour satisfaire aux exigences -réglementaires. +tenus, le cas échéant, de s'enregistrer auprès de TOPS et de fournir les informations demandées à cette occasion. +Les bénéficiaires peuvent être amenés à fournir des documents de vérification d'identité. +Ils seront informés de toute demande d'informations KYC et disposeront de 30 jours pour y répondre. +TOPS se réserve le droit de demander à tout moment des informations supplémentaires pour satisfaire aux exigences réglementaires. Il n'y a pas de création de compte des *utilisateurs* chez TOPS. TOPS enregistre cependant les comptes IBAN des utilisateurs qui transfèrent des CHF à TOPS pour acheter des jetons. Pour recevoir des paiements d'égal à égal (peer-to-peer), @@ -117,7 +122,7 @@ Un terminal numérique perdu avec un portefeuille dessus sans sauvegarde sur un 3. Il faut veiller à ce que le terminal numérique sur lequel est installé un portefeuille Taler se connecte **dans un délai d'un an** après la dernière transaction **au service de paiement par Internet**, faute de quoi l'avoir du portefeuille peut être perdu. -Le renouvellement des jetons a lieu normalement un mois avant la fin de leur validité, qui est d'environ un an après leur retrait. +Le renouvellement de l'avoir a lieu normalement un mois avant la fin de leur validité, qui est d'environ un an après leur retrait. 4. La communication de TOPS avec les utilisateurs se fait en principe par le biais de notifications dans le protocole de GNU Taler. Il incombe aux utilisateurs de répondre aux notifications correspondantes. TOPS a le droit de ne pas effectuer de transactions jusqu'à ce que @@ -166,7 +171,8 @@ Réserves concernant les modifications apportées aux présentes CGU --------------------------------------------------------------------------------------------------------------- TOPS peut modifier les CGU à tout moment. Les modifications n'ont d'effet que sur les jetons obtenus après la modification. -Les portefeuilles Taler électroniques corrects informent les utilisateurs des modifications avant l'achat de nouveaux jetons. +Les portefeuilles Taler conformes au protocole GNU Taler informent les utilisateurs des changements avant que de nouveaux +jetons ne soient retirés. Le retrait de jetons de TOPS après une modification des CGU est considéré comme une acceptation des conditions modifiées. Les éventuelles dispositions légales régissant le fonctionnement et l'utilisation des terminaux numériques, des services de paiement, @@ -212,8 +218,8 @@ réguliers des virements du service de paiement vers les comptes IBAN des béné TOPS peut à tout moment - notamment en cas d'abus avec effet immédiat - résilier la relation commerciale avec les bénéficiaires. Une résiliation écrite par TOPS est envoyée à l'une des dernières adresses communiquées par les partenaires commerciaux (par ex. par e-mail ou par lettre). -Si aucune transaction n'est effectuée vers les bénéficiaires pendant plus de 12 mois, -la relation commerciale est considérée comme terminée. +Si aucune transaction n'est effectuée en faveur les bénéficiaires pendant plus de 12 mois, la relation commerciale est +automatiquement considérée comme terminée. Les utilisateurs des portefeuilles Taler peuvent à tout moment faire transférer l'avoir qu'ils détiennent dans les portefeuilles Taler sur des comptes bancaires en Suisse et ainsi solder leur avoir. diff --git a/contrib/exchange-tos-tops-v0.rst b/contrib/exchange-tos-tops-v0.rst index 862990357..d6bd0cb18 100644 --- a/contrib/exchange-tos-tops-v0.rst +++ b/contrib/exchange-tos-tops-v0.rst @@ -1,280 +1,226 @@ -Allgemeine Geschäftsbedingungen der Taler Operations AG -========================================================== - -Diese Allgemeinen Geschäftsbedingungen (nachfolgend **AGB**) der Taler -Operations AG regeln die Rechte und Pflichten von Nutzern und -Zahlungsempfängern (Begünstigten) des angebotenen Zahlungsdiensts. -Mit der Nutzung des Zahlungsdiensts akzeptieren die Nutzer automatisch diese AGB. - - -Dienstleistung; Geltungsbereich --------------------------------- - -GNU Taler ist ein technisches System, das bargeldlose Zahlungen ermöglicht. -Taler Operations AG (nachfolgend **TOPS**) mit Sitz in Biel/Bienne, Schweiz, -bietet einen **Zahlungsdienst** auf Basis von GNU Taler für Nutzer in der -Schweiz an. TOPS ist Mitglied im VQF, einer FINMA-akkreditierten -Selbstregulierungsorganisation. TOPS wird daher nicht direkt von der FINMA -beaufsichtigt, sondern betreibt eine Finanzdienstleistung nach Art. 6 Abs. 2 -BankV ohne gewerbsmässige Bankeneigenschaft (Nichtbank) und somit ohne -Kundeneinlagensicherung. - -**Nutzer** sind Eigentümer von durch TOPS signierten und in CHF denominierten -Wertmarken (e-Geld), welche in Taler-Wallets in Eigenverantwortung der Nutzer -gespeichert werden und mit denen die Nutzer bezahlen können. - -**Taler-Wallets** sind Produkte, die digitales Bargeld (e-Geld) nach dem GNU -Taler-Protokoll verwalten, welches ein Zahlungsdienst emittiert und zur -Zahlung an Begünstigte wieder einlöst. Die von TOPS emittierten Wertmarken -(e-CHF) können als Zahlungsmittel im stationären Handel, an Automaten, online -und in Apps bei autorisierten Händlern oder Dienstleistungsanbietern, die -dieses Zahlungsmittel akzeptieren (nachfolgend **Begünstigte**), eingesetzt -werden. Nutzer können auch Zahlungen an andere Nutzer durchführen oder -das e-Geld auf ein Schweizer Bankkonto zurückübertragen. - - -Technische Voraussetzungen --------------------------- - -Um die angebotenen Dienste wahrnehmen zu können, müssen Nutzer ein Taler-Wallet -(elektronische Geldbörse) als Taler-App auf ihrem Smartphone oder als -Erweiterung in einem Browser auf dem PC installieren. Die Nutzer sind frei in -der Wahl ihrer Taler-Wallet-Anwendung. Begünstigte sind ebenfalls frei in der -Wahl ihrer Taler-Wallet-Anwendung bzw. ihres Taler-Backends. Verschiedene -Lösungen werden von diversen Anbietern bereitgestellt. TOPS macht hier keine -Einschränkungen und übernimmt keine Gewährleistung für die gewählte Lösung. Die -Nutzer sind eigenverantwortlich für die Sicherheit ihrer Taler-Wallets bzw. -Taler-Backends und der darin gespeicherten Wertmarken bzw. Transaktionsdaten. - -Das Taler-Wallet wird von den Nutzern über die hierfür vorgesehenen -Mechanismen aufgeladen. Zum Aufbuchen der gewünschten Geldmenge wählt man im -Taler-Wallet den von TOPS betriebenen Zahlungsdienst, an den man diese -Geldmenge vom Girokonto überweist und von dem schliesslich das Taler-Wallet die -elektronischen Repräsentanten der Geldmenge abhebt. TOPS kann weitere -Aufladeoptionen einführen oder auch bestehende Mechanismen nicht mehr anbieten. -Allfällige mit der Aufladung verbundene Transaktionsgebühren oder sonstige Gebühren -sind durch die Nutzer zu tragen. Das Guthaben der Nutzer in Wallets wird nicht -verzinst. Die Nutzer nehmen zur Kenntnis, dass das Guthaben nicht von der -Einlagensicherung gedeckt ist. - -Das Entladen des Taler-Wallet muss auf ein Schweizer Bankkonto -erfolgen. Internationale Zahlungen sind nicht erlaubt. Die Nutzer können mit -dem im Smartphone oder Webbrowser installierten Taler-Wallet innerhalb der -geltenden Limiten bei natürlichen und juristischen Personen bezahlen, die -diese Bezahloption akzeptieren und ein Schweizer Bankkonto zum Geldempfang -führen (z.B. Ladengeschäfte, Webshops, Apps und sonstige Begünstigte). Bei -einer Bezahlung wird der entsprechende Betrag direkt vom Taler-Wallet -abgebucht. Es muss im Taler-Wallet mindestens der Transaktionsbetrag verfügbar -sein. Die Nutzer anerkennen sämtliche getätigten Zahlungen, welche mit dem -Taler-Wallet von ihrem digitalen Endgerät erfolgten, selbst wenn diese -Zahlungen ohne ihre Zustimmung erfolgt sind. Wer ein Guthaben im Taler-Wallet -einlöst, hat den Wert des Guthabens zur Zahlung verwendet. - -Der Verarbeitungsprozess für das Erhöhen und Verringern des Guthabens im -Taler-Wallet kann je nach Mechanismus mehrere Tage in Anspruch nehmen. - - -Preise, Gebühren und Limiten ----------------------------- - -TOPS kann die Gebühren jederzeit ändern. Änderungen haben nur Wirkung auf nach -der Änderung bezogene Wertmarken. Korrekte Taler-Wallets informieren Nutzer -über Gebührenänderungen vor dem Bezug von neuen Wertmarken. Der Bezug von -Wertmarken der TOPS nach Änderung der Gebühren gilt als Zustimmung zu den -geänderten Bedingungen. - -Es bestehen Limiten von CHF 3.000 pro Monat und CHF 15.000 pro Kalenderjahr -für das Abheben von e-Geld von einem Girokonto bzw. für den Empfang von -Peer-to-Peer-Zahlungen zwischen Taler-Wallets mit bestätigter Schweizer -Mobilfunknummer. - - -Allgemeine Mitwirkungspflichten -------------------------------- - -Zur Nutzung des Zahlungsdiensts sind Nutzer und Begünstigte verpflichtet, TOPS -bei der Erfüllung regulatorischer und gesetzlicher Vorgaben zu unterstützen. -Insbesondere kann TOPS über die Identität von wirtschaftlich Berechtigten -Auskunft verlangen. TOPS hat das Recht und ggf. die gesetzliche Pflicht, -Nutzer und Begünstigte von der Nutzung des Zahlungsdiensts auszuschliessen, -sollten diese die erforderlichen Auskünfte verweigern oder unwahre Angaben -machen. - -Zur Nutzung des Zahlungsdiensts gehen *Begünstigte* eine Geschäftsbeziehung -mit TOPS ein und können ggf. verpflichtet sein, sich bei TOPS zu registrieren -und die dabei verlangten Informationen zur Verfügung zu stellen. TOPS behält -sich vor, zur Erfüllung regulatorischer Vorgaben jederzeit weitere -Informationen zu verlangen. - -Es erfolgt keine Kontenanlage der *Nutzer* bei TOPS. Erfasst werden jedoch -die IBAN-Konten von Nutzern, die CHF an TOPS überweisen, um Wertmarken zu -kaufen. Die Nutzer brauchen zum Empfang von Peer-to-Peer-Zahlungen mindestens -eine Schweizer Mobiltelefonnummer zum Empfang von SMS zur Identifizierung. - - -Sorgfaltspflichten und andere Pflichten der Nutzer ---------------------------------------------------------------------- +Terms of Service of Taler Operations AG +============================================ + +These Terms of Service (hereinafter **ToS**) of Taler Operations AG regulate the rights and obligations of users and +recipients (beneficiaries) of the payment service offered. By using the payment service, users automatically accept these ToS. + + +Service; scope of application +---------------------------------------------- + +GNU Taler is a technical system that enables cashless payments. Taler Operations AG (hereinafter **TOPS**), +headquartered in Biel/Bienne, Switzerland, provides a **payment system** based on GNU Taler for users in Switzerland. +TOPS is a member of VQF, a FINMA-accredited self-regulating organisation. Consequently, TOPS will therefore not be +directly supervised by the Swiss financial services regulation authority FINMA, but operates a financial service in +accordance with Art. 6 para. 2 Banking Ordinance without commercial banking status (non-bank) and therefore without +customer deposit protection. + +**Users** are the owners of tokens signed by TOPS, denominated in CHF (e-money), which they store in their Taler +wallets under their own responsibility. These tokens can be used by the users to make payments. + +**Taler-Wallets** are products that, in accordance with the GNU Taler protocol, manage digital cash (e-money) , which a +payment service issues and redeems for payments to beneficiaries. The tokens issued by TOPS (e-CHF) can be used as a +means of payment in bricks-and-mortar shops, at vending machines, in online shops, and in apps at authorized merchants +or service providers that accept this means of payment (hereinafter **beneficiaries**). Users can also make payments to +other users or transfer the e-money back to a Swiss bank account. + + +Technical requirements +-------------------------------------- + +In order to use the services offered, users must have a Taler wallet (an electronic wallet) as a Taler application on +their smartphone or as an extension in a browser on the PC. Users are free to choose their Taler wallet application. +Beneficiaries are also free to choose their Taler wallet application or Taler backend. Various solutions are provided +by various providers. TOPS does not impose any restrictions and does not provide any guarantee for the chosen solution. +The users are responsible for the security of their Taler wallets or Taler backends and the tokens or transaction data +stored in them. + +The Taler wallet is topped up by users through mechanisms foreseen for the purpose of withdrawals. In order to let the +wallet withdraw the desired amount of money, users select from within the Taler wallet the payment service provider +operated by TOPS and wire this amount of money to the bank account of the payment service provider. TOPS may introduce +further withdrawal options or cease to offer existing mechanisms. Any transaction fees or other fees associated with +wiring or with withdrawals shall be borne by the users. Users’ funds do not earn interest. +Users acknowledge that their credit balance is not covered by customer deposit protection. + +To unload a Taler wallet, users must transfer their funds to a Swiss bank account. International payments +are not permitted. With the Taler wallet installed in the smartphone or web browser, users can make payments +(within applicable limits) to natural persons and legal entities that accept this payment method and have a +Swiss bank account to receive the funds (e.g., stores, web shops, apps, and other beneficiaries). +When users make payments, the corresponding amount of e-money is debited directly from the Taler wallet. +At least the transaction amount must be available in the Taler wallet's balance. Users consent to all payments made +with the Taler wallet from their digital end device, even if these payments were made without their agreement. +Anyone who redeems a token in the Taler wallet has used its represented value of the credit for payment. + +The procedure for increasing and decreasing the credit balance in the Taler wallet can take several days, depending on +the mechanism. + + +Prices, fees and limits +----------------------------------- + +TOPS may change the fees at any time. Fee changes only apply to tokens withdrawn after the change takes effect. +Taler wallets compliant to the GNU Taler protocol will inform users about fee changes before they withdraw new tokens. +Withdrawing tokens issued by TOPS after a fee change is considered the user’s consent to the updated conditions. + +There are limits of CHF 3,000 per month and CHF 15,000 per calendar year for withdrawing e-money from a bank account +or receiving peer-to-peer payments between Taler wallets with a confirmed Swiss mobile number. + + +Legal and regulatory requirements +------------------------------------------------------- + +In order to use the payment service, users and beneficiaries are obliged to support TOPS in fulfilling legal and regulatory requirements. +TOPS complies with all applicable anti-money laundering (AML) and know-your-customer (KYC) regulations. +TOPS will ensure that all personal data is processed in accordance with Swiss privacy laws, including the +new Swiss Data Protection Act (nFADP) and the Ordinance on Data Protection (DPO). +TOPS has the right and, where applicable, the legal obligation to exclude users and beneficiaries from using the payment service, +if they refuse to provide the required information or provide false information. + +In order to use the payment service, *beneficiaries* enter into a business relationship with TOPS and, where applicable, +may be required to register with TOPS and provide the requested information for this purpose. +Beneficiaries may be required to provide identity verification documents. +They will be notified of any KYC information requests and will have 30 days to respond. +TOPS reserves the right to request further information at any time to fulfill regulatory compliance. + +No accounts are created for *users* at TOPS. However, the bank accounts of users who transfer CHF to TOPS in order to +purchase tokens are recorded. To accept peer-to-peer payments, users must have a Swiss cell phone number to receive +SMS for identification purposes. + + +Duty of care and other obligations of users +-------------------------------------------------------------------- 1. -Beim Umgang mit dem Zahlungsdienst sind insbesondere folgende Sorgfaltspflichten von Nutzern einzuhalten: +Users must comply with the following duties of care when using the payment service: -* Das Smartphone, PC, Notebook etc. ist vor unbefugter Benutzung oder Manipulation zu schützen (z.B. mittels Geräte- bzw. Displaysperre). +* The smartphone, PC, notebook, etc. must be protected against unauthorized use or manipulation (e.g. by means of a device lock or display lock). -* Im Schadenfall haben die Nutzer nach bestem Wissen zur Aufklärung des Falls und zur Schadensminderung beizutragen. Bei strafbaren Handlungen ist Anzeige bei der Polizei zu erstatten. +* In the event of damage, users must contribute to the best of their knowledge to help clarify the case and minimizing the damage. Criminal acts must be reported to the police. -* Vor jeder Ausführung einer Zahlung sind die Angaben zum Zahlungsempfänger zu überprüfen, um Fehltransaktionen zu verhindern. +* Before each payment is made, the details of the payee must be double-checked in order to prevent incorrect transactions. -* Die Nutzer sind für die Nutzung verantwortlich und tragen sämtliche Folgen, die sich aus der Verwendung ergeben. +* Users are responsible for their use of the system and bear all consequences arising from such use. -* Insbesondere werden Handlungen, die eine Drittperson unberechtigt mit dem Taler-Wallet vornimmt, dem Eigentümer des Wallet zugerechnet. +* In particular, any unauthorized use of the Taler wallet by a third party shall be attributed to the owner of the wallet. -2. Die Nutzer müssen sich darüber im klaren sein, **elektronisches Geld wie Bargeld zu behandeln** und ebenso zu -sichern, d.h. ein Backup der Wallet-Daten anzulegen. -Die Nutzer der Taler-App sind daher verpflichtet, den Zugang zum digitalen Endgerät zu sichern und vor unbefugtem Zugriff zu bewahren. -Sie müssen die Wallet-Daten mit einer Sicherungskopie auf einem anderen Gerät speichern. -Die Exportfunktion des Wallet hilft dabei, ein Backup der Wallet-Daten anzulegen und zu speichern. -Ein verlorenes Nutzergerät mit einem Wallet darauf ohne Backup auf einem anderen Gerät oder Datenträger bedeutet einen Totalverlust des Guthabens. +2. Users must be aware of the need to **treat electronic money like cash** and to secure it in the same way, i.e. to create a backup of the wallet data. +The users of the Taler app are therefore obliged to secure access to the digital end device and protect it from unauthorized access. +They must save the wallet's data with a backup copy on another device. The wallet's export function helps to create and save a backup of the wallet data. +A lost user device with a wallet on it without a backup on another device or data carrier means a total loss of the credit. -3. Es ist dafür zu sorgen, dass sich das Endgerät mit einem darauf installierten Taler-Wallet **innerhalb eines Jahres** -nach der letzten Transaktion **mit dem Zahlungsdienst über das Internet verbindet**, ansonsten kann das Guthaben im -Wallet verloren werden. Ein Erneuern des Guthabens erfolgt regulär einen Monat vor dem Ende der Gültigkeit des -elektronischen Bargelds, die zum Abhebezeitpunkt ca. ein Jahr beträgt. +3. It must be ensured that the end device with a Taler wallet installed on it connects to the payment service via the Internet **within one year** +after the last transaction, otherwise the credit balance in the wallet may be lost. +The credit balance is usually renewed one month before the end of the validity of the electronic cash, +which is approximately one year after its withdrawal. -4. Die Kommunikation von TOPS zu Nutzern erfolgt grundsätzlich über Benachrichtigungen im Protokoll von GNU Taler. -Die Nutzer sind dafür verantwortlich, auf entsprechende Benachrichtigungen zu reagieren. -TOPS hat das Recht, Transaktionen solange nicht auszuführen, bis die Nutzer auf diesem Weg angeforderte rechtlich notwendige Daten bereitstellen. +4. Communication from TOPS to users is generally carried out via notifications in the GNU Taler protocol. +Users are responsible for responding to such notifications. +TOPS has the right not to execute transactions until the users provide legally required data. -Haftung -------- +Liability +------------ -TOPS haftet nicht für entstandene Verluste oder Schäden der Nutzer aufgrund -der Verwendung von GNU Taler, insbesondere nicht für Verluste oder Schäden +TOPS is not liable for any loss or damage incurred by users as a result of +the use of GNU Taler, in particular not for loss or damage -* aufgrund von Übermittlungsfehlern, technischen Störungen oder Defekten, Ausfällen und unberechtigten Zugriffen oder Eingriffen auf das digitale Endgerät, +* due to transmission errors, technical malfunctions or defects, failures and unauthorized access to or interference with the digital end device, -* die ganz oder teilweise auf einen Verstoss der Nutzer gegen diese AGB oder anwendbare Gesetze zurückzuführen sind, +* which are due in whole or in part to a breach by the user of these ToS or applicable laws, -* aufgrund einer Störung oder eines Fehlers der Software oder der verwendeten Hardware, +* due to a malfunction or error in the software or hardware used, -* aufgrund von Störungen, Unterbrechungen (einschliesslich Systemwartungsarbeiten) oder Überlastungen der relevanten Informatiksysteme bzw. Netze, +* due to malfunctions, interruptions (including system maintenance work) or overloads of the relevant IT systems or networks, -* aufgrund von Zahlungen, die nicht oder verzögert verarbeitet werden, +* due to payments that are not processed or are delayed, -* die auf Handlungen oder Unterlassungen von Dritten (inkl. Hilfspersonen der TOPS) zurückzuführen sind, +* due to acts or omissions of third parties (including auxiliary persons of TOPS), -es sei denn, diese Verluste oder Schäden sind auf grobe Fahrlässigkeit oder -vorsätzliches Verschulden von TOPS zurückzuführen. TOPS ersetzt Sach- und -Vermögensschäden je Schadenereignis bis höchstens CHF 1.000. Die Haftung für -Folgeschäden, entgangenen Gewinn oder Datenverluste ist - soweit gesetzlich -zulässig - in jedem Fall ausgeschlossen. +unless these losses or damages are attributable to gross negligence or willful misconduct on the part of TOPS. +Liability caps are set at CHF 1,000 for certain loss events. +Liability for consequential damages, loss of profit or loss of data is - to the extent permitted by law - excluded in any case. -Nutzung; Missbräuche +Use; misuse -------------------- -Nutzer halten TOPS schadlos für Schäden oder Verluste, die TOPS aufgrund der -Nichteinhaltung dieser AGB oder gesetzlicher Vorgaben, aufgrund fehlerhafter -oder unvollständiger Angaben der Nutzer oder der fehlerhaften Ausführung von -Anweisungen entstehen. +Users shall indemnify TOPS for any damages or losses incurred by TOPS due to non-compliance with these ToS +or legal requirements, due to incorrect or incomplete information provided by users or the incorrect execution of +instructions. -Weicht die Nutzung erheblich vom üblichen Gebrauch ab oder bestehen Anzeichen -eines rechts- oder vertragswidrigen Verhaltens, kann TOPS die Nutzer zur -rechts- und vertragskonformen Nutzung anhalten, die Leistungserbringung ohne -Vorankündigung entschädigungslos ändern, einschränken oder einstellen, die -Geschäftsbeziehung fristlos und entschädigungslos auflösen und gegebenenfalls -Schadenersatz sowie die Freistellung von Ansprüchen Dritter verlangen. TOPS -behält sich vor, bei Verletzung von Regeln oder Missbrauch Zahlungen an -Begünstigte zurückzuhalten. +If the use deviates significantly from normal use or if there are signs of illegal or non-contractual behavior, TOPS +may require users to act in accordance with the law and the contract, to suspend, restrict or discontinue the provision +of services without prior notice and without compensation, terminate the business relationship without prior notice +and without compensation and, if necessary, demand compensation for damages and indemnification from third-party claims. +TOPS reserves the right to withhold payments to beneficiaries in the event of a breach of rules or abuse. -Vorbehalte zu Änderungen an diesen AGB --------------------------------------- +Reservations regarding changes to these ToS +------------------------------------------------------------------------- -TOPS kann die AGB jederzeit ändern. Änderungen haben nur Wirkung auf nach der -Änderung bezogene Wertmarken. Korrekte Taler-Wallets informieren Nutzer über -Änderungen vor dem Bezug von neuen Wertmarken. Der Bezug von Wertmarken der -TOPS nach Änderung der AGB gilt als Zustimmung zu den geänderten Bedingungen. - -Allfällige Gesetzesbestimmungen, die den Betrieb und die Nutzung von digitalen -Endgeräten, Zahlungsdiensten, des Internets und sonstiger Infrastruktur -regeln, bleiben vorbehalten und gelten ab ihrer Inkraftsetzung auch für die -TOPS-Dienstleistungen. - -TOPS behält sich vor, das Angebot von Dienstleistungen jederzeit und ohne -vorherige Ankündigung zu ändern, zu beschränken oder vollständig einzustellen, -insbesondere aufgrund rechtlicher Anforderungen, technischer Probleme, zur -Verhinderung von Missbräuchen, auf behördliche Anordnung oder aus -Sicherheitsgründen. - -TOPS kann die Vertragsbeziehungen (einschliesslich eines Guthabens) jederzeit -und ohne vorherige Information auf eine andere Gesellschaft übertragen. - - -Geheimhaltung und Datenschutz ------------------------------ - -Personenbezogene Daten werden von TOPS nur im Rahmen der Erfüllung -gesetzlicher Verpflichtungen erhoben, verarbeitet, aufbewahrt oder -weitergegeben. Beim Bezahlvorgang mit e-Geld werden keine Daten zur Identität -der Nutzer erfasst. - -TOPS stellt Nutzern auf Anfrage technischen Support zur Verfügung. An der -Erbringung dieses Supports können Dritte beteiligt sein. Diese erhalten -hierfür Zugriff auf notwendige personenbezogene Daten zur Kommunikation mit -den Nutzern. - -TOPS verpflichtet sich hinsichtlich der Beschaffung, Bearbeitung und Nutzung -personenbezogener Daten von Nutzern die Bestimmungen der schweizerischen -Datenschutzgesetzgebung, insbesondere des Bundesgesetzes über den Datenschutz -und der Verordnung über den Datenschutz, einzuhalten. - -Alle Systemdaten werden primär in der Schweiz gehostet. - -KYC-Prozesse werden ggf. durch Dienstleister gesteuert. Diese sind ebenfalls -verpflichtet, die Daten nach Recht und Gesetz der Schweiz zu sichern. Die -eigentlichen Daten des Kernsystems werden auf verschlüsselten Festplatten -redundant (d.h. mit Backup) gespeichert und sind nur autorisiertem Personal -zugänglich. Autorisiertes Personal wird von TOPS einer Sicherheitsprüfung -unterzogen. Das gesamte Design des Zahlungsdiensts GNU Taler wurde strikt nach -den Grundsätzen "Privacy-by-Design" und "Privacy-by-Default" umgesetzt. - -Weitere Informationen zu den Datenverarbeitungen finden sich in der -Datenschutzerklärung auf der Webseite der TOPS (www.taler-ops.ch). - - -Dauer und Kündigung -------------------- - -Die Geschäftsbeziehung zwischen TOPS und Begünstigten (Händler, Betriebe, -Verkäufer und sonstige regelmässige Empfänger von Überweisungen des -Zahlungsdiensts an die begünstigten IBAN-Konten) wird auf eine unbestimmte -Dauer abgeschlossen. TOPS kann die Geschäftsbeziehung mit den Begünstigten -jederzeit - insbesondere in Missbrauchsfällen mit sofortiger Wirkung - -kündigen. Eine schriftliche Kündigung durch TOPS erfolgt an eine der zuletzt -bekanntgegebenen Adressen der Geschäftspartner (z.B. per E-Mail oder -Brief). Sollten für über 12 Monate keine Transaktionen an die Begünstigen -erfolgen, gilt die Geschäftsbeziehung als beendet. - -Die Nutzer von Taler-Wallets können das Guthaben in diesen jederzeit an -Bankkonten in der Schweiz zurücküberweisen lassen und so das Guthaben -saldieren. Bei einer -Betriebsaufgabe des Zahlungsdiensts der TOPS werden die Nutzer über die -bevorstehende Einstellung des Zahlungsdiensts durch das Taler-Protokoll -informiert und von den Taler-Wallets aufgefordert, das bestehende Guthaben zu -saldieren. Nutzer, die diese Saldierung unterlassen, verlieren nach 3 Monaten -den Anspruch auf das danach noch bestehende Guthaben, welches in das Eigentum -der TOPS übergeht. - - -Anwendbares Recht und Gerichtsstand ------------------------------------ +TOPS may amend the ToS at any time. Amendments only have effect on tokens withdrawn after the change. +Taler wallets compliant to the GNU Taler protocol inform users about changes before new tokens are withdrawn. The withdrawal of tokens +issued by TOPS after the ToS have been amended shall be deemed to constitute acceptance of the amended conditions. + +Any legal provisions governing the operation and use of digital devices, payment services, the Internet and other +infrastructure remain reserved and shall also apply to the TOPS services. + +TOPS reserves the right to change, restrict, modify or completely discontinue its range of services at any time +and without prior notice, in particular due to legal requirements, technical problems, prevention of misuse, +by order of the authorities or for security reasons. + +TOPS may transfer the contractual relationship (including a credit balance) to another company +at any time and without prior notification. + + +Confidentiality and data protection +------------------------------------------------------- + +Personal data is only collected, processed, stored or used by TOPS within the scope of legal obligations. +When paying with e-money, no data on the identity of the user is recorded. + +TOPS provides users with technical support on request. In the provision of this support third parties may be involved. +They will receive access to the personal data required for communication with users. + +TOPS undertakes to comply with the provisions of Swiss law with regard to the personal data of users, in particular +the Federal Act on Data Protection and the Ordinance on Data Protection. + +All system data is primarily hosted in Switzerland. + +KYC processes may be controlled by service providers. These are also obliged to secure the data in accordance with Swiss law. +The core system’s data is stored on encrypted hard disks with redundancy (including backups) and is accessible only to authorized personnel. +Authorized personnel are subjected to security checks by TOPS. +The entire design of the GNU Taler payment service has been strictly developed according to the principles of +“Privacy-by-Design” and “Privacy-by-Default”. + +Further information on data processing can be found in the privacy policy on the TOPS website (www.taler-ops.ch). + + +Duration and termination +---------------------------------------- + +The business relationship between TOPS and beneficiaries (merchants, businesses, and other regular recipients +of transfers from the payment service to the beneficiary IBAN accounts) is concluded for an indefinite period. +TOPS may terminate the business relationship with the beneficiaries at any time - in particular in cases of abuse +with immediate effect. +Written notice of termination by TOPS shall be sent to one of the last addresses provided by the business partners +(e.g. by e-mail or letter). +If no transactions are made to the beneficiaries for more than 12 months, the business relationship shall be automatically +deemed terminated. + +Users of Taler wallets can return the existing credit in these wallets to bank accounts in Switzerland at any time, +thereby balancing the credit. +If the TOPS payment service is discontinued, users will be notified through the GNU Taler protocol and prompted +by their Taler wallets to balance any remaining credit. +Users who fail to balance the credit within 3 months will lose their entitlement to the remaining amount, +which will become the property of TOPS. + + +Applicable law and place of jurisdiction +--------------------------------------------------------------- -Soweit gesetzlich zulässig unterstehen alle Rechtsbeziehungen zwischen TOPS -und Nutzern ausschliesslich dem materiellen schweizerischen Recht, unter -Ausschluss von Kollisionsrecht und unter Ausschluss von Staatsverträgen. +To the extent permitted by law, all legal relationships between TOPS and users shall be governed exclusively by +substantive Swiss law, excluding conflict of laws and international treaties. -Unter dem Vorbehalt von entgegenstehenden zwingenden gesetzlichen -Bestimmungen ist Biel ausschliesslicher Gerichtsstand und Erfüllungsort. Für -Nutzer und Begünstigte mit einem Wohnsitz ausserhalb der Schweiz ist Biel -sodann auch Betreibungsort. +Subject to any mandatory statutory provisions to the contrary, Biel is the exclusive place of jurisdiction and the place of performance. +For users and beneficiaries domiciled outside Switzerland, Biel/Bienne is also the place of debt collection. diff --git a/contrib/exchange-tos-v0.rst b/contrib/exchange-tos-v0.rst index 1fdb66664..633a39757 100644 --- a/contrib/exchange-tos-v0.rst +++ b/contrib/exchange-tos-v0.rst @@ -1,7 +1,7 @@ Terms of Service ================ -Last update: 26.4.2024 +Last update: 3.10.2024 ---------------------- Welcome! Taler Systems SA (“we,” “our,” or “us”) provides a payment service diff --git a/contrib/gana b/contrib/gana -Subproject cef0ad358584b76a3f29fdcc6be202a332e4d95 +Subproject cbbf44fdd7a0d74a0b216a72daed134ac647c01 diff --git a/contrib/locale/de/LC_MESSAGES/exchange-tos-tops-v0.po b/contrib/locale/de/LC_MESSAGES/exchange-tos-tops-v0.po new file mode 100644 index 000000000..70495982f --- /dev/null +++ b/contrib/locale/de/LC_MESSAGES/exchange-tos-tops-v0.po @@ -0,0 +1,248 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2014-2024 Taler Systems SA (GPLv3+ or GFDL 1.3+) +# This file is distributed under the same license as the exchange-tos-tops-v0 package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: exchange-tos-tops-v0 exchange-tos-tops-v0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-09 15:17+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <languages@taler.net>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:2 +msgid "Terms of Service of Taler Operations AG" +msgstr "Allgemeine Geschäftsbedingungen der Taler Operations AG" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:4 +msgid "These Terms of Service (hereinafter **ToS**) of Taler Operations AG regulate the rights and obligations of users and recipients (beneficiaries) of the payment service offered. By using the payment service, users automatically accept these ToS." +msgstr "Diese Allgemeinen Geschäftsbedingungen (nachfolgend **AGB**) der Taler Operations AG regeln die Rechte und Pflichten von Nutzern und Zahlungsempfängern (Begünstigten) des angebotenen Zahlungsdiensts. Mit der Nutzung des Zahlungsdiensts akzeptieren die Nutzer automatisch diese AGB." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:9 +msgid "Service; scope of application" +msgstr "Dienstleistung; Geltungsbereich" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:11 +msgid "GNU Taler is a technical system that enables cashless payments. Taler Operations AG (hereinafter **TOPS**), headquartered in Biel/Bienne, Switzerland, provides a **payment system** based on GNU Taler for users in Switzerland. TOPS is a member of VQF, a FINMA-accredited self-regulating organisation. Consequently, TOPS will therefore not be directly supervised by the Swiss financial services regulation authority FINMA, but operates a financial service in accordance with Art. 6 para. 2 Banking Ordinance without commercial banking status (non-bank) and therefore without customer deposit protection." +msgstr "GNU Taler ist ein technisches System, das bargeldlose Zahlungen ermöglicht. Taler Operations AG (nachfolgend **TOPS**) mit Sitz in Biel/Bienne, Schweiz, bietet einen **Zahlungsdienst** auf Basis von GNU Taler für Nutzer in der Schweiz an. TOPS ist Mitglied im VQF, einer FINMA-akkreditierten Selbstregulierungsorganisation. TOPS wird daher nicht direkt von der FINMA beaufsichtigt, sondern betreibt eine Finanzdienstleistung nach Art. 6 Abs. 2 BankV ohne gewerbsmässige Bankeneigenschaft (Nichtbank) und somit ohne Kundeneinlagensicherung." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:18 +msgid "**Users** are the owners of tokens signed by TOPS, denominated in CHF (e-money), which they store in their Taler wallets under their own responsibility. These tokens can be used by the users to make payments." +msgstr "**Nutzer** sind Eigentümer von durch TOPS signierten und in CHF denominierten Wertmarken (e-Geld), welche in Taler-Wallets in Eigenverantwortung der Nutzer gespeichert werden und mit denen die Nutzer bezahlen können." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:21 +msgid "**Taler-Wallets** are products that, in accordance with the GNU Taler protocol, manage digital cash (e-money) , which a payment service issues and redeems for payments to beneficiaries. The tokens issued by TOPS (e-CHF) can be used as a means of payment in bricks-and-mortar shops, at vending machines, in online shops, and in apps at authorized merchants or service providers that accept this means of payment (hereinafter **beneficiaries**). Users can also make payments to other users or transfer the e-money back to a Swiss bank account." +msgstr "**Taler-Wallets** sind Produkte, die digitales Bargeld (e-Geld) nach dem GNU Taler-Protokoll verwalten, welches ein Zahlungsdienst emittiert und zur Zahlung an Begünstigte wieder einlöst. Die von TOPS emittierten Wertmarken (e-CHF) können als Zahlungsmittel im stationären Handel, an Automaten, online und in Apps bei autorisierten Händlern oder Dienstleistungsanbietern, die dieses Zahlungsmittel akzeptieren (nachfolgend **Begünstigte**), eingesetzt werden. Nutzer können auch Zahlungen an andere Nutzer durchführen oder das e-Geld auf ein Schweizer Bankkonto zurückübertragen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:29 +msgid "Technical requirements" +msgstr "Technische Voraussetzungen" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:31 +msgid "In order to use the services offered, users must have a Taler wallet (an electronic wallet) as a Taler application on their smartphone or as an extension in a browser on the PC. Users are free to choose their Taler wallet application. Beneficiaries are also free to choose their Taler wallet application or Taler backend. Various solutions are provided by various providers. TOPS does not impose any restrictions and does not provide any guarantee for the chosen solution. The users are responsible for the security of their Taler wallets or Taler backends and the tokens or transaction data stored in them." +msgstr "Um die angebotenen Dienste wahrnehmen zu können, müssen Nutzer ein Taler-Wallet (elektronische Geldbörse) als Taler-App auf ihrem Smartphone oder als Erweiterung in einem Browser auf dem PC installieren. Die Nutzer sind frei in der Wahl ihrer Taler-Wallet-Anwendung. Begünstigte sind ebenfalls frei in der Wahl ihrer Taler-Wallet-Anwendung bzw. ihres Taler-Backends. Verschiedene Lösungen werden von diversen Anbietern bereitgestellt. TOPS macht hier keine Einschränkungen und übernimmt keine Gewährleistung für die gewählte Lösung. Die Nutzer sind eigenverantwortlich für die Sicherheit ihrer Taler-Wallets bzw. Taler-Backends und der darin gespeicherten Wertmarken bzw. Transaktionsdaten." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:38 +msgid "The Taler wallet is topped up by users through mechanisms foreseen for the purpose of withdrawals. In order to let the wallet withdraw the desired amount of money, users select from within the Taler wallet the payment service provider operated by TOPS and wire this amount of money to the bank account of the payment service provider. TOPS may introduce further withdrawal options or cease to offer existing mechanisms. Any transaction fees or other fees associated with wiring or with withdrawals shall be borne by the users. Users’ funds do not earn interest. Users acknowledge that their credit balance is not covered by customer deposit protection." +msgstr "Das Taler-Wallet wird von den Nutzern über die hierfür vorgesehenen Mechanismen aufgeladen. Zum Aufbuchen der gewünschten Geldmenge wählt man im Taler-Wallet den von TOPS betriebenen Zahlungsdienst, an den man diese Geldmenge vom Girokonto überweist und von dem schliesslich das Taler-Wallet die elektronischen Repräsentanten der Geldmenge abhebt. TOPS kann weitere Aufladeoptionen einführen oder auch bestehende Mechanismen nicht mehr anbieten. Allfällige mit der Aufladung verbundene Transaktionsgebühren oder sonstige Gebühren sind durch die Nutzer zu tragen. Das Guthaben der Nutzer wird nicht verzinst. Die Nutzer nehmen zur Kenntnis, dass das Guthaben nicht von der Einlagensicherung gedeckt ist." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:45 +msgid "To unload a Taler wallet, users must transfer their funds to a Swiss bank account. International payments are not permitted. With the Taler wallet installed in the smartphone or web browser, users can make payments (within applicable limits) to natural persons and legal entities that accept this payment method and have a Swiss bank account to receive the funds (e.g., stores, web shops, apps, and other beneficiaries). When users make payments, the corresponding amount of e-money is debited directly from the Taler wallet. At least the transaction amount must be available in the Taler wallet's balance. Users consent to all payments made with the Taler wallet from their digital end device, even if these payments were made without their agreement. Anyone who redeems a token in the Taler wallet has used its represented value of the credit for payment." +msgstr "Das Entladen des Taler-Wallet muss auf ein Schweizer Bankkonto erfolgen. Internationale Zahlungen sind nicht erlaubt. Die Nutzer können mit dem im Smartphone oder Webbrowser installierten Taler-Wallet innerhalb der geltenden Limiten bei natürlichen und juristischen Personen bezahlen, die diese Bezahloption akzeptieren und ein Schweizer Bankkonto zum Geldempfang führen (z.B. Ladengeschäfte, Webshops, Apps und sonstige Begünstigte). Bei einer Bezahlung wird der entsprechende Betrag direkt vom Taler-Wallet abgebucht. Es muss im Taler-Wallet mindestens der Transaktionsbetrag verfügbar sein. Die Nutzer anerkennen sämtliche getätigten Zahlungen, welche mit dem Taler-Wallet von ihrem digitalen Endgerät erfolgten, selbst wenn diese Zahlungen ohne ihre Zustimmung erfolgt sind. Wer ein Guthaben im Taler-Wallet einlöst, hat den Wert des Guthabens zur Zahlung verwendet." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:54 +msgid "The procedure for increasing and decreasing the credit balance in the Taler wallet can take several days, depending on the mechanism." +msgstr "Der Verarbeitungsprozess für das Erhöhen und Verringern des Guthabens im Taler-Wallet kann je nach Mechanismus mehrere Tage in Anspruch nehmen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:59 +msgid "Prices, fees and limits" +msgstr "Preise, Gebühren und Limiten" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:61 +msgid "TOPS may change the fees at any time. Fee changes only apply to tokens withdrawn after the change takes effect. Taler wallets compliant to the GNU Taler protocol will inform users about fee changes before they withdraw new tokens. Withdrawing tokens issued by TOPS after a fee change is considered the user’s consent to the updated conditions." +msgstr "TOPS kann die Gebühren jederzeit ändern. Änderungen haben nur Wirkung auf nach der Änderung bezogene Wertmarken. Mit dem GNU Taler-Protokoll konforme Taler-Wallets informieren Nutzer über Gebührenänderungen vor dem Bezug von neuen Wertmarken. Der Bezug von Wertmarken der TOPS nach Änderung der Gebühren gilt als Zustimmung zu den geänderten Bedingungen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:65 +msgid "There are limits of CHF 3,000 per month and CHF 15,000 per calendar year for withdrawing e-money from a bank account or receiving peer-to-peer payments between Taler wallets with a confirmed Swiss mobile number." +msgstr "Es bestehen Limiten von CHF 3.000 pro Monat und CHF 15.000 pro Kalenderjahr für das Abheben von e-Geld von einem Girokonto bzw. für den Empfang von Peer-to-Peer-Zahlungen zwischen Taler-Wallets mit bestätigter Schweizer Mobilfunknummer." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:70 +msgid "Legal and regulatory requirements" +msgstr "Allgemeine Mitwirkungspflichten" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:72 +msgid "In order to use the payment service, users and beneficiaries are obliged to support TOPS in fulfilling legal and regulatory requirements. TOPS complies with all applicable anti-money laundering (AML) and know-your-customer (KYC) regulations. TOPS will ensure that all personal data is processed in accordance with Swiss privacy laws, including the new Swiss Data Protection Act (nFADP) and the Ordinance on Data Protection (DPO). TOPS has the right and, where applicable, the legal obligation to exclude users and beneficiaries from using the payment service, if they refuse to provide the required information or provide false information." +msgstr "Zur Nutzung des Zahlungsdiensts sind Nutzer und Begünstigte verpflichtet, TOPS bei der Erfüllung regulatorischer und gesetzlicher Vorgaben zu unterstützen. TOPS hält sich an alle geltenden Gesetze zur Bekämpfung der Geldwäsche (AML) und zur Feststellung wirtschaftlich Berechtigter. TOPS stellt sicher, dass alle privaten Daten im Einklang mit den Schweizerischen Datenschutzbestimmungen, insbesondere dem Schweizer Datenschutzgesetz (DSG) und der Verordnung über den Datenschutz (DSV), behandelt werden. Insbesondere kann TOPS über die Identität von wirtschaftlich Berechtigten Auskunft verlangen. TOPS hat das Recht und ggf. die gesetzliche Pflicht, Nutzer und Begünstigte von der Nutzung des Zahlungsdiensts auszuschliessen, sollten diese die erforderlichen Auskünfte verweigern oder unwahre Angaben machen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:79 +msgid "In order to use the payment service, *beneficiaries* enter into a business relationship with TOPS and, where applicable, may be required to register with TOPS and provide the requested information for this purpose. Beneficiaries may be required to provide identity verification documents. They will be notified of any KYC information requests and will have 30 days to respond. TOPS reserves the right to request further information at any time to fulfill regulatory compliance." +msgstr "Zur Nutzung des Zahlungsdiensts gehen *Begünstigte* eine Geschäftsbeziehung mit TOPS ein und können ggf. verpflichtet sein, sich bei TOPS zu registrieren und die dabei verlangten Informationen zur Verfügung zu stellen. Die Begünstigten können aufgefordert werden, Dokumente zur ihrer Identitätsprüfung vorzulegen. Für KYC-Anfragen haben sie 30 Tage Zeit, auf diese zu antworten. TOPS behält sich vor, zur Erfüllung regulatorischer Vorgaben jederzeit weitere Informationen zu verlangen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:85 +msgid "No accounts are created for *users* at TOPS. However, the bank accounts of users who transfer CHF to TOPS in order to purchase tokens are recorded. To accept peer-to-peer payments, users must have a Swiss cell phone number to receive SMS for identification purposes." +msgstr "Es erfolgt keine Kontenanlage der *Nutzer* bei TOPS. Erfasst werden jedoch die IBAN-Konten von Nutzern, die CHF an TOPS überweisen, um Wertmarken zu kaufen. Die Nutzer brauchen zum Empfang von Peer-to-Peer-Zahlungen mindestens eine Schweizer Mobiltelefonnummer zum Empfang von SMS zur Identifizierung." +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:91 +msgid "Duty of care and other obligations of users" +msgstr "Sorgfaltspflichten und andere Pflichten der Nutzer" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:93 +msgid "1. Users must comply with the following duties of care when using the payment service:" +msgstr "1. Beim Umgang mit dem Zahlungsdienst sind insbesondere folgende Sorgfaltspflichten von Nutzern einzuhalten:" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:96 +msgid "The smartphone, PC, notebook, etc. must be protected against unauthorized use or manipulation (e.g. by means of a device lock or display lock)." +msgstr "Das Smartphone, PC, Notebook etc. ist vor unbefugter Benutzung oder Manipulation zu schützen (z.B. mittels Geräte- bzw. Displaysperre)." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:98 +msgid "In the event of damage, users must contribute to the best of their knowledge to help clarify the case and minimizing the damage. Criminal acts must be reported to the police." +msgstr "Im Schadenfall haben die Nutzer nach bestem Wissen zur Aufklärung des Falls und zur Schadensminderung beizutragen. Bei strafbaren Handlungen ist Anzeige bei der Polizei zu erstatten." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:100 +msgid "Before each payment is made, the details of the payee must be double-checked in order to prevent incorrect transactions." +msgstr "Vor jeder Ausführung einer Zahlung sind die Angaben zum Zahlungsempfänger zu überprüfen, um Fehltransaktionen zu verhindern." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:102 +msgid "Users are responsible for their use of the system and bear all consequences arising from such use." +msgstr "Die Nutzer sind für die Nutzung verantwortlich und tragen sämtliche Folgen, die sich aus der Verwendung ergeben." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:104 +msgid "In particular, any unauthorized use of the Taler wallet by a third party shall be attributed to the owner of the wallet." +msgstr "Insbesondere werden Handlungen, die eine Drittperson unberechtigt mit dem Taler-Wallet vornimmt, dem Eigentümer des Wallet zugerechnet." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:106 +msgid "2. Users must be aware of the need to **treat electronic money like cash** and to secure it in the same way, i.e. to create a backup of the wallet data. The users of the Taler app are therefore obliged to secure access to the digital end device and protect it from unauthorized access. They must save the wallet's data with a backup copy on another device. The wallet's export function helps to create and save a backup of the wallet data. A lost user device with a wallet on it without a backup on another device or data carrier means a total loss of the credit." +msgstr "2. Die Nutzer müssen sich darüber im klaren sein, **elektronisches Geld wie Bargeld zu behandeln** und ebenso zu sichern, d.h. ein Backup der Wallet-Daten anzulegen. Die Nutzer der Taler-App sind daher verpflichtet, den Zugang zum digitalen Endgerät zu sichern und vor unbefugtem Zugriff zu bewahren. Sie müssen die Wallet-Daten mit einer Sicherungskopie auf einem anderen Gerät speichern. Die Exportfunktion des Wallet hilft dabei, ein Backup der Wallet-Daten anzulegen und zu speichern. Ein verlorenes Nutzergerät mit einem Wallet darauf ohne Backup auf einem anderen Gerät oder Datenträger bedeutet einen Totalverlust des Guthabens." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:111 +msgid "3. It must be ensured that the end device with a Taler wallet installed on it connects to the payment service via the Internet **within one year** after the last transaction, otherwise the credit balance in the wallet may be lost. The credit balance is usually renewed one month before the end of the validity of the electronic cash, which is approximately one year after its withdrawal." +msgstr "3. Es ist dafür zu sorgen, dass sich das Endgerät mit einem darauf installierten Taler-Wallet **innerhalb eines Jahres** nach der letzten Transaktion **mit dem Zahlungsdienst über das Internet verbindet**, ansonsten kann das Guthaben im Wallet verloren werden. Ein Erneuern des Guthabens erfolgt regulär einen Monat vor dem Ende der Gültigkeit des elektronischen Bargelds, die zum Abhebezeitpunkt ca. ein Jahr beträgt." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:116 +msgid "4. Communication from TOPS to users is generally carried out via notifications in the GNU Taler protocol. Users are responsible for responding to such notifications. TOPS has the right not to execute transactions until the users provide legally required data." +msgstr "4. Die Kommunikation von TOPS zu Nutzern erfolgt grundsätzlich über Benachrichtigungen im Protokoll von GNU Taler. Die Nutzer sind dafür verantwortlich, auf entsprechende Benachrichtigungen zu reagieren. TOPS hat das Recht, Transaktionen solange nicht auszuführen, bis die Nutzer auf diesem Weg angeforderte rechtlich notwendige Daten bereitstellen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:122 +msgid "Liability" +msgstr "Haftung" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:124 +msgid "TOPS is not liable for any loss or damage incurred by users as a result of the use of GNU Taler, in particular not for loss or damage" +msgstr "TOPS haftet nicht für entstandene Verluste oder Schäden der Nutzer aufgrund der Verwendung von GNU Taler, insbesondere nicht für Verluste oder Schäden" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:127 +msgid "due to transmission errors, technical malfunctions or defects, failures and unauthorized access to or interference with the digital end device," +msgstr "aufgrund von Übermittlungsfehlern, technischen Störungen oder Defekten, Ausfällen und unberechtigten Zugriffen oder Eingriffen auf das digitale Endgerät," + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:129 +msgid "which are due in whole or in part to a breach by the user of these ToS or applicable laws," +msgstr "die ganz oder teilweise auf einen Verstoss der Nutzer gegen diese AGB oder anwendbare Gesetze zurückzuführen sind," + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:131 +msgid "due to a malfunction or error in the software or hardware used," +msgstr "aufgrund einer Störung oder eines Fehlers der Software oder der verwendeten Hardware," + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:133 +msgid "due to malfunctions, interruptions (including system maintenance work) or overloads of the relevant IT systems or networks," +msgstr "aufgrund von Störungen, Unterbrechungen (einschliesslich Systemwartungsarbeiten) oder Überlastungen der relevanten Informatiksysteme bzw. Netze," + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:135 +msgid "due to payments that are not processed or are delayed," +msgstr "aufgrund von Zahlungen, die nicht oder verzögert verarbeitet werden," + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:137 +msgid "due to acts or omissions of third parties (including auxiliary persons of TOPS)," +msgstr "die auf Handlungen oder Unterlassungen von Dritten (inkl. Hilfspersonen der TOPS) zurückzuführen sind," + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:139 +msgid "unless these losses or damages are attributable to gross negligence or willful misconduct on the part of TOPS. Liability caps are set at CHF 1,000 for certain loss events. Liability for consequential damages, loss of profit or loss of data is - to the extent permitted by law - excluded in any case." +msgstr "es sei denn, diese Verluste oder Schäden sind auf grobe Fahrlässigkeit oder vorsätzliches Verschulden von TOPS zurückzuführen. TOPS ersetzt Sach- und Vermögensschäden je Schadenereignis bis höchstens CHF 1.000. Die Haftung für Folgeschäden, entgangenen Gewinn oder Datenverluste ist - soweit gesetzlich zulässig - in jedem Fall ausgeschlossen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:145 +msgid "Use; misuse" +msgstr "Nutzung; Missbräuche" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:147 +msgid "Users shall indemnify TOPS for any damages or losses incurred by TOPS due to non-compliance with these ToS or legal requirements, due to incorrect or incomplete information provided by users or the incorrect execution of instructions." +msgstr "Nutzer halten TOPS schadlos für Schäden oder Verluste, die TOPS aufgrund der Nichteinhaltung dieser AGB oder gesetzlicher Vorgaben, aufgrund fehlerhafter oder unvollständiger Angaben der Nutzer oder der fehlerhaften Ausführung von Anweisungen entstehen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:151 +msgid "If the use deviates significantly from normal use or if there are signs of illegal or non-contractual behavior, TOPS may require users to act in accordance with the law and the contract, to suspend, restrict or discontinue the provision of services without prior notice and without compensation, terminate the business relationship without prior notice and without compensation and, if necessary, demand compensation for damages and indemnification from third-party claims. TOPS reserves the right to withhold payments to beneficiaries in the event of a breach of rules or abuse." +msgstr "Weicht die Nutzung erheblich vom üblichen Gebrauch ab oder bestehen Anzeichen eines rechts- oder vertragswidrigen Verhaltens, kann TOPS die Nutzer zur rechts- und vertragskonformen Nutzung anhalten, die Leistungserbringung ohne Vorankündigung entschädigungslos ändern, einschränken oder einstellen, die Geschäftsbeziehung fristlos und entschädigungslos auflösen und gegebenenfalls Schadenersatz sowie die Freistellung von Ansprüchen Dritter verlangen. TOPS behält sich vor, bei Verletzung von Regeln oder Missbrauch Zahlungen an Begünstigte zurückzuhalten." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:159 +msgid "Reservations regarding changes to these ToS" +msgstr "Vorbehalte zu Änderungen an diesen AGB" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:161 +msgid "TOPS may amend the ToS at any time. Amendments only have effect on tokens withdrawn after the change. Taler wallets compliant to the GNU Taler protocol inform users about changes before new tokens are withdrawn. The withdrawal of tokens issued by TOPS after the ToS have been amended shall be deemed to constitute acceptance of the amended conditions." +msgstr "TOPS kann die AGB jederzeit ändern. Änderungen haben nur Wirkung auf nach der Änderung bezogene Wertmarken. Mit dem GNU Taler-Protokoll konforme Taler-Wallets informieren Nutzer über Änderungen vor dem Bezug von neuen Wertmarken. Der Bezug von Wertmarken der TOPS nach Änderung der AGB gilt als Zustimmung zu den geänderten Bedingungen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:165 +msgid "Any legal provisions governing the operation and use of digital devices, payment services, the Internet and other infrastructure remain reserved and shall also apply to the TOPS services." +msgstr "Allfällige Gesetzesbestimmungen, die den Betrieb und die Nutzung von digitalen Endgeräten, Zahlungsdiensten, des Internets und sonstiger Infrastruktur regeln, bleiben vorbehalten und gelten ab ihrer Inkraftsetzung auch für die TOPS-Dienstleistungen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:168 +msgid "TOPS reserves the right to change, restrict, modify or completely discontinue its range of services at any time and without prior notice, in particular due to legal requirements, technical problems, prevention of misuse, by order of the authorities or for security reasons." +msgstr "TOPS behält sich vor, das Angebot von Dienstleistungen jederzeit und ohne vorherige Ankündigung zu ändern, zu beschränken oder vollständig einzustellen, insbesondere aufgrund rechtlicher Anforderungen, technischer Probleme, zur Verhinderung von Missbräuchen, auf behördliche Anordnung oder aus Sicherheitsgründen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:172 +msgid "TOPS may transfer the contractual relationship (including a credit balance) to another company at any time and without prior notification." +msgstr "TOPS kann die Vertragsbeziehungen (einschliesslich eines Guthabens) jederzeit und ohne vorherige Information auf eine andere Gesellschaft übertragen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:177 +msgid "Confidentiality and data protection" +msgstr "Geheimhaltung und Datenschutz" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:179 +msgid "Personal data is only collected, processed, stored or used by TOPS within the scope of legal obligations. When paying with e-money, no data on the identity of the user is recorded." +msgstr "Personenbezogene Daten werden von TOPS nur im Rahmen der Erfüllung gesetzlicher Verpflichtungen erhoben, verarbeitet, aufbewahrt oder weitergegeben. Beim Bezahlvorgang mit e-Geld werden keine Daten zur Identität der Nutzer erfasst." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:182 +msgid "TOPS provides users with technical support on request. In the provision of this support third parties may be involved. They will receive access to the personal data required for communication with users." +msgstr "TOPS stellt Nutzern auf Anfrage technischen Support zur Verfügung. An der Erbringung dieses Supports können Dritte beteiligt sein. Diese erhalten hierfür Zugriff auf notwendige personenbezogene Daten zur Kommunikation mit den Nutzern." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:185 +msgid "TOPS undertakes to comply with the provisions of Swiss law with regard to the personal data of users, in particular the Federal Act on Data Protection and the Ordinance on Data Protection." +msgstr "TOPS verpflichtet sich hinsichtlich der Beschaffung, Bearbeitung und Nutzung personenbezogener Daten von Nutzern die Bestimmungen der schweizerischen Datenschutzgesetzgebung, insbesondere des Bundesgesetzes über den Datenschutz und der Verordnung über den Datenschutz, einzuhalten." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:188 +msgid "All system data is primarily hosted in Switzerland." +msgstr "Alle Systemdaten werden primär in der Schweiz gehostet." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:190 +msgid "KYC processes may be controlled by service providers. These are also obliged to secure the data in accordance with Swiss law. The core system’s data is stored on encrypted hard disks with redundancy (including backups) and is accessible only to authorized personnel. Authorized personnel are subjected to security checks by TOPS. The entire design of the GNU Taler payment service has been strictly developed according to the principles of “Privacy-by-Design” and “Privacy-by-Default”." +msgstr "KYC-Prozesse werden ggf. durch Dienstleister gesteuert. Diese sind ebenfalls verpflichtet, die Daten nach Recht und Gesetz der Schweiz zu sichern. Die eigentlichen Daten des Kernsystems werden auf verschlüsselten Festplatten redundant (d.h. mit Backup) gespeichert und sind nur autorisiertem Personal zugänglich. Autorisiertes Personal wird von TOPS einer Sicherheitsprüfung unterzogen. Das gesamte Design des Zahlungsdiensts GNU Taler wurde strikt nach den Grundsätzen 'Privacy-by-Design' und 'Privacy-by-Default' umgesetzt." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:196 +msgid "Further information on data processing can be found in the privacy policy on the TOPS website (www.taler-ops.ch)." +msgstr "Weitere Informationen zu den Datenverarbeitungen finden sich in der Datenschutzerklärung auf der Webseite der TOPS (www.taler-ops.ch)." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:200 +msgid "Duration and termination" +msgstr "Dauer und Kündigung" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:202 +msgid "The business relationship between TOPS and beneficiaries (merchants, businesses, and other regular recipients of transfers from the payment service to the beneficiary IBAN accounts) is concluded for an indefinite period. TOPS may terminate the business relationship with the beneficiaries at any time - in particular in cases of abuse with immediate effect. Written notice of termination by TOPS shall be sent to one of the last addresses provided by the business partners (e.g. by e-mail or letter). If no transactions are made to the beneficiaries for more than 12 months, the business relationship shall be automatically deemed terminated." +msgstr "Die Geschäftsbeziehung zwischen TOPS und Begünstigten (Händler, Betriebe, Verkäufer und sonstige regelmässige Empfänger von Überweisungen des Zahlungsdiensts an die begünstigten IBAN-Konten) wird auf eine unbestimmte Dauer abgeschlossen. TOPS kann die Geschäftsbeziehung mit den Begünstigten jederzeit - insbesondere in Missbrauchsfällen mit sofortiger Wirkung - kündigen. Eine schriftliche Kündigung durch TOPS erfolgt an eine der zuletzt bekanntgegebenen Adressen der Geschäftspartner (z.B. per E-Mail oder Brief). Sollten für über 12 Monate keine Transaktionen an die Begünstigen erfolgen, gilt die Geschäftsbeziehung automatisch als beendet." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:211 +msgid "Users of Taler wallets can return the existing credit in these wallets to bank accounts in Switzerland at any time, thereby balancing the credit. If the TOPS payment service is discontinued, users will be notified through the GNU Taler protocol and prompted by their Taler wallets to balance any remaining credit. Users who fail to balance the credit within 3 months will lose their entitlement to the remaining amount, which will become the property of TOPS." +msgstr "Die Nutzer von Taler-Wallets können das Guthaben in diesen jederzeit an Bankkonten in der Schweiz zurücküberweisen lassen und so das Guthaben saldieren. Bei einer Betriebsaufgabe des Zahlungsdiensts der TOPS werden die Nutzer über die bevorstehende Einstellung des Zahlungsdiensts durch das Taler-Protokoll informiert und von den Taler-Wallets aufgefordert, das bestehende Guthaben zu saldieren. Nutzer, die diese Saldierung unterlassen, verlieren nach 3 Monaten den Anspruch auf das danach noch bestehende Guthaben, welches in das Eigentum der TOPS übergeht." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:220 +msgid "Applicable law and place of jurisdiction" +msgstr "Anwendbares Recht und Gerichtsstand" + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:222 +msgid "To the extent permitted by law, all legal relationships between TOPS and users shall be governed exclusively by substantive Swiss law, excluding conflict of laws and international treaties." +msgstr "Soweit gesetzlich zulässig unterstehen alle Rechtsbeziehungen zwischen TOPS und Nutzern ausschliesslich dem materiellen schweizerischen Recht, unter Ausschluss von Kollisionsrecht und unter Ausschluss von Staatsverträgen." + +#: ../../../../../../tmp/taler-terms-HcTwZN/exchange-tos-tops-v0.rst:225 +msgid "Subject to any mandatory statutory provisions to the contrary, Biel is the exclusive place of jurisdiction and the place of performance. For users and beneficiaries domiciled outside Switzerland, Biel/Bienne is also the place of debt collection." +msgstr "Unter dem Vorbehalt von entgegenstehenden zwingenden gesetzlichen Bestimmungen ist Biel ausschliesslicher Gerichtsstand und Erfüllungsort. Für Nutzer und Begünstigte mit einem Wohnsitz ausserhalb der Schweiz ist Biel sodann auch Betreibungsort." diff --git a/contrib/locale/de/LC_MESSAGES/exchange-tos-v0.po b/contrib/locale/de/LC_MESSAGES/exchange-tos-v0.po deleted file mode 100644 index 1b0d296cf..000000000 --- a/contrib/locale/de/LC_MESSAGES/exchange-tos-v0.po +++ /dev/null @@ -1,403 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2014-2023 Taler Systems SA (GPLv3+ or GFDL 1.3+) -# This file is distributed under the same license as the tos-v0 package. -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: tos-v0 tos-v0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-20 15:38+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -"Language-Team: LANGUAGE <LL@li.org>\n" -"Language: de\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -msgid "Terms of Service" -msgstr "Allgemeine Geschäftsbedingungen" - -msgid "Last Updated: 27.11.2023" -msgstr "" - -msgid "" -"Welcome! Taler Systems SA (“we,” “our,” or “us”) provides a payment service " -"through our Internet presence (collectively the “Services”). Before using " -"our Services, please read the Terms of Service (the “Terms” or the " -"“Agreement”) carefully." -msgstr "" - -msgid "Overview" -msgstr "" - -msgid "" -"This section provides a brief summary of the highlights of this Agreement. " -"Please note that when you accept this Agreement, you are accepting all of " -"the terms and conditions and not just this section. We and possibly other " -"third parties provide Internet services which interact with the Taler " -"Wallet’s self-hosted personal payment application. When using the Taler " -"Wallet to interact with our Services, you are agreeing to our Terms, so " -"please read carefully." -msgstr "" - -msgid "Highlights:" -msgstr "" - -msgid "" -"You are responsible for keeping the data in your Taler Wallet at all times " -"under your control. Any losses arising from you not being in control of your " -"private information are your problem." -msgstr "" - -msgid "" -"We will try to transfer funds we hold in escrow for our users to any legal " -"recipient to the best of our ability within the limitations of the law and " -"our implementation. However, the Services offered today are highly " -"experimental and the set of recipients of funds is severely restricted." -msgstr "" - -msgid "" -"For our Services, we may charge transaction fees. The specific fee structure " -"is provided based on the Taler protocol and should be shown to you when you " -"withdraw electronic coins using a Taler Wallet. You agree and understand " -"that the Taler protocol allows for the fee structure to change." -msgstr "" - -msgid "" -"You agree to not intentionally overwhelm our systems with requests and " -"follow responsible disclosure if you find security issues in our services." -msgstr "" - -msgid "" -"We cannot be held accountable for our Services not being available due to " -"circumstances beyond our control. If we modify or terminate our services, we " -"will try to give you the opportunity to recover your funds. However, given " -"the experimental state of the Services today, this may not be possible. You " -"are strongly advised to limit your use of the Service to small-scale " -"experiments expecting total loss of all funds." -msgstr "" - -msgid "" -"These terms outline approved uses of our Services. The Services and these " -"Terms are still at an experimental stage. If you have any questions or " -"comments related to this Agreement, please send us a message to legal@taler-" -"systems.com. If you do not agree to this Agreement, you must not use our " -"Services." -msgstr "" - -msgid "How you accept this policy" -msgstr "" - -msgid "" -"By sending funds to us (to top-up your Taler Wallet), you acknowledge that " -"you have read, understood, and agreed to these Terms. We reserve the right " -"to change these Terms at any time. If you disagree with the change, we may " -"in the future offer you with an easy option to recover your unspent funds. " -"However, in the current experimental period you acknowledge that this " -"feature is not yet available, resulting in your funds being lost unless you " -"accept the new Terms. If you continue to use our Services other than to " -"recover your unspent funds, your continued use of our Services following any " -"such change will signify your acceptance to be bound by the then current " -"Terms. Please check the effective date above to determine if there have been " -"any changes since you have last reviewed these Terms." -msgstr "" - -msgid "Services" -msgstr "" - -msgid "" -"We will try to transfer funds that we hold in escrow for our users to any " -"legal recipient to the best of our ability and within the limitations of the " -"law and our implementation. However, the Services offered today are highly " -"experimental and the set of recipients of funds is severely restricted. The " -"Taler Wallet can be loaded by exchanging fiat currencies against electronic " -"coins. We are providing this exchange service. Once your Taler Wallet is " -"loaded with electronic coins they can be spent for purchases if the seller " -"is accepting Taler as a means of payment. We are not guaranteeing that any " -"seller is accepting Taler at all or a particular seller. The seller or " -"recipient of deposits of electronic coins must specify the target account, " -"as per the design of the Taler protocol. They are responsible for following " -"the protocol and specifying the correct bank account, and are solely liable " -"for any losses that may arise from specifying the wrong account. We will " -"allow the government to link wire transfers to the underlying contract hash. " -"It is the responsibility of recipients to preserve the full contracts and to " -"pay whatever taxes and charges may be applicable. Technical issues may lead " -"to situations where we are unable to make transfers at all or lead to " -"incorrect transfers that cannot be reversed. We will only refuse to execute " -"transfers if the transfers are prohibited by a competent legal authority and " -"we are ordered to do so." -msgstr "" - -msgid "" -"When using our Services, you agree to not take any action that intentionally " -"imposes an unreasonable load on our infrastructure. If you find security " -"problems in our Services, you agree to first report them to security@taler-" -"systems.com and grant us the right to publish your report. We warrant that " -"we will ourselves publicly disclose any issues reported within 3 months, and " -"that we will not prosecute anyone reporting security issues if they did not " -"exploit the issue beyond a proof-of-concept, and followed the above " -"responsible disclosure practice." -msgstr "" - -msgid "Fees" -msgstr "" - -msgid "" -"You agree to pay the fees for exchanges and withdrawals completed via the " -"Taler Wallet (\"Fees\") as defined by us, which we may change from time to " -"time. With the exception of wire transfer fees, Taler transaction fees are " -"set for any electronic coin at the time of withdrawal and fixed throughout " -"the validity period of the respective electronic coin. Your wallet should " -"obtain and display applicable fees when withdrawing funds. Fees for coins " -"obtained as change may differ from the fees applicable to the original coin. " -"Wire transfer fees that are independent from electronic coins may change " -"annually. You authorize us to charge or deduct applicable fees owed in " -"connection with deposits, exchanges and withdrawals following the rules of " -"the Taler protocol. We reserve the right to provide different types of " -"rewards to users either in the form of discount for our Services or in any " -"other form at our discretion and without prior notice to you." -msgstr "" - -msgid "Eligibility and Financial self-responsibility" -msgstr "" - -msgid "" -"To be eligible to use our Services, you must be able to form legally binding " -"contracts or have the permission of your legal guardian. By using our " -"Services, you represent and warrant that you meet all eligibility " -"requirements that we outline in these Terms." -msgstr "" - -msgid "" -"You will be responsible for maintaining the availability, integrity and " -"confidentiality of the data stored in your wallet. When you setup a Taler " -"Wallet, you are strongly advised to follow the precautionary measures " -"offered by the software to minimize the chances to losse access to or " -"control over your Wallet data. We will not be liable for any loss or damage " -"arising from your failure to comply with this paragraph." -msgstr "" - -msgid "Copyrights and trademarks" -msgstr "" - -msgid "" -"The Taler Wallet is released under the terms of the GNU General Public " -"License (GNU GPL). You have the right to access, use, and share the Taler " -"Wallet, in modified or unmodified form. However, the GPL is a strong " -"copyleft license, which means that any derivative works must be distributed " -"under the same license terms as the original software. If you have any " -"questions, you should review the GNU GPL’s full terms and conditions at " -"https://www.gnu.org/licenses/. “Taler” itself is a trademark " -"of Taler Systems SA. You are welcome to use the name in relation to " -"processing payments using the Taler protocol, assuming your use is " -"compatible with an official release from the GNU Project that is not older " -"than two years." -msgstr "" - -msgid "Limitation of liability & disclaimer of warranties" -msgstr "" - -msgid "" -"You understand and agree that we have no control over, and no duty to take " -"any action regarding: Failures, disruptions, errors, or delays in processing " -"that you may experience while using our Services; The risk of failure of " -"hardware, software, and Internet connections; The risk of malicious software " -"being introduced or found in the software underlying the Taler Wallet; The " -"risk that third parties may obtain unauthorized access to information stored " -"within your Taler Wallet, including, but not limited to your Taler Wallet " -"coins or backup encryption keys. You release us from all liability related " -"to any losses, damages, or claims arising from:" -msgstr "" - -msgid "" -"user error such as forgotten passwords, incorrectly constructed transactions;" -msgstr "" - -msgid "server failure or data loss;" -msgstr "" - -msgid "unauthorized access to the Taler Wallet application;" -msgstr "" - -msgid "bugs or other errors in the Taler Wallet software; and" -msgstr "" - -msgid "" -"any unauthorized third party activities, including, but not limited to, the " -"use of viruses, phishing, brute forcing, or other means of attack against " -"the Taler Wallet. We make no representations concerning any Third Party " -"Content contained in or accessed through our Services." -msgstr "" - -msgid "" -"Any other terms, conditions, warranties, or representations associated with " -"such content, are solely between you and such organizations and/or " -"individuals." -msgstr "" - -msgid "" -"To the fullest extent permitted by applicable law, in no event will we or " -"any of our officers, directors, representatives, agents, servants, counsel, " -"employees, consultants, lawyers, and other personnel authorized to act, " -"acting, or purporting to act on our behalf (collectively the “Taler " -"Parties”) be liable to you under contract, tort, strict liability, " -"negligence, or any other legal or equitable theory, for:" -msgstr "" - -msgid "" -"any lost profits, data loss, cost of procurement of substitute goods or " -"services, or direct, indirect, incidental, special, punitive, compensatory, " -"or consequential damages of any kind whatsoever resulting from:" -msgstr "" - -msgid "your use of, or conduct in connection with, our services;" -msgstr "" - -msgid "" -"any unauthorized use of your wallet and/or private key due to your failure " -"to maintain the confidentiality of your wallet;" -msgstr "" - -msgid "" -"any interruption or cessation of transmission to or from the services; or" -msgstr "" - -msgid "" -"any bugs, viruses, trojan horses, or the like that are found in the Taler " -"Wallet software or that may be transmitted to or through our services by any " -"third party (regardless of the source of origination), or" -msgstr "" - -msgid "any direct damages." -msgstr "" - -msgid "" -"These limitations apply regardless of legal theory, whether based on tort, " -"strict liability, breach of contract, breach of warranty, or any other legal " -"theory, and whether or not we were advised of the possibility of such " -"damages. Some jurisdictions do not allow the exclusion or limitation of " -"liability for consequential or incidental damages, so the above limitation " -"may not apply to you." -msgstr "" - -msgid "" -"Our services are provided \"as is\" and without warranty of any kind. To the " -"maximum extent permitted by law, we disclaim all representations and " -"warranties, express or implied, relating to the services and underlying " -"software or any content on the services, whether provided or owned by us or " -"by any third party, including without limitation, warranties of " -"merchantability, fitness for a particular purpose, title, non-infringement, " -"freedom from computer virus, and any implied warranties arising from course " -"of dealing, course of performance, or usage in trade, all of which are " -"expressly disclaimed. In addition, we do not represent or warrant that the " -"content accessible via the services is accurate, complete, available, " -"current, free of viruses or other harmful components, or that the results of " -"using the services will meet your requirements. Some states do not allow the " -"disclaimer of implied warranties, so the foregoing disclaimers may not apply " -"to you. This paragraph gives you specific legal rights and you may also have " -"other legal rights that vary from state to state." -msgstr "" - -msgid "Indemnity and Time limitation on claims and Termination" -msgstr "" - -msgid "" -"To the extent permitted by applicable law, you agree to defend, indemnify, " -"and hold harmless the Taler Parties from and against any and all claims, " -"damages, obligations, losses, liabilities, costs or debt, and expenses " -"(including, but not limited to, attorney’s fees) arising from: (a) your use " -"of and access to the Services; (b) any feedback or submissions you provide " -"to us concerning the Taler Wallet; (c) your violation of any term of this " -"Agreement; or (d) your violation of any law, rule, or regulation, or the " -"rights of any third party." -msgstr "" - -msgid "" -"You agree that any claim you may have arising out of or related to your " -"relationship with us must be filed within one year after such claim arises, " -"otherwise, your claim in permanently barred." -msgstr "" - -msgid "" -"In the event of termination concerning your use of our Services, your " -"obligations under this Agreement will still continue." -msgstr "" - -msgid "Discontinuance of services and Force majeure" -msgstr "" - -msgid "" -"We may, in our sole discretion and without cost to you, with or without " -"prior notice, and at any time, modify or discontinue, temporarily or " -"permanently, any portion of our Services. We will use the Taler protocol’s " -"provisions to notify Wallets if our Services are to be discontinued. It is " -"your responsibility to ensure that the Taler Wallet is online at least once " -"every three months to observe these notifications. We shall not be held " -"responsible or liable for any loss of funds in the event that we discontinue " -"or depreciate the Services and your Taler Wallet fails to transfer out the " -"coins within a three months notification period." -msgstr "" - -msgid "" -"We shall not be held liable for any delays, failure in performance, or " -"interruptions of service which result directly or indirectly from any cause " -"or condition beyond our reasonable control, including but not limited to: " -"any delay or failure due to any act of God, act of civil or military " -"authorities, act of terrorism, civil disturbance, war, strike or other labor " -"dispute, fire, interruption in telecommunications or Internet services or " -"network provider services, failure of equipment and/or software, other " -"catastrophe, or any other occurrence which is beyond our reasonable control " -"and shall not affect the validity and enforceability of any remaining " -"provisions." -msgstr "" - -msgid "Governing law, Waivers, Severability and Assignment" -msgstr "" - -msgid "" -"No matter where you’re located, the laws of Switzerland will govern these " -"Terms. If any provisions of these Terms are inconsistent with any applicable " -"law, those provisions will be superseded or modified only to the extent such " -"provisions are inconsistent. The parties agree to submit to the ordinary " -"courts in Zurich, Switzerland for exclusive jurisdiction of any dispute " -"arising out of or related to your use of the Services or your breach of " -"these Terms." -msgstr "" - -msgid "" -"Our failure to exercise or delay in exercising any right, power, or " -"privilege under this Agreement shall not operate as a waiver; nor shall any " -"single or partial exercise of any right, power, or privilege preclude any " -"other or further exercise thereof." -msgstr "" - -msgid "" -"You agree that we may assign any of our rights and/or transfer, sub-" -"contract, or delegate any of our obligations under these Terms." -msgstr "" - -msgid "" -"If it turns out that any part of this Agreement is invalid, void, or for any " -"reason unenforceable, that term will be deemed severable and limited or " -"eliminated to the minimum extent necessary." -msgstr "" - -msgid "" -"This Agreement sets forth the entire understanding and agreement as to the " -"subject matter hereof and supersedes any and all prior discussions, " -"agreements, and understandings of any kind (including, without limitation, " -"any prior versions of this Agreement) and every nature between us. Except as " -"provided for above, any modification to this Agreement must be in writing " -"and must be signed by both parties." -msgstr "" - -msgid "Questions or comments" -msgstr "" - -msgid "" -"We welcome comments, questions, concerns, or suggestions. Please send us a " -"message on our contact page at legal@taler-systems.com." -msgstr "" diff --git a/contrib/locale/fr/LC_MESSAGES/exchange-tos-tops-v0.po b/contrib/locale/fr/LC_MESSAGES/exchange-tos-tops-v0.po new file mode 100644 index 000000000..cfe675b16 --- /dev/null +++ b/contrib/locale/fr/LC_MESSAGES/exchange-tos-tops-v0.po @@ -0,0 +1,249 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2014-2024 Taler Systems SA (GPLv3+ or GFDL 1.3+) +# This file is distributed under the same license as the exchange-tos-tops-v0 package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: exchange-tos-tops-v0 exchange-tos-tops-v0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-09 15:17+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <languages@taler.net>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:2 +msgid "Terms of Service of Taler Operations AG" +msgstr "Conditions générales d'utilisation de Taler Operations AG" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:4 +msgid "These Terms of Service (hereinafter **ToS**) of Taler Operations AG regulate the rights and obligations of users and recipients (beneficiaries) of the payment service offered. By using the payment service, users automatically accept these ToS." +msgstr "Les présentes conditions générales d'utilisation (ci-après **CGU**) de l'entreprise Taler Operations AG régissent les droits et obligations des utilisateurs et des bénéficiaires du service de paiement proposé. En utilisant le service de paiement, les utilisateurs acceptent automatiquement les présentes CGU." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:9 +msgid "Service; scope of application" +msgstr "Prestation de services ; champ d'application" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:11 +msgid "GNU Taler is a technical system that enables cashless payments. Taler Operations AG (hereinafter **TOPS**), headquartered in Biel/Bienne, Switzerland, provides a **payment system** based on GNU Taler for users in Switzerland. TOPS is a member of VQF, a FINMA-accredited self-regulating organisation. Consequently, TOPS will therefore not be directly supervised by the Swiss financial services regulation authority FINMA, but operates a financial service in accordance with Art. 6 para. 2 Banking Ordinance without commercial banking status (non-bank) and therefore without customer deposit protection." +msgstr "GNU Taler est un système technique qui permet d'effectuer des paiements sans argent liquide. Taler Operations AG (ci-après **TOPS**), dont le siège est à Biel/Bienne, Suisse, propose un **service de paiement** basé sur GNU Taler pour les utilisateurs en Suisse. TOPS est membre du VQF, un organisme d'autorégulation accrédité par la FINMA. TOPS n'est donc pas directement surveillée par la FINMA, mais exploite un service financier selon l'art. 6 al. 2 OB sans être une banque à titre professionnel (non-banque) et donc sans garantie des dépôts des clients." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:18 +msgid "**Users** are the owners of tokens signed by TOPS, denominated in CHF (e-money), which they store in their Taler wallets under their own responsibility. These tokens can be used by the users to make payments." +msgstr "**Les utilisateurs** sont propriétaires de jetons (monnaie électronique) signés par TOPS et libellés en CHF, qui sont stockés dans des portefeuilles Taler sous la responsabilité des utilisateurs et avec lesquels les utilisateurs peuvent payer." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:21 +msgid "**Taler-Wallets** are products that, in accordance with the GNU Taler protocol, manage digital cash (e-money) , which a payment service issues and redeems for payments to beneficiaries. The tokens issued by TOPS (e-CHF) can be used as a means of payment in bricks-and-mortar shops, at vending machines, in online shops, and in apps at authorized merchants or service providers that accept this means of payment (hereinafter **beneficiaries**). Users can also make payments to other users or transfer the e-money back to a Swiss bank account." +msgstr "Les **portefeuilles Taler** sont des produits qui gèrent des jetons (espèces numériques), monnaie électronique selon le protocole GNU Taler, qu'un service de paiement émet et rachète pour payer des bénéficiaires. Les jetons émis par TOPS (e-CHF) peuvent être utilisés comme moyen de paiement dans les commerces fixes, dans les distributeurs automatiques, dans les boutiques en ligne et dans les applications auprès de commerçants ou de prestataires de services autorisés qui acceptent ce moyen de paiement (ci-après **bénéficiaires**). Les utilisateurs peuvent également effectuer des paiements à d'autres utilisateurs ou retransférer la monnaie électronique sur un compte bancaire suisse." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:29 +msgid "Technical requirements" +msgstr "Exigences techniques" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:31 +msgid "In order to use the services offered, users must have a Taler wallet (an electronic wallet) as a Taler application on their smartphone or as an extension in a browser on the PC. Users are free to choose their Taler wallet application. Beneficiaries are also free to choose their Taler wallet application or Taler backend. Various solutions are provided by various providers. TOPS does not impose any restrictions and does not provide any guarantee for the chosen solution. The users are responsible for the security of their Taler wallets or Taler backends and the tokens or transaction data stored in them." +msgstr "Pour pouvoir bénéficier des services proposés, les utilisateurs doivent installer un portefeuille Taler (porte-monnaie électronique) soit sous la forme de l'application Taler sur leur smartphone soit sous la forme d'une extension dans un navigateur sur leur PC. Les utilisateurs sont libres de choisir leur application de portefeuille Taler. Les bénéficiaires sont également libres de choisir leur application de portefeuille Taler ou leur backend Taler. Différentes solutions sont proposées par divers fournisseurs. TOPS n'impose aucune restriction à cet égard et ne donne aucune garantie quant à la solution choisie. Les utilisateurs sont responsables de la sécurité de leurs portefeuilles Taler ou backends Taler et des jetons ou données de transaction qui y sont enregistrés." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:38 +msgid "The Taler wallet is topped up by users through mechanisms foreseen for the purpose of withdrawals. In order to let the wallet withdraw the desired amount of money, users select from within the Taler wallet the payment service provider operated by TOPS and wire this amount of money to the bank account of the payment service provider. TOPS may introduce further withdrawal options or cease to offer existing mechanisms. Any transaction fees or other fees associated with wiring or with withdrawals shall be borne by the users. Users’ funds do not earn interest. Users acknowledge that their credit balance is not covered by customer deposit protection." +msgstr "Le portefeuille Taler est chargé par les utilisateurs via les mécanismes prévus à cet effet. Pour créditer la quantité d'argent souhaitée, on choisit dans le portefeuille Taler le service de paiement exploité par TOPS, auquel on transfère cette quantité d'argent sur le compte courant du service de paiement et duquel le portefeuille Taler retire finalement les jetons électroniques correspondant à la quantité d'argent envoyée. TOPS peut introduire d'autres options de rechargement ou ne plus proposer les mécanismes existants. Les éventuels frais de transaction ou autres frais liés à la recharge sont à la charge des utilisateurs. L'avoir des utilisateurs ne porte pas d'intérêts. Les utilisateurs prennent connaissance du fait que l'avoir n'est pas couvert par la garantie des dépôts des clients." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:45 +msgid "To unload a Taler wallet, users must transfer their funds to a Swiss bank account. International payments are not permitted. With the Taler wallet installed in the smartphone or web browser, users can make payments (within applicable limits) to natural persons and legal entities that accept this payment method and have a Swiss bank account to receive the funds (e.g., stores, web shops, apps, and other beneficiaries). When users make payments, the corresponding amount of e-money is debited directly from the Taler wallet. At least the transaction amount must be available in the Taler wallet's balance. Users consent to all payments made with the Taler wallet from their digital end device, even if these payments were made without their agreement. Anyone who redeems a token in the Taler wallet has used its represented value of the credit for payment." +msgstr "Le débit du portefeuille Taler doit être effectué sur un compte bancaire suisse. Les paiements internationaux ne sont pas autorisés. Les utilisateurs peuvent payer avec le portefeuille Taler installé dans leur smartphone ou leur navigateur web, dans les limites en vigueur, auprès de personnes physiques et morales qui acceptent cette option de paiement et qui ont un compte bancaire suisse pour recevoir de l'argent (p. ex. magasins, boutiques en ligne, apps et autres bénéficiaires). Lors d'un paiement, le montant correspondant est directement débité du portefeuille Taler. Il faut qu'au moins le montant de la transaction soit disponible dans le portefeuille Taler. Les utilisateurs sont tenus responsables de tous les paiements effectués avec le portefeuille Taler depuis leur terminal numérique, même si ces paiements ont été effectués sans leur consentement. La personne qui a dépensé un jeton dans le portefeuille Taler a utilisé le valeur d'argent correspondant pour effectuer un paiement." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:54 +msgid "The procedure for increasing and decreasing the credit balance in the Taler wallet can take several days, depending on the mechanism." +msgstr "Le processus de traitement pour augmenter ou diminuer l'avoir stocké dans le portefeuille Taler peut prendre jusqu'à plusieurs jours, selon le mécanisme utilisé." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:59 +msgid "Prices, fees and limits" +msgstr "Tarifs, frais, commissions et limites" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:61 +msgid "TOPS may change the fees at any time. Fee changes only apply to tokens withdrawn after the change takes effect. Taler wallets compliant to the GNU Taler protocol will inform users about fee changes before they withdraw new tokens. Withdrawing tokens issued by TOPS after a fee change is considered the user’s consent to the updated conditions." +msgstr "TOPS peut modifier les frais à tout moment. Les modifications n'ont d'effet que sur les jetons achetés après la modification. Les portefeuilles Taler conformes au protocole GNU Taler informent les utilisateurs des changements de frais avant que de nouveaux jetons ne soient retirés. Le retrait de jetons de TOPS après une modification des frais vaut acceptation par l'utilisateur des conditions modifiées." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:65 +msgid "There are limits of CHF 3,000 per month and CHF 15,000 per calendar year for withdrawing e-money from a bank account or receiving peer-to-peer payments between Taler wallets with a confirmed Swiss mobile number." +msgstr "Des limites de 3 000 CHF par mois et de 15 000 CHF par année civile sont définies pour le retrait de la monnaie électronique d'un compte courant ou pour la réception de paiements peer-to-peer (d'égal à égal) entre les portefeuilles Taler ayant un numéro de portable suisse confirmé." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:70 +msgid "Legal and regulatory requirements" +msgstr "Obligations générales de coopération" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:72 +msgid "In order to use the payment service, users and beneficiaries are obliged to support TOPS in fulfilling legal and regulatory requirements. TOPS complies with all applicable anti-money laundering (AML) and know-your-customer (KYC) regulations. TOPS will ensure that all personal data is processed in accordance with Swiss privacy laws, including the new Swiss Data Protection Act (nFADP) and the Ordinance on Data Protection (DPO). TOPS has the right and, where applicable, the legal obligation to exclude users and beneficiaries from using the payment service, if they refuse to provide the required information or provide false information." +msgstr "Pour utiliser le service de paiement, l'utilisateur et le bénéficiaire sont tenus d'aider TOPS à satisfaire aux exigences réglementaires et légales. TOPS se conforme à toutes les réglementations applicables en matière de lutte contre le blanchiment d'argent (AML) et de connaissance des bénéficiaires effectifs. TOPS veillera à ce que toutes les données personnelles soient traitées conformément aux lois suisses sur la protection des données, y compris la nouvelle loi suisse sur la protection des données (nLPD) et l'ordonnance sur la protection des données (OPDo). En particulier, TOPS peut demander des informations sur l'identité des bénéficiaires effectifs. TOPS a le droit et, le cas échéant, l'obligation légale d'exclure les utilisateurs et les bénéficiaires de l'utilisation du service de paiement s'ils refusent de fournir les informations requises ou s'ils fournissent des informations fausses." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:79 +msgid "In order to use the payment service, *beneficiaries* enter into a business relationship with TOPS and, where applicable, may be required to register with TOPS and provide the requested information for this purpose. Beneficiaries may be required to provide identity verification documents. They will be notified of any KYC information requests and will have 30 days to respond. TOPS reserves the right to request further information at any time to fulfill regulatory compliance." +msgstr "Pour utiliser le service de paiement, les *bénéficiaires* établissent une relation commerciale avec TOPS et peuvent être tenus, le cas échéant, de s'enregistrer auprès de TOPS et de fournir les informations demandées à cette occasion. Les bénéficiaires peuvent être amenés à fournir des documents de vérification d'identité. Ils seront informés de toute demande d'informations KYC et disposeront de 30 jours pour y répondre. TOPS se réserve le droit de demander à tout moment des informations supplémentaires pour satisfaire aux exigences réglementaires." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:85 +msgid "No accounts are created for *users* at TOPS. However, the bank accounts of users who transfer CHF to TOPS in order to purchase tokens are recorded. To accept peer-to-peer payments, users must have a Swiss cell phone number to receive SMS for identification purposes." +msgstr "Il n'y a pas de création de compte des *utilisateurs* chez TOPS. TOPS enregistre cependant les comptes IBAN des utilisateurs qui transfèrent des CHF à TOPS pour acheter des jetons. Pour recevoir des paiements d'égal à égal (peer-to-peer), les utilisateurs ont besoin d'au moins un numéro de téléphone portable suisse pouvant recevoir des SMS qui serviront à leur identification." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:91 +msgid "Duty of care and other obligations of users" +msgstr "Devoir de diligence et autres obligations des utilisateurs" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:93 +msgid "1. Users must comply with the following duties of care when using the payment service:" +msgstr "1. Lors de l'utilisation du service de paiement, les utilisateurs doivent notamment respecter les obligations de diligence suivantes :" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:96 +msgid "The smartphone, PC, notebook, etc. must be protected against unauthorized use or manipulation (e.g. by means of a device lock or display lock)." +msgstr "Le smartphone, le PC, l'ordinateur portable, etc. doivent être protégés contre toute utilisation ou manipulation non autorisée (p. ex. au moyen d'un verrouillage de l'appareil ou de l'écran)." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:98 +msgid "In the event of damage, users must contribute to the best of their knowledge to help clarify the case and minimizing the damage. Criminal acts must be reported to the police." +msgstr "En cas de dommage, les utilisateurs doivent contribuer de leur mieux à l'élucidation du cas et à la réduction du dommage. En cas d'actes délictueux, ils doivent porter plainte auprès de la police." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:100 +msgid "Before each payment is made, the details of the payee must be double-checked in order to prevent incorrect transactions." +msgstr "Avant chaque exécution d'un paiement, les données relatives au bénéficiaire doivent être vérifiées afin d'éviter les transactions erronées." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:102 +msgid "Users are responsible for their use of the system and bear all consequences arising from such use." +msgstr "Les utilisateurs sont responsables de leur utilisation du système et assument toutes les conséquences qui en découlent." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:104 +msgid "In particular, any unauthorized use of the Taler wallet by a third party shall be attributed to the owner of the wallet." +msgstr "En particulier, les actions qu'une tierce personne effectue sans autorisation avec un portefeuille Taler sont imputées au propriétaire du portefeuille." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:106 +msgid "2. Users must be aware of the need to **treat electronic money like cash** and to secure it in the same way, i.e. to create a backup of the wallet data. The users of the Taler app are therefore obliged to secure access to the digital end device and protect it from unauthorized access. They must save the wallet's data with a backup copy on another device. The wallet's export function helps to create and save a backup of the wallet data. A lost user device with a wallet on it without a backup on another device or data carrier means a total loss of the credit." +msgstr "2. Les utilisateurs doivent être conscients de la nécessité de **traiter la monnaie électronique comme des espèces** et de la sécuriser comme celle-ci, c'est-à-dire faire une sauvegarde des données du portefeuille. Les utilisateurs du portefeuille Taler sont donc tenus de sécuriser l'accès au terminal numérique et de le protéger contre tout accès non autorisé. Ils doivent enregistrer les données du portefeuille avec une copie de sauvegarde sur un autre appareil. La fonction d'exportation du portefeuille aide à créer et à enregistrer une sauvegarde des données du portefeuille. Un terminal numérique perdu avec un portefeuille dessus sans sauvegarde sur un autre appareil ou un autre support de données signifie une perte totale de l'avoir." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:111 +msgid "3. It must be ensured that the end device with a Taler wallet installed on it connects to the payment service via the Internet **within one year** after the last transaction, otherwise the credit balance in the wallet may be lost. The credit balance is usually renewed one month before the end of the validity of the electronic cash, which is approximately one year after its withdrawal." +msgstr "3. Il faut veiller à ce que le terminal numérique sur lequel est installé un portefeuille Taler se connecte **dans un délai d'un an** après la dernière transaction **au service de paiement par Internet**, faute de quoi l'avoir du portefeuille peut être perdu. Le renouvellement de l'avoir a lieu normalement un mois avant la fin de leur validité, qui est d'environ un an après leur retrait." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:116 +msgid "4. Communication from TOPS to users is generally carried out via notifications in the GNU Taler protocol. Users are responsible for responding to such notifications. TOPS has the right not to execute transactions until the users provide legally required data." +msgstr "4. La communication de TOPS avec les utilisateurs se fait en principe par le biais de notifications dans le protocole de GNU Taler. Il incombe aux utilisateurs de répondre aux notifications correspondantes. TOPS a le droit de ne pas effectuer de transactions jusqu'à ce que les utilisateurs aient fourni les données légalement nécessaires demandées par ce biais." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:122 +msgid "Liability" +msgstr "Responsabilité" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:124 +msgid "TOPS is not liable for any loss or damage incurred by users as a result of the use of GNU Taler, in particular not for loss or damage" +msgstr "TOPS n'est pas responsable des pertes ou des dommages subis par les utilisateurs en raison de l'utilisation de GNU Taler, en particulier des pertes ou des dommages" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:127 +msgid "due to transmission errors, technical malfunctions or defects, failures and unauthorized access to or interference with the digital end device," +msgstr "en raison d'erreurs de transmission, de pannes techniques ou de défauts, de défaillances et d'accès ou d'interventions non autorisés sur le terminal numérique," + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:129 +msgid "which are due in whole or in part to a breach by the user of these ToS or applicable laws," +msgstr "résultant en tout ou en partie d'une violation des présentes CGU ou des lois applicables par les utilisateurs," + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:131 +msgid "due to a malfunction or error in the software or hardware used," +msgstr "en raison d'un dysfonctionnement ou d'un défaut du logiciel ou du matériel utilisé," + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:133 +msgid "due to malfunctions, interruptions (including system maintenance work) or overloads of the relevant IT systems or networks," +msgstr "en raison de perturbations, d'interruptions (y compris les travaux de maintenance du système) ou de surcharges des systèmes informatiques ou des réseaux concernés," + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:135 +msgid "due to payments that are not processed or are delayed," +msgstr "en raison de paiements qui ne sont pas traités ou qui sont traités avec retard," + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:137 +msgid "due to acts or omissions of third parties (including auxiliary persons of TOPS)," +msgstr "résultant d'actions ou d'omissions de tiers (y compris des auxiliaires de TOPS)," + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:139 +msgid "unless these losses or damages are attributable to gross negligence or willful misconduct on the part of TOPS. Liability caps are set at CHF 1,000 for certain loss events. Liability for consequential damages, loss of profit or loss of data is - to the extent permitted by law - excluded in any case." +msgstr "à moins que ces pertes ou dommages ne soient dus à une négligence grave ou à une faute intentionnelle de TOPS. TOPS indemnise les dommages matériels et pécuniaires à hauteur de 1 000 CHF maximum par événement. La responsabilité pour les dommages consécutifs, le manque à gagner ou la perte de données est exclue dans tous les cas - dans la mesure où la loi le permet." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:145 +msgid "Use; misuse" +msgstr "Utilisation ; abus" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:147 +msgid "Users shall indemnify TOPS for any damages or losses incurred by TOPS due to non-compliance with these ToS or legal requirements, due to incorrect or incomplete information provided by users or the incorrect execution of instructions." +msgstr "Les utilisateurs indemnisent TOPS en cas de dommages ou de pertes subis par TOPS en raison du non-respect des présentes CGU ou des dispositions légales, en raison d'informations erronées ou incomplètes fournies par les utilisateurs ou en raison d'une exécution incorrecte des instructions." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:151 +msgid "If the use deviates significantly from normal use or if there are signs of illegal or non-contractual behavior, TOPS may require users to act in accordance with the law and the contract, to suspend, restrict or discontinue the provision of services without prior notice and without compensation, terminate the business relationship without prior notice and without compensation and, if necessary, demand compensation for damages and indemnification from third-party claims. TOPS reserves the right to withhold payments to beneficiaries in the event of a breach of rules or abuse." +msgstr "Si l'utilisation s'écarte considérablement de l'usage habituel ou s'il existe des signes d'un comportement contraire à la loi ou au contrat, TOPS peut exiger des utilisateurs qu'ils utilisent les services conformément à la loi et au contrat, modifier, restreindre ou suspendre la fourniture des services sans préavis et sans indemnité, résilier la relation commerciale sans préavis et sans indemnité et, le cas échéant, exiger la compensation des dommages et intérêts ainsi que l'exonération des créances de tiers. TOPS se réserve le droit de retenir les paiements aux bénéficiaires en cas de violation des règles ou d'abus." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:159 +msgid "Reservations regarding changes to these ToS" +msgstr "Réserves concernant les modifications apportées aux présentes CGU" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:161 +msgid "TOPS may amend the ToS at any time. Amendments only have effect on tokens withdrawn after the change. Taler wallets compliant to the GNU Taler protocol inform users about changes before new tokens are withdrawn. The withdrawal of tokens issued by TOPS after the ToS have been amended shall be deemed to constitute acceptance of the amended conditions." +msgstr "TOPS peut modifier les CGU à tout moment. Les modifications n'ont d'effet que sur les jetons obtenus après la modification. Les portefeuilles Taler conformes au protocole GNU Taler informent les utilisateurs des changements avant que de nouveaux jetons ne soient retirés. Le retrait de jetons de TOPS après une modification des CGU est considéré comme une acceptation des conditions modifiées." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:165 +msgid "Any legal provisions governing the operation and use of digital devices, payment services, the Internet and other infrastructure remain reserved and shall also apply to the TOPS services." +msgstr "Les éventuelles dispositions légales régissant le fonctionnement et l'utilisation des terminaux numériques, des services de paiement, de l'Internet et d'autres infrastructures demeurent réservées et s'appliquent également aux services TOPS dès leur entrée en vigueur." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:168 +msgid "TOPS reserves the right to change, restrict, modify or completely discontinue its range of services at any time and without prior notice, in particular due to legal requirements, technical problems, prevention of misuse, by order of the authorities or for security reasons." +msgstr "TOPS se réserve le droit de modifier, de limiter ou d'interrompre complètement l'offre de services à tout moment et sans préavis, notamment en raison d'exigences légales, de problèmes techniques, pour prévenir les abus, sur ordre des autorités ou pour des raisons de sécurité." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:172 +msgid "TOPS may transfer the contractual relationship (including a credit balance) to another company at any time and without prior notification." +msgstr "TOPS peut transférer les relations contractuelles (y compris un avoir) à une autre société ou entreprise à tout moment et sans information préalable." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:177 +msgid "Confidentiality and data protection" +msgstr "Confidentialité et protection des données" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:179 +msgid "Personal data is only collected, processed, stored or used by TOPS within the scope of legal obligations. When paying with e-money, no data on the identity of the user is recorded." +msgstr "Les données personnelles ne sont collectées, traitées, conservées ou transmises par TOPS que dans le cadre du respect des obligations légales. Aucune donnée relative à l'identité de l'utilisateur n'est collectée lors du processus de paiement par monnaie électronique." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:182 +msgid "TOPS provides users with technical support on request. In the provision of this support third parties may be involved. They will receive access to the personal data required for communication with users." +msgstr "TOPS fournit une assistance technique aux utilisateurs qui en font la demande. Des tiers peuvent participer à la fourniture de cette assistance. Ceux-ci ont accès aux données personnelles nécessaires pour communiquer avec les utilisateurs." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:185 +msgid "TOPS undertakes to comply with the provisions of Swiss law with regard to the personal data of users, in particular the Federal Act on Data Protection and the Ordinance on Data Protection." +msgstr "En ce qui concerne la collecte, le traitement et l'utilisation des données personnelles des utilisateurs, TOPS s'engage à respecter les dispositions de la législation suisse sur la protection des données, notamment la loi fédérale sur la protection des données et l'ordonnance sur la protection des données." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:188 +msgid "All system data is primarily hosted in Switzerland." +msgstr "Toutes les données du système sont hébergées en premier lieu en Suisse." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:190 +msgid "KYC processes may be controlled by service providers. These are also obliged to secure the data in accordance with Swiss law. The core system’s data is stored on encrypted hard disks with redundancy (including backups) and is accessible only to authorized personnel. Authorized personnel are subjected to security checks by TOPS. The entire design of the GNU Taler payment service has been strictly developed according to the principles of “Privacy-by-Design” and “Privacy-by-Default”." +msgstr "Le cas échéant, les processus de connaissance du client (abrévié KYC en anglais) sont gérés par des prestataires de services. Ceux-ci sont également tenus de sécuriser les données conformément au droit et à la législation suisses. Les données proprement dites du système central sont stockées de manière redondante (c'est-à-dire avec une sauvegarde) sur des disques durs cryptés et ne sont accessibles qu'au personnel autorisé. Le personnel autorisé est soumis à un contrôle de sécurité par TOPS. L'ensemble du design du service de paiement GNU Taler a été strictement mis en œuvre selon les principes « Privacy-by-Design » et « Privacy-by-Default »." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:196 +msgid "Further information on data processing can be found in the privacy policy on the TOPS website (www.taler-ops.ch)." +msgstr "Pour plus d'informations sur le traitement des données, veuillez consulter la déclaration de confidentialité sur le site web de TOPS (www.taler-ops.ch)." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:200 +msgid "Duration and termination" +msgstr "Durée et résiliation" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:202 +msgid "The business relationship between TOPS and beneficiaries (merchants, businesses, and other regular recipients of transfers from the payment service to the beneficiary IBAN accounts) is concluded for an indefinite period. TOPS may terminate the business relationship with the beneficiaries at any time - in particular in cases of abuse with immediate effect. Written notice of termination by TOPS shall be sent to one of the last addresses provided by the business partners (e.g. by e-mail or letter). If no transactions are made to the beneficiaries for more than 12 months, the business relationship shall be automatically deemed terminated." +msgstr "La relation commerciale entre TOPS et les bénéficiaires (commerçants, entreprises, vendeurs et autres destinataires réguliers des virements du service de paiement vers les comptes IBAN des bénéficiaires) est conclue pour une durée indéterminée. TOPS peut à tout moment - notamment en cas d'abus avec effet immédiat - résilier la relation commerciale avec les bénéficiaires. Une résiliation écrite par TOPS est envoyée à l'une des dernières adresses communiquées par les partenaires commerciaux (par ex. par e-mail ou par lettre). Si aucune transaction n'est effectuée en faveur les bénéficiaires pendant plus de 12 mois, la relation commerciale est automatiquement considérée comme terminée." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:211 +msgid "Users of Taler wallets can return the existing credit in these wallets to bank accounts in Switzerland at any time, thereby balancing the credit. If the TOPS payment service is discontinued, users will be notified through the GNU Taler protocol and prompted by their Taler wallets to balance any remaining credit. Users who fail to balance the credit within 3 months will lose their entitlement to the remaining amount, which will become the property of TOPS." +msgstr "Les utilisateurs des portefeuilles Taler peuvent à tout moment faire transférer l'avoir qu'ils détiennent dans les portefeuilles Taler sur des comptes bancaires en Suisse et ainsi solder leur avoir. En cas de cessation d'activité du service de paiement de TOPS, les utilisateurs sont informés de l'arrêt imminent du service de paiement par le protocole de Taler et sont invités par les portefeuilles Taler à solder l'avoir existant. Les utilisateurs qui omettent de procéder à cette compensation perdent, au bout de 3 mois, le droit à l'avoir existant encore après cette période, lequel devient la propriété de TOPS." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:220 +msgid "Applicable law and place of jurisdiction" +msgstr "Droit applicable et juridiction compétente" + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:222 +msgid "To the extent permitted by law, all legal relationships between TOPS and users shall be governed exclusively by substantive Swiss law, excluding conflict of laws and international treaties." +msgstr "Dans la mesure où la loi le permet, toutes les relations juridiques entre TOPS et les utilisateurs sont exclusivement soumises au droit matériel suisse, à l'exclusion des règles de conflit de lois et à l'exclusion des traités internationaux." + +#: ../../../../../../tmp/taler-terms-ZgSjPo/exchange-tos-tops-v0.rst:225 +msgid "Subject to any mandatory statutory provisions to the contrary, Biel is the exclusive place of jurisdiction and the place of performance. For users and beneficiaries domiciled outside Switzerland, Biel/Bienne is also the place of debt collection." +msgstr "Sous réserve de dispositions légales impératives contraires, Bienne est le for exclusif et le lieu d'exécution. Pour les utilisateurs et les bénéficiaires domiciliés en dehors de la Suisse, Bienne est également le lieu de poursuite." diff --git a/contrib/taler-terms-generator b/contrib/taler-terms-generator index 4a25afa4b..274a1927e 100755 --- a/contrib/taler-terms-generator +++ b/contrib/taler-terms-generator @@ -88,8 +88,8 @@ function failcat() { # defaults AUTHOR="GNU Taler team" VERSION="exchange-tos-v0" -LOCALE_DIR=$(taler-config -s "PATHS" -o "LOCALEDIR" -f) -OUTPUT=$(taler-config -s "EXCHANGE" -o "TERMS_DIR" -f) +LOCALE_DIR=${TALER_PATHS_LOCALEDIR:-$(taler-config -s "PATHS" -o "LOCALEDIR" -f)} +OUTPUT=${TALER_EXCHANGE_TERMS_DIR:-$(taler-config -s "EXCHANGE" -o "TERMS_DIR" -f)} PAPER="a4" COPYRIGHT="2014-2023 Taler Systems SA (GPLv3+ or GFDL 1.3+)" INCREMENTAL=0 diff --git a/contrib/wallet-core b/contrib/wallet-core -Subproject 63bcc78233be147eb7725b4d019f912f99bc7f4 +Subproject a9923dce3051635bc8489b60512dfac396e5ad2 diff --git a/debian/taler-exchange.install b/debian/taler-exchange.install index 3a4a4f623..3ac76f378 100644 --- a/debian/taler-exchange.install +++ b/debian/taler-exchange.install @@ -24,6 +24,7 @@ usr/share/man/man1/taler-exchange-dbinit* usr/share/man/man1/taler-exchange-drain* usr/share/man/man1/taler-exchange-expire* usr/share/man/man1/taler-exchange-httpd* +usr/share/man/man1/taler-exchange-kyc-trigger* usr/share/man/man1/taler-exchange-kyc-aml-pep-trigger* usr/share/man/man1/taler-exchange-router* usr/share/man/man1/taler-exchange-secmod-cs* diff --git a/doc/Makefile.am b/doc/Makefile.am index ca973a1a5..b3d481ab9 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -27,6 +27,7 @@ man_MANS = \ prebuilt/man/taler-exchange-httpd.1 \ prebuilt/man/taler-exchange-kyc-aml-pep-trigger.1 \ prebuilt/man/taler-exchange-kyc-tester.1 \ + prebuilt/man/taler-exchange-kyc-trigger.1 \ prebuilt/man/taler-exchange-offline.1 \ prebuilt/man/taler-exchange-router.1\ prebuilt/man/taler-exchange-secmod-cs.1\ diff --git a/doc/prebuilt b/doc/prebuilt -Subproject b420ea339295885530ecadba0ed849d42415456 +Subproject dac140335967c9c8409698186f0cba0635c7cd7 diff --git a/src/auditor/Makefile.am b/src/auditor/Makefile.am index c1035fad3..a3b1cc747 100644 --- a/src/auditor/Makefile.am +++ b/src/auditor/Makefile.am @@ -195,11 +195,9 @@ taler_auditor_httpd_SOURCES = \ taler-auditor-httpd_spa.c taler-auditor-httpd_spa.h \ taler-auditor-httpd_deposit-confirmation.c taler-auditor-httpd_deposit-confirmation.h \ taler-auditor-httpd_deposit-confirmation-get.c taler-auditor-httpd_deposit-confirmation-get.h \ - taler-auditor-httpd_deposit-confirmation-upd.c taler-auditor-httpd_deposit-confirmation-upd.h \ taler-auditor-httpd_amount-arithmetic-inconsistency-get.c taler-auditor-httpd_amount-arithmetic-inconsistency-get.h \ taler-auditor-httpd_coin-inconsistency-get.c taler-auditor-httpd_coin-inconsistency-get.h \ taler-auditor-httpd_row-inconsistency-get.c taler-auditor-httpd_row-inconsistency-get.h \ - taler-auditor-httpd_amount-arithmetic-inconsistency-upd.c taler-auditor-httpd_amount-arithmetic-inconsistency-upd.h \ taler-auditor-httpd_emergency-get.c taler-auditor-httpd_emergency-get.h \ taler-auditor-httpd_emergency-by-count-get.c taler-auditor-httpd_emergency-by-count-get.h \ taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.c taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.h \ @@ -208,43 +206,23 @@ taler_auditor_httpd_SOURCES = \ taler-auditor-httpd_patch_generic_suppressed.c taler-auditor-httpd_patch_generic_suppressed.h \ taler-auditor-httpd_delete_generic.c taler-auditor-httpd_delete_generic.h \ taler-auditor-httpd_bad-sig-losses-get.c taler-auditor-httpd_bad-sig-losses-get.h \ - taler-auditor-httpd_bad-sig-losses-upd.c taler-auditor-httpd_bad-sig-losses-upd.h \ taler-auditor-httpd_closure-lags-get.c taler-auditor-httpd_closure-lags-get.h \ taler-auditor-httpd_progress-get.c taler-auditor-httpd_progress-get.h \ taler-auditor-httpd_refreshes-hanging-get.c taler-auditor-httpd_refreshes-hanging-get.h \ - taler-auditor-httpd_emergency-by-count-upd.c taler-auditor-httpd_emergency-by-count-upd.h \ - taler-auditor-httpd_row-inconsistency-upd.c taler-auditor-httpd_row-inconsistency-upd.h \ - taler-auditor-httpd_purse-not-closed-inconsistencies-upd.c taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h \ - taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.c taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h \ - taler-auditor-httpd_coin-inconsistency-upd.c taler-auditor-httpd_coin-inconsistency-upd.h \ - taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.c taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h \ - taler-auditor-httpd_refreshes-hanging-upd.c taler-auditor-httpd_refreshes-hanging-upd.h \ - taler-auditor-httpd_emergency-upd.c taler-auditor-httpd_emergency-upd.h \ - taler-auditor-httpd_closure-lags-upd.c taler-auditor-httpd_closure-lags-upd.h \ taler-auditor-httpd_reserve-in-inconsistency-get.c taler-auditor-httpd_reserve-in-inconsistency-get.h \ - taler-auditor-httpd_reserve-in-inconsistency-upd.c taler-auditor-httpd_reserve-in-inconsistency-upd.h \ taler-auditor-httpd_reserve-not-closed-inconsistency-get.c taler-auditor-httpd_reserve-not-closed-inconsistency-get.h \ - taler-auditor-httpd_reserve-not-closed-inconsistency-upd.c taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h \ taler-auditor-httpd_denominations-without-sigs-get.c taler-auditor-httpd_denominations-without-sigs-get.h \ - taler-auditor-httpd_denominations-without-sigs-upd.c taler-auditor-httpd_denominations-without-sigs-upd.h \ taler-auditor-httpd_misattribution-in-inconsistency-get.c taler-auditor-httpd_misattribution-in-inconsistency-get.h \ - taler-auditor-httpd_misattribution-in-inconsistency-upd.c taler-auditor-httpd_misattribution-in-inconsistency-upd.h \ taler-auditor-httpd_reserves-get.c taler-auditor-httpd_reserves-get.h \ taler-auditor-httpd_purses-get.c taler-auditor-httpd_purses-get.h \ taler-auditor-httpd_historic-denomination-revenue-get.c taler-auditor-httpd_historic-denomination-revenue-get.h \ taler-auditor-httpd_denomination-pending-get.c taler-auditor-httpd_denomination-pending-get.h \ - taler-auditor-httpd_denomination-pending-upd.c taler-auditor-httpd_denomination-pending-upd.h \ taler-auditor-httpd_historic-reserve-summary-get.c taler-auditor-httpd_historic-reserve-summary-get.h \ taler-auditor-httpd_wire-format-inconsistency-get.c taler-auditor-httpd_wire-format-inconsistency-get.h \ - taler-auditor-httpd_wire-format-inconsistency-upd.c taler-auditor-httpd_wire-format-inconsistency-upd.h \ taler-auditor-httpd_wire-out-inconsistency-get.c taler-auditor-httpd_wire-out-inconsistency-get.h \ - taler-auditor-httpd_wire-out-inconsistency-upd.c taler-auditor-httpd_wire-out-inconsistency-upd.h \ taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h \ - taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.c taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h \ taler-auditor-httpd_row-minor-inconsistencies-get.c taler-auditor-httpd_row-minor-inconsistencies-get.h \ - taler-auditor-httpd_row-minor-inconsistencies-upd.c taler-auditor-httpd_row-minor-inconsistencies-upd.h \ taler-auditor-httpd_fee-time-inconsistency-get.c taler-auditor-httpd_fee-time-inconsistency-get.h \ - taler-auditor-httpd_fee-time-inconsistency-upd.c taler-auditor-httpd_fee-time-inconsistency-upd.h \ taler-auditor-httpd_balances-get.c taler-auditor-httpd_balances-get.h \ taler-auditor-httpd_mhd.c taler-auditor-httpd_mhd.h taler_auditor_httpd_LDADD = \ @@ -286,8 +264,8 @@ check_SCRIPTS = \ TESTS = \ test-revocation.sh \ - test-sync.sh -# test-auditor.sh + test-sync.sh \ + test-auditor.sh EXTRA_DIST = \ diff --git a/src/auditor/batch.conf b/src/auditor/batch.conf index 2de9bbb32..3b6402e77 100644 --- a/src/auditor/batch.conf +++ b/src/auditor/batch.conf @@ -118,7 +118,7 @@ HONOR_default = YES PAYTO_URI = payto://x-taler-bank/localhost/42 [exchange-accountcredentials-1] -PASSWORD = x +PASSWORD = password USERNAME = exchange WIRE_GATEWAY_AUTH_METHOD = basic WIRE_GATEWAY_URL = http://localhost:8082/accounts/exchange/taler-wire-gateway/ diff --git a/src/auditor/generate-auditor-basedb.conf b/src/auditor/generate-auditor-basedb.conf index 36de9d244..a9928bb97 100644 --- a/src/auditor/generate-auditor-basedb.conf +++ b/src/auditor/generate-auditor-basedb.conf @@ -36,6 +36,8 @@ WIRE_TYPE = iban IBAN_PAYTO_BIC = SANDBOXX SERVE = tcp PORT = 8082 +PWD_HASH_CONFIG = { "cost": 4 } +PWD_AUTH_COMPAT = yes [libeufin-bankdb-postgres] CONFIG = postgresql:///auditor-basedb @@ -55,7 +57,7 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = http://localhost:8082/accounts/exchange/taler-wire-gateway/ WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = exchange -PASSWORD = x +PASSWORD = password [merchant] FORCE_AUDIT = YES @@ -89,6 +91,8 @@ REGISTRATION_BONUS = TESTKUDOS:100 SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/ SERVE = tcp PORT = 8082 +PWD_HASH_CONFIG = { "cost": 4 } +PWD_AUTH_COMPAT = yes [auditor] BASE_URL = http://localhost:8083/ diff --git a/src/auditor/generate-auditor-basedb.sh b/src/auditor/generate-auditor-basedb.sh index ae695f450..33831d06f 100755 --- a/src/auditor/generate-auditor-basedb.sh +++ b/src/auditor/generate-auditor-basedb.sh @@ -97,7 +97,7 @@ libeufin-bank create-account \ --config="${CONF}" \ --name="Merchant43" \ --username="Merchant43" \ - --password="X" \ + --password="password" \ --payto_uri="payto://iban/DE474361?receiver-name=Merchant43" echo " DONE" diff --git a/src/auditor/report-lib.c b/src/auditor/report-lib.c index 2bbdf569d..7b6ceea86 100644 --- a/src/auditor/report-lib.c +++ b/src/auditor/report-lib.c @@ -133,7 +133,7 @@ add_denomination ( enum GNUNET_DB_QueryStatus TALER_ARL_get_denomination_info_by_hash ( const struct TALER_DenominationHashP *dh, - const struct TALER_EXCHANGEDB_DenominationKeyInformation **issue) + const struct TALER_EXCHANGEDB_DenominationKeyInformation **issuep) { enum GNUNET_DB_QueryStatus qs; @@ -147,7 +147,7 @@ TALER_ARL_get_denomination_info_by_hash ( if (0 > qs) { GNUNET_break (0); - *issue = NULL; + *issuep = NULL; return qs; } } @@ -159,7 +159,7 @@ TALER_ARL_get_denomination_info_by_hash ( if (NULL != i) { /* cache hit */ - *issue = i; + *issuep = i; return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } } @@ -191,7 +191,7 @@ TALER_ARL_get_denomination_info_by_hash ( if (NULL != i) { /* cache hit */ - *issue = i; + *issuep = i; return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } } @@ -634,7 +634,8 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) } } if (NULL == - (TALER_ARL_edb = TALER_EXCHANGEDB_plugin_load (TALER_ARL_cfg))) + (TALER_ARL_edb = TALER_EXCHANGEDB_plugin_load (TALER_ARL_cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize exchange database plugin.\n"); @@ -642,7 +643,8 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) return GNUNET_SYSERR; } if (NULL == - (TALER_ARL_adb = TALER_AUDITORDB_plugin_load (TALER_ARL_cfg))) + (TALER_ARL_adb = TALER_AUDITORDB_plugin_load (TALER_ARL_cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize auditor database plugin.\n"); diff --git a/src/auditor/report-lib.h b/src/auditor/report-lib.h index bf2d63740..369ac3ccf 100644 --- a/src/auditor/report-lib.h +++ b/src/auditor/report-lib.h @@ -135,14 +135,14 @@ extern struct GNUNET_TIME_Absolute start_time; * Obtain information about a @a denom_pub. * * @param dh hash of the denomination public key to look up - * @param[out] issue set to detailed information about @a denom_pub, NULL if not found, must + * @param[out] issuep set to detailed information about @a denom_pub, NULL if not found, must * NOT be freed by caller * @return transaction status code */ enum GNUNET_DB_QueryStatus TALER_ARL_get_denomination_info_by_hash ( const struct TALER_DenominationHashP *dh, - const struct TALER_EXCHANGEDB_DenominationKeyInformation **issue); + const struct TALER_EXCHANGEDB_DenominationKeyInformation **issuep); /** diff --git a/src/auditor/revoke-basedb.conf b/src/auditor/revoke-basedb.conf index 706f97347..c3bf83bf0 100644 --- a/src/auditor/revoke-basedb.conf +++ b/src/auditor/revoke-basedb.conf @@ -12,7 +12,7 @@ enable_credit = yes WIRE_GATEWAY_URL = "http://localhost:8082/accounts/exchange/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = exchange -PASSWORD = x +PASSWORD = password [exchangedb] WIREFEE_BASE_DIR = ${PWD}/wirefees/ diff --git a/src/auditor/setup.sh b/src/auditor/setup.sh index bb17e92ae..18892e896 100755 --- a/src/auditor/setup.sh +++ b/src/auditor/setup.sh @@ -11,83 +11,97 @@ set -eu # Cleanup to run whenever we exit -function exit_cleanup() -{ - if [ ! -z ${SETUP_PID+x} ] - then - echo "Killing taler-unified-setup ($SETUP_PID)" >&2 - kill -TERM "$SETUP_PID" 2> /dev/null || true - wait "$SETUP_PID" 2> /dev/null || true - fi +function exit_cleanup() { + if [ ! -z ${SETUP_PID+x} ]; then + echo "Killing taler-unified-setup ($SETUP_PID)" >&2 + kill -TERM "$SETUP_PID" 2>/dev/null || true + wait "$SETUP_PID" 2>/dev/null || true + fi } # Install cleanup handler (except for kill -9) trap exit_cleanup EXIT -function setup() -{ - echo "Starting test system ..." >&2 - # Create a named pipe in a temp directory we own. - FIFO_DIR=$(mktemp -d fifo-XXXXXX) - FIFO_OUT=$(echo "$FIFO_DIR/out") - mkfifo "$FIFO_OUT" - # Open pipe as FD 3 (RW) and FD 4 (RO) - exec 3<> "$FIFO_OUT" 4< "$FIFO_OUT" - rm -rf "$FIFO_DIR" - # We require '-W' for our termination logic to work. - taler-unified-setup.sh -W "$@" \ - > >(tee taler-unified-setup.log >&3) & - SETUP_PID=$! - # Close FD3 - exec 3>&- - sed -u '/<<READY>>/ q' <&4 - # Close FD4 - exec 4>&- - echo "Test system ready" >&2 +function setup() { + echo "Starting test system ..." >&2 + # Create a named pipe in a temp directory we own. + FIFO_DIR=$(mktemp -d fifo-XXXXXX) + FIFO_OUT=$(echo "$FIFO_DIR/out") + mkfifo "$FIFO_OUT" + # Open pipe as FD 3 (RW) and FD 4 (RO) + exec 3<>"$FIFO_OUT" 4<"$FIFO_OUT" + rm -rf "$FIFO_DIR" + # We require '-W' for our termination logic to work. + taler-unified-setup.sh -W "$@" \ + > >(tee taler-unified-setup.log >&3) & + SETUP_PID=$! + # Close FD3 + exec 3>&- + sed -u '/<<READY>>/ q' <&4 + # Close FD4 + exec 4>&- + echo "Test system ready" >&2 } # Exit, with status code "skip" (no 'real' failure) function exit_fail() { - echo "$@" >&2 - exit 1 + echo "$@" >&2 + exit 1 } # Exit, with status code "skip" (no 'real' failure) function exit_skip() { - echo "SKIPPING: $1" - exit 77 + echo "SKIPPING: $1" + exit 77 } function get_payto_uri() { - export LIBEUFIN_SANDBOX_USERNAME="$1" - export LIBEUFIN_SANDBOX_PASSWORD="$2" - export LIBEUFIN_SANDBOX_URL="http://localhost:18082" - echo "get_payto_uri currently not implemented" - exit 1 -# libeufin-cli sandbox demobank info --bank-account "$1" | jq --raw-output '.paytoUri' + export LIBEUFIN_SANDBOX_USERNAME="$1" + export LIBEUFIN_SANDBOX_PASSWORD="$2" + export LIBEUFIN_SANDBOX_URL="http://localhost:18082" + echo "get_payto_uri currently not implemented" + exit 1 + # libeufin-cli sandbox demobank info --bank-account "$1" | jq --raw-output '.paytoUri' } # Stop libeufin-bank (if running) -function stop_libeufin() -{ - echo -n "Stopping libeufin... " - if [ -f "${MY_TMP_DIR:-/}/libeufin-bank.pid" ] - then - PID=$(cat "${MY_TMP_DIR}/libeufin-bank.pid" 2> /dev/null) - echo "Killing libeufin-bank $PID" - rm "${MY_TMP_DIR}/libeufin-bank.pid" - kill "$PID" 2> /dev/null || true - wait "$PID" || true - fi +function stop_libeufin() { + if [ -f "${MY_TMP_DIR:-/}/libeufin-bank.pid" ]; then + PID=$(cat "${MY_TMP_DIR}/libeufin-bank.pid" 2>/dev/null) + echo -n "Stopping libeufin $PID... " + rm "${MY_TMP_DIR}/libeufin-bank.pid" + kill "$PID" 2>/dev/null || true + wait "$PID" || true echo "DONE" + fi } - -function launch_libeufin () { +function launch_libeufin() { + echo "launching libeufin-bank" libeufin-bank serve \ -c "$CONF" \ -L "INFO" \ - > "${MY_TMP_DIR}/libeufin-bank-stdout.log" \ - 2> "${MY_TMP_DIR}/libeufin-bank-stderr.log" & - echo $! > "${MY_TMP_DIR}/libeufin-bank.pid" + >"${MY_TMP_DIR}/libeufin-bank-stdout.log" \ + 2>"${MY_TMP_DIR}/libeufin-bank-stderr.log" & + echo $! >"${MY_TMP_DIR}/libeufin-bank.pid" + BANK_PORT=$(taler-config -c "$CONF" -s "libeufin-bank" -o "PORT") + BANK_URL="http://localhost:${BANK_PORT}/" + for n in $(seq 1 100); do + echo -n "." + sleep 0.2 + wget --timeout=1 \ + --tries=3 \ + --waitretry=0 \ + -a wget-bank-check.log \ + -o /dev/null \ + -O /dev/null \ + "${BANK_URL}config" || continue + OK="1" + break + done + if [ "1" != "$OK" ]; then + echo "Failed to launch libeufin-bank" + exit 1 + fi + echo "launched libeufin-bank" } diff --git a/src/auditor/taler-auditor-dbinit.c b/src/auditor/taler-auditor-dbinit.c index 4cb46f470..311959a40 100644 --- a/src/auditor/taler-auditor-dbinit.c +++ b/src/auditor/taler-auditor-dbinit.c @@ -66,7 +66,8 @@ run (void *cls, (void) args; (void) cfgfile; if (NULL == - (plugin = TALER_AUDITORDB_plugin_load (cfg))) + (plugin = TALER_AUDITORDB_plugin_load (cfg, + true))) { fprintf (stderr, "Failed to initialize database plugin.\n"); @@ -139,10 +140,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; /* force linker to link against libtalerutil; if we do not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ @@ -153,7 +150,6 @@ main (int argc, gettext_noop ("Initialize Taler auditor database"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index b681543cb..a7864e98b 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -34,81 +34,35 @@ #include "taler-auditor-httpd_deposit-confirmation.h" #include "taler-auditor-httpd_deposit-confirmation-get.h" #include "taler-auditor-httpd_amount-arithmetic-inconsistency-get.h" -#include "taler-auditor-httpd_amount-arithmetic-inconsistency-upd.h" #include "taler-auditor-httpd_coin-inconsistency-get.h" #include "taler-auditor-httpd_row-inconsistency-get.h" - #include "taler-auditor-httpd_emergency-get.h" - #include "taler-auditor-httpd_emergency-by-count-get.h" - #include \ "taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.h" - #include "taler-auditor-httpd_purse-not-closed-inconsistencies-get.h" - #include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.h" - #include "taler-auditor-httpd_bad-sig-losses-get.h" -#include "taler-auditor-httpd_bad-sig-losses-upd.h" - #include "taler-auditor-httpd_closure-lags-get.h" - #include "taler-auditor-httpd_refreshes-hanging-get.h" - #include "taler-auditor-httpd_mhd.h" #include "taler-auditor-httpd.h" - #include "taler-auditor-httpd_delete_generic.h" #include "taler-auditor-httpd_patch_generic_suppressed.h" -#include "taler-auditor-httpd_emergency-by-count-upd.h" -#include "taler-auditor-httpd_row-inconsistency-upd.h" -#include "taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h" -#include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h" -#include "taler-auditor-httpd_coin-inconsistency-upd.h" -#include \ - "taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h" -#include "taler-auditor-httpd_refreshes-hanging-upd.h" -#include "taler-auditor-httpd_emergency-upd.h" -#include "taler-auditor-httpd_closure-lags-upd.h" -#include "taler-auditor-httpd_row-minor-inconsistencies-upd.h" - #include "taler-auditor-httpd_reserve-in-inconsistency-get.h" -#include "taler-auditor-httpd_reserve-in-inconsistency-upd.h" - #include "taler-auditor-httpd_reserve-not-closed-inconsistency-get.h" -#include "taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h" - #include "taler-auditor-httpd_denominations-without-sigs-get.h" -#include "taler-auditor-httpd_denominations-without-sigs-upd.h" - #include "taler-auditor-httpd_misattribution-in-inconsistency-get.h" -#include "taler-auditor-httpd_misattribution-in-inconsistency-upd.h" - #include "taler-auditor-httpd_reserves-get.h" #include "taler-auditor-httpd_purses-get.h" - #include "taler-auditor-httpd_historic-denomination-revenue-get.h" #include "taler-auditor-httpd_historic-reserve-summary-get.h" - #include "taler-auditor-httpd_denomination-pending-get.h" -#include "taler-auditor-httpd_denomination-pending-upd.h" - #include "taler-auditor-httpd_wire-format-inconsistency-get.h" -#include "taler-auditor-httpd_wire-format-inconsistency-upd.h" - #include "taler-auditor-httpd_wire-out-inconsistency-get.h" -#include "taler-auditor-httpd_wire-out-inconsistency-upd.h" - #include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h" -#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h" - #include "taler-auditor-httpd_row-minor-inconsistencies-get.h" -#include "taler-auditor-httpd_row-minor-inconsistencies-upd.h" - #include "taler-auditor-httpd_fee-time-inconsistency-get.h" -#include "taler-auditor-httpd_fee-time-inconsistency-upd.h" - #include "taler-auditor-httpd_balances-get.h" #include "taler-auditor-httpd_progress-get.h" @@ -399,7 +353,7 @@ handle_mhd_request (void *cls, "application/json", NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_DEPOSIT_CONFIRMATION }, + .table = TALER_AUDITORDB_DEPOSIT_CONFIRMATION }, { "/monitoring/amount-arithmetic-inconsistency", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -408,7 +362,7 @@ handle_mhd_request (void *cls, "application/json", NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_AMOUNT_ARITHMETIC_INCONSISTENCY }, + .table = TALER_AUDITORDB_AMOUNT_ARITHMETIC_INCONSISTENCY }, { "/monitoring/amount-arithmetic-inconsistency", MHD_HTTP_METHOD_PATCH, @@ -428,11 +382,12 @@ handle_mhd_request (void *cls, "application/json", NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_COIN_INCONSISTENCY }, + .table = TALER_AUDITORDB_COIN_INCONSISTENCY }, { "/monitoring/coin-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_COIN_INCONSISTENCY_handler_update, MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_COIN_INCONSISTENCY }, { "/monitoring/row-inconsistency", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -445,7 +400,8 @@ handle_mhd_request (void *cls, { "/monitoring/row-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_ROW_INCONSISTENCY_handler_update, MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_ROW_INCONSISTENCY }, { "/monitoring/bad-sig-losses", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -460,8 +416,9 @@ handle_mhd_request (void *cls, { "/monitoring/bad-sig-losses", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_BAD_SIG_LOSSES_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_BAD_SIG_LOSSES }, { "/monitoring/closure-lags", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -472,12 +429,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_CLOSURE_LAGS }, + .table = TALER_AUDITORDB_CLOSURE_LAGS }, { "/monitoring/closure-lags", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_CLOSURE_LAGS_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_CLOSURE_LAGS }, { "/monitoring/emergency", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -488,12 +446,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_EMERGENCY }, + .table = TALER_AUDITORDB_EMERGENCY }, { "/monitoring/emergency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_EMERGENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_EMERGENCY }, { "/monitoring/refreshes-hanging", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -504,12 +463,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_REFRESHES_HANGING }, + .table = TALER_AUDITORDB_REFRESHES_HANGING }, { "/monitoring/refreshes-hanging", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_REFRESHES_HANGING_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_REFRESHES_HANGING }, { "/monitoring/denomination-key-validity-withdraw-inconsistency", MHD_HTTP_METHOD_GET, "application/json", @@ -522,13 +482,16 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY }, + .table = TALER_AUDITORDB_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY} + , { "/monitoring/denomination-key-validity-withdraw-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY} + , { "/monitoring/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_GET, "application/json", @@ -541,13 +504,14 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY }, + .table = TALER_AUDITORDB_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY }, { "/monitoring/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY }, { "/monitoring/purse-not-closed-inconsistencies", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -558,12 +522,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCY }, + .table = TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCY }, { "/monitoring/purse-not-closed-inconsistencies", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCY }, { "/monitoring/emergency-by-count", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -574,12 +539,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_EMERGENCY_BY_COUNT }, + .table = TALER_AUDITORDB_EMERGENCY_BY_COUNT }, { "/monitoring/emergency-by-count", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_EMERGENCY_BY_COUNT_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_EMERGENCY_BY_COUNT }, { "/monitoring/reserve-in-inconsistency", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -590,12 +556,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_RESERVE_IN_INCONSISTENCY }, + .table = TALER_AUDITORDB_RESERVE_IN_INCONSISTENCY }, { "/monitoring/reserve-in-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_RESERVE_IN_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_RESERVE_IN_INCONSISTENCY }, { "/monitoring/reserve-not-closed-inconsistency", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -606,12 +573,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_RESERVE_NOT_CLOSED_INCONSISTENCY }, + .table = TALER_AUDITORDB_RESERVE_NOT_CLOSED_INCONSISTENCY }, { "/monitoring/reserve-not-closed-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_RESERVE_NOT_CLOSED_INCONSISTENCY }, { "/monitoring/denominations-without-sigs", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -622,12 +590,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_DENOMINATIONS_WITHOUT_SIG }, + .table = TALER_AUDITORDB_DENOMINATIONS_WITHOUT_SIG }, { "/monitoring/denominations-without-sigs", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_DENOMINATIONS_WITHOUT_SIGS_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_DENOMINATIONS_WITHOUT_SIG }, { "/monitoring/misattribution-in-inconsistency", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -638,12 +607,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_MISATTRIBUTION_IN_INCONSISTENCY }, + .table = TALER_AUDITORDB_MISATTRIBUTION_IN_INCONSISTENCY }, { "/monitoring/misattribution-in-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_MISATTRIBUTION_IN_INCONSISTENCY }, { "/monitoring/reserves", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -669,7 +639,7 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_DENOMINATION_PENDING }, + .table = TALER_AUDITORDB_DENOMINATION_PENDING }, { "/monitoring/historic-reserve-summary", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -685,12 +655,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_WIRE_FORMAT_INCONSISTENCY }, + .table = TALER_AUDITORDB_WIRE_FORMAT_INCONSISTENCY }, { "/monitoring/wire-format-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_WIRE_FORMAT_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_WIRE_FORMAT_INCONSISTENCY }, { "/monitoring/wire-out-inconsistency", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -701,12 +672,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_WIRE_OUT_INCONSISTENCY }, + .table = TALER_AUDITORDB_WIRE_OUT_INCONSISTENCY }, { "/monitoring/wire-out-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_WIRE_OUT_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_WIRE_OUT_INCONSISTENCY }, { "/monitoring/reserve-balance-summary-wrong-inconsistency", MHD_HTTP_METHOD_GET, "application/json", @@ -719,13 +691,14 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY }, + .table = TALER_AUDITORDB_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY }, { "/monitoring/reserve-balance-summary-wrong-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY }, { "/monitoring/row-minor-inconsistencies", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -736,12 +709,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_ROW_MINOR_INCONSISTENCY }, + .table = TALER_AUDITORDB_ROW_MINOR_INCONSISTENCY }, { "/monitoring/row-minor-inconsistencies", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_ROW_MINOR_INCONSISTENCIES_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_ROW_MINOR_INCONSISTENCY }, { "/monitoring/fee-time-inconsistency", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -752,12 +726,13 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_delete_handler_generic, MHD_HTTP_OK, true, - .table = TALER_AUDITORDB_FEE_TIME_INCONSISTENCY }, + .table = TALER_AUDITORDB_FEE_TIME_INCONSISTENCY }, { "/monitoring/fee-time-inconsistency", MHD_HTTP_METHOD_PATCH, "application/json", NULL, 0, - &TAH_FEE_TIME_INCONSISTENCY_handler_update, - MHD_HTTP_OK, true }, + &TAH_patch_handler_generic_suppressed, + MHD_HTTP_OK, true, + .table = TALER_AUDITORDB_FEE_TIME_INCONSISTENCY }, { "/monitoring/balances", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, @@ -920,7 +895,7 @@ not_found: } #define NOT_FOUND \ - "<html><title>404: not found</title><body>auditor endpoints have been moved to /monitoring/...</body></html>" + "<html><title>404: not found</title><body>auditor endpoints have been moved to /monitoring/...</body></html>" return TALER_MHD_reply_static (connection, MHD_HTTP_NOT_FOUND, "text/html", @@ -940,14 +915,16 @@ static enum GNUNET_GenericReturnValue auditor_serve_process_config (void) { if (NULL == - (TAH_plugin = TALER_AUDITORDB_plugin_load (cfg))) + (TAH_plugin = TALER_AUDITORDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem to interact with auditor database\n"); return GNUNET_SYSERR; } if (NULL == - (TAH_eplugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (TAH_eplugin = TALER_EXCHANGEDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem to query exchange database\n"); diff --git a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-upd.c deleted file mode 100644 index 642307a2d..000000000 --- a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-upd.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_amount-arithmetic-inconsistency-upd.h" - -MHD_RESULT -TAH_AMOUNT_ARITHMETIC_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[1] != NULL) - row_id = atoi (args[1]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_amount_arithmetic_inconsistency (TAH_plugin->cls, - &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-upd.h deleted file mode 100644 index bbda9d3cd..000000000 --- a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-upd.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -#ifndef SRC_TALER_AUDITOR_HTTPD_AMOUNT_ARITHMETIC_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_AMOUNT_ARITHMETIC_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_AMOUNT_ARITHMETIC_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif diff --git a/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.c b/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.c deleted file mode 100644 index 1be070766..000000000 --- a/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_bad-sig-losses-upd.h" - -MHD_RESULT -TAH_BAD_SIG_LOSSES_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_bad_sig_losses (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.h b/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.h deleted file mode 100644 index 9ab5bfbc0..000000000 --- a/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -#ifndef SRC_TALER_AUDITOR_HTTPD_BAD_SIG_LOSSES_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_BAD_SIG_LOSSES_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_BAD_SIG_LOSSES_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_BAD_SIG_LOSSES_UPD_H diff --git a/src/auditor/taler-auditor-httpd_closure-lags-get.c b/src/auditor/taler-auditor-httpd_closure-lags-get.c index 2a226ce4a..b15668140 100644 --- a/src/auditor/taler-auditor-httpd_closure-lags-get.c +++ b/src/auditor/taler-auditor-httpd_closure-lags-get.c @@ -51,8 +51,8 @@ process_closure_lags ( dc->deadline), GNUNET_JSON_pack_data_auto ("wtid", &dc->wtid), - GNUNET_JSON_pack_string ("account", - dc->account), + TALER_JSON_pack_full_payto ("account", + dc->account), GNUNET_JSON_pack_bool ("suppressed", dc->suppressed) ); diff --git a/src/auditor/taler-auditor-httpd_closure-lags-upd.c b/src/auditor/taler-auditor-httpd_closure-lags-upd.c deleted file mode 100644 index 9b043f974..000000000 --- a/src/auditor/taler-auditor-httpd_closure-lags-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_closure-lags-upd.h" - -MHD_RESULT -TAH_CLOSURE_LAGS_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_closure_lags (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_closure-lags-upd.h b/src/auditor/taler-auditor-httpd_closure-lags-upd.h deleted file mode 100644 index b77146d12..000000000 --- a/src/auditor/taler-auditor-httpd_closure-lags-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_CLOSURE_LAGS_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_CLOSURE_LAGS_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_CLOSURE_LAGS_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif diff --git a/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c b/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c index 1d96e2340..f5eb28ac0 100644 --- a/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -24,9 +22,9 @@ #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-auditor-httpd.h" - #include "taler-auditor-httpd_coin-inconsistency-get.h" + /** * Add deposit confirmation to the list. * @@ -51,12 +49,9 @@ add_coin_inconsistency ( GNUNET_JSON_pack_data_auto ("coin_pub",&dc->coin_pub), GNUNET_JSON_pack_bool ("profitable", dc->profitable) ); - GNUNET_break (0 == json_array_append_new (list, obj)); - - return GNUNET_OK; } @@ -72,6 +67,9 @@ TAH_COIN_INCONSISTENCY_handler_get ( { json_t *ja; enum GNUNET_DB_QueryStatus qs; + int64_t limit = -20; + uint64_t offset; + bool return_suppressed = false; if (GNUNET_SYSERR == TAH_plugin->preflight (TAH_plugin->cls)) @@ -82,34 +80,27 @@ TAH_COIN_INCONSISTENCY_handler_get ( TALER_EC_GENERIC_DB_SETUP_FAILED, NULL); } - ja = json_array (); - GNUNET_break (NULL != ja); - - int64_t limit = -20; - uint64_t offset; - TALER_MHD_parse_request_snumber (connection, "limit", &limit); - if (limit < 0) offset = INT64_MAX; else offset = 0; - TALER_MHD_parse_request_number (connection, "offset", &offset); - - bool return_suppressed = false; - const char *ret_s = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "return_suppressed"); - if (ret_s != NULL && strcmp (ret_s, "true") == 0) { - return_suppressed = true; + const char *ret_s = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "return_suppressed"); + if (ret_s != NULL && strcmp (ret_s, "true") == 0) + { + return_suppressed = true; + } } - + ja = json_array (); + GNUNET_break (NULL != ja); qs = TAH_plugin->get_coin_inconsistency ( TAH_plugin->cls, limit, @@ -117,7 +108,6 @@ TAH_COIN_INCONSISTENCY_handler_get ( return_suppressed, &add_coin_inconsistency, ja); - if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); diff --git a/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.c deleted file mode 100644 index 63dc00ca5..000000000 --- a/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_coin-inconsistency-upd.h" - -MHD_RESULT -TAH_COIN_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_coin_inconsistency (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.h deleted file mode 100644 index f7a179ddf..000000000 --- a/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_COIN_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_COIN_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_COIN_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif diff --git a/src/auditor/taler-auditor-httpd_delete_generic.c b/src/auditor/taler-auditor-httpd_delete_generic.c index 2f2775cd1..f435454fe 100644 --- a/src/auditor/taler-auditor-httpd_delete_generic.c +++ b/src/auditor/taler-auditor-httpd_delete_generic.c @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -24,6 +22,7 @@ #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_delete_generic.h" MHD_RESULT @@ -33,64 +32,66 @@ TAH_delete_handler_generic ( void **connection_cls, const char *upload_data, size_t *upload_data_size, - const char *const args[]) { - enum GNUNET_DB_QueryStatus qs; - unsigned long long row_id; - - (void) connection_cls; - if (GNUNET_SYSERR == - TAH_plugin->preflight(TAH_plugin->cls)) { - GNUNET_break(0); - return TALER_MHD_reply_with_error(connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - if ((NULL == args[1]) || - (1 != sscanf(args[1], - "%llu", - &row_id))) { - GNUNET_break_op(0); - return TALER_MHD_reply_with_error(connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - } + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + unsigned long long row_id; + char dummy; - { + (void) connection_cls; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } - /* execute transaction */ - qs = TAH_plugin->delete_generic(TAH_plugin->cls, - rh->table, - row_id); + if ((NULL == args[1]) || + (1 != sscanf (args[1], + "%llu%c", + &row_id, + &dummy))) + { + GNUNET_break_op (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, + "no row id specified"); + } - switch (qs) { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break(0); - return TALER_MHD_reply_with_error(connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "db store failed"); - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break(0); - return TALER_MHD_reply_with_error(connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error(connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no delete executed"); - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - return TALER_MHD_reply_static(connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - } - GNUNET_break(0); - return MHD_NO; - } -}
\ No newline at end of file + /* execute transaction */ + qs = TAH_plugin->delete_generic (TAH_plugin->cls, + rh->table, + row_id); + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "db store failed"); + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, + "no delete executed"); + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + return TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + } + GNUNET_break (0); + return MHD_NO; +} diff --git a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.c deleted file mode 100644 index d83e701fb..000000000 --- a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include \ - "taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h" - -MHD_RESULT -TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_denomination_key_validity_withdraw_inconsistency ( - TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h deleted file mode 100644 index 32267bf64..000000000 --- a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef \ - SRC_TALER_AUDITOR_HTTPD_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_UPD_H -#define \ - SRC_TALER_AUDITOR_HTTPD_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-upd.c b/src/auditor/taler-auditor-httpd_denomination-pending-upd.c deleted file mode 100644 index 569cf87f0..000000000 --- a/src/auditor/taler-auditor-httpd_denomination-pending-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_denomination-pending-upd.h" - -MHD_RESULT -TAH_DENOMINATION_PENDING_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_denomination_pending (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-upd.h b/src/auditor/taler-auditor-httpd_denomination-pending-upd.h deleted file mode 100644 index 54800ad43..000000000 --- a/src/auditor/taler-auditor-httpd_denomination-pending-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_DENOMINATION_PENDING_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.c b/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.c deleted file mode 100644 index c903b86ee..000000000 --- a/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_denominations-without-sigs-upd.h" - -MHD_RESULT -TAH_DENOMINATIONS_WITHOUT_SIGS_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_denominations_without_sigs (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.h b/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.h deleted file mode 100644 index df2980ecf..000000000 --- a/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_DENOMINATIONS_WITHOUT_SIGS_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-upd.c b/src/auditor/taler-auditor-httpd_deposit-confirmation-upd.c deleted file mode 100644 index 6b2fc70ec..000000000 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_deposit-confirmation-upd.h" - -MHD_RESULT -TAH_DEPOSIT_CONFIRMATION_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_deposit_confirmations (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-upd.h b/src/auditor/taler-auditor-httpd_deposit-confirmation-upd.h deleted file mode 100644 index 764af917b..000000000 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_DEPOSIT_CONFIRMATION_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_DEPOSIT_CONFIRMATION_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_DEPOSIT_CONFIRMATION_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif diff --git a/src/auditor/taler-auditor-httpd_emergency-by-count-upd.c b/src/auditor/taler-auditor-httpd_emergency-by-count-upd.c deleted file mode 100644 index 37c92ab28..000000000 --- a/src/auditor/taler-auditor-httpd_emergency-by-count-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_emergency-by-count-upd.h" - -MHD_RESULT -TAH_EMERGENCY_BY_COUNT_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_emergency_by_count (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_emergency-by-count-upd.h b/src/auditor/taler-auditor-httpd_emergency-by-count-upd.h deleted file mode 100644 index 15be00a9c..000000000 --- a/src/auditor/taler-auditor-httpd_emergency-by-count-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_EMERGENCY_BY_COUNT_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_EMERGENCY_BY_COUNT_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_EMERGENCY_BY_COUNT_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif diff --git a/src/auditor/taler-auditor-httpd_emergency-upd.c b/src/auditor/taler-auditor-httpd_emergency-upd.c deleted file mode 100644 index eba466a9f..000000000 --- a/src/auditor/taler-auditor-httpd_emergency-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_emergency-upd.h" - -MHD_RESULT -TAH_EMERGENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_emergency (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_emergency-upd.h b/src/auditor/taler-auditor-httpd_emergency-upd.h deleted file mode 100644 index 3e9161bcf..000000000 --- a/src/auditor/taler-auditor-httpd_emergency-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_EMERGENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_EMERGENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_EMERGENCY_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_EMERGENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_fee-time-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_fee-time-inconsistency-upd.c deleted file mode 100644 index 3b4cea024..000000000 --- a/src/auditor/taler-auditor-httpd_fee-time-inconsistency-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_fee-time-inconsistency-upd.h" - -MHD_RESULT -TAH_FEE_TIME_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_fee_time_inconsistency (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_fee-time-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_fee-time-inconsistency-upd.h deleted file mode 100644 index 04aa5c90d..000000000 --- a/src/auditor/taler-auditor-httpd_fee-time-inconsistency-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_FEE_TIME_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_FEE_TIME_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_FEE_TIME_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_FEE_TIME_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.c deleted file mode 100644 index 3a2a7cdd3..000000000 --- a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_misattribution-in-inconsistency-upd.h" - -MHD_RESULT -TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_misattribution_in_inconsistency (TAH_plugin->cls, - &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.h deleted file mode 100644 index 966c5e1d7..000000000 --- a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_update (struct - TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_patch_generic_suppressed.c b/src/auditor/taler-auditor-httpd_patch_generic_suppressed.c index f58635c5b..841f7a824 100644 --- a/src/auditor/taler-auditor-httpd_patch_generic_suppressed.c +++ b/src/auditor/taler-auditor-httpd_patch_generic_suppressed.c @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -24,7 +22,7 @@ #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_amount-arithmetic-inconsistency-upd.h" +#include "taler-auditor-httpd_patch_generic_suppressed.h" MHD_RESULT diff --git a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.c b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.c deleted file mode 100644 index 10024be5e..000000000 --- a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h" - -MHD_RESULT -TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_purse_not_closed_inconsistencies (TAH_plugin->cls, - &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h deleted file mode 100644 index cd0b3f602..000000000 --- a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_PURSE_NOT_CLOSED_INCONSISTENCIES_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_PURSE_NOT_CLOSED_INCONSISTENCIES_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_update (struct - TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_PURSE_NOT_CLOSED_INCONSISTENCIES_UPD_H diff --git a/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.c b/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.c deleted file mode 100644 index edcb3b7a3..000000000 --- a/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_refreshes-hanging-upd.h" - -MHD_RESULT -TAH_REFRESHES_HANGING_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_refreshes_hanging (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.h b/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.h deleted file mode 100644 index ffc241c55..000000000 --- a/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_REFRESHES_HANGING_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_REFRESHES_HANGING_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_REFRESHES_HANGING_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_REFRESHES_HANGING_UPD_H diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.c deleted file mode 100644 index d72915b06..000000000 --- a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h" - -MHD_RESULT -TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_reserve_balance_insufficient_inconsistency ( - TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h deleted file mode 100644 index 2b0df97dc..000000000 --- a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_update (struct - TAH_RequestHandler - *rh, - struct - MHD_Connection * - connection, - void ** - connection_cls, - const char * - upload_data, - size_t * - upload_data_size, - const char *const - args[]); - -#endif \ - // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c index 39d13b2d6..689e0e0e4 100644 --- a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -26,38 +24,32 @@ #include "taler-auditor-httpd.h" #include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h" + /** -* Add reserve-balance-summary-wrong-inconsistency to the list. -* -* @param[in,out] cls a `json_t *` array to extend -* @param serial_id location of the @a dc in the database -* @param dc struct of inconsistencies -* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating -*/ + * Add reserve-balance-summary-wrong-inconsistency to the list. + * + * @param[in,out] cls a `json_t *` array to extend + * @param dc struct of inconsistencies + * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating + */ static enum GNUNET_GenericReturnValue process_reserve_balance_summary_wrong_inconsistency ( void *cls, - uint64_t serial_id, const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc) { json_t *list = cls; json_t *obj; obj = GNUNET_JSON_PACK ( - - GNUNET_JSON_pack_int64 ("row_id", serial_id), + GNUNET_JSON_pack_int64 ("row_id", dc->row_id), GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub), TALER_JSON_pack_amount ("exchange_amount", &dc->exchange_amount), TALER_JSON_pack_amount ("auditor_amount", &dc->auditor_amount), GNUNET_JSON_pack_bool ("suppressed", dc->suppressed) - - ); GNUNET_break (0 == json_array_append_new (list, obj)); - - return GNUNET_OK; } @@ -73,6 +65,9 @@ TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_get ( { json_t *ja; enum GNUNET_DB_QueryStatus qs; + int64_t limit = -20; + uint64_t offset; + bool return_suppressed = false; (void) rh; (void) connection_cls; @@ -87,35 +82,28 @@ TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_get ( TALER_EC_GENERIC_DB_SETUP_FAILED, NULL); } - ja = json_array (); - GNUNET_break (NULL != ja); - - int64_t limit = -20; - uint64_t offset; - TALER_MHD_parse_request_snumber (connection, "limit", &limit); - if (limit < 0) offset = INT64_MAX; else offset = 0; - TALER_MHD_parse_request_number (connection, "offset", &offset); - - bool return_suppressed = false; - const char *ret_s = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "return_suppressed"); - - if (ret_s != NULL && strcmp (ret_s, "true") == 0) { - return_suppressed = true; + const char *ret_s = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "return_suppressed"); + + if (ret_s != NULL && strcmp (ret_s, "true") == 0) + { + return_suppressed = true; + } } - + ja = json_array (); + GNUNET_break (NULL != ja); qs = TAH_plugin->get_reserve_balance_summary_wrong_inconsistency ( TAH_plugin->cls, limit, @@ -130,10 +118,11 @@ TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_get ( json_decref (ja); TALER_LOG_WARNING ( "Failed to handle GET /reserve-balance-summary-wrong-inconsistency"); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - "reserve-balance-summary-wrong-inconsistency"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "reserve-balance-summary-wrong-inconsistency"); } return TALER_MHD_REPLY_JSON_PACK ( connection, diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.c deleted file mode 100644 index aa20c9ca7..000000000 --- a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h" - -MHD_RESULT -TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_reserve_balance_summary_wrong_inconsistency ( - TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h deleted file mode 100644 index 939b4e01a..000000000 --- a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef \ - SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_UPD_H -#define \ - SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_update (struct - TAH_RequestHandler - *rh, - struct - MHD_Connection * - connection, - void ** - connection_cls, - const char * - upload_data, - size_t * - upload_data_size, - const char * - const args[]); - -#endif \ - // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c index 0ec7b82ba..e8648b4b2 100644 --- a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c @@ -55,8 +55,8 @@ process_reserve_in_inconsistency ( &dc->reserve_pub), TALER_JSON_pack_time_abs_human ("timestamp", dc->timestamp), - GNUNET_JSON_pack_string ("account", - dc->account), + TALER_JSON_pack_full_payto ("account", + dc->account), GNUNET_JSON_pack_string ("diagnostic", dc->diagnostic), GNUNET_JSON_pack_bool ("suppressed", diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.c deleted file mode 100644 index c4707bb15..000000000 --- a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_reserve-in-inconsistency-upd.h" - -MHD_RESULT -TAH_RESERVE_IN_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_reserve_in_inconsistency (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.h deleted file mode 100644 index 0f66574df..000000000 --- a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_RESERVE_IN_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.c deleted file mode 100644 index 586b15cdc..000000000 --- a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h" - -MHD_RESULT -TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_reserve_not_closed_inconsistency (TAH_plugin->cls, - &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h deleted file mode 100644 index 7a8fa6d4e..000000000 --- a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_update (struct - TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_reserves-get.c b/src/auditor/taler-auditor-httpd_reserves-get.c index 901557475..4808534e4 100644 --- a/src/auditor/taler-auditor-httpd_reserves-get.c +++ b/src/auditor/taler-auditor-httpd_reserves-get.c @@ -45,16 +45,26 @@ process_reserves ( obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_int64 ("auditor_reserves_rowid", dc->auditor_reserves_rowid), - GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub), - TALER_JSON_pack_amount ("reserve_balance", &dc->reserve_balance), - TALER_JSON_pack_amount ("reserve_loss", &dc->reserve_loss), - TALER_JSON_pack_amount ("withdraw_fee_balance", &dc->withdraw_fee_balance), - TALER_JSON_pack_amount ("close_fee_balance", &dc->close_fee_balance), - TALER_JSON_pack_amount ("purse_fee_balance", &dc->purse_fee_balance), - TALER_JSON_pack_amount ("open_fee_balance", &dc->open_fee_balance), - TALER_JSON_pack_amount ("history_fee_balance", &dc->history_fee_balance), - TALER_JSON_pack_time_abs_human ("expiration_date", dc->expiration_date), - GNUNET_JSON_pack_string ("origin_account", dc->origin_account) + GNUNET_JSON_pack_data_auto ("reserve_pub", + &dc->reserve_pub), + TALER_JSON_pack_amount ("reserve_balance", + &dc->reserve_balance), + TALER_JSON_pack_amount ("reserve_loss", + &dc->reserve_loss), + TALER_JSON_pack_amount ("withdraw_fee_balance", + &dc->withdraw_fee_balance), + TALER_JSON_pack_amount ("close_fee_balance", + &dc->close_fee_balance), + TALER_JSON_pack_amount ("purse_fee_balance", + &dc->purse_fee_balance), + TALER_JSON_pack_amount ("open_fee_balance", + &dc->open_fee_balance), + TALER_JSON_pack_amount ("history_fee_balance", + &dc->history_fee_balance), + TALER_JSON_pack_time_abs_human ("expiration_date", + dc->expiration_date), + TALER_JSON_pack_full_payto ("origin_account", + dc->origin_account) ); GNUNET_break (0 == json_array_append_new (list, diff --git a/src/auditor/taler-auditor-httpd_row-inconsistency-get.c b/src/auditor/taler-auditor-httpd_row-inconsistency-get.c index f1120b674..05bd21280 100644 --- a/src/auditor/taler-auditor-httpd_row-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_row-inconsistency-get.c @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -24,9 +22,9 @@ #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-auditor-httpd.h" - #include "taler-auditor-httpd_row-inconsistency-get.h" + /** * Add deposit confirmation to the list. * @@ -57,7 +55,6 @@ add_row_inconsistency ( GNUNET_break (0 == json_array_append_new (list, obj)); - return GNUNET_OK; } @@ -73,6 +70,9 @@ TAH_ROW_INCONSISTENCY_handler_get ( { json_t *ja; enum GNUNET_DB_QueryStatus qs; + int64_t limit = -20; + uint64_t offset; + bool return_suppressed = false; (void) rh; (void) connection_cls; @@ -87,34 +87,28 @@ TAH_ROW_INCONSISTENCY_handler_get ( TALER_EC_GENERIC_DB_SETUP_FAILED, NULL); } - ja = json_array (); - GNUNET_break (NULL != ja); - - int64_t limit = -20; - uint64_t offset; - TALER_MHD_parse_request_snumber (connection, "limit", &limit); - if (limit < 0) offset = INT64_MAX; else offset = 0; - TALER_MHD_parse_request_number (connection, "offset", &offset); - - bool return_suppressed = false; - const char *ret_s = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "return_suppressed"); - if (ret_s != NULL && strcmp (ret_s, "true") == 0) { - return_suppressed = true; + const char *ret_s = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "return_suppressed"); + if (ret_s != NULL && strcmp (ret_s, "true") == 0) + { + return_suppressed = true; + } } + ja = json_array (); + GNUNET_break (NULL != ja); qs = TAH_plugin->get_row_inconsistency ( TAH_plugin->cls, limit, @@ -122,7 +116,6 @@ TAH_ROW_INCONSISTENCY_handler_get ( return_suppressed, &add_row_inconsistency, ja); - if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); diff --git a/src/auditor/taler-auditor-httpd_row-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_row-inconsistency-upd.c deleted file mode 100644 index 405af1414..000000000 --- a/src/auditor/taler-auditor-httpd_row-inconsistency-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_row-inconsistency-upd.h" - -MHD_RESULT -TAH_ROW_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_row_inconsistency (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_row-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_row-inconsistency-upd.h deleted file mode 100644 index 9b29d1e0d..000000000 --- a/src/auditor/taler-auditor-httpd_row-inconsistency-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_ROW_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_ROW_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_ROW_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_ROW_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.c b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.c deleted file mode 100644 index 515b2ea10..000000000 --- a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_row-minor-inconsistencies-upd.h" - -MHD_RESULT -TAH_ROW_MINOR_INCONSISTENCIES_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_row_minor_inconsistencies (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.h b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.h deleted file mode 100644 index 8ff1fd16d..000000000 --- a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_ROW_MINOR_INCONSISTENCIES_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_UPD_H diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.c deleted file mode 100644 index de3b90c2d..000000000 --- a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_wire-format-inconsistency-upd.h" - -MHD_RESULT -TAH_WIRE_FORMAT_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_wire_format_inconsistency (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.h deleted file mode 100644 index 4ebf5b5ec..000000000 --- a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_WIRE_FORMAT_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c index c7cddceb2..be0acf477 100644 --- a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c @@ -43,8 +43,8 @@ process_wire_out_inconsistency ( obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_int64 ("row_id", dc->row_id), - GNUNET_JSON_pack_string ("destination_account", - dc->destination_account), + TALER_JSON_pack_full_payto ("destination_account", + dc->destination_account), GNUNET_JSON_pack_int64 ("wire_out_row_id", dc->wire_out_row_id), GNUNET_JSON_pack_string ("diagnostic", diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.c deleted file mode 100644 index 0f889f737..000000000 --- a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <jansson.h> -#include <microhttpd.h> -#include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" -#include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_wire-out-inconsistency-upd.h" - -MHD_RESULT -TAH_WIRE_OUT_INCONSISTENCY_handler_update ( - struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]) -{ - enum GNUNET_DB_QueryStatus qs; - - if (GNUNET_SYSERR == - TAH_plugin->preflight (TAH_plugin->cls)) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - } - - uint64_t row_id; - - if (args[2] != NULL) - row_id = atoi (args[2]); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no row id specified"); - - - struct TALER_AUDITORDB_Generic_Update gu; - - gu.row_id = row_id; - - struct GNUNET_JSON_Specification spec[] = { - - // GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), - GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), - - GNUNET_JSON_spec_end () - }; - - json_t *json; - - (void) rh; - (void) connection_cls; - (void) upload_data; - (void) upload_data_size; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); - if (GNUNET_SYSERR == res) - return MHD_NO; - if ((GNUNET_NO == res) || - (NULL == json)) - return MHD_YES; - res = TALER_MHD_parse_json_data (connection, - json, - spec); - if (GNUNET_SYSERR == res) - { - json_decref (json); - return MHD_NO; /* hard failure */ - } - if (GNUNET_NO == res) - { - json_decref (json); - return MHD_YES; /* failure */ - } - } - - /* execute transaction */ - qs = TAH_plugin->update_wire_out_inconsistency (TAH_plugin->cls, &gu); - - GNUNET_JSON_parse_free (spec); - json_decref (json); - - MHD_RESULT ret = MHD_NO; - - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_STORE_FAILED, - "update_account"); - break; - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "unexpected serialization problem"); - break; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_AUDITOR_RESOURCE_NOT_FOUND, - "no updates executed"); - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - ret = TALER_MHD_reply_static (connection, - MHD_HTTP_NO_CONTENT, - NULL, - NULL, - 0); - break; - } - - return ret; -} diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.h deleted file mode 100644 index 6b48d6a0e..000000000 --- a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_UPD_H -#define SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_UPD_H - - -#include <microhttpd.h> -#include "taler-auditor-httpd.h" - -MHD_RESULT -TAH_WIRE_OUT_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, - struct MHD_Connection * - connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size, - const char *const args[]); - -#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_UPD_H diff --git a/src/auditor/taler-auditor-sync.c b/src/auditor/taler-auditor-sync.c index e49eb8047..d7f45e384 100644 --- a/src/auditor/taler-auditor-sync.c +++ b/src/auditor/taler-auditor-sync.c @@ -523,13 +523,15 @@ static void setup (struct GNUNET_CONFIGURATION_Handle *src_cfg, struct GNUNET_CONFIGURATION_Handle *dst_cfg) { - src = TALER_EXCHANGEDB_plugin_load (src_cfg); + src = TALER_EXCHANGEDB_plugin_load (src_cfg, + false); if (NULL == src) { global_ret = EXIT_NOTINSTALLED; return; } - dst = TALER_EXCHANGEDB_plugin_load (dst_cfg); + dst = TALER_EXCHANGEDB_plugin_load (dst_cfg, + false); if (NULL == dst) { global_ret = EXIT_NOTINSTALLED; diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index 22ba23b4c..f88665b9a 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c @@ -362,7 +362,7 @@ struct WireCheckContext /** * Target account details of the receiver. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Execution time of the wire transfer. @@ -778,8 +778,8 @@ wire_transfer_information_cb ( void *cls, uint64_t rowid, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *account_pay_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto account_pay_uri, + const struct TALER_FullPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp exec_time, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_DenominationPublicKey *denom_pub, @@ -794,13 +794,13 @@ wire_transfer_information_cb ( struct TALER_EXCHANGEDB_TransactionList *tl; struct TALER_CoinPublicInfo coin; enum GNUNET_DB_QueryStatus qs; - struct TALER_PaytoHashP hpt; + struct TALER_FullPaytoHashP hpt; uint64_t etag_out; if (0 > wcc->qs) return; - TALER_payto_hash (account_pay_uri, - &hpt); + TALER_full_payto_hash (account_pay_uri, + &hpt); if (0 != GNUNET_memcmp (&hpt, h_payto)) @@ -998,8 +998,8 @@ wire_transfer_information_cb ( } } /* Check other details of wire transfer match */ - if (0 != strcmp (account_pay_uri, - wcc->payto_uri)) + if (0 != TALER_full_payto_cmp (account_pay_uri, + wcc->payto_uri)) { qs = report_row_inconsistency ("aggregation", rowid, @@ -1189,7 +1189,7 @@ check_wire_out_cb (void *cls, uint64_t rowid, struct GNUNET_TIME_Timestamp date, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_Amount *amount) { struct AggregationContext *ac = cls; @@ -1209,7 +1209,7 @@ check_wire_out_cb (void *cls, TALER_B2S (wtid), TALER_amount2s (amount), GNUNET_TIME_timestamp2s (date)); - if (NULL == (method = TALER_payto_get_method (payto_uri))) + if (NULL == (method = TALER_payto_get_method (payto_uri.full_payto))) { qs = report_row_inconsistency ("wire_out", rowid, @@ -1341,7 +1341,7 @@ check_wire_out_cb (void *cls, { struct TALER_AUDITORDB_WireOutInconsistency woi = { - .destination_account = (char *) payto_uri, + .destination_account = payto_uri, .diagnostic = "aggregated amount does not match expectations", .wire_out_row_id = rowid, .expected = final_amount, @@ -1418,6 +1418,7 @@ analyze_aggregations (void *cls) TALER_ARL_GET_AB (aggregation_total_wire_out_delta_plus), TALER_ARL_GET_AB (aggregation_total_wire_out_delta_minus), TALER_ARL_GET_AB (aggregation_total_coin_delta_plus), + TALER_ARL_GET_AB (aggregation_total_coin_delta_minus), NULL); if (0 > qs) { @@ -1468,6 +1469,7 @@ analyze_aggregations (void *cls) TALER_ARL_SET_AB (aggregation_total_wire_out_delta_plus), TALER_ARL_SET_AB (aggregation_total_wire_out_delta_minus), TALER_ARL_SET_AB (aggregation_total_coin_delta_plus), + TALER_ARL_SET_AB (aggregation_total_coin_delta_minus), NULL); if (0 > qs) { @@ -1485,6 +1487,7 @@ analyze_aggregations (void *cls) TALER_ARL_SET_AB (aggregation_total_wire_out_delta_plus), TALER_ARL_SET_AB (aggregation_total_wire_out_delta_minus), TALER_ARL_SET_AB (aggregation_total_coin_delta_plus), + TALER_ARL_SET_AB (aggregation_total_coin_delta_minus), NULL); if (0 > qs) { @@ -1661,10 +1664,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1673,7 +1672,6 @@ main (int argc, options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index 6cd3aa243..8654d802e 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -227,11 +227,6 @@ report_emergency_by_amount ( const struct TALER_Amount *risk, const struct TALER_Amount *loss) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Reporting emergency on denomination `%s' over loss of %s\n", - GNUNET_h2s (&issue->denom_hash.hash), - TALER_amount2s (loss)); - enum GNUNET_DB_QueryStatus qs; struct TALER_AUDITORDB_Emergency emergency = { .denom_loss = *loss, @@ -242,10 +237,13 @@ report_emergency_by_amount ( .value = *&issue->value }; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Reporting emergency on denomination `%s' over loss of %s\n", + GNUNET_h2s (&issue->denom_hash.hash), + TALER_amount2s (loss)); qs = TALER_ARL_adb->insert_emergency ( TALER_ARL_adb->cls, &emergency); - if (qs < 0) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -3131,10 +3129,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -3143,7 +3137,6 @@ main (int argc, options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c index 25bb54b59..dbe20487c 100644 --- a/src/auditor/taler-helper-auditor-deposits.c +++ b/src/auditor/taler-helper-auditor-deposits.c @@ -139,8 +139,10 @@ test_dc (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Deleting matching deposit confirmation %llu\n", (unsigned long long) dc->row_id); - qs = TALER_ARL_adb->delete_deposit_confirmation (TALER_ARL_adb->cls, - dc->row_id); + qs = TALER_ARL_adb->delete_generic ( + TALER_ARL_adb->cls, + TALER_AUDITORDB_DEPOSIT_CONFIRMATION, + dc->row_id); if (qs < 0) { GNUNET_break (0); /* DB error, complain */ @@ -404,10 +406,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -417,7 +415,6 @@ main (int argc, options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c index f9988fb52..2ad99aacf 100644 --- a/src/auditor/taler-helper-auditor-purses.c +++ b/src/auditor/taler-helper-auditor-purses.c @@ -722,7 +722,7 @@ handle_purse_merged ( TALER_ARL_USE_PP (purse_merges_serial_id) = rowid + 1; { - char *reserve_url; + struct TALER_NormalizedPayto reserve_url; reserve_url = TALER_reserve_make_payto (NULL == partner_base_url @@ -743,7 +743,7 @@ handle_purse_merged ( .operation_specific_pub = merge_pub->eddsa_pub }; - GNUNET_free (reserve_url); + GNUNET_free (reserve_url.normalized_payto); qs = TALER_ARL_adb->insert_bad_sig_losses ( TALER_ARL_adb->cls, &bsl); @@ -758,7 +758,7 @@ handle_purse_merged ( amount); return GNUNET_OK; } - GNUNET_free (reserve_url); + GNUNET_free (reserve_url.normalized_payto); } ps = setup_purse (pc, @@ -1592,10 +1592,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1604,7 +1600,6 @@ main (int argc, options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index 41ce9ff5b..c51c63416 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -279,7 +279,7 @@ struct ReserveSummary /** * Which account did originally put money into the reserve? */ - char *sender_account; + struct TALER_FullPayto sender_account; /** * Did we have a previous reserve info? Used to decide between @@ -468,7 +468,7 @@ handle_reserve_in ( uint64_t rowid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *credit, - const char *sender_account_details, + const struct TALER_FullPayto sender_account_details, uint64_t wire_reference, struct GNUNET_TIME_Timestamp execution_date) { @@ -487,8 +487,9 @@ handle_reserve_in ( GNUNET_break (0); return GNUNET_SYSERR; } - if (NULL == rs->sender_account) - rs->sender_account = GNUNET_strdup (sender_account_details); + if (NULL == rs->sender_account.full_payto) + rs->sender_account.full_payto + = GNUNET_strdup (sender_account_details.full_payto); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Additional incoming wire transfer for reserve `%s' of %s\n", TALER_B2S (reserve_pub), @@ -580,8 +581,7 @@ handle_reserve_out ( <, execution_date)) { - struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency dkvwi = - { + struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency dkvwi ={ .problem_row_id = rowid, .execution_date = execution_date.abs_time, .denompub_h = *&h_denom_pub, @@ -854,7 +854,7 @@ handle_recoup_by_reserve ( * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -get_closing_fee (const char *receiver_account, +get_closing_fee (const struct TALER_FullPayto receiver_account, struct GNUNET_TIME_Timestamp atime, struct TALER_Amount *fee) { @@ -864,7 +864,7 @@ get_closing_fee (const char *receiver_account, struct TALER_WireFeeSet fees; char *method; - method = TALER_payto_get_method (receiver_account); + method = TALER_payto_get_method (receiver_account.full_payto); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Method is `%s'\n", method); @@ -1008,7 +1008,7 @@ handle_reserve_closed ( const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, - const char *receiver_account, + const struct TALER_FullPayto receiver_account, const struct TALER_WireTransferIdentifierRawP *transfer_details, uint64_t close_request_row) { @@ -1067,7 +1067,7 @@ handle_reserve_closed ( struct GNUNET_TIME_Timestamp request_timestamp; struct TALER_Amount close_balance; struct TALER_Amount close_fee; - char *payto_uri; + struct TALER_FullPayto payto_uri; enum GNUNET_DB_QueryStatus qs; qs = TALER_ARL_edb->select_reserve_close_request_info ( @@ -1089,10 +1089,10 @@ handle_reserve_closed ( } else { - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; - TALER_payto_hash (payto_uri, - &h_payto); + TALER_full_payto_hash (payto_uri, + &h_payto); if (GNUNET_OK != TALER_wallet_reserve_close_verify ( request_timestamp, @@ -1115,7 +1115,7 @@ handle_reserve_closed ( { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); rc->qs = qs; - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); return GNUNET_SYSERR; } TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss), @@ -1123,8 +1123,8 @@ handle_reserve_closed ( amount_with_fee); } } - if ( (NULL == payto_uri) && - (NULL == rs->sender_account) ) + if ( (NULL == payto_uri.full_payto) && + (NULL == rs->sender_account.full_payto) ) { GNUNET_break (! rs->had_ri); report_row_inconsistency ("reserves_close", @@ -1133,11 +1133,11 @@ handle_reserve_closed ( if (global_qs < 0) return GNUNET_SYSERR; } - if (NULL == payto_uri) + if (NULL == payto_uri.full_payto) { - if ((NULL == rs->sender_account) || - (0 != strcmp (rs->sender_account, - receiver_account))) + if ((NULL == rs->sender_account.full_payto) || + (0 != TALER_full_payto_cmp (rs->sender_account, + receiver_account))) { report_row_inconsistency ("reserves_close", rowid, @@ -1148,24 +1148,24 @@ handle_reserve_closed ( } else { - if (0 != strcmp (payto_uri, - receiver_account)) + if (0 != TALER_full_payto_cmp (payto_uri, + receiver_account)) { report_row_inconsistency ("reserves_close", rowid, "target account does not match origin account"); if (global_qs < 0) { - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); return GNUNET_SYSERR; } } } - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); } else { - if (NULL == rs->sender_account) + if (NULL == rs->sender_account.full_payto) { GNUNET_break (! rs->had_ri); report_row_inconsistency ("reserves_close", @@ -1174,8 +1174,8 @@ handle_reserve_closed ( if (global_qs < 0) return GNUNET_SYSERR; } - else if (0 != strcmp (rs->sender_account, - receiver_account)) + else if (0 != TALER_full_payto_cmp (rs->sender_account, + receiver_account)) { report_row_inconsistency ("reserves_close", rowid, @@ -1528,7 +1528,7 @@ verify_reserve_balance (void *cls, /* Reserve is expired */ struct TALER_Amount cfee; - if ( (NULL != rs->sender_account) && + if ( (NULL != rs->sender_account.full_payto) && (GNUNET_OK == get_closing_fee (rs->sender_account, rs->a_expiration_date, @@ -1542,7 +1542,7 @@ verify_reserve_balance (void *cls, .reserve_pub = rs->reserve_pub, .expiration_time = rs->a_expiration_date.abs_time, .balance = nbalance, - .diagnostic = rs->sender_account + .diagnostic = rs->sender_account.full_payto }; /* remaining balance (according to us) exceeds closing fee */ @@ -1706,25 +1706,25 @@ verify_reserve_balance (void *cls, GNUNET_CONTAINER_multihashmap_remove (rc->reserves, key, rs)); - GNUNET_free (rs->sender_account); + GNUNET_free (rs->sender_account.full_payto); GNUNET_free (rs); return ret; } #define CHECK_DB() do { \ - if (qs < 0) { \ - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); \ - return qs; \ - } \ - if (global_qs < 0) { \ - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == global_qs); \ - return global_qs; \ - } \ - if (rc.qs < 0) { \ - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == rc.qs); \ - return rc.qs; \ - } \ + if (qs < 0) { \ + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); \ + return qs; \ + } \ + if (global_qs < 0) { \ + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == global_qs); \ + return global_qs; \ + } \ + if (rc.qs < 0) { \ + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == rc.qs); \ + return rc.qs; \ + } \ } while (0) @@ -2129,10 +2129,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -2141,7 +2137,6 @@ main (int argc, options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/taler-helper-auditor-transfer.c b/src/auditor/taler-helper-auditor-transfer.c index e75982742..e2ab47ffa 100644 --- a/src/auditor/taler-helper-auditor-transfer.c +++ b/src/auditor/taler-helper-auditor-transfer.c @@ -121,7 +121,7 @@ import_wire_missing_cb ( void *cls, uint64_t batch_deposit_serial_id, const struct TALER_Amount *total_amount, - const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_FullPaytoHashP *wire_target_h_payto, struct GNUNET_TIME_Timestamp deadline) { struct ImportMissingWireContext *wc = cls; @@ -536,10 +536,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -549,7 +545,6 @@ main (int argc, options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/taler-helper-auditor-wire-credit.c b/src/auditor/taler-helper-auditor-wire-credit.c index 487d26a95..d070b055f 100644 --- a/src/auditor/taler-helper-auditor-wire-credit.c +++ b/src/auditor/taler-helper-auditor-wire-credit.c @@ -445,16 +445,14 @@ reserve_in_cb (void *cls, uint64_t rowid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *credit, - const char *sender_account_details, + const struct TALER_FullPayto sender_account_details, uint64_t wire_reference, struct GNUNET_TIME_Timestamp execution_date) { struct WireAccount *wa = cls; struct ReserveInInfo *rii; size_t slen; - char *snp; - snp = TALER_payto_normalize (sender_account_details); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Analyzing exchange wire IN (%llu) at %s of %s with reserve_pub %s\n", (unsigned long long) rowid, @@ -464,18 +462,17 @@ reserve_in_cb (void *cls, TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_wire_in), &TALER_ARL_USE_AB (total_wire_in), credit); - slen = strlen (snp) + 1; + slen = strlen (sender_account_details.full_payto) + 1; rii = GNUNET_malloc (sizeof (struct ReserveInInfo) + slen); rii->rowid = rowid; rii->credit_details.type = TALER_BANK_CT_RESERVE; rii->credit_details.amount = *credit; rii->credit_details.execution_date = execution_date; rii->credit_details.details.reserve.reserve_pub = *reserve_pub; - rii->credit_details.debit_account_uri = (const char *) &rii[1]; + rii->credit_details.debit_account_uri.full_payto = (const char *) &rii[1]; GNUNET_memcpy (&rii[1], - snp, + sender_account_details.full_payto, slen); - GNUNET_free (snp); GNUNET_CRYPTO_hash (&wire_reference, sizeof (uint64_t), &rii->row_off_hash); @@ -530,7 +527,7 @@ complain_in_not_found (void *cls, struct TALER_AUDITORDB_ReserveInInconsistency riiDb = { .bank_row_id = rii->rowid, .diagnostic = "incoming wire transfer claimed by exchange not found", - .account = (char *) wa->ai->section_name, + .account = { .full_payto = (const char *) wa->ai->section_name }, .amount_exchange_expected = rii->credit_details.amount, .amount_wired = zero, .reserve_pub = rii->credit_details.details.reserve.reserve_pub, @@ -731,11 +728,13 @@ analyze_credit ( } { - char *np; + struct TALER_NormalizedPayto np; + struct TALER_NormalizedPayto np2; np = TALER_payto_normalize (credit_details->debit_account_uri); - if (0 != strcasecmp (np, - rii->credit_details.debit_account_uri)) + np2 = TALER_payto_normalize (rii->credit_details.debit_account_uri); + if (0 != TALER_normalized_payto_cmp (np, + np2)) { struct TALER_AUDITORDB_MisattributionInInconsistency mii = { .reserve_pub = rii->credit_details.details.reserve.reserve_pub, @@ -753,14 +752,16 @@ analyze_credit ( { global_qs = qs; GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - GNUNET_free (np); + GNUNET_free (np.normalized_payto); + GNUNET_free (np2.normalized_payto); return false; } TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_misattribution_in), &TALER_ARL_USE_AB (total_misattribution_in), &rii->credit_details.amount); } - GNUNET_free (np); + GNUNET_free (np.normalized_payto); + GNUNET_free (np2.normalized_payto); } if (GNUNET_TIME_timestamp_cmp (credit_details->execution_date, !=, @@ -1217,10 +1218,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1230,7 +1227,6 @@ main (int argc, options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/taler-helper-auditor-wire-debit.c b/src/auditor/taler-helper-auditor-wire-debit.c index fde369182..f9c5be5c4 100644 --- a/src/auditor/taler-helper-auditor-wire-debit.c +++ b/src/auditor/taler-helper-auditor-wire-debit.c @@ -54,24 +54,24 @@ * created by imperfect clock synchronization and network delay. */ #define TIME_TOLERANCE GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_MINUTES, \ - 15) + GNUNET_TIME_UNIT_MINUTES, \ + 15) /** * How long do we try to long-poll for bank wire transfers? */ #define MAX_LONGPOLL_DELAY GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_HOURS, \ - 1) + GNUNET_TIME_UNIT_HOURS, \ + 1) /** * How long do we wait between polling for bank wire transfers at the minimum? */ #define MIN_LONGPOLL_DELAY GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_MINUTES, \ - 5) + GNUNET_TIME_UNIT_MINUTES, \ + 5) /** @@ -167,7 +167,7 @@ struct ReserveClosure /** * Target account where the money was sent. */ - char *receiver_account; + struct TALER_FullPayto receiver_account; /** * Wire transfer subject used. @@ -352,7 +352,7 @@ free_rc (void *cls, GNUNET_CONTAINER_multihashmap_remove (reserve_closures, key, rc)); - GNUNET_free (rc->receiver_account); + GNUNET_free (rc->receiver_account.full_payto); GNUNET_free (rc); return GNUNET_OK; } @@ -444,9 +444,9 @@ check_pending_rc (void *cls, (void) cls; (void) key; - TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_closure_amount_lag), - &TALER_ARL_USE_AB (total_closure_amount_lag), - &rc->amount); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Missing wire transfer for closed reserve with balance %s\n", + TALER_amount2s (&rc->amount)); if (! TALER_amount_is_zero (&rc->amount)) { struct TALER_AUDITORDB_ClosureLags cl = { @@ -458,6 +458,8 @@ check_pending_rc (void *cls, }; enum GNUNET_DB_QueryStatus qs; + /* FIXME: where do we *undo* this if the wire transfer is + found later? */ qs = TALER_ARL_adb->insert_auditor_closure_lags ( TALER_ARL_adb->cls, &cl); @@ -467,10 +469,12 @@ check_pending_rc (void *cls, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return GNUNET_SYSERR; } + /* FIXME: where do we *undo* this if the wire transfer is + found later? */ + TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_closure_amount_lag), + &TALER_ARL_USE_AB (total_closure_amount_lag), + &rc->amount); } - TALER_ARL_USE_PP (wire_reserve_close_id) - = GNUNET_MIN (TALER_ARL_USE_PP (wire_reserve_close_id), - rc->rowid); return GNUNET_OK; } @@ -484,22 +488,25 @@ check_pending_rc (void *cls, * @param[out] key set to the key */ static void -hash_rc (const char *receiver_account, +hash_rc (const struct TALER_FullPayto receiver_account, const struct TALER_WireTransferIdentifierRawP *wtid, struct GNUNET_HashCode *key) { - size_t slen = strlen (receiver_account); + struct TALER_NormalizedPayto npto + = TALER_payto_normalize (receiver_account); + size_t slen = strlen (npto.normalized_payto); char buf[sizeof (struct TALER_WireTransferIdentifierRawP) + slen]; GNUNET_memcpy (buf, wtid, sizeof (*wtid)); GNUNET_memcpy (&buf[sizeof (*wtid)], - receiver_account, + npto.normalized_payto, slen); GNUNET_CRYPTO_hash (buf, sizeof (buf), key); + GNUNET_free (npto.normalized_payto); } @@ -520,6 +527,9 @@ begin_transaction (void); static void commit (enum GNUNET_DB_QueryStatus qs) { + GNUNET_CONTAINER_multihashmap_iterate (reserve_closures, + &check_pending_rc, + NULL); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Transaction logic ended with status %d\n", qs); @@ -581,9 +591,6 @@ commit (enum GNUNET_DB_QueryStatus qs) (unsigned long long) wa->last_wire_out_serial_id, wa->ai->section_name); } - GNUNET_CONTAINER_multihashmap_iterate (reserve_closures, - &check_pending_rc, - NULL); qs = TALER_ARL_adb->update_auditor_progress ( TALER_ARL_adb->cls, TALER_ARL_SET_PP (wire_reserve_close_id), @@ -717,8 +724,8 @@ check_rc_matches (void *cls, if ((0 == GNUNET_memcmp (&cmx->roi->details.wtid, &rc->wtid)) && - (0 == strcasecmp (rc->receiver_account, - cmx->roi->details.credit_account_uri)) && + (0 == TALER_full_payto_cmp (rc->receiver_account, + cmx->roi->details.credit_account_uri)) && (0 == TALER_amount_cmp (&rc->amount, &cmx->roi->details.amount))) { @@ -785,7 +792,7 @@ check_reported_inconsistency (struct ReserveOutInfo *roi) char diag[MAX_DIAG_LEN]; struct TALER_AUDITORDB_WireOutInconsistency woi = { .wire_out_row_id = roi->details.serial_id, - .destination_account = (char *) roi->details.credit_account_uri, + .destination_account = roi->details.credit_account_uri, .diagnostic = diag, .expected = roi->details.amount, .claimed = zero, @@ -808,7 +815,7 @@ check_reported_inconsistency (struct ReserveOutInfo *roi) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Deletion of wire out inconsistency %llu (%s, %s, %s) failed: not reported missing!\n", (unsigned long long) roi->details.serial_id, - roi->details.credit_account_uri, + roi->details.credit_account_uri.full_payto, diag, TALER_amount2s (&roi->details.amount)); return GNUNET_NO; @@ -834,7 +841,7 @@ check_profit_drain (struct ReserveOutInfo *roi) enum GNUNET_DB_QueryStatus qs; uint64_t serial; char *account_section; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_TIME_Timestamp request_timestamp; struct TALER_Amount amount; struct TALER_MasterSignatureP master_sig; @@ -868,7 +875,7 @@ check_profit_drain (struct ReserveOutInfo *roi) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Profit drain of %s to %s found!\n", TALER_amount2s (&amount), - payto_uri); + payto_uri.full_payto); if (GNUNET_OK != TALER_exchange_offline_profit_drain_verify ( &roi->details.wtid, @@ -889,7 +896,7 @@ check_profit_drain (struct ReserveOutInfo *roi) qs = TALER_ARL_adb->insert_row_inconsistency ( TALER_ARL_adb->cls, &ri); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); GNUNET_free (account_section); if (qs < 0) { @@ -902,21 +909,18 @@ check_profit_drain (struct ReserveOutInfo *roi) GNUNET_free (account_section); { - char *np = TALER_payto_normalize (payto_uri); - if (0 != - strcasecmp (np, - roi->details.credit_account_uri)) + TALER_full_payto_normalize_and_cmp (payto_uri, + roi->details.credit_account_uri)) { struct TALER_AUDITORDB_WireOutInconsistency woi = { .wire_out_row_id = serial, - .destination_account = (char *) roi->details.credit_account_uri, + .destination_account = roi->details.credit_account_uri, .diagnostic = "profit drain wired to invalid account", .expected = roi->details.amount, .claimed = zero, }; - GNUNET_free (np); qs = TALER_ARL_adb->insert_wire_out_inconsistency ( TALER_ARL_adb->cls, &woi); @@ -924,25 +928,24 @@ check_profit_drain (struct ReserveOutInfo *roi) { global_qs = qs; GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); return GNUNET_SYSERR; } TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_bad_amount_out_plus), &TALER_ARL_USE_AB (total_bad_amount_out_plus), &amount); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); return GNUNET_YES; /* justified, kind-of */ } - GNUNET_free (np); } - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); if (0 != TALER_amount_cmp (&amount, &roi->details.amount)) { struct TALER_AUDITORDB_WireOutInconsistency woi = { .wire_out_row_id = roi->details.serial_id, - .destination_account = (char *) roi->details.credit_account_uri, + .destination_account = roi->details.credit_account_uri, .diagnostic = "incorrect amount drained to correct account", .expected = roi->details.amount, .claimed = amount, @@ -1006,7 +1009,7 @@ complain_out_not_found (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Checking for reserve closure %s benefiting %s\n", GNUNET_h2s (&rkey), - roi->details.credit_account_uri); + roi->details.credit_account_uri.full_payto); GNUNET_CONTAINER_multihashmap_get_multiple (reserve_closures, &rkey, &check_rc_matches, @@ -1023,7 +1026,7 @@ complain_out_not_found (void *cls, { struct TALER_AUDITORDB_WireOutInconsistency woi = { - .destination_account = (char *) roi->details.credit_account_uri, + .destination_account = roi->details.credit_account_uri, .diagnostic = "missing justification for outgoing wire transfer", .wire_out_row_id = roi->details.serial_id, .expected = zero, @@ -1066,7 +1069,7 @@ wire_out_cb ( uint64_t rowid, struct GNUNET_TIME_Timestamp date, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_Amount *amount) { struct WireAccount *wa = cls; @@ -1098,7 +1101,7 @@ wire_out_cb ( May be cleared later by check_reported_inconsistency() */ char diag[MAX_DIAG_LEN]; struct TALER_AUDITORDB_WireOutInconsistency woi = { - .destination_account = (char *) payto_uri, + .destination_account = payto_uri, .diagnostic = diag, .wire_out_row_id = rowid, .expected = *amount, @@ -1125,53 +1128,53 @@ wire_out_cb ( amount); return GNUNET_OK; } + + if (0 != TALER_full_payto_normalize_and_cmp (payto_uri, + roi->details.credit_account_uri)) { - char *np = TALER_payto_normalize (payto_uri); + /* Destination bank account is wrong in actual wire transfer, so + we should count the wire transfer as entirely spurious, and + additionally consider the justified wire transfer as missing. */ + struct TALER_AUDITORDB_WireOutInconsistency woi = { + .wire_out_row_id = rowid, + .destination_account = payto_uri, + .diagnostic = "receiver account mismatch", + .expected = *amount, + .claimed = roi->details.amount, + }; + enum GNUNET_DB_QueryStatus qs; - if (0 != strcasecmp (np, - roi->details.credit_account_uri)) + qs = TALER_ARL_adb->insert_wire_out_inconsistency ( + TALER_ARL_adb->cls, + &woi); + if (qs < 0) { - /* Destination bank account is wrong in actual wire transfer, so - we should count the wire transfer as entirely spurious, and - additionally consider the justified wire transfer as missing. */ - struct TALER_AUDITORDB_WireOutInconsistency woi = { - .wire_out_row_id = rowid, - .destination_account = (char *) payto_uri, - .diagnostic = "receiver account mismatch", - .expected = *amount, - .claimed = zero, - }; - enum GNUNET_DB_QueryStatus qs; - - GNUNET_free (np); - qs = TALER_ARL_adb->insert_wire_out_inconsistency ( - TALER_ARL_adb->cls, - &woi); - if (qs < 0) - { - global_qs = qs; - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - return GNUNET_SYSERR; - } - TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_bad_amount_out_plus), - &TALER_ARL_USE_AB (total_bad_amount_out_plus), - &roi->details.amount); - TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_bad_amount_out_minus), - &TALER_ARL_USE_AB (total_bad_amount_out_minus), - amount); - return GNUNET_OK; + global_qs = qs; + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + return GNUNET_SYSERR; } - GNUNET_free (np); + TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_bad_amount_out_plus), + &TALER_ARL_USE_AB (total_bad_amount_out_plus), + &roi->details.amount); + TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_bad_amount_out_minus), + &TALER_ARL_USE_AB (total_bad_amount_out_minus), + amount); + GNUNET_assert (GNUNET_OK == + free_roi (NULL, + &key, + roi)); + return GNUNET_OK; } + if (0 != TALER_amount_cmp (&roi->details.amount, amount)) { struct TALER_AUDITORDB_WireOutInconsistency woi = { - .destination_account = (char *) payto_uri, + .destination_account = payto_uri, .diagnostic = "wire amount does not match", .wire_out_row_id = rowid, .expected = *amount, - .claimed = zero, + .claimed = roi->details.amount, }; enum GNUNET_DB_QueryStatus qs; @@ -1209,6 +1212,10 @@ wire_out_cb ( &TALER_ARL_USE_AB (total_bad_amount_out_plus), &delta); } + GNUNET_assert (GNUNET_OK == + free_roi (NULL, + &key, + roi)); return GNUNET_OK; } @@ -1363,7 +1370,6 @@ history_debit_cb ( { const struct TALER_BANK_DebitDetails *dd = &dhr->details.ok.details[i]; - char *np = TALER_payto_normalize (dd->credit_account_uri); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Analyzing bank DEBIT #%llu at %s of %s with WTID %s\n", @@ -1372,19 +1378,18 @@ history_debit_cb ( TALER_amount2s (&dd->amount), TALER_B2S (&dd->wtid)); wa->wire_off_out = dd->serial_id + 1; - slen = strlen (np) + 1; + slen = strlen (dd->credit_account_uri.full_payto) + 1; roi = GNUNET_malloc (sizeof (struct ReserveOutInfo) + slen); GNUNET_CRYPTO_hash (&dd->wtid, sizeof (dd->wtid), &roi->subject_hash); roi->details = *dd; - roi->details.credit_account_uri + roi->details.credit_account_uri.full_payto = (const char *) &roi[1]; GNUNET_memcpy (&roi[1], - np, + dd->credit_account_uri.full_payto, slen); - GNUNET_free (np); if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (out_map, &roi->subject_hash, @@ -1506,7 +1511,7 @@ reserve_closed_cb ( const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, - const char *receiver_account, + const struct TALER_FullPayto receiver_account, const struct TALER_WireTransferIdentifierRawP *wtid, uint64_t close_request_row) { @@ -1515,6 +1520,8 @@ reserve_closed_cb ( (void) cls; (void) close_request_row; + GNUNET_assert (TALER_ARL_USE_PP (wire_reserve_close_id) <= rowid); + TALER_ARL_USE_PP (wire_reserve_close_id) = rowid + 1; rc = GNUNET_new (struct ReserveClosure); if (TALER_ARL_SR_INVALID_NEGATIVE == TALER_ARL_amount_subtract_neg (&rc->amount, @@ -1540,10 +1547,8 @@ reserve_closed_cb ( GNUNET_free (rc); return GNUNET_OK; } - TALER_ARL_USE_PP (wire_reserve_close_id) - = GNUNET_MAX (TALER_ARL_USE_PP (wire_reserve_close_id), - rowid + 1); - rc->receiver_account = TALER_payto_normalize (receiver_account); + rc->receiver_account.full_payto + = GNUNET_strdup (receiver_account.full_payto); rc->wtid = *wtid; rc->execution_date = execution_date; rc->rowid = rowid; @@ -1555,7 +1560,7 @@ reserve_closed_cb ( (unsigned long long) rowid, GNUNET_h2s (&key), TALER_amount2s (amount_with_fee), - receiver_account); + receiver_account.full_payto); (void) GNUNET_CONTAINER_multihashmap_put ( reserve_closures, &key, @@ -1678,7 +1683,8 @@ begin_transaction (void) (unsigned long long) TALER_ARL_USE_PP (wire_reserve_close_id)); } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Iterating over reserve closures\n"); + "Iterating over reserve closures from %llu\n", + (unsigned long long) TALER_ARL_USE_PP (wire_reserve_close_id)); qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( TALER_ARL_edb->cls, TALER_ARL_USE_PP (wire_reserve_close_id), @@ -1887,10 +1893,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1900,7 +1902,6 @@ main (int argc, options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index a18897d89..b2e5aac20 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -30,7 +30,7 @@ set -eu # Set of numbers for all the testcases. # When adding new tests, increase the last number: -ALL_TESTS=$(seq 0 33) +ALL_TESTS=$(seq 0 32) # $TESTS determines which tests we should run. # This construction is used to make it easy to @@ -71,14 +71,15 @@ function cleanup() # Cleanup to run whenever we exit function exit_cleanup() { + jobs if [ -n "${POSTGRES_PATH:-}" ] then echo -n "Stopping Postgres at ${POSTGRES_PATH} ..." "${POSTGRES_PATH}/pg_ctl" \ -D "$TMPDIR" \ - -l /dev/null \ + --log="${MY_TMP_DIR}/pg_ctl.log" \ stop \ - &> /dev/null \ + &> ${MY_TMP_DIR}/pg_ctl.out \ || true echo "DONE" fi @@ -96,13 +97,7 @@ function exit_cleanup() trap exit_cleanup EXIT -# Operations to run before the actual audit -function pre_audit () { - # Launch bank - echo -n "Launching libeufin-bank" - export CONF - export MY_TMP_DIR - launch_libeufin +function await_bank () { for n in $(seq 1 80) do echo -n "." @@ -119,6 +114,16 @@ function pre_audit () { then exit_skip "Failed to launch libeufin-bank" fi + } + +# Operations to run before the actual audit +function pre_audit () { + # Launch bank + echo -n "Launching libeufin-bank" + export CONF + export MY_TMP_DIR + launch_libeufin + await_bank echo " DONE" if [ "${1:-no}" = "aggregator" ] @@ -353,7 +358,7 @@ function run_audit () { -L DEBUG \ -c "${CONF}" \ drain TESTKUDOS:0.1 \ - exchange-account-1 payto://iban/DE360679?receiver-name=Exchange+Drain \ + exchange-account-1 payto://iban/DE474361?receiver-name=Merchant43 \ upload \ 2> "${MY_TMP_DIR}/taler-exchange-offline-drain.log" \ || exit_fail "offline draining failed" @@ -382,11 +387,23 @@ function run_audit () { } +function stop_auditor_httpd() { + if [ -n "${APID:-}" ] + then + echo -n "Stopping auditor $APID..." + kill -TERM "$APID" + wait "$APID" || true + echo "DONE" + unset APID + fi +} + + # Do a full reload of the (original) database function full_reload() { echo -n "Doing full reload of the database (loading ${BASEDB}.sql into $DB at $PGHOST)... " - dropdb -f "$DB" 2> /dev/null || true + dropdb -f "$DB" &>> ${MY_TMP_DIR}/drop.log || true createdb -T template0 "$DB" \ || exit_skip "could not create database $DB (at $PGHOST)" # Import pre-generated database, -q(ietly) using single (-1) transaction @@ -394,16 +411,17 @@ function full_reload() -q \ -1 \ -f "${BASEDB}.sql" \ - > /dev/null \ + &>> ${MY_TMP_DIR}/postgresql-reload.log \ || exit_skip "Failed to load database $DB from ${BASEDB}.sql" echo "DONE" # Technically, this call shouldn't be needed as libeufin should already be stopped here... stop_libeufin + stop_auditor_httpd } function run_auditor_httpd() { echo -n "Starting auditor..." - taler-auditor-httpd \ + $VALGRIND taler-auditor-httpd \ -c "${CONF}" \ -L INFO \ 2> "${MY_TMP_DIR}/auditor-httpd.err" & @@ -425,19 +443,8 @@ function run_auditor_httpd() { break done echo "... DONE." - export CONF } -function stop_auditor_httpd() { - if [ -n "${APID:-}" ] - then - echo -n "Stopping auditor $APID..." - kill -TERM "$APID" - wait "$APID" || true - echo "DONE" - unset APID - fi -} function check_auditor_running() { ARUNSTATUS=$(curl -Is http://localhost:8083/config | head -1) @@ -745,7 +752,6 @@ function test_2() { echo -n "Undoing database modification " echo "UPDATE exchange.reserves_in SET credit.val=10 WHERE reserve_in_serial_id=1" \ | psql -Aqt "$DB" - stop_auditor_httpd full_reload cleanup } @@ -802,7 +808,6 @@ function test_3() { # Undo database modification echo "UPDATE exchange.reserves_in SET credit.val=10 WHERE reserve_in_serial_id=1" | psql -Aqt "$DB" - stop_auditor_httpd full_reload cleanup } @@ -847,7 +852,6 @@ function test_4() { # Undo: echo "UPDATE exchange.coin_deposits SET coin_sig='$OLD_COIN_SIG' WHERE coin_deposit_serial_id=${SERIALE}" | psql -Aqt "$DB" - stop_auditor_httpd full_reload cleanup } @@ -899,7 +903,8 @@ function test_5() { function test_6() { echo "===========6: known_coins signature wrong=================" # Modify denom_sig, so it is wrong - OLD_SIG=$(echo 'SELECT denom_sig FROM exchange.known_coins LIMIT 1;' | psql "$DB" -Aqt) + OLD_ROW=$(echo "SELECT known_coin_id FROM exchange.known_coins LIMIT 1;" | psql "$DB" -Aqt) + OLD_SIG=$(echo "SELECT denom_sig FROM exchange.known_coins WHERE known_coin_id=$OLD_ROW;" | psql "$DB" -Aqt) COIN_PUB=$(echo "SELECT coin_pub FROM exchange.known_coins WHERE denom_sig='$OLD_SIG';" | psql "$DB" -Aqt) # shellcheck disable=SC2028 echo "UPDATE exchange.known_coins SET denom_sig='\x0000000100000000287369672d76616c200a2028727361200a2020287320233542383731423743393036444643303442424430453039353246413642464132463537303139374131313437353746324632323332394644443146324643333445393939413336363430334233413133324444464239413833353833464536354442374335434445304441453035374438363336434541423834463843323843344446304144363030343430413038353435363039373833434431333239393736423642433437313041324632414132414435413833303432434346314139464635394244434346374436323238344143354544364131373739463430353032323241373838423837363535453434423145443831364244353638303232413123290a2020290a20290b' WHERE coin_pub='$COIN_PUB'" \ @@ -909,7 +914,9 @@ function test_6() { check_auditor_running echo -n "Checking bad-signature-loss detected ..." - check_row "bad-sig-losses" 1 + check_row \ + "bad-sig-losses" \ + "problem_row_id" "1" # Row reported is that of deposits or melt table, not known_coins echo -n "Checking bad-signature-loss amount detected ..." check_report_neg \ "bad-sig-losses" \ @@ -926,10 +933,8 @@ function test_6() { echo -n "Undo database change ... " echo "UPDATE exchange.known_coins SET denom_sig='$OLD_SIG' WHERE coin_pub='$COIN_PUB'" | psql -Aqt "$DB" - stop_auditor_httpd full_reload cleanup - } @@ -978,7 +983,6 @@ function test_7() { # Undo: echo "UPDATE exchange.reserves_out SET reserve_sig='$OLD_SIG' WHERE h_blind_ev='$HBE'" | psql -Aqt "$DB" - stop_auditor_httpd full_reload cleanup } @@ -1030,7 +1034,6 @@ function test_8() { # Undo database modification echo "UPDATE libeufin_bank.taler_exchange_incoming SET reserve_pub='$OLD_WTID' WHERE exchange_incoming_id='$OLD_ID';" \ | psql "${DB}" -q - stop_auditor_httpd full_reload cleanup } @@ -1044,10 +1047,10 @@ function test_9() { stop_libeufin OLD_ID=$(echo "SELECT bank_transaction FROM libeufin_bank.taler_exchange_incoming JOIN libeufin_bank.bank_account_transactions ON (bank_transaction=bank_transaction_id) WHERE (amount).val=10 ORDER BY bank_transaction LIMIT 1;" | psql "${DB}" -Aqt) \ || exit_fail "Failed to SELECT FROM libeufin_bank.bank_account_transactions!" - OLD_ACC=$(echo "SELECT debtor_payto_uri FROM libeufin_bank.bank_account_transactions WHERE bank_transaction_id='$OLD_ID';" | psql "${DB}" -Aqt) + OLD_ACC=$(echo "SELECT debtor_payto FROM libeufin_bank.bank_account_transactions WHERE bank_transaction_id='$OLD_ID';" | psql "${DB}" -Aqt) echo -n "Modifying $OLD_ID ..." - echo "UPDATE libeufin_bank.bank_account_transactions SET debtor_payto_uri='payto://iban/DE144373' WHERE bank_transaction_id='$OLD_ID';" \ + echo "UPDATE libeufin_bank.bank_account_transactions SET debtor_payto='payto://iban/DE144373' WHERE bank_transaction_id='$OLD_ID';" \ | psql "${DB}" -At run_audit @@ -1063,9 +1066,8 @@ function test_9() { "TESTKUDOS:10" \ "Reported total_misattribution_in wrong" # Undo database modification - echo "UPDATE libeufin_bank.bank_account_transactions SET debtor_payto_uri='$OLD_ACC' WHERE bank_transaction_id='$OLD_ID';" \ + echo "UPDATE libeufin_bank.bank_account_transactions SET debtor_payto='$OLD_ACC' WHERE bank_transaction_id='$OLD_ID';" \ | psql "${DB}" -Atq - stop_auditor_httpd full_reload cleanup } @@ -1098,79 +1100,62 @@ function test_10() { # Undo database modification echo "UPDATE libeufin_bank.bank_account_transactions SET transaction_date=$OLD_DATE WHERE bank_transaction_id=$OLD_ID;" \ | psql "${DB}" -Aqt - stop_auditor_httpd full_reload cleanup } # Test for extra outgoing wire transfer. -# In case of changing the subject in the Nexus -# ingested table: '.batches[0].batchTransactions[0].details.unstructuredRemittanceInformation' -# FIXME: test-11 not implemented function test_11() { echo "===========11: spurious outgoing transfer ===========" # Technically, this call shouldn't be needed, as libeufin should already be stopped here. stop_libeufin - echo "FIXME: test needs update to new libeufin-bank schema" - #TODO: see fixme - #exit 0 - #OLD_ID=$(echo "SELECT id FROM NexusBankTransactions WHERE amount='10' AND currency='TESTKUDOS' ORDER BY id LIMIT 1;" | psql "${DB}" -Aqt) - #OLD_TX=$(echo "SELECT \"transactionJson\" FROM NexusBankTransactions WHERE id='$OLD_ID';" | psql "${DB}" -Aqt) - # Change wire transfer to be FROM the exchange (#2) to elsewhere! - # (Note: this change also causes a missing incoming wire transfer, but - # this test is only concerned about the outgoing wire transfer - # being detected as such, and we simply ignore the other - # errors being reported.) - #OTHER_IBAN=$(echo -e "SELECT iban FROM BankAccounts WHERE label='fortytwo'" | psql "${DB}" -Aqt) - #NEW_TX=$(echo "$OLD_TX" | jq .batches[0].batchTransactions[0].details.creditDebitIndicator='"DBIT"' | jq 'del(.batches[0].batchTransactions[0].details.debtor)' | jq 'del(.batches[0].batchTransactions[0].details.debtorAccount)' | jq 'del(.batches[0].batchTransactions[0].details.debtorAgent)' | jq '.batches[0].batchTransactions[0].details.creditor'='{"name": "Forty Two"}' | jq .batches[0].batchTransactions[0].details.creditorAccount='{"iban": "'"$OTHER_IBAN"'"}' | jq .batches[0].batchTransactions[0].details.creditorAgent='{"bic": "SANDBOXX"}' | jq .batches[0].batchTransactions[0].details.unstructuredRemittanceInformation='"CK9QBFY972KR32FVA1MW958JWACEB6XCMHHKVFMCH1A780Q12SVG http://exchange.example.com/"') - #echo -e "UPDATE NexusBankTransactions SET \"transactionJson\"='""$NEW_TX""' WHERE id=$OLD_ID" \ - # | psql "${DB}" -q - # Now fake that the exchange prepared this payment (= it POSTed to /transfer) - # This step is necessary, because the TWG table that accounts for outgoing - # payments needs it. Worth noting here is the column 'rawConfirmation' that - # points to the transaction from the main Nexus ledger; without that column set, - # a prepared payment won't appear as actually outgoing. - #echo -e "INSERT INTO PaymentInitiations (\"bankAccount\",\"preparationDate\",\"submissionDate\",sum,currency,\"endToEndId\",\"paymentInformationId\",\"instructionId\",subject,\"creditorIban\",\"creditorBic\",\"creditorName\",submitted,\"messageId\",\"rawConfirmation\") VALUES (1,1,1,10,'TESTKUDOS','NOTGIVEN','unused','unused','CK9QBFY972KR32FVA1MW958JWACEB6XCMHHKVFMCH1A780Q12SVG http://exchange.example.com/','""$OTHER_IBAN""','SANDBOXX','Forty Two',false,1,$OLD_ID)" \ - # | psql "${DB}" -q - # Now populate the TWG table that accounts for outgoing payments, in - # order to let /history/outgoing return one result. - #echo -e "INSERT INTO TalerRequestedPayments (facade,payment,\"requestUid\",amount,\"exchangeBaseUrl\",wtid,\"creditAccount\") VALUES (1,1,'unused','TESTKUDOS:10','http://exchange.example.com/','CK9QBFY972KR32FVA1MW958JWACEB6XCMHHKVFMCH1A780Q12SVG','payto://iban/""$OTHER_IBAN""?receiver-name=Forty+Two')" \ - # | psql "${DB}" -q + launch_libeufin + OTHER_IBAN=$(echo "SELECT internal_payto FROM libeufin_bank.bank_accounts ba JOIN libeufin_bank.customers bc ON (ba.owning_customer_id = bc.customer_id) WHERE username='fortytwo'" | psql "${DB}" -Aqt) + + await_bank + echo -n "Creating bogus transfer... " + STATUS=$(curl -H "Content-Type: application/json" -X POST \ + -u 'exchange:password' \ + http://localhost:8082/accounts/exchange/taler-wire-gateway/transfer \ + -d '{"credit_account":"'"$OTHER_IBAN"'","exchange_base_url":"http://exchange.example.com/","amount":"TESTKUDOS:10","wtid":"7X93HVKPHE0KAQ6KHSB3921KJGSVDMQFHMQV17885YJDMZ20XS9G","request_uid":"7X93HKPHE0KAQ6KHSB3921KJGSVDMQFHMQV17885YJDMZ20XS9G7X93HVKPHE0KAQ6KHSB3921KJGSVDMQFHMQV17885YJDMZ20XS9G"}' \ + -w "%{http_code}" -s -o /dev/null) + + if [ "$STATUS" != "200" ] + then + exit_fail "Expected 200 OK. Got: $STATUS" + fi + echo "DONE" + stop_libeufin run_audit check_auditor_running - #TODO: fix helper wire - #echo -n "Testing inconsistency detection... " - #AMOUNT=$(jq -r .wire_out_amount_inconsistencies[0].amount_wired < test-audit-wire.json") - #if [ "x$AMOUNT" != "xTESTKUDOS:10" ] - #then - # exit_fail "Reported wired amount wrong: $AMOUNT" - #fi - #AMOUNT=$(jq -r .total_wire_out_delta_plus < test-audit-wire.json") - #if [ "x$AMOUNT" != "xTESTKUDOS:10" ] - #then - # exit_fail "Reported total plus amount wrong: $AMOUNT" - #fi - #AMOUNT=$(jq -r .total_wire_out_delta_minus < test-audit-wire.json") - #if [ "x$AMOUNT" != "xTESTKUDOS:0" ] - #then - # exit_fail "Reported total minus amount wrong: $AMOUNT" - #fi - #AMOUNT=$(jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-audit-wire.json") - #if [ "x$AMOUNT" != "xTESTKUDOS:0" ] - #then - # exit_fail "Reported justified amount wrong: $AMOUNT" - #fi - #DIAG=$(jq -r .wire_out_amount_inconsistencies[0].diagnostic < test-audit-wire.json") - #if [ "x$DIAG" != "xjustification for wire transfer not found" ] - #then - # exit_fail "Reported diagnostic wrong: $DIAG" - #fi - #echo "PASS" - - stop_auditor_httpd + echo -n "Testing inconsistency detection... " + check_report \ + "wire-out-inconsistency" \ + "claimed" \ + "TESTKUDOS:10" + echo -n "Testing bad_amount_plus balance reporting... " + check_balance \ + "total_bad_amount_out_plus" \ + "TESTKUDOS:10" \ + "reported total_bad_amount_plus wrong" + echo -n "Testing bad_amount_minus balance reporting... " + check_balance \ + "total_bad_amount_out_minus" \ + "TESTKUDOS:0" \ + "reported total_bad_amount_minus wrong" + echo -n "Testing expected amount is correct... " + check_report \ + "wire-out-inconsistency" \ + "expected" \ + "TESTKUDOS:0" + echo -n "Testing diagnostic message is correct... " + check_report \ + "wire-out-inconsistency" \ + "diagnostic" \ + "missing justification for outgoing wire transfer" full_reload } @@ -1197,7 +1182,6 @@ function test_12() { # cannot easily undo DELETE, hence full reload full_reload - stop_auditor_httpd } @@ -1232,7 +1216,6 @@ function test_13() { # cannot easily undo DELETE, hence full reload full_reload - stop_auditor_httpd } @@ -1262,7 +1245,6 @@ function test_14() { # cannot easily undo aggregator, hence full reload full_reload - stop_auditor_httpd } @@ -1294,130 +1276,136 @@ function test_15() { # Test where wired amount (wire out) is wrong -# FIXME: test-16 not implemented function test_16() { echo "===========16: incorrect wire_out amount=================" - # Check wire transfer lag reported (no aggregator!) - # First, we need to run the aggregator so we even # have a wire_out to modify. pre_audit aggregator check_auditor_running -#TODO FIX LIBEUFIN - #stop_libeufin - #OLD_AMOUNT=$(echo "SELECT amount FROM TalerRequestedPayments WHERE id='1';" | psql "${DB}" -Aqt) - #NEW_AMOUNT="TESTKUDOS:50" - #echo "UPDATE TalerRequestedPayments SET amount='${NEW_AMOUNT}' WHERE id='1';" \ - # | psql "${DB}" -q - #launch_libeufin - #audit_only - #check_auditor_running -# - #echo -n "Testing inconsistency detection... " -# - #AMOUNT=$(jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-audit-wire.json) - #if [ "$AMOUNT" != "$OLD_AMOUNT" ] - #then - # exit_fail "Reported justified amount wrong: $AMOUNT" - #fi - #AMOUNT=$(jq -r .wire_out_amount_inconsistencies[0].amount_wired < test-audit-wire.json) - #if [ "$AMOUNT" != "$NEW_AMOUNT" ] - #then - # exit_fail "Reported wired amount wrong: $AMOUNT" - #fi - #TOTAL_AMOUNT=$(jq -r .total_wire_out_delta_minus < test-audit-wire.json) - #if [ "$TOTAL_AMOUNT" != "TESTKUDOS:0" ] - #then - # exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT" - #fi - #TOTAL_AMOUNT=$(jq -r .total_wire_out_delta_plus < test-audit-wire.json) - #if [ "$TOTAL_AMOUNT" = "TESTKUDOS:0" ] - #then - # exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT" - #fi - #echo "PASS" -# - #stop_libeufin - #echo "Second modification: wire nothing" - #NEW_AMOUNT="TESTKUDOS:0" - #echo "UPDATE TalerRequestedPayments SET amount='${NEW_AMOUNT}' WHERE id='1';" \ - # | psql "${DB}" -q - #launch_libeufin - #audit_only - #stop_libeufin - #echo -n "Testing inconsistency detection... " -# - #AMOUNT=$(jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-audit-wire.json) - #if [ "$AMOUNT" != "$OLD_AMOUNT" ] - #then - # exit_fail "Reported justified amount wrong: $AMOUNT" - #fi - #AMOUNT=$(jq -r .wire_out_amount_inconsistencies[0].amount_wired < test-audit-wire.json) - #if [ "$AMOUNT" != "$NEW_AMOUNT" ] - #then - # exit_fail "Reported wired amount wrong: $AMOUNT" - #fi - #TOTAL_AMOUNT=$(jq -r .total_wire_out_delta_minus < test-audit-wire.json) - #if [ "$TOTAL_AMOUNT" != "$OLD_AMOUNT" ] - #then - # exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT (wanted $OLD_AMOUNT)" - #fi - #TOTAL_AMOUNT=$(jq -r .total_wire_out_delta_plus < test-audit-wire.json) - #if [ "$TOTAL_AMOUNT" != "TESTKUDOS:0" ] - #then - # exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT" - #fi - #echo "PASS" -# - #post_audit + stop_libeufin + OLD_AMOUNT_VAL=$(echo "SELECT (amount).val FROM libeufin_bank.bank_account_transactions WHERE debtor_name='Exchange Company' AND direction='debit';" | psql "${DB}" -Aqt) + OLD_AMOUNT_FRAC=$(echo "SELECT (amount).frac FROM libeufin_bank.bank_account_transactions WHERE debtor_name='Exchange Company' AND direction='debit';" | psql "${DB}" -Aqt) + if [[ 0 = "$OLD_AMOUNT_FRAC" ]] + then + OLD_AMOUNT="TESTKUDOS:${OLD_AMOUNT_VAL}" + else + OLD_AMOUNT_CENTS=$(($OLD_AMOUNT_FRAC / 1000000)) + if [[ 10 -gt "$OLD_AMOUNT_CENTS" ]] + then + OLD_AMOUNT="TESTKUDOS:${OLD_AMOUNT_VAL}.0${OLD_AMOUNT_CENTS}" + else + OLD_AMOUNT="TESTKUDOS:${OLD_AMOUNT_VAL}.${OLD_AMOUNT_CENTS}" + fi + fi + NEW_AMOUNT="TESTKUDOS:50" + echo "UPDATE libeufin_bank.bank_account_transactions SET amount=(50,0) WHERE debtor_name='Exchange Company';" \ + | psql "${DB}" -q + launch_libeufin + await_bank + + audit_only + check_auditor_running + + echo -n "Testing wire-out-inconsistency-expected... " + check_report \ + "wire-out-inconsistency" \ + "expected" \ + "$OLD_AMOUNT" + echo -n "Testing wire-out-inconsistency-claimed... " + check_report \ + "wire-out-inconsistency" \ + "claimed" \ + "$NEW_AMOUNT" + echo -n "Testing bad_amount_minus balance reporting... " + check_balance \ + "total_bad_amount_out_minus" \ + "TESTKUDOS:0" \ + "reported total_bad_amount_minus wrong" + echo -n "Testing bad_amount_plus balance reporting... " + check_not_balance \ + "total_bad_amount_out_plus" \ + "TESTKUDOS:0" \ + "reported total_bad_amount_plus wrong" + + stop_libeufin + echo "Second modification: wire nothing" + NEW_AMOUNT="TESTKUDOS:0" + echo "UPDATE libeufin_bank.bank_account_transactions SET amount=(0,0) WHERE debtor_name='Exchange Company';" \ + | psql "${DB}" -q + launch_libeufin + audit_only + stop_libeufin + + echo -n "Testing wire-out-inconsistency-expected... " + check_report \ + "wire-out-inconsistency" \ + "expected" \ + "$OLD_AMOUNT" + echo -n "Testing wire-out-inconsistency-claimed... " + check_report \ + "wire-out-inconsistency" \ + "claimed" \ + "$NEW_AMOUNT" + echo -n "Testing bad_amount_minus balance reporting... " + check_balance \ + "total_bad_amount_out_minus" \ + "$OLD_AMOUNT" \ + "reported total_bad_amount_minus wrong" + echo -n "Testing bad_amount_plus balance reporting... " + check_balance \ + "total_bad_amount_out_plus" \ + "TESTKUDOS:0" \ + "reported total_bad_amount_plus wrong" + + post_audit # cannot easily undo aggregator, hence full reload full_reload - stop_auditor_httpd } # Test where wire-out timestamp is wrong -# FIXME: test-17 not implemented function test_17() { echo "===========17: incorrect wire_out timestamp=================" # First, we need to run the aggregator so we even # have a wire_out to modify. -#TODO FIX libeufin -# pre_audit aggregator -# stop_libeufin -# OLD_ID=1 -# OLD_PREP=$(echo "SELECT payment FROM TalerRequestedPayments WHERE id='${OLD_ID}';" | psql "${DB}" -Aqt) -# OLD_DATE=$(echo "SELECT \"preparationDate\" FROM PaymentInitiations WHERE id='${OLD_ID}';" | psql "${DB}" -Aqt) -# # Note: need - interval '1h' as "NOW()" may otherwise be exactly what is already in the DB -# # (due to rounding, if this machine is fast...) -# NOW_1HR=$(( $(date +%s) - 3600)) -# echo "UPDATE PaymentInitiations SET \"preparationDate\"='$NOW_1HR' WHERE id='${OLD_PREP}';" \ -# | psql "${DB}" -q -# launch_libeufin -# echo "DONE" -# audit_only -# post_audit -# check_auditor_running -# -# echo -n "Testing inconsistency detection... " -# TABLE=$(jq -r .row_minor_inconsistencies[0].table < test-audit-wire.json) -# if [ "$TABLE" != "wire_out" ] -# then -# exit_fail "Reported table wrong: $TABLE" -# fi -# DIAG=$(jq -r .row_minor_inconsistencies[0].diagnostic < test-audit-wire.json) -# DIAG=$(echo "$DIAG" | awk '{print $1 " " $2 " " $3}') -# if [ "$DIAG" != "execution date mismatch" ] -# then -# exit_fail "Reported diagnostic wrong: $DIAG" -# fi -# echo "PASS" -# -# # cannot easily undo aggregator, hence full reload -# full_reload + pre_audit aggregator + stop_libeufin + + echo -n "Modifying timestamp of existing wire_out transaction... " + OLD_DATE=$(echo "SELECT transaction_date FROM libeufin_bank.bank_account_transactions WHERE debtor_name='Exchange Company' AND direction='debit';" | psql "${DB}" -Aqt) + # Note: need - interval '1h' as "NOW()" may otherwise be exactly what is already in the DB + # (due to rounding, if this machine is fast...) + NOW_1HR=$(( $(date +%s) - 3600)) + + echo "UPDATE libeufin_bank.bank_account_transactions SET transaction_date='${NOW_1HR}000000' WHERE debtor_name='Exchange Company';" \ + | psql "${DB}" -q + echo "DONE" + + launch_libeufin + await_bank + audit_only + post_audit + check_auditor_running + + echo -n "Testing inconsistency detection... " + check_report \ + row-minor-inconsistencies \ + "row_table" "wire_out" + + echo -n "Testing inconsistency diagnostic... " + call_endpoint "row-minor-inconsistencies" + DIAG=$(jq -r .row_minor_inconsistencies[0].diagnostic < "${MY_TMP_DIR}/row-minor-inconsistencies.json" | awk '{print $1 " " $2 " " $3}') + if [ "$DIAG" != "execution date mismatch" ] + then + exit_fail "Reported diagnostic wrong: $DIAG" + fi + echo "PASS" + + # cannot easily undo aggregator, hence full reload + full_reload } @@ -1460,7 +1448,6 @@ function test_18() { "Emergency loss not reported" # cannot easily undo broad DELETE operation, hence full reload full_reload - stop_auditor_httpd } @@ -1491,7 +1478,6 @@ function test_19() { # cannot easily undo aggregator, hence full reload full_reload - stop_auditor_httpd } @@ -1530,12 +1516,10 @@ function test_20() { | psql -Aqt "$DB" full_reload - stop_auditor_httpd } # Test reserve closure reported but wire transfer missing detection -# FIXME: test-21 not implemented function test_21() { echo "===========21: reserve closure missreported =================" @@ -1551,42 +1535,38 @@ function test_21() { | psql -Aqt "$DB" echo "UPDATE exchange.reserves SET current_balance.val=${VAL_DELTA}+(current_balance).val,expiration_date='${NEW_EXP}' WHERE reserve_pub='${RES_PUB}';" \ | psql -Aqt "$DB" -#TODO FIX AUDITOR wire - # Need to first run the aggregator so the transfer is marked as done exists -# pre_audit aggregator -# stop_libeufin -# # remove transaction from bank DB -# # Currently emulating this (to be deleted): -# echo "DELETE FROM TalerRequestedPayments WHERE amount='TESTKUDOS:${VAL_DELTA}'" \ -# | psql "${DB}" -q -# launch_libeufin -# audit_only -# post_audit -# check_auditor_running -# -# call_endpoint "reserve-not-closed-inconsistency" -# -# -# echo -n "Testing lack of reserve closure transaction detected... " -# -# jq -e .reserve_lag_details[0] \ -# < test-audit-wire.json" \ -# > /dev/null \ -# || exit_fail "Reserve closure lag not detected" -# -# AMOUNT=$(jq -r .reserve_lag_details[0].amount < test-audit-wire.json") -# if [ "$AMOUNT" != "TESTKUDOS:${VAL_DELTA}" ] -# then -# exit_fail "Reported total amount wrong: $AMOUNT" -# fi -# AMOUNT=$(jq -r .total_closure_amount_lag < test-audit-wire.json") -# if [ "$AMOUNT" != "TESTKUDOS:${VAL_DELTA}" ] -# then -# exit_fail "Reported total amount wrong: $AMOUNT" -# fi - echo "PASS" + # Need to first run the aggregator so the transfer is marked as done + pre_audit aggregator + stop_libeufin + + # remove wire transfer from bank DB + echo "DELETE FROM libeufin_bank.bank_account_transactions WHERE debtor_name='Exchange Company';" \ + | psql "${DB}" -q + launch_libeufin + audit_only + post_audit + check_auditor_running + + echo -n "Testing reserve_in inconsistency detection... " + check_report \ + row-minor-inconsistencies \ + "row_table" "reserves_in" + + echo -n "Testing lack of reserve closure transaction detected... " + check_report \ + "closure-lags" \ + "suppressed" "false" + echo -n "Checking closure lag amount ..." + check_report \ + "closure-lags" \ + "amount" "TESTKUDOS:${VAL_DELTA}" + echo -n "Checking closure lag total balance ..." + check_balance \ + "total_closure_amount_lag" \ + "TESTKUDOS:${VAL_DELTA}" \ + "Reported total_closure_amount_lag wrong" # cannot easily undo aggregator, hence full reload full_reload } @@ -1619,7 +1599,6 @@ function test_22() { echo "UPDATE exchange.denominations SET expire_withdraw=${OLD_WEXP} WHERE denominations_serial='${S_DENOM}';" | psql -Aqt "$DB" full_reload - stop_auditor_httpd } @@ -1689,7 +1668,6 @@ function test_23() { # cannot easily undo aggregator, hence full reload full_reload - stop_auditor_httpd } @@ -1726,12 +1704,12 @@ function test_24() { # Test for inconsistent coin history. -# FIXME: test-25 not implemented function test_25() { echo "=========25: inconsistent coin history=========" # Drop refund, so coin history is bogus. + echo -n "Dropping refund from DB... " echo "DELETE FROM exchange.refunds WHERE refund_serial_id=1;" \ | psql -At "$DB" @@ -1739,137 +1717,78 @@ function test_25() { check_auditor_running echo -n "Testing inconsistency detection... " - - call_endpoint "coin-inconsistency" - call_endpoint "emergency" - call_endpoint "balances" "coins_reported_emergency_risk_by_amount" - -#TODO: doesn't find any - #jq -e .coin_inconsistency[0] \ - # < "${MY_TMP_DIR}/coin-inconsistency.json" \ - # > /dev/null \ - # || exit_fail "Coin inconsistency NOT detected" - - # Note: if the wallet withdrew much more than it spent, this might indeed - # go legitimately unnoticed. - #jq -e .emergency[0] \ - # < "${MY_TMP_DIR}/emergency.json" \ - # > /dev/null \ - # || exit_fail "Denomination value emergency NOT reported" -#TODO: find's only wrong amount - call_endpoint "balances" "aggregation_total_coin_delta_minus" - #AMOUNT=$(jq -er .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_coin_delta_minus.json") - #if [ "$AMOUNT" = "TESTKUDOS:0" ] - #then - # exit_fail "Expected non-zero total inconsistency amount from coins" - #fi - # Note: if the wallet withdrew much more than it spent, this might indeed - # go legitimately unnoticed. - #COUNT=$(jq -er .balances[0].balance_value < "${MY_TMP_DIR}/coins_reported_emergency_risk_by_amount.json") - #if [ "$COUNT" = "TESTKUDOS:0" ] - #then - # exit_fail "Expected non-zero emergency-by-amount" - #fi - #echo "PASS" - + check_report \ + "coin-inconsistency" \ + "profitable" "true" + echo -n "Testing emergency risk reporting... " + check_report \ + "emergency" \ + "denom_risk" "TESTKUDOS:10" + echo -n "Testing emergency loss reporting... " + check_report \ + "emergency" \ + "denom_loss" "TESTKUDOS:5.98" + echo -n "Testing double-spending reporting... " + check_balance \ + "coins_reported_emergency_risk_by_amount" \ + "TESTKUDOS:10" \ + "double-spending not detected" + echo -n "Testing balance loss update... " + check_balance \ + "aggregation_total_coin_delta_minus" \ + "TESTKUDOS:5.98" \ + "aggregation total coin delta minus not reported" # cannot easily undo DELETE, hence full reload full_reload - stop_auditor_httpd } # Test for deposit wire target malformed -# FIXME: test-26 not implemented function test_26() { echo "===========26: deposit wire target malformed =================" - #TODO needs to be rebuild -# # Expects 'payto_uri', not 'url' (also breaks signature, but we cannot even check that). -# SERIAL=$(echo "SELECT deposit_serial_id FROM exchange.coin_deposits WHERE (amount_with_fee).val=3 AND (amount_with_fee).frac=0 ORDER BY deposit_serial_id LIMIT 1" | psql "$DB" -Aqt) -# OLD_WIRE_ID=$(echo "SELECT wire_target_h_payto FROM exchange.deposits WHERE deposit_serial_id=${SERIAL};" | psql "$DB" -Aqt) -## shellcheck disable=SC2028 -# echo "INSERT INTO exchange.wire_targets (payto_uri, wire_target_h_payto) VALUES ('payto://x-taler-bank/localhost/testuser-xxlargtp', '\x1e8f31936b3cee8f8afd3aac9e38b5db42d45b721ffc4eb1e5b9ddaf1565660b');" \ -# | psql "$DB" -Aqt -## shellcheck disable=SC2028 -# echo "UPDATE exchange.deposits SET wire_target_h_payto='\x1e8f31936b3cee8f8afd3aac9e38b5db42d45b721ffc4eb1e5b9ddaf1565660b' WHERE deposit_serial_id=${SERIAL}" \ -# | psql -Aqt "$DB" -# -# run_audit -# check_auditor_running -# -# echo -n "Testing inconsistency detection... " -# -# jq -e .bad_sig_losses[0] < test-audit-coins.json > /dev/null || exit_fail "Bad signature not detected" -# -# ROW=$(jq -e .bad_sig_losses[0].row < test-audit-coins.json") -# if [ "$ROW" != "${SERIAL}" ] -# then -# exit_fail "Row wrong, got $ROW" -# fi -# -# LOSS=$(jq -r .bad_sig_losses[0].loss < test-audit-coins.json") -# if [ "$LOSS" != "TESTKUDOS:3" ] -# then -# exit_fail "Wrong deposit bad signature loss, got $LOSS" -# fi -# -# OP=$(jq -r .bad_sig_losses[0].operation < test-audit-coins.json") -# if [ "$OP" != "deposit" ] -# then -# exit_fail "Wrong operation, got $OP" -# fi -# -# LOSS=$(jq -r .irregular_loss < test-audit-coins.json") -# if [ "$LOSS" != "TESTKUDOS:3" ] -# then -# exit_fail "Wrong total bad sig loss, got $LOSS" -# fi -# -# echo "PASS" -# # Undo: -# echo "UPDATE exchange.deposits SET wire_target_h_payto='$OLD_WIRE_ID' WHERE deposit_serial_id=${SERIAL}" \ -# | psql -Aqt "$DB" -} -# Test for duplicate wire transfer subject -# FIXME: test-27 not implemented -function test_27() { - echo "===========27: duplicate WTID detection =================" -#TODO libeufin fix - # pre_audit aggregator - # stop_libeufin - # # Obtain data to duplicate. - # WTID=$(echo SELECT wtid FROM TalerRequestedPayments WHERE id=1 | psql "${DB}" -Aqt) - # OTHER_IBAN=$(echo -e "SELECT iban FROM BankAccounts WHERE label='fortytwo'" | psql "${DB}" -Aqt) - # # 'rawConfirmation' is set to 2 here, that doesn't - # # point to any record. That's only needed to set a non null value. - # echo -e "INSERT INTO PaymentInitiations (\"bankAccount\",\"preparationDate\",\"submissionDate\",sum,currency,\"endToEndId\",\"paymentInformationId\",\"instructionId\",subject,\"creditorIban\",\"creditorBic\",\"creditorName\",submitted,\"messageId\",\"rawConfirmation\") VALUES (1,$(date +%s),$(( $(date +%s) + 2)),10,'TESTKUDOS','NOTGIVEN','unused','unused','$WTID http://exchange.example.com/','$OTHER_IBAN','SANDBOXX','Forty Two',false,1,2)" \ - # | psql "${DB}" -q - # echo -e "INSERT INTO TalerRequestedPayments (facade,payment,\"requestUid\",amount,\"exchangeBaseUrl\",wtid,\"creditAccount\") VALUES (1,2,'unused','TESTKUDOS:1','http://exchange.example.com/','$WTID','payto://iban/$OTHER_IBAN?receiver-name=Forty+Two')" \ - # | psql "${DB}" -q - # launch_libeufin - # audit_only - # post_audit -# - # echo -n "Testing inconsistency detection... " -# - # AMOUNT=$(jq -r .wire_format_inconsistencies[0].amount < test-audit-wire.json") - # if [ "${AMOUNT}" != "TESTKUDOS:1" ] - # then - # exit_fail "Amount wrong, got ${AMOUNT}" - # fi - # - # # cannot easily undo aggregator, hence full reload - # full_reload -} + # Expects 'payto_uri', not 'url' (also breaks signature, but we cannot even check that). + SERIAL=$(echo "SELECT batch_deposit_serial_id FROM exchange.coin_deposits WHERE (amount_with_fee).val=3 ORDER BY batch_deposit_serial_id LIMIT 1" | psql "$DB" -Aqt) + OLD_WIRE_ID=$(echo "SELECT wire_target_h_payto FROM exchange.batch_deposits WHERE batch_deposit_serial_id=${SERIAL};" | psql "$DB" -Aqt) +# shellcheck disable=SC2028 + echo "INSERT INTO exchange.wire_targets (payto_uri, wire_target_h_payto) VALUES ('payto://x-taler-bank/localhost/testuser-xxlargtp', '\x1e8f31936b3cee8f8afd3aac9e38b5db42d45b721ffc4eb1e5b9ddaf1565660b');" \ + | psql "$DB" -Aqt +# shellcheck disable=SC2028 + echo "UPDATE exchange.batch_deposits SET wire_target_h_payto='\x1e8f31936b3cee8f8afd3aac9e38b5db42d45b721ffc4eb1e5b9ddaf1565660b' WHERE batch_deposit_serial_id=${SERIAL};" \ + | psql -Aqt "$DB" + + run_audit + check_auditor_running + check_balance \ + "coin_irregular_loss" \ + "TESTKUDOS:3.02" \ + "wrong total irregular coin loss" + call_endpoint "bad_sig_losses" + echo -n "Checking correct operation of loss reported... " + check_report \ + "bad-sig-losses" \ + "operation" "deposit" + echo -n "Checking correct loss reported... " + check_report \ + "bad-sig-losses" \ + "loss" "TESTKUDOS:3.02" + echo -n "Checking correct problem row ID reported... " + check_report \ + "bad-sig-losses" \ + "problem_row_id" "$SERIAL" + # Undo: + echo "UPDATE exchange.batch_deposits SET wire_target_h_payto='$OLD_WIRE_ID' WHERE batch_deposit_serial_id=${SERIAL}" \ + | psql -Aqt "$DB" +} # Test where denom_sig in known_coins table is wrong # (=> bad signature) AND the coin is used in aggregation -function test_28() { +function test_27() { - echo "===========28: known_coins signature wrong=================" + echo "===========27: known_coins signature wrong=================" # Modify denom_sig, so it is wrong OLD_SIG=$(echo 'SELECT denom_sig FROM exchange.known_coins LIMIT 1;' | psql "$DB" -Aqt) COIN_PUB=$(echo "SELECT coin_pub FROM exchange.known_coins WHERE denom_sig='$OLD_SIG';" | psql "$DB" -Aqt) @@ -1900,15 +1819,14 @@ function test_28() { # cannot easily undo aggregator, hence full reload full_reload - stop_auditor_httpd } # Test where fees known to the auditor differ from those # accounted for by the exchange -function test_29() { - echo "===========29: withdraw fee inconsistency =================" +function test_28() { + echo "===========28: withdraw fee inconsistency =================" echo "UPDATE exchange.denominations SET fee_withdraw.frac=5000000 WHERE (coin).val=1;" | psql -Aqt "$DB" @@ -1927,14 +1845,13 @@ function test_29() { # Undo echo "UPDATE exchange.denominations SET fee_withdraw.frac=2000000 WHERE (coin).val=1;" | psql -Aqt "$DB" full_reload - stop_auditor_httpd } # Test where fees known to the auditor differ from those # accounted for by the exchange -function test_30() { - echo "===========30: melt fee inconsistency =================" +function test_29() { + echo "===========29: melt fee inconsistency =================" echo "UPDATE exchange.denominations SET fee_refresh.frac=5000000 WHERE (coin).val=10;" | psql -Aqt "$DB" @@ -1956,14 +1873,13 @@ function test_30() { echo "UPDATE exchange.denominations SET fee_refresh.frac=3000000 WHERE (coin).val=10;" | psql -Aqt "$DB" full_reload - stop_auditor_httpd } # Test where fees known to the auditor differ from those # accounted for by the exchange -function test_31() { - echo "===========31: deposit fee inconsistency =================" +function test_30() { + echo "===========30: deposit fee inconsistency =================" echo "UPDATE exchange.denominations SET fee_deposit.frac=5000000 WHERE (coin).val=8;" | psql -Aqt "$DB" @@ -1981,7 +1897,6 @@ function test_31() { "operation" "deposit" # Undo echo "UPDATE exchange.denominations SET fee_deposit.frac=2000000 WHERE (coin).val=8;" | psql -Aqt "$DB" - stop_auditor_httpd full_reload } @@ -1990,8 +1905,8 @@ function test_31() { # Test where denom_sig in known_coins table is wrong # (=> bad signature) -function test_32() { - echo "===========32: known_coins signature wrong w. aggregation=================" +function test_31() { + echo "===========31: known_coins signature wrong w. aggregation=================" # Modify denom_sig, so it is wrong OLD_SIG=$(echo 'SELECT denom_sig FROM exchange.known_coins LIMIT 1;' | psql "$DB" -Aqt) COIN_PUB=$(echo "SELECT coin_pub FROM exchange.known_coins WHERE denom_sig='$OLD_SIG';" | psql "$DB" -Aqt) @@ -2013,169 +1928,201 @@ function test_32() { "Missed updating aggregation_total_bad_sig_loss" # Cannot undo aggregation, do full reload - stop_auditor_httpd full_reload cleanup } +function test_32() { -# FIXME: test-33 not implemented -function test_33() { - - echo "===========33: normal run with aggregator and profit drain===========" + echo "===========32: normal run with aggregator and profit drain===========" run_audit aggregator drain check_auditor_running echo "Checking output" # if an emergency was detected, that is a bug and we should fail echo -n "Test for emergencies... " - call_endpoint "emergency" - jq -e .emergency[0] < "${MY_TMP_DIR}/emergency.json" > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo PASS + check_no_report "emergency" echo -n "Test for deposit confirmation detection... " - call_endpoint "deposit-confirmation" - jq -e .deposit_confirmation[0] < "${MY_TMP_DIR}/deposit-confirmation.json" > /dev/null && exit_fail "Unexpected deposit confirmation inconsistency detected" || echo PASS + check_no_report "deposit-confirmation" echo -n "Test for emergencies by count... " - call_endpoint "emergency-by-count" - jq -e .emergency_by_count[0] < "${MY_TMP_DIR}/emergency-by-count.json" > /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo PASS + check_no_report "emergency-by-count" - echo -n "Test for wire inconsistencies... " - #TODO: fix wire - #jq -e .wire_out_amount_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in ordinary run" - #jq -e .reserve_in_amount_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected reserve in inconsistency detected in ordinary run" - #jq -e .misattribution_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected misattribution inconsistency detected in ordinary run" - #jq -e .row_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected row inconsistency detected in ordinary run" - #jq -e .denomination_key_validity_withdraw_inconsistencies[0] < test-audit-reserves.json > /dev/null && exit_fail "Unexpected denomination key withdraw inconsistency detected in ordinary run" - #jq -e .row_minor_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected minor row inconsistency detected in ordinary run" - #jq -e .lag_details[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected lag detected in ordinary run" - #jq -e .wire_format_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected wire format inconsistencies detected in ordinary run" + echo -n "Testing bad sig loss balance... " + check_balance \ + "aggregation_total_bad_sig_loss" \ + "TESTKUDOS:0" \ + "Wrong total bad sig loss from aggregation, got unexpected loss" + echo -n "Testing coin irregular loss balances... " + check_balance \ + "coin_irregular_loss" \ + "TESTKUDOS:0" \ + "Wrong total bad sig loss from coins" - # TODO: check operation balances are correct (once we have all transaction types and wallet is deterministic) - # TODO: check revenue summaries are correct (once we have all transaction types and wallet is deterministic) + echo -n "Testing reserves bad sig loss balances... " + check_balance \ + "reserves_total_bad_sig_loss" \ + "TESTKUDOS:0" \ + "Wrong total bad sig loss from reserves" - echo "PASS" + echo -n "Test for aggregation wire out delta plus... " + check_balance \ + "aggregation_total_wire_out_delta_plus" \ + "TESTKUDOS:0" \ + "Expected total wire out delta plus wrong" - echo "Testing for aggregation bad sig loss" - call_endpoint "balances" "aggregation_total_bad_sig_loss" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_bad_sig_loss.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong total bad sig loss from aggregation, got unexpected loss of $LOSS" - fi - call_endpoint "balances" "coin_irregular_loss" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/coin_irregular_loss.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong total bad sig loss from coins, got unexpected loss of $LOSS" - fi - call_endpoint "balances" "reserves_total_bad_sig_loss" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/reserves_total_bad_sig_loss.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong total bad sig loss from reserves, got unexpected loss of $LOSS" - fi + echo -n "Test for aggregation wire out delta minus... " + check_balance \ + "aggregation_total_wire_out_delta_minus" \ + "TESTKUDOS:0" \ + "Expected total wire out delta minus wrong" - echo -n "Test for wire amounts... " - #WIRED=$(jq -r .total_wire_in_delta_plus < test-audit-wire.json") - #if [ "$WIRED" != "TESTKUDOS:0" ] - #then - # exit_fail "Expected total wire delta plus wrong, got $WIRED" - #fi - #WIRED=$(jq -r .total_wire_in_delta_minus < test-audit-wire.json") - #if [ "$WIRED" != "TESTKUDOS:0" ] - #then - # exit_fail "Expected total wire delta minus wrong, got $WIRED" - #fi - #WIRED=$(jq -r .total_wire_out_delta_plus < test-audit-wire.json") - #if [ "$WIRED" != "TESTKUDOS:0" ] - #then - # exit_fail "Expected total wire delta plus wrong, got $WIRED" - #fi - #WIRED=$(jq -r .total_wire_out_delta_minus < test-audit-wire.json") - #if [ "$WIRED" != "TESTKUDOS:0" ] - #then - # exit_fail "Expected total wire delta minus wrong, got $WIRED" - #fi - #WIRED=$(jq -r .total_misattribution_in < test-audit-wire.json") - #if [ "$WIRED" != "TESTKUDOS:0" ] - #then - # exit_fail "Expected total misattribution in wrong, got $WIRED" - #fi - echo "PASS" + echo -n "Test for bad incoming delta plus... " + check_balance \ + "total_bad_amount_in_plus" \ + "TESTKUDOS:0" \ + "Expected total wire in delta plus wrong" - echo -n "Checking for unexpected arithmetic differences... " - call_endpoint "balances" "aggregation_total_arithmetic_delta_plus" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_arithmetic_delta_plus.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong arithmetic delta from aggregations, got unexpected plus of $LOSS" - fi - call_endpoint "balances" "aggregation_total_arithmetic_delta_minus" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/aggregation_total_arithmetic_delta_minus.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong arithmetic delta from aggregation, got unexpected minus of $LOSS" - fi - call_endpoint "balances" "coins_total_arithmetic_delta_plus" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/coins_total_arithmetic_delta_plus.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong arithmetic delta from coins, got unexpected plus of $LOSS" - fi - call_endpoint "balances" "coins_total_arithmetic_delta_minus" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/coins_total_arithmetic_delta_minus.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong arithmetic delta from coins, got unexpected minus of $LOSS" - fi - call_endpoint "balances" "reserves_total_arithmetic_delta_plus" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/reserves_total_arithmetic_delta_plus.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong arithmetic delta from reserves, got unexpected plus of $LOSS" - fi - call_endpoint "balances" "reserves_total_arithmetic_delta_minus" - LOSS=$(jq -r .balances[0].balance_value < "${MY_TMP_DIR}/reserves_total_arithmetic_delta_minus.json") - if [ "$LOSS" != "TESTKUDOS:0" ] - then - exit_fail "Wrong arithmetic delta from reserves, got unexpected minus of $LOSS" - fi + echo -n "Test for total misattribution in ... " + check_balance \ + "total_misattribution_in" \ + "TESTKUDOS:0" \ + "Expected total wire in delta plus wrong" - #DRAINED=$(jq -r .total_drained < test-audit-wire.json") - #if [ "$DRAINED" != "TESTKUDOS:0.1" ] - #then - # exit_fail "Wrong amount drained, got unexpected drain of $DRAINED" - #fi - -#TODO: fix AAI - call_endpoint "amount-arithmetic-inconsistency" -# jq -e .amount_arithmetic_inconsistency[0] \ -# < "${MY_TMP_DIR}/amount-arithmetic-inconsistency.json" \ -# > /dev/null \ -# && exit_fail "Unexpected arithmetic inconsistencies from aggregations detected in ordinary run" -# jq -e .amount_arithmetic_inconsistency[0] \ -# < "${MY_TMP_DIR}/amount-arithmetic-inconsistency.json" \ -# > /dev/null \ -# && exit_fail "Unexpected arithmetic inconsistencies from coins detected in ordinary run" -# jq -e .amount_arithmetic_inconsistency[0] \ -# < "${MY_TMP_DIR}/amount-arithmetic-inconsistency.json" \ -# > /dev/null \ -# && exit_fail "Unexpected arithmetic inconsistencies from reserves detected in ordinary run" - echo "PASS" + echo -n "Test for bad incoming delta minus... " + check_balance \ + "total_bad_amount_in_minus" \ + "TESTKUDOS:0" \ + "Expected total wire in delta minus wrong" + + echo -n "Test for bad outgoing delta plus... " + check_balance \ + "total_bad_amount_out_plus" \ + "TESTKUDOS:0" \ + "Expected total wire out delta plus wrong" + + echo -n "Test for bad outgoing delta minus... " + check_balance \ + "total_bad_amount_out_minus" \ + "TESTKUDOS:0" \ + "Expected total wire in delta minus wrong" + + echo -n "Test for misattribution amounts... " + check_balance \ + "total_misattribution_in" \ + "TESTKUDOS:0" \ + "Expected total misattribution in wrong" + + echo -n "Checking for unexpected aggregation delta plus differences... " + check_balance \ + "aggregation_total_arithmetic_delta_plus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta plus from aggregations" + + echo -n "Checking for unexpected aggregation delta minus differences... " + check_balance \ + "aggregation_total_arithmetic_delta_minus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta minus from aggregations" + + echo -n "Checking for unexpected coin delta plus differences... " + check_balance \ + "coins_total_arithmetic_delta_plus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta plus from coins" + + echo -n "Checking for unexpected coin delta minus differences... " + check_balance \ + "coins_total_arithmetic_delta_minus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta minus from coins" + + echo -n "Checking for unexpected reserves delta plus... " + check_balance \ + "reserves_total_arithmetic_delta_plus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta plus from reserves" + + echo -n "Checking for unexpected reserves delta minus... " + check_balance \ + "reserves_total_arithmetic_delta_minus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta minus from reserves" echo -n "Checking for unexpected wire out differences... " - call_endpoint "wire-out-inconsistency" - jq -e .wire_out_inconsistency[0] \ - < "${MY_TMP_DIR}/wire-out-inconsistency.json" \ - > /dev/null \ - && exit_fail "Unexpected wire out inconsistencies detected in ordinary run" - echo "PASS" + check_no_report "wire-out-inconsistency" + + # Just to test the endpoint and for logging ... + call_endpoint "balances" + echo -n "Testing for aggregation bad sig loss... " + check_balance \ + "aggregation_total_bad_sig_loss" \ + "TESTKUDOS:0" \ + "Wrong total bad sig loss from aggregation, got unexpected loss" + + echo -n "Testing for coin bad sig loss... " + check_balance \ + "coin_irregular_loss" \ + "TESTKUDOS:0" \ + "Wrong total bad sig loss from coins, got unexpected loss" + + echo -n "Testing for reserves bad sig loss... " + check_balance \ + "reserves_total_bad_sig_loss" \ + "TESTKUDOS:0" \ + "Wrong total bad sig loss from reserves, got unexpected loss" + + echo -n "Checking for unexpected aggregation delta plus differences... " + check_balance \ + "aggregation_total_arithmetic_delta_plus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta plus from aggregations" + + echo -n "Checking for unexpected aggregation delta minus differences... " + check_balance \ + "aggregation_total_arithmetic_delta_minus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta minus from aggregations" + + echo -n "Checking for unexpected coin delta plus differences... " + check_balance \ + "coins_total_arithmetic_delta_plus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta plus from coins" + + echo -n "Checking for unexpected coin delta minus differences... " + check_balance \ + "coins_total_arithmetic_delta_minus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta minus from coins" + + echo -n "Checking for unexpected reserves delta plus... " + check_balance \ + "reserves_total_arithmetic_delta_plus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta plus from reserves" + + echo -n "Checking for unexpected reserves delta minus... " + check_balance \ + "reserves_total_arithmetic_delta_minus" \ + "TESTKUDOS:0" \ + "Wrong arithmetic delta minus from reserves" + + echo -n "Checking amount arithmetic inconsistency" + check_no_report "amount-arithmetic-inconsistency" + + echo -n "Checking for unexpected wire out differences " + check_no_report "wire-out-inconsistency" + + echo -n "Checking total drained... " + check_balance \ + "total_drained" \ + "TESTKUDOS:0.1" \ + "Wrong total drained amount reported" # cannot easily undo aggregator, hence full reload full_reload - stop_auditor_httpd - } @@ -2188,6 +2135,7 @@ function check_with_database() { BASEDB="$1" CONF="$1.conf" + export CONF echo "Running test suite with database $BASEDB using configuration $CONF" MASTER_PRIV_FILE="${BASEDB}.mpriv" taler-config \ diff --git a/src/auditordb/0002-auditor_deposit_confirmations.sql b/src/auditordb/0002-auditor_deposit_confirmations.sql index 7e47b4fd1..c9541d603 100644 --- a/src/auditordb/0002-auditor_deposit_confirmations.sql +++ b/src/auditordb/0002-auditor_deposit_confirmations.sql @@ -15,24 +15,24 @@ -- CREATE TABLE auditor_deposit_confirmations -(deposit_confirmation_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE - ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64) - ,h_policy BYTEA NOT NULL CHECK (LENGTH(h_policy)=64) - ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64) - ,exchange_timestamp BIGINT NOT NULL - ,refund_deadline BIGINT NOT NULL - ,wire_deadline BIGINT NOT NULL - ,total_without_fee taler_amount NOT NULL - ,coin_pubs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_pubs)>0) - ,coin_sigs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_sigs)=CARDINALITY(coin_pubs)) - ,merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32) - ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) - ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32) - ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64) - ,suppressed BOOLEAN NOT NULL DEFAULT FALSE - ,ancient BOOLEAN NOT NULL DEFAULT FALSE - ,PRIMARY KEY (h_contract_terms,h_wire,merchant_pub,exchange_sig,exchange_pub,master_sig) - ); + (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE + ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64) + ,h_policy BYTEA NOT NULL CHECK (LENGTH(h_policy)=64) + ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64) + ,exchange_timestamp BIGINT NOT NULL + ,refund_deadline BIGINT NOT NULL + ,wire_deadline BIGINT NOT NULL + ,total_without_fee taler_amount NOT NULL + ,coin_pubs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_pubs)>0) + ,coin_sigs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_sigs)=CARDINALITY(coin_pubs)) + ,merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32) + ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) + ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32) + ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64) + ,suppressed BOOLEAN NOT NULL DEFAULT FALSE + ,ancient BOOLEAN NOT NULL DEFAULT FALSE + ,PRIMARY KEY (h_contract_terms,h_wire,merchant_pub,exchange_sig,exchange_pub,master_sig) + ); COMMENT ON TABLE auditor_deposit_confirmations IS 'deposit confirmation sent to us by merchants; we must check that the exchange reported these properly.'; diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am index a96df2a24..7f6cf8537 100644 --- a/src/auditordb/Makefile.am +++ b/src/auditordb/Makefile.am @@ -62,7 +62,6 @@ libtaler_plugin_auditordb_postgres_la_SOURCES = \ plugin_auditordb_postgres.c \ pg_helper.h pg_helper.c \ pg_delete_generic.c pg_delete_generic.h \ - pg_delete_deposit_confirmations.c pg_delete_deposit_confirmations.h \ pg_delete_pending_deposit.c pg_delete_pending_deposit.h \ pg_delete_purse_info.c pg_delete_purse_info.h \ pg_del_denomination_balance.h pg_del_denomination_balance.c \ @@ -107,64 +106,42 @@ libtaler_plugin_auditordb_postgres_la_SOURCES = \ pg_get_denomination_key_validity_withdraw_inconsistency.c pg_get_denomination_key_validity_withdraw_inconsistency.h \ pg_insert_purse_not_closed_inconsistencies.c pg_insert_purse_not_closed_inconsistencies.h \ pg_get_purse_not_closed_inconsistencies.c pg_get_purse_not_closed_inconsistencies.h \ -pg_insert_reserve_balance_insufficient_inconsistency.c pg_insert_reserve_balance_insufficient_inconsistency.h \ -pg_get_reserve_balance_insufficient_inconsistency.c pg_get_reserve_balance_insufficient_inconsistency.h \ -pg_insert_bad_sig_losses.c pg_insert_bad_sig_losses.h \ -pg_get_bad_sig_losses.c pg_get_bad_sig_losses.h \ -pg_update_bad_sig_losses.c pg_update_bad_sig_losses.h \ -pg_insert_auditor_closure_lags.c pg_insert_auditor_closure_lags.h \ -pg_get_auditor_closure_lags.c pg_get_auditor_closure_lags.h \ -pg_insert_refreshes_hanging.c pg_insert_refreshes_hanging.h \ -pg_get_refreshes_hanging.c pg_get_refreshes_hanging.h \ -pg_update_emergency_by_count.c pg_update_emergency_by_count.h \ -pg_update_row_inconsistency.c pg_update_row_inconsistency.h \ -pg_update_purse_not_closed_inconsistencies.c pg_update_purse_not_closed_inconsistencies.h \ -pg_update_reserve_balance_insufficient_inconsistency.c pg_update_reserve_balance_insufficient_inconsistency.h \ -pg_update_coin_inconsistency.c pg_update_coin_inconsistency.h \ -pg_update_denomination_key_validity_withdraw_inconsistency.c pg_update_denomination_key_validity_withdraw_inconsistency.h \ -pg_update_refreshes_hanging.c pg_update_refreshes_hanging.h \ -pg_update_emergency.c pg_update_emergency.h \ -pg_update_closure_lags.c pg_update_closure_lags.h \ -pg_get_reserve_in_inconsistency.c pg_get_reserve_in_inconsistency.h \ -pg_insert_reserve_in_inconsistency.c pg_insert_reserve_in_inconsistency.h \ -pg_update_reserve_in_inconsistency.c pg_update_reserve_in_inconsistency.h \ -pg_get_reserve_not_closed_inconsistency.c pg_get_reserve_not_closed_inconsistency.h \ -pg_insert_reserve_not_closed_inconsistency.c pg_insert_reserve_not_closed_inconsistency.h \ -pg_update_reserve_not_closed_inconsistency.c pg_update_reserve_not_closed_inconsistency.h \ -pg_get_denominations_without_sigs.c pg_get_denominations_without_sigs.h \ -pg_insert_denominations_without_sigs.c pg_insert_denominations_without_sigs.h \ -pg_update_denominations_without_sigs.c pg_update_denominations_without_sigs.h \ -pg_get_misattribution_in_inconsistency.c pg_get_misattribution_in_inconsistency.h \ -pg_insert_misattribution_in_inconsistency.c pg_insert_misattribution_in_inconsistency.h \ -pg_update_misattribution_in_inconsistency.c pg_update_misattribution_in_inconsistency.h \ -pg_update_balance.c pg_update_balance.h \ -pg_get_reserves.c pg_get_reserves.h \ -pg_get_purses.c pg_get_purses.h \ -pg_insert_historic_denom_revenue.c pg_insert_historic_denom_revenue.h \ -pg_get_denomination_pending.c pg_get_denomination_pending.h \ -pg_insert_denomination_pending.c pg_insert_denomination_pending.h \ -pg_update_denomination_pending.c pg_update_denomination_pending.h \ -pg_get_exchange_signkeys.c pg_get_exchange_signkeys.h \ -pg_get_wire_format_inconsistency.c pg_get_wire_format_inconsistency.h \ -pg_insert_wire_format_inconsistency.c pg_insert_wire_format_inconsistency.h \ -pg_update_wire_format_inconsistency.c pg_update_wire_format_inconsistency.h \ -pg_get_wire_out_inconsistency.c pg_get_wire_out_inconsistency.h \ -pg_insert_wire_out_inconsistency.c pg_insert_wire_out_inconsistency.h \ -pg_delete_wire_out_inconsistency_if_matching.c pg_delete_wire_out_inconsistency_if_matching.h \ -pg_update_wire_out_inconsistency.c pg_update_wire_out_inconsistency.h \ -pg_get_reserve_balance_summary_wrong_inconsistency.c pg_get_reserve_balance_summary_wrong_inconsistency.h \ -pg_insert_reserve_balance_summary_wrong_inconsistency.c pg_insert_reserve_balance_summary_wrong_inconsistency.h \ -pg_update_reserve_balance_summary_wrong_inconsistency.c pg_update_reserve_balance_summary_wrong_inconsistency.h \ -pg_get_row_minor_inconsistencies.c pg_get_row_minor_inconsistencies.h \ -pg_insert_row_minor_inconsistencies.c pg_insert_row_minor_inconsistencies.h \ -pg_update_row_minor_inconsistencies.c pg_update_row_minor_inconsistencies.h \ -pg_get_fee_time_inconsistency.c pg_get_fee_time_inconsistency.h \ -pg_insert_fee_time_inconsistency.c pg_insert_fee_time_inconsistency.h \ -pg_update_fee_time_inconsistency.c pg_update_fee_time_inconsistency.h \ -pg_get_balances.c pg_get_balances.h \ -pg_insert_exchange_signkey.c pg_insert_exchange_signkey.h \ -pg_update_deposit_confirmations.c pg_update_deposit_confirmations.h \ -pg_update_amount_arithmetic_inconsistency.c pg_update_amount_arithmetic_inconsistency.h + pg_insert_reserve_balance_insufficient_inconsistency.c pg_insert_reserve_balance_insufficient_inconsistency.h \ + pg_get_reserve_balance_insufficient_inconsistency.c pg_get_reserve_balance_insufficient_inconsistency.h \ + pg_insert_bad_sig_losses.c pg_insert_bad_sig_losses.h \ + pg_get_bad_sig_losses.c pg_get_bad_sig_losses.h \ + pg_insert_auditor_closure_lags.c pg_insert_auditor_closure_lags.h \ + pg_get_auditor_closure_lags.c pg_get_auditor_closure_lags.h \ + pg_insert_refreshes_hanging.c pg_insert_refreshes_hanging.h \ + pg_get_refreshes_hanging.c pg_get_refreshes_hanging.h \ + pg_get_reserve_in_inconsistency.c pg_get_reserve_in_inconsistency.h \ + pg_insert_reserve_in_inconsistency.c pg_insert_reserve_in_inconsistency.h \ + pg_get_reserve_not_closed_inconsistency.c pg_get_reserve_not_closed_inconsistency.h \ + pg_insert_reserve_not_closed_inconsistency.c pg_insert_reserve_not_closed_inconsistency.h \ + pg_get_denominations_without_sigs.c pg_get_denominations_without_sigs.h \ + pg_insert_denominations_without_sigs.c pg_insert_denominations_without_sigs.h \ + pg_get_misattribution_in_inconsistency.c pg_get_misattribution_in_inconsistency.h \ + pg_insert_misattribution_in_inconsistency.c pg_insert_misattribution_in_inconsistency.h \ + pg_update_balance.c pg_update_balance.h \ + pg_get_reserves.c pg_get_reserves.h \ + pg_get_purses.c pg_get_purses.h \ + pg_insert_historic_denom_revenue.c pg_insert_historic_denom_revenue.h \ + pg_get_denomination_pending.c pg_get_denomination_pending.h \ + pg_insert_denomination_pending.c pg_insert_denomination_pending.h \ + pg_get_exchange_signkeys.c pg_get_exchange_signkeys.h \ + pg_get_wire_format_inconsistency.c pg_get_wire_format_inconsistency.h \ + pg_insert_wire_format_inconsistency.c pg_insert_wire_format_inconsistency.h \ + pg_get_wire_out_inconsistency.c pg_get_wire_out_inconsistency.h \ + pg_insert_wire_out_inconsistency.c pg_insert_wire_out_inconsistency.h \ + pg_delete_wire_out_inconsistency_if_matching.c pg_delete_wire_out_inconsistency_if_matching.h \ + pg_get_reserve_balance_summary_wrong_inconsistency.c pg_get_reserve_balance_summary_wrong_inconsistency.h \ + pg_insert_reserve_balance_summary_wrong_inconsistency.c pg_insert_reserve_balance_summary_wrong_inconsistency.h \ + pg_get_row_minor_inconsistencies.c pg_get_row_minor_inconsistencies.h \ + pg_insert_row_minor_inconsistencies.c pg_insert_row_minor_inconsistencies.h \ + pg_get_fee_time_inconsistency.c pg_get_fee_time_inconsistency.h \ + pg_insert_fee_time_inconsistency.c pg_insert_fee_time_inconsistency.h \ + pg_get_balances.c pg_get_balances.h \ + pg_insert_exchange_signkey.c pg_insert_exchange_signkey.h libtaler_plugin_auditordb_postgres_la_LDFLAGS = \ $(TALER_PLUGIN_LDFLAGS) diff --git a/src/auditordb/auditordb_plugin.c b/src/auditordb/auditordb_plugin.c index 635247aa3..7aaeabf7b 100644 --- a/src/auditordb/auditordb_plugin.c +++ b/src/auditordb/auditordb_plugin.c @@ -25,7 +25,8 @@ struct TALER_AUDITORDB_Plugin * -TALER_AUDITORDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) +TALER_AUDITORDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg, + bool skip_preflight) { char *plugin_name; char *lib_name; @@ -52,6 +53,15 @@ TALER_AUDITORDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) plugin->library_name = lib_name; else GNUNET_free (lib_name); + if ( (! skip_preflight) && + (GNUNET_OK != + plugin->preflight (plugin->cls)) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Database not ready. Try running taler-auditor-dbinit!\n"); + TALER_AUDITORDB_plugin_unload (plugin); + return NULL; + } return plugin; } diff --git a/src/auditordb/pg_delete_deposit_confirmations.c b/src/auditordb/pg_delete_deposit_confirmations.c deleted file mode 100644 index b337239c8..000000000 --- a/src/auditordb/pg_delete_deposit_confirmations.c +++ /dev/null @@ -1,47 +0,0 @@ -/*
- This file is part of TALER
- Copyright (C) 2024 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file auditordb/pg_delete_deposit_confirmations.c
- * @brief Implementation of the delete_deposit_confirmations function for Postgres
- * @author Nicola Eigel
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_delete_deposit_confirmations.h"
-#include "pg_helper.h"
-
-enum GNUNET_DB_QueryStatus
-TAH_PG_delete_deposit_confirmation (
- void *cls,
- uint64_t row_id)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&row_id),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "auditor_delete_deposit_confirmation",
- "DELETE"
- " FROM auditor_deposit_confirmations"
- " WHERE deposit_confirmation_serial_id=$1;");
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "auditor_delete_deposit_confirmation",
- params);
-}
diff --git a/src/auditordb/pg_delete_wire_out_inconsistency_if_matching.c b/src/auditordb/pg_delete_wire_out_inconsistency_if_matching.c index 3e959bf5d..b0390b426 100644 --- a/src/auditordb/pg_delete_wire_out_inconsistency_if_matching.c +++ b/src/auditordb/pg_delete_wire_out_inconsistency_if_matching.c @@ -26,7 +26,7 @@ TAH_PG_delete_wire_out_inconsistency_if_matching ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (dc->destination_account), + GNUNET_PQ_query_param_string (dc->destination_account.full_payto), GNUNET_PQ_query_param_string (dc->diagnostic), GNUNET_PQ_query_param_uint64 (&dc->wire_out_row_id), TALER_PQ_query_param_amount (pg->conn, diff --git a/src/auditordb/pg_get_auditor_closure_lags.c b/src/auditordb/pg_get_auditor_closure_lags.c index de2b98dd6..e81367ed0 100644 --- a/src/auditordb/pg_get_auditor_closure_lags.c +++ b/src/auditordb/pg_get_auditor_closure_lags.c @@ -78,7 +78,7 @@ closure_lags_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("wtid", &dc.wtid), GNUNET_PQ_result_spec_string ("account", - &dc.account), + &dc.account.full_payto), GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), GNUNET_PQ_result_spec_end diff --git a/src/auditordb/pg_get_deposit_confirmations.c b/src/auditordb/pg_get_deposit_confirmations.c index b6c33117e..f1f28b8a2 100644 --- a/src/auditordb/pg_get_deposit_confirmations.c +++ b/src/auditordb/pg_get_deposit_confirmations.c @@ -80,7 +80,7 @@ deposit_confirmation_cb (void *cls, size_t num_pubs = 0; size_t num_sigs = 0; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("deposit_confirmation_serial_id", + GNUNET_PQ_result_spec_uint64 ("row_id", &dc.row_id), GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms", &dc.h_contract_terms), @@ -174,7 +174,7 @@ TAH_PG_get_deposit_confirmations ( PREPARE (pg, "auditor_deposit_confirmation_select_desc", "SELECT" - " deposit_confirmation_serial_id" + " row_id" ",h_contract_terms" ",h_policy" ",h_wire" @@ -190,15 +190,15 @@ TAH_PG_get_deposit_confirmations ( ",master_sig" ",suppressed" " FROM auditor_deposit_confirmations" - " WHERE (deposit_confirmation_serial_id < $1)" + " WHERE (row_id < $1)" " AND ($2 OR NOT suppressed)" - " ORDER BY deposit_confirmation_serial_id DESC" + " ORDER BY row_id DESC" " LIMIT $3" ); PREPARE (pg, "auditor_deposit_confirmation_select_asc", "SELECT" - " deposit_confirmation_serial_id" + " row_id" ",h_contract_terms" ",h_policy" ",h_wire" @@ -214,9 +214,9 @@ TAH_PG_get_deposit_confirmations ( ",master_sig" ",suppressed" " FROM auditor_deposit_confirmations" - " WHERE (deposit_confirmation_serial_id > $1)" + " WHERE (row_id > $1)" " AND ($2 OR NOT suppressed)" - " ORDER BY deposit_confirmation_serial_id ASC" + " ORDER BY row_id ASC" " LIMIT $3" ); qs = GNUNET_PQ_eval_prepared_multi_select ( diff --git a/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c index d41d1cbf9..89ef0d178 100644 --- a/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c +++ b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c @@ -13,14 +13,11 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_helper.h" - #include "pg_get_reserve_balance_summary_wrong_inconsistency.h" @@ -65,26 +62,21 @@ reserve_balance_summary_wrong_inconsistency_cb (void *cls, { struct ReserveBalanceSummaryWrongInconsistencyContext *dcc = cls; struct PostgresClosure *pg = dcc->pg; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "---found rbswi's in reserveblanace...\n"); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "---num_results: %u\n", num_results); - for (unsigned int i = 0; i < num_results; i++) { - uint64_t serial_id; - struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency dc; - struct GNUNET_PQ_ResultSpec rs[] = { - - GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), - GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub), - TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_amount", &dc.exchange_amount), - TALER_PQ_RESULT_SPEC_AMOUNT ("auditor_amount", &dc.auditor_amount), - GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), - - + GNUNET_PQ_result_spec_uint64 ("row_id", + &dc.row_id), + GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", + &dc.reserve_pub), + TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_amount", + &dc.exchange_amount), + TALER_PQ_RESULT_SPEC_AMOUNT ("auditor_amount", + &dc.auditor_amount), + GNUNET_PQ_result_spec_bool ("suppressed", + &dc.suppressed), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -98,11 +90,8 @@ reserve_balance_summary_wrong_inconsistency_cb (void *cls, dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } - dcc->qs = i + 1; - rval = dcc->cb (dcc->cb_cls, - serial_id, &dc); GNUNET_PQ_cleanup_result (rs); if (GNUNET_OK != rval) @@ -116,14 +105,12 @@ TAH_PG_get_reserve_balance_summary_wrong_inconsistency ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed + bool return_suppressed, TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb, void *cb_cls) { - - uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); - struct PostgresClosure *pg = cls; + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_bool (return_suppressed), @@ -140,41 +127,39 @@ TAH_PG_get_reserve_balance_summary_wrong_inconsistency ( PREPARE (pg, "auditor_reserve_balance_summary_wrong_inconsistency_get_desc", "SELECT" - " row_id," - " reserve_pub," - " exchange_amount," - " auditor_amount," - " suppressed" + " row_id" + ",reserve_pub" + ",exchange_amount" + ",auditor_amount" + ",suppressed" " FROM auditor_reserve_balance_summary_wrong_inconsistency" " WHERE (row_id < $1)" - " AND ($2 OR suppressed is false)" + " AND ($2 OR NOT suppressed)" " ORDER BY row_id DESC" " LIMIT $3" ); PREPARE (pg, "auditor_reserve_balance_summary_wrong_inconsistency_get_asc", "SELECT" - " row_id," - " reserve_pub," - " exchange_amount," - " auditor_amount," - " suppressed" + " row_id" + ",reserve_pub" + ",exchange_amount" + ",auditor_amount" + ",suppressed" " FROM auditor_reserve_balance_summary_wrong_inconsistency" " WHERE (row_id > $1)" - " AND ($2 OR suppressed is false)" + " AND ($2 OR NOT suppressed)" " ORDER BY row_id ASC" " LIMIT $3" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) - ? - "auditor_reserve_balance_summary_wrong_inconsistency_get_asc" - : - "auditor_reserve_balance_summary_wrong_inconsistency_get_desc", - params, - & - reserve_balance_summary_wrong_inconsistency_cb, - &dcc); + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_reserve_balance_summary_wrong_inconsistency_get_asc" + : "auditor_reserve_balance_summary_wrong_inconsistency_get_desc", + params, + &reserve_balance_summary_wrong_inconsistency_cb, + &dcc); if (qs > 0) return dcc.qs; diff --git a/src/auditordb/pg_get_reserve_in_inconsistency.c b/src/auditordb/pg_get_reserve_in_inconsistency.c index b3abc8799..0d9562733 100644 --- a/src/auditordb/pg_get_reserve_in_inconsistency.c +++ b/src/auditordb/pg_get_reserve_in_inconsistency.c @@ -81,7 +81,7 @@ reserve_in_inconsistency_cb (void *cls, GNUNET_PQ_result_spec_absolute_time ("timestamp", &dc.timestamp), GNUNET_PQ_result_spec_string ("account", - &dc.account), + &dc.account.full_payto), GNUNET_PQ_result_spec_string ("diagnostic", &dc.diagnostic), GNUNET_PQ_result_spec_bool ("suppressed", diff --git a/src/auditordb/pg_get_reserve_info.c b/src/auditordb/pg_get_reserve_info.c index f16c6d995..2dac3f76b 100644 --- a/src/auditordb/pg_get_reserve_info.c +++ b/src/auditordb/pg_get_reserve_info.c @@ -32,7 +32,7 @@ TAH_PG_get_reserve_info (void *cls, uint64_t *rowid, struct TALER_AUDITORDB_ReserveFeeBalance *rfb, struct GNUNET_TIME_Timestamp *expiration_date, - char **sender_account) + struct TALER_FullPayto *sender_account) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -60,12 +60,12 @@ TAH_PG_get_reserve_info (void *cls, rowid), GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_string ("origin_account", - sender_account), + &sender_account->full_payto), NULL), GNUNET_PQ_result_spec_end }; - *sender_account = NULL; + sender_account->full_payto = NULL; PREPARE (pg, "auditor_get_reserve_info", "SELECT" diff --git a/src/auditordb/pg_get_reserve_info.h b/src/auditordb/pg_get_reserve_info.h index 3eba035fc..5e3fa6281 100644 --- a/src/auditordb/pg_get_reserve_info.h +++ b/src/auditordb/pg_get_reserve_info.h @@ -43,7 +43,7 @@ TAH_PG_get_reserve_info (void *cls, uint64_t *rowid, struct TALER_AUDITORDB_ReserveFeeBalance *rfb, struct GNUNET_TIME_Timestamp *expiration_date, - char **sender_account); + struct TALER_FullPayto *sender_account); #endif diff --git a/src/auditordb/pg_get_reserves.c b/src/auditordb/pg_get_reserves.c index 222fec908..55ae81d3a 100644 --- a/src/auditordb/pg_get_reserves.c +++ b/src/auditordb/pg_get_reserves.c @@ -88,7 +88,7 @@ reserves_cb (void *cls, GNUNET_PQ_result_spec_absolute_time ("expiration_date", &dc.expiration_date), GNUNET_PQ_result_spec_string ("origin_account", - &dc.origin_account), + &dc.origin_account.full_payto), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; diff --git a/src/auditordb/pg_get_wire_out_inconsistency.c b/src/auditordb/pg_get_wire_out_inconsistency.c index 4e9ca905f..aa365b67e 100644 --- a/src/auditordb/pg_get_wire_out_inconsistency.c +++ b/src/auditordb/pg_get_wire_out_inconsistency.c @@ -70,7 +70,7 @@ wire_out_inconsistency_cb (void *cls, GNUNET_PQ_result_spec_uint64 ("row_id", &dc.row_id), GNUNET_PQ_result_spec_string ("destination_account", - &dc.destination_account), + &dc.destination_account.full_payto), GNUNET_PQ_result_spec_string ("diagnostic", &dc.diagnostic), GNUNET_PQ_result_spec_uint64 ("wire_out_serial_id", diff --git a/src/auditordb/pg_helper.c b/src/auditordb/pg_helper.c index 446e685f3..a3664aab1 100644 --- a/src/auditordb/pg_helper.c +++ b/src/auditordb/pg_helper.c @@ -26,7 +26,9 @@ const char * -TAH_PG_get_deletable_suppressable_table_name (enum TALER_AUDITORDB_DeletableSuppressableTables table) +TAH_PG_get_deletable_suppressable_table_name (enum + TALER_AUDITORDB_DeletableSuppressableTables + table) { const char *tables[] = { "auditor_amount_arithmetic_inconsistency", @@ -37,21 +39,21 @@ TAH_PG_get_deletable_suppressable_table_name (enum TALER_AUDITORDB_DeletableSupp "auditor_denomination_key_validity_withdraw_inconsistency", "auditor_denomination_pending", "auditor_denomination_without_sig", - "auditor_deposit_confirmation", + "auditor_deposit_confirmations", "auditor_emergency", - "auditor_emergency_by_count", - "auditor_fee_time_inconsistency", - "auditor_misattribution_in_inconsistency", - "auditor_purse_not_closed_inconsistency", - "auditor_refreshes_haning", - "auditor_reserve_balance_insufficient_inconsistency", - "auditor_reserve_balance_summary_wrong_inconsistency", - "auditor_reserve_in_inconsistency", - "auditor_reserve_not_closed_inconsistency", - "auditor_row_inconsistency", - "auditor_row_minor_inconsistency", - "auditor_wire_format_inconsistency", - "auditor_wire_out_inconsistency", + "auditor_emergency_by_count", + "auditor_fee_time_inconsistency", + "auditor_misattribution_in_inconsistency", + "auditor_purse_not_closed_inconsistency", + "auditor_refreshes_haning", + "auditor_reserve_balance_insufficient_inconsistency", + "auditor_reserve_balance_summary_wrong_inconsistency", + "auditor_reserve_in_inconsistency", + "auditor_reserve_not_closed_inconsistency", + "auditor_row_inconsistency", + "auditor_row_minor_inconsistency", + "auditor_wire_format_inconsistency", + "auditor_wire_out_inconsistency", NULL, }; diff --git a/src/auditordb/pg_insert_auditor_closure_lags.c b/src/auditordb/pg_insert_auditor_closure_lags.c index b437a5d7f..f66c1df7c 100644 --- a/src/auditordb/pg_insert_auditor_closure_lags.c +++ b/src/auditordb/pg_insert_auditor_closure_lags.c @@ -31,7 +31,7 @@ TAH_PG_insert_auditor_closure_lags ( GNUNET_PQ_query_param_uint64 (&dc->problem_row_id), GNUNET_PQ_query_param_absolute_time (&dc->deadline), GNUNET_PQ_query_param_auto_from_type (&dc->wtid), - GNUNET_PQ_query_param_string (dc->account), + GNUNET_PQ_query_param_string (dc->account.full_payto), GNUNET_PQ_query_param_end }; diff --git a/src/auditordb/pg_insert_coin_inconsistency.c b/src/auditordb/pg_insert_coin_inconsistency.c index 70d105175..2fcf7f498 100644 --- a/src/auditordb/pg_insert_coin_inconsistency.c +++ b/src/auditordb/pg_insert_coin_inconsistency.c @@ -40,12 +40,11 @@ TAH_PG_insert_coin_inconsistency ( "auditor_coin_inconsistency_insert", "INSERT INTO auditor_coin_inconsistency " "(operation" - ",problem_row_id" ",exchange_amount" ",auditor_amount" ",coin_pub" ",profitable" - ") VALUES ($1,$2,$3,$4,$5,$6)" + ") VALUES ($1,$2,$3,$4,$5)" ); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_coin_inconsistency_insert", diff --git a/src/auditordb/pg_insert_pending_deposit.c b/src/auditordb/pg_insert_pending_deposit.c index 50b655ee7..fd2b62505 100644 --- a/src/auditordb/pg_insert_pending_deposit.c +++ b/src/auditordb/pg_insert_pending_deposit.c @@ -30,7 +30,7 @@ enum GNUNET_DB_QueryStatus TAH_PG_insert_pending_deposit ( void *cls, uint64_t batch_deposit_serial_id, - const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_FullPaytoHashP *wire_target_h_payto, const struct TALER_Amount *total_amount, struct GNUNET_TIME_Timestamp deadline) { diff --git a/src/auditordb/pg_insert_pending_deposit.h b/src/auditordb/pg_insert_pending_deposit.h index 7c2b59809..bebe47265 100644 --- a/src/auditordb/pg_insert_pending_deposit.h +++ b/src/auditordb/pg_insert_pending_deposit.h @@ -40,7 +40,7 @@ enum GNUNET_DB_QueryStatus TAH_PG_insert_pending_deposit ( void *cls, uint64_t batch_deposit_serial_id, - const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_FullPaytoHashP *wire_target_h_payto, const struct TALER_Amount *total_amount, struct GNUNET_TIME_Timestamp deadline); diff --git a/src/auditordb/pg_insert_reserve_in_inconsistency.c b/src/auditordb/pg_insert_reserve_in_inconsistency.c index c584a0ff4..37bc20124 100644 --- a/src/auditordb/pg_insert_reserve_in_inconsistency.c +++ b/src/auditordb/pg_insert_reserve_in_inconsistency.c @@ -33,7 +33,7 @@ TAH_PG_insert_reserve_in_inconsistency ( &dc->amount_wired), GNUNET_PQ_query_param_auto_from_type (&dc->reserve_pub), GNUNET_PQ_query_param_absolute_time (&dc->timestamp), - GNUNET_PQ_query_param_string (dc->account), + GNUNET_PQ_query_param_string (dc->account.full_payto), GNUNET_PQ_query_param_string (dc->diagnostic), GNUNET_PQ_query_param_end }; diff --git a/src/auditordb/pg_insert_reserve_info.c b/src/auditordb/pg_insert_reserve_info.c index 4c99394fe..f0cc7ba77 100644 --- a/src/auditordb/pg_insert_reserve_info.c +++ b/src/auditordb/pg_insert_reserve_info.c @@ -32,7 +32,7 @@ TAH_PG_insert_reserve_info ( const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, struct GNUNET_TIME_Timestamp expiration_date, - const char *origin_account) + const struct TALER_FullPayto origin_account) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -52,9 +52,9 @@ TAH_PG_insert_reserve_info ( TALER_PQ_query_param_amount (pg->conn, &rfb->history_fee_balance), GNUNET_PQ_query_param_timestamp (&expiration_date), - NULL == origin_account + NULL == origin_account.full_payto ? GNUNET_PQ_query_param_null () - : GNUNET_PQ_query_param_string (origin_account), + : GNUNET_PQ_query_param_string (origin_account.full_payto), GNUNET_PQ_query_param_end }; diff --git a/src/auditordb/pg_insert_reserve_info.h b/src/auditordb/pg_insert_reserve_info.h index b416aa556..a5764ac32 100644 --- a/src/auditordb/pg_insert_reserve_info.h +++ b/src/auditordb/pg_insert_reserve_info.h @@ -43,6 +43,6 @@ TAH_PG_insert_reserve_info ( const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, struct GNUNET_TIME_Timestamp expiration_date, - const char *origin_account); + const struct TALER_FullPayto origin_account); #endif diff --git a/src/auditordb/pg_insert_wire_out_inconsistency.c b/src/auditordb/pg_insert_wire_out_inconsistency.c index 2e9354644..431852c0f 100644 --- a/src/auditordb/pg_insert_wire_out_inconsistency.c +++ b/src/auditordb/pg_insert_wire_out_inconsistency.c @@ -28,7 +28,7 @@ TAH_PG_insert_wire_out_inconsistency ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (dc->destination_account), + GNUNET_PQ_query_param_string (dc->destination_account.full_payto), GNUNET_PQ_query_param_string (dc->diagnostic), GNUNET_PQ_query_param_uint64 (&dc->wire_out_row_id), TALER_PQ_query_param_amount (pg->conn, diff --git a/src/auditordb/pg_select_pending_deposits.c b/src/auditordb/pg_select_pending_deposits.c index 1190fb132..6501d4fea 100644 --- a/src/auditordb/pg_select_pending_deposits.c +++ b/src/auditordb/pg_select_pending_deposits.c @@ -75,7 +75,7 @@ wire_missing_cb (void *cls, { uint64_t batch_deposit_serial_id; struct TALER_Amount total_amount; - struct TALER_PaytoHashP wire_target_h_payto; + struct TALER_FullPaytoHashP wire_target_h_payto; struct GNUNET_TIME_Timestamp deadline; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("batch_deposit_serial_id", diff --git a/src/auditordb/pg_update_amount_arithmetic_inconsistency.c b/src/auditordb/pg_update_amount_arithmetic_inconsistency.c deleted file mode 100644 index 581d5c4d8..000000000 --- a/src/auditordb/pg_update_amount_arithmetic_inconsistency.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_amount_arithmetic_inconsistency.h" - - -enum GNUNET_DB_QueryStatus -TAH_PG_update_amount_arithmetic_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_amount_arithmetic_inconsistency", - "UPDATE auditor_amount_arithmetic_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_amount_arithmetic_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_amount_arithmetic_inconsistency.h b/src/auditordb/pg_update_amount_arithmetic_inconsistency.h deleted file mode 100644 index 2ad99ea41..000000000 --- a/src/auditordb/pg_update_amount_arithmetic_inconsistency.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -#ifndef SRC_PG_UPDATE_AMOUNT_ARITHMETIC_INCONSISTENCY_H -#define SRC_PG_UPDATE_AMOUNT_ARITHMETIC_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_amount_arithmetic_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_AMOUNT_ARITHMETIC_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_bad_sig_losses.c b/src/auditordb/pg_update_bad_sig_losses.c deleted file mode 100644 index 4fdb1ae94..000000000 --- a/src/auditordb/pg_update_bad_sig_losses.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_bad_sig_losses.h" - - -enum GNUNET_DB_QueryStatus -TAH_PG_update_bad_sig_losses ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_bad_sig_losses", - "UPDATE auditor_bad_sig_losses SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_bad_sig_losses", - params); -} diff --git a/src/auditordb/pg_update_bad_sig_losses.h b/src/auditordb/pg_update_bad_sig_losses.h deleted file mode 100644 index aa36bb847..000000000 --- a/src/auditordb/pg_update_bad_sig_losses.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -#ifndef SRC_PG_UPDATE_BAD_SIG_LOSSES_H -#define SRC_PG_UPDATE_BAD_SIG_LOSSES_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_bad_sig_losses ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_BAD_SIG_LOSSES_H diff --git a/src/auditordb/pg_update_closure_lags.c b/src/auditordb/pg_update_closure_lags.c deleted file mode 100644 index a49d29f3e..000000000 --- a/src/auditordb/pg_update_closure_lags.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_closure_lags.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_closure_lags ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_closure_lags", - "UPDATE auditor_closure_lags SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_closure_lags", - params); -} diff --git a/src/auditordb/pg_update_closure_lags.h b/src/auditordb/pg_update_closure_lags.h deleted file mode 100644 index 61c9e264a..000000000 --- a/src/auditordb/pg_update_closure_lags.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_CLOSURE_LAGS_H -#define SRC_PG_UPDATE_CLOSURE_LAGS_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_closure_lags ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_CLOSURE_LAGS_H diff --git a/src/auditordb/pg_update_coin_inconsistency.c b/src/auditordb/pg_update_coin_inconsistency.c deleted file mode 100644 index e9d845690..000000000 --- a/src/auditordb/pg_update_coin_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_coin_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_coin_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_coin_inconsistency", - "UPDATE auditor_coin_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_coin_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_coin_inconsistency.h b/src/auditordb/pg_update_coin_inconsistency.h deleted file mode 100644 index 73c5223e8..000000000 --- a/src/auditordb/pg_update_coin_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_COIN_INCONSISTENCY_H -#define SRC_PG_UPDATE_COIN_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_coin_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_COIN_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c deleted file mode 100644 index a9b3f820f..000000000 --- a/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_denomination_key_validity_withdraw_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_denomination_key_validity_withdraw_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_denomination_key_validity_withdraw_inconsistency", - "UPDATE auditor_denomination_key_validity_withdraw_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_denomination_key_validity_withdraw_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h deleted file mode 100644 index 574f67b22..000000000 --- a/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H -#define SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_denomination_key_validity_withdraw_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_denomination_pending.c b/src/auditordb/pg_update_denomination_pending.c deleted file mode 100644 index 62129aeaf..000000000 --- a/src/auditordb/pg_update_denomination_pending.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_denomination_pending.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_denomination_pending ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_denomination_pending", - "UPDATE auditor_denomination_pending SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_denomination_pending", - params); -} diff --git a/src/auditordb/pg_update_denomination_pending.h b/src/auditordb/pg_update_denomination_pending.h deleted file mode 100644 index eebed2b0c..000000000 --- a/src/auditordb/pg_update_denomination_pending.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_DENOMINATION_PENDING_H -#define SRC_PG_UPDATE_DENOMINATION_PENDING_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_denomination_pending ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_DENOMINATION_PENDING_H diff --git a/src/auditordb/pg_update_denominations_without_sigs.c b/src/auditordb/pg_update_denominations_without_sigs.c deleted file mode 100644 index 39a26a694..000000000 --- a/src/auditordb/pg_update_denominations_without_sigs.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_denominations_without_sigs.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_denominations_without_sigs ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_denominations_without_sigs", - "UPDATE auditor_denominations_without_sigs SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_denominations_without_sigs", - params); -} diff --git a/src/auditordb/pg_update_denominations_without_sigs.h b/src/auditordb/pg_update_denominations_without_sigs.h deleted file mode 100644 index bb126224e..000000000 --- a/src/auditordb/pg_update_denominations_without_sigs.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H -#define SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_denominations_without_sigs ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H diff --git a/src/auditordb/pg_update_deposit_confirmations.c b/src/auditordb/pg_update_deposit_confirmations.c deleted file mode 100644 index f8774069f..000000000 --- a/src/auditordb/pg_update_deposit_confirmations.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_deposit_confirmations.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_deposit_confirmations ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_deposit_confirmations", - "UPDATE auditor_deposit_confirmations SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_deposit_confirmations", - params); -} diff --git a/src/auditordb/pg_update_deposit_confirmations.h b/src/auditordb/pg_update_deposit_confirmations.h deleted file mode 100644 index 0d2e81d60..000000000 --- a/src/auditordb/pg_update_deposit_confirmations.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_DEPOSIT_CONFIRMATIONS_H -#define SRC_PG_UPDATE_DEPOSIT_CONFIRMATIONS_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_deposit_confirmations ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_DEPOSIT_CONFIRMATIONS_H diff --git a/src/auditordb/pg_update_emergency.c b/src/auditordb/pg_update_emergency.c deleted file mode 100644 index a4d542c00..000000000 --- a/src/auditordb/pg_update_emergency.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" -#include "pg_update_emergency.h" - -/** - * Update a given resource – for now this only means suppressing - */ -enum GNUNET_DB_QueryStatus -TAH_PG_update_emergency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - PREPARE (pg, - "update_emergency", - "UPDATE auditor_emergency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_emergency", - params); -} diff --git a/src/auditordb/pg_update_emergency.h b/src/auditordb/pg_update_emergency.h deleted file mode 100644 index 98028dfca..000000000 --- a/src/auditordb/pg_update_emergency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_EMERGENCY_H -#define SRC_PG_UPDATE_EMERGENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_emergency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_EMERGENCY_H diff --git a/src/auditordb/pg_update_emergency_by_count.c b/src/auditordb/pg_update_emergency_by_count.c deleted file mode 100644 index d2c67831c..000000000 --- a/src/auditordb/pg_update_emergency_by_count.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_emergency_by_count.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_emergency_by_count ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_emergency_by_count", - "UPDATE auditor_emergency_by_count SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_emergency_by_count", - params); -} diff --git a/src/auditordb/pg_update_emergency_by_count.h b/src/auditordb/pg_update_emergency_by_count.h deleted file mode 100644 index fa60241d2..000000000 --- a/src/auditordb/pg_update_emergency_by_count.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H -#define SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_emergency_by_count ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H diff --git a/src/auditordb/pg_update_fee_time_inconsistency.c b/src/auditordb/pg_update_fee_time_inconsistency.c deleted file mode 100644 index fe324edf8..000000000 --- a/src/auditordb/pg_update_fee_time_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_fee_time_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_fee_time_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_fee_time_inconsistency", - "UPDATE auditor_fee_time_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_fee_time_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_fee_time_inconsistency.h b/src/auditordb/pg_update_fee_time_inconsistency.h deleted file mode 100644 index ef55de19f..000000000 --- a/src/auditordb/pg_update_fee_time_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_FEE_TIME_INCONSISTENCY_H -#define SRC_PG_UPDATE_FEE_TIME_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_fee_time_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_FEE_TIME_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_misattribution_in_inconsistency.c b/src/auditordb/pg_update_misattribution_in_inconsistency.c deleted file mode 100644 index 5b1b46b04..000000000 --- a/src/auditordb/pg_update_misattribution_in_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_misattribution_in_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_misattribution_in_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_misattribution_in_inconsistency", - "UPDATE auditor_misattribution_in_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_misattribution_in_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_misattribution_in_inconsistency.h b/src/auditordb/pg_update_misattribution_in_inconsistency.h deleted file mode 100644 index 840168fcc..000000000 --- a/src/auditordb/pg_update_misattribution_in_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H -#define SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_misattribution_in_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_purse_not_closed_inconsistencies.c b/src/auditordb/pg_update_purse_not_closed_inconsistencies.c deleted file mode 100644 index 97d661d3d..000000000 --- a/src/auditordb/pg_update_purse_not_closed_inconsistencies.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_purse_not_closed_inconsistencies.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_purse_not_closed_inconsistencies ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_purse_not_closed_inconsistencies", - "UPDATE auditor_purse_not_closed_inconsistencies SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_purse_not_closed_inconsistencies", - params); -} diff --git a/src/auditordb/pg_update_purse_not_closed_inconsistencies.h b/src/auditordb/pg_update_purse_not_closed_inconsistencies.h deleted file mode 100644 index 66a677476..000000000 --- a/src/auditordb/pg_update_purse_not_closed_inconsistencies.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H -#define SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_purse_not_closed_inconsistencies ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H diff --git a/src/auditordb/pg_update_refreshes_hanging.c b/src/auditordb/pg_update_refreshes_hanging.c deleted file mode 100644 index f2dfd0789..000000000 --- a/src/auditordb/pg_update_refreshes_hanging.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_refreshes_hanging.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_refreshes_hanging ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_refreshes_hanging", - "UPDATE auditor_refreshes_hanging SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_refreshes_hanging", - params); -} diff --git a/src/auditordb/pg_update_refreshes_hanging.h b/src/auditordb/pg_update_refreshes_hanging.h deleted file mode 100644 index 071add3cd..000000000 --- a/src/auditordb/pg_update_refreshes_hanging.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_REFRESHES_HANGING_H -#define SRC_PG_UPDATE_REFRESHES_HANGING_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_refreshes_hanging ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_REFRESHES_HANGING_H diff --git a/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c deleted file mode 100644 index 93302c51f..000000000 --- a/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_reserve_balance_insufficient_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_reserve_balance_insufficient_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_reserve_balance_insufficient_inconsistency", - "UPDATE auditor_reserve_balance_insufficient_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_reserve_balance_insufficient_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h deleted file mode 100644 index ccc8d0715..000000000 --- a/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H -#define SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_reserve_balance_insufficient_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c deleted file mode 100644 index ff95de80c..000000000 --- a/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_reserve_balance_summary_wrong_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_reserve_balance_summary_wrong_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_reserve_balance_summary_wrong_inconsistency", - "UPDATE auditor_reserve_balance_summary_wrong_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_reserve_balance_summary_wrong_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h deleted file mode 100644 index 341acac1e..000000000 --- a/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H -#define SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_reserve_balance_summary_wrong_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_reserve_in_inconsistency.c b/src/auditordb/pg_update_reserve_in_inconsistency.c deleted file mode 100644 index f905e3750..000000000 --- a/src/auditordb/pg_update_reserve_in_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_reserve_in_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_reserve_in_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_reserve_in_inconsistency", - "UPDATE auditor_reserve_in_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_reserve_in_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_reserve_in_inconsistency.h b/src/auditordb/pg_update_reserve_in_inconsistency.h deleted file mode 100644 index 5eacb68da..000000000 --- a/src/auditordb/pg_update_reserve_in_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H -#define SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_reserve_in_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_reserve_not_closed_inconsistency.c b/src/auditordb/pg_update_reserve_not_closed_inconsistency.c deleted file mode 100644 index 4eea64fee..000000000 --- a/src/auditordb/pg_update_reserve_not_closed_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_reserve_not_closed_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_reserve_not_closed_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_reserve_not_closed_inconsistency", - "UPDATE auditor_reserve_not_closed_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_reserve_not_closed_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_reserve_not_closed_inconsistency.h b/src/auditordb/pg_update_reserve_not_closed_inconsistency.h deleted file mode 100644 index 4739bc5f6..000000000 --- a/src/auditordb/pg_update_reserve_not_closed_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H -#define SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_reserve_not_closed_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_row_inconsistency.c b/src/auditordb/pg_update_row_inconsistency.c deleted file mode 100644 index 985f7e2ee..000000000 --- a/src/auditordb/pg_update_row_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_row_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_row_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_row_inconsistency", - "UPDATE auditor_row_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_row_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_row_inconsistency.h b/src/auditordb/pg_update_row_inconsistency.h deleted file mode 100644 index d6431558f..000000000 --- a/src/auditordb/pg_update_row_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_ROW_INCONSISTENCY_H -#define SRC_PG_UPDATE_ROW_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_row_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_ROW_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_row_minor_inconsistencies.c b/src/auditordb/pg_update_row_minor_inconsistencies.c deleted file mode 100644 index 36ba5d62f..000000000 --- a/src/auditordb/pg_update_row_minor_inconsistencies.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_row_minor_inconsistencies.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_row_minor_inconsistencies ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_row_minor_inconsistencies", - "UPDATE auditor_row_minor_inconsistencies SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_row_minor_inconsistencies", - params); -} diff --git a/src/auditordb/pg_update_row_minor_inconsistencies.h b/src/auditordb/pg_update_row_minor_inconsistencies.h deleted file mode 100644 index fccb9fa99..000000000 --- a/src/auditordb/pg_update_row_minor_inconsistencies.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H -#define SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_row_minor_inconsistencies ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H diff --git a/src/auditordb/pg_update_wire_format_inconsistency.c b/src/auditordb/pg_update_wire_format_inconsistency.c deleted file mode 100644 index 70953582d..000000000 --- a/src/auditordb/pg_update_wire_format_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_wire_format_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_wire_format_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_wire_format_inconsistency", - "UPDATE auditor_wire_format_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_wire_format_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_wire_format_inconsistency.h b/src/auditordb/pg_update_wire_format_inconsistency.h deleted file mode 100644 index 32a612afc..000000000 --- a/src/auditordb/pg_update_wire_format_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H -#define SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_wire_format_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H diff --git a/src/auditordb/pg_update_wire_out_inconsistency.c b/src/auditordb/pg_update_wire_out_inconsistency.c deleted file mode 100644 index 543ce3cc6..000000000 --- a/src/auditordb/pg_update_wire_out_inconsistency.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "platform.h" -#include "taler_pq_lib.h" -#include "pg_helper.h" - -#include "pg_update_wire_out_inconsistency.h" - -/* -Update a given resource – for now this only means suppressing -*/ -enum GNUNET_DB_QueryStatus -TAH_PG_update_wire_out_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&gu->row_id), - GNUNET_PQ_query_param_bool (gu->suppressed), - GNUNET_PQ_query_param_end - }; - - - PREPARE (pg, - "update_wire_out_inconsistency", - "UPDATE auditor_wire_out_inconsistency SET" - " suppressed=$2" - " WHERE row_id=$1"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "update_wire_out_inconsistency", - params); -} diff --git a/src/auditordb/pg_update_wire_out_inconsistency.h b/src/auditordb/pg_update_wire_out_inconsistency.h deleted file mode 100644 index 3032a6c0e..000000000 --- a/src/auditordb/pg_update_wire_out_inconsistency.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H -#define SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_update_wire_out_inconsistency ( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *dc); - -#endif // SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 3e585af0d..4b3bf8c92 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -24,7 +24,6 @@ #include <pthread.h> #include <libpq-fe.h> #include "pg_delete_generic.h" -#include "pg_delete_deposit_confirmations.h" #include "pg_delete_pending_deposit.h" #include "pg_delete_purse_info.h" #include "pg_del_denomination_balance.h" @@ -62,17 +61,6 @@ #include "pg_get_amount_arithmetic_inconsistency.h" #include "pg_get_coin_inconsistency.h" #include "pg_get_row_inconsistency.h" -#include "pg_update_emergency_by_count.h" -#include "pg_update_row_inconsistency.h" -#include "pg_update_purse_not_closed_inconsistencies.h" -#include "pg_update_reserve_balance_insufficient_inconsistency.h" -#include "pg_update_coin_inconsistency.h" -#include "pg_update_denomination_key_validity_withdraw_inconsistency.h" -#include "pg_update_refreshes_hanging.h" -#include "pg_update_emergency.h" -#include "pg_update_closure_lags.h" -#include "pg_update_row_minor_inconsistencies.h" - #include "pg_update_balance.h" @@ -91,14 +79,12 @@ #include "pg_get_bad_sig_losses.h" #include "pg_insert_bad_sig_losses.h" -#include "pg_update_bad_sig_losses.h" #include "pg_get_denomination_key_validity_withdraw_inconsistency.h" #include "pg_insert_denomination_key_validity_withdraw_inconsistency.h" #include "pg_get_fee_time_inconsistency.h" #include "pg_insert_fee_time_inconsistency.h" -#include "pg_update_fee_time_inconsistency.h" #include "pg_get_purse_not_closed_inconsistencies.h" #include "pg_insert_purse_not_closed_inconsistencies.h" @@ -111,48 +97,36 @@ #include "pg_get_reserve_in_inconsistency.h" #include "pg_insert_reserve_in_inconsistency.h" -#include "pg_update_reserve_in_inconsistency.h" #include "pg_get_reserve_not_closed_inconsistency.h" #include "pg_insert_reserve_not_closed_inconsistency.h" -#include "pg_update_reserve_not_closed_inconsistency.h" #include "pg_get_denominations_without_sigs.h" #include "pg_insert_denominations_without_sigs.h" -#include "pg_update_denominations_without_sigs.h" #include "pg_get_misattribution_in_inconsistency.h" #include "pg_insert_misattribution_in_inconsistency.h" -#include "pg_update_misattribution_in_inconsistency.h" #include "pg_get_reserves.h" #include "pg_get_purses.h" #include "pg_get_denomination_pending.h" #include "pg_insert_denomination_pending.h" -#include "pg_update_denomination_pending.h" #include "pg_get_exchange_signkeys.h" #include "pg_get_wire_format_inconsistency.h" #include "pg_insert_wire_format_inconsistency.h" -#include "pg_update_wire_format_inconsistency.h" #include "pg_get_wire_out_inconsistency.h" #include "pg_insert_wire_out_inconsistency.h" #include "pg_delete_wire_out_inconsistency_if_matching.h" -#include "pg_update_wire_out_inconsistency.h" #include "pg_get_reserve_balance_summary_wrong_inconsistency.h" #include "pg_insert_reserve_balance_summary_wrong_inconsistency.h" -#include "pg_update_reserve_balance_summary_wrong_inconsistency.h" #include "pg_get_row_minor_inconsistencies.h" #include "pg_insert_row_minor_inconsistencies.h" -#include "pg_update_row_minor_inconsistencies.h" - -#include "pg_update_amount_arithmetic_inconsistency.h" -#include "pg_update_deposit_confirmations.h" #define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \ __VA_ARGS__) @@ -341,11 +315,12 @@ setup_connection (struct PostgresClosure *pg) GNUNET_PQ_reconnect_if_down (pg->conn); return GNUNET_OK; } - db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg, - "auditordb-postgres", - NULL, - es, - NULL); + db_conn = GNUNET_PQ_connect_with_cfg2 (pg->cfg, + "auditordb-postgres", + "auditor-", + es, + NULL, /* prepared statements */ + GNUNET_PQ_FLAG_CHECK_CURRENT); if (NULL == db_conn) return GNUNET_SYSERR; pg->conn = db_conn; @@ -372,15 +347,10 @@ postgres_preflight (void *cls) GNUNET_PQ_EXECUTE_STATEMENT_END }; - if (NULL == pg->conn) - { - if (GNUNET_OK != - setup_connection (pg)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - } + if ( (NULL == pg->conn) && + (GNUNET_OK != + setup_connection (pg)) ) + return GNUNET_SYSERR; if (NULL == pg->transaction_name) return GNUNET_OK; /* all good */ if (GNUNET_OK == @@ -550,8 +520,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) return NULL; } - // MARK: CRUD - plugin = GNUNET_new (struct TALER_AUDITORDB_Plugin); plugin->cls = pg; plugin->preflight = &postgres_preflight; @@ -579,6 +547,8 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_update_generic_suppressed; plugin->delete_generic = &TAH_PG_delete_generic; + plugin->delete_wire_out_inconsistency_if_matching + = &TAH_PG_delete_wire_out_inconsistency_if_matching; plugin->update_auditor_progress @@ -587,9 +557,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_insert_deposit_confirmation; plugin->get_deposit_confirmations = &TAH_PG_get_deposit_confirmations; - plugin->delete_deposit_confirmation - = &TAH_PG_delete_deposit_confirmation; - plugin->get_amount_arithmetic_inconsistency = &TAH_PG_get_amount_arithmetic_inconsistency; @@ -679,7 +646,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_bad_sig_losses = &TAH_PG_insert_bad_sig_losses; plugin->get_bad_sig_losses = &TAH_PG_get_bad_sig_losses; - plugin->update_bad_sig_losses = &TAH_PG_update_bad_sig_losses; plugin->insert_auditor_closure_lags = &TAH_PG_insert_auditor_closure_lags; plugin->get_auditor_closure_lags = &TAH_PG_get_auditor_closure_lags; @@ -688,41 +654,19 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_refreshes_hanging = &TAH_PG_insert_refreshes_hanging; plugin->get_refreshes_hanging = &TAH_PG_get_refreshes_hanging; - plugin->update_emergency_by_count = &TAH_PG_update_emergency_by_count; - plugin->update_row_inconsistency = &TAH_PG_update_row_inconsistency; - plugin->update_purse_not_closed_inconsistencies = - &TAH_PG_update_purse_not_closed_inconsistencies; - plugin->update_reserve_balance_insufficient_inconsistency = - &TAH_PG_update_reserve_balance_insufficient_inconsistency; - plugin->update_coin_inconsistency = &TAH_PG_update_coin_inconsistency; - plugin->update_denomination_key_validity_withdraw_inconsistency = - &TAH_PG_update_denomination_key_validity_withdraw_inconsistency; - plugin->update_refreshes_hanging = &TAH_PG_update_refreshes_hanging; - plugin->update_emergency = &TAH_PG_update_emergency; - plugin->update_closure_lags = &TAH_PG_update_closure_lags; - - plugin->insert_reserve_in_inconsistency = &TAH_PG_insert_reserve_in_inconsistency; plugin->get_reserve_in_inconsistency = &TAH_PG_get_reserve_in_inconsistency; - plugin->update_reserve_in_inconsistency = - &TAH_PG_update_reserve_in_inconsistency; - plugin->insert_reserve_not_closed_inconsistency = &TAH_PG_insert_reserve_not_closed_inconsistency; plugin->get_reserve_not_closed_inconsistency = &TAH_PG_get_reserve_not_closed_inconsistency; - plugin->update_reserve_not_closed_inconsistency = - &TAH_PG_update_reserve_not_closed_inconsistency; - plugin->insert_denominations_without_sigs = &TAH_PG_insert_denominations_without_sigs; plugin->get_denominations_without_sigs = &TAH_PG_get_denominations_without_sigs; - plugin->update_denominations_without_sigs = - &TAH_PG_update_denominations_without_sigs; plugin->get_progress_points = &TAH_PG_get_progress_points; @@ -732,49 +676,36 @@ libtaler_plugin_auditordb_postgres_init (void *cls) &TAH_PG_insert_misattribution_in_inconsistency; plugin->get_misattribution_in_inconsistency = &TAH_PG_get_misattribution_in_inconsistency; - plugin->update_misattribution_in_inconsistency = - &TAH_PG_update_misattribution_in_inconsistency; plugin->get_reserves = &TAH_PG_get_reserves; plugin->get_purses = &TAH_PG_get_purses; plugin->insert_denomination_pending = &TAH_PG_insert_denomination_pending; plugin->get_denomination_pending = &TAH_PG_get_denomination_pending; - plugin->update_denomination_pending = &TAH_PG_update_denomination_pending; plugin->get_exchange_signkeys = &TAH_PG_get_exchange_signkeys; plugin->insert_wire_format_inconsistency = &TAH_PG_insert_wire_format_inconsistency; plugin->get_wire_format_inconsistency = &TAH_PG_get_wire_format_inconsistency; - plugin->update_wire_format_inconsistency = - &TAH_PG_update_wire_format_inconsistency; - plugin->insert_wire_out_inconsistency = &TAH_PG_insert_wire_out_inconsistency; plugin->get_wire_out_inconsistency = &TAH_PG_get_wire_out_inconsistency; - plugin->update_wire_out_inconsistency - = &TAH_PG_update_wire_out_inconsistency; plugin->insert_reserve_balance_summary_wrong_inconsistency = &TAH_PG_insert_reserve_balance_summary_wrong_inconsistency; plugin->get_reserve_balance_summary_wrong_inconsistency = &TAH_PG_get_reserve_balance_summary_wrong_inconsistency; - plugin->update_reserve_balance_summary_wrong_inconsistency = - &TAH_PG_update_reserve_balance_summary_wrong_inconsistency; plugin->insert_row_minor_inconsistencies = &TAH_PG_insert_row_minor_inconsistencies; plugin->get_row_minor_inconsistencies = &TAH_PG_get_row_minor_inconsistencies; - plugin->update_row_minor_inconsistencies = - &TAH_PG_update_row_minor_inconsistencies; plugin->insert_fee_time_inconsistency = &TAH_PG_insert_fee_time_inconsistency; plugin->get_fee_time_inconsistency = &TAH_PG_get_fee_time_inconsistency; - plugin->update_fee_time_inconsistency = &TAH_PG_update_fee_time_inconsistency; plugin->update_balance = &TAH_PG_update_balance; @@ -782,11 +713,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_exchange_signkey = &TAH_PG_insert_exchange_signkey; - plugin->update_deposit_confirmations - = &TAH_PG_update_deposit_confirmations; - plugin->update_amount_arithmetic_inconsistency - = &TAH_PG_update_amount_arithmetic_inconsistency; - return plugin; } diff --git a/src/auditordb/restart.sql b/src/auditordb/restart.sql index 2dc6864ff..d13d3acd1 100644 --- a/src/auditordb/restart.sql +++ b/src/auditordb/restart.sql @@ -32,13 +32,34 @@ SET search_path TO auditor; -- latest requirements for dropping tables. DELETE FROM auditor_amount_arithmetic_inconsistency; +DELETE FROM auditor_bad_sig_losses; DELETE FROM auditor_balances; +DELETE FROM auditor_closure_lags; +DELETE FROM auditor_coin_inconsistency; +DELETE FROM auditor_denomination_key_validity_withdraw_inconsistency; DELETE FROM auditor_denomination_pending; +DELETE FROM auditor_denominations_without_sigs; +DELETE FROM auditor_emergency; +DELETE FROM auditor_emergency_by_count; +DELETE FROM auditor_fee_time_inconsistency; DELETE FROM auditor_historic_denomination_revenue; DELETE FROM auditor_historic_reserve_summary; +DELETE FROM auditor_misattribution_in_inconsistency; +DELETE FROM auditor_pending_deposits; DELETE FROM auditor_progress; +DELETE FROM auditor_purse_not_closed_inconsistencies; DELETE FROM auditor_purses; +DELETE FROM auditor_refreshes_hanging; +DELETE FROM auditor_reserve_balance_insufficient_inconsistency; +DELETE FROM auditor_reserve_balance_summary_wrong_inconsistency; +DELETE FROM auditor_reserve_in_inconsistency; +DELETE FROM auditor_reserve_not_closed_inconsistency; DELETE FROM auditor_reserves; +DELETE FROM auditor_row_inconsistency; +DELETE FROM auditor_row_minor_inconsistencies; +DELETE FROM auditor_wire_format_inconsistency; +DELETE FROM auditor_wire_out_inconsistency; + -- And we're out of here... COMMIT; diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index c859e7239..c8583add8 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -199,7 +199,8 @@ run (void *cls) "loading database plugin\n"); if (NULL == - (plugin = TALER_AUDITORDB_plugin_load (cfg))) + (plugin = TALER_AUDITORDB_plugin_load (cfg, + true))) { result = 77; return; @@ -294,12 +295,18 @@ run (void *cls) GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":53.456789", &rfb.history_fee_balance)); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_reserve_info (plugin->cls, - &reserve_pub, - &rfb, - past, - "payto://bla/blub")); + { + struct TALER_FullPayto pt = { + .full_payto = (char *) "payto://bla/blub?receiver-name=blub" + }; + + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->insert_reserve_info (plugin->cls, + &reserve_pub, + &rfb, + past, + pt)); + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: update_reserve_info\n"); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != @@ -310,7 +317,7 @@ run (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: get_reserve_info\n"); { - char *payto; + struct TALER_FullPayto payto; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_reserve_info (plugin->cls, @@ -319,9 +326,9 @@ run (void *cls) &rfb2, &date, &payto)); - FAILIF (0 != strcmp (payto, - "payto://bla/blub")); - GNUNET_free (payto); + FAILIF (0 != strcmp (payto.full_payto, + "payto://bla/blub?receiver-name=blub")); + GNUNET_free (payto.full_payto); } FAILIF ( (0 != GNUNET_memcmp (&date, &future)) @@ -341,12 +348,11 @@ run (void *cls) } { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Test: insert_denomination_balance\n"); - struct TALER_AUDITORDB_DenominationCirculationData dcd; struct TALER_AUDITORDB_DenominationCirculationData dcd2; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Test: insert_denomination_balance\n"); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":12.345678", &dcd.denom_balance)); diff --git a/src/auditordb/test_auditordb_checkpoints.c b/src/auditordb/test_auditordb_checkpoints.c index 2000a674a..bf7c6efb1 100644 --- a/src/auditordb/test_auditordb_checkpoints.c +++ b/src/auditordb/test_auditordb_checkpoints.c @@ -89,7 +89,8 @@ run (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "loading database plugin\n"); if (NULL == - (plugin = TALER_AUDITORDB_plugin_load (cfg))) + (plugin = TALER_AUDITORDB_plugin_load (cfg, + true))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect to database\n"); @@ -178,56 +179,68 @@ run (void *cls) * Test2 = 123 * Test3 = 245 * Let's make sure that's the case! */ - uint64_t value; - uint64_t valueNX; - uint64_t value3; - GNUNET_assert ( - 3 == - plugin->get_auditor_progress ( - plugin->cls, - "Test", - &value, - "TestNX", - &valueNX, - "Test3", - &value3, - NULL) - ); - GNUNET_assert (value == 42); - GNUNET_assert (valueNX == 0); - GNUNET_assert (value3 == 245); + { + uint64_t value; + uint64_t valueNX; + uint64_t value3; + GNUNET_assert ( + 3 == + plugin->get_auditor_progress ( + plugin->cls, + "Test", + &value, + "TestNX", + &valueNX, + "Test3", + &value3, + NULL) + ); + GNUNET_assert (value == 42); + GNUNET_assert (valueNX == 0); + GNUNET_assert (value3 == 245); + } /* Ensure the rest are also at their expected values */ - GNUNET_assert ( - GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == - plugin->get_auditor_progress ( - plugin->cls, - "Test2", - &value, - NULL) - ); - GNUNET_assert (value == 123); - GNUNET_assert ( - GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == - plugin->get_auditor_progress ( - plugin->cls, - "Test3", - &value, - NULL) - ); - GNUNET_assert (value == 245); + { + uint64_t value; - /* Try fetching value that does not exist */ - GNUNET_assert ( - GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == - plugin->get_auditor_progress ( - plugin->cls, - "TestNX", - &value, - NULL) - ); - GNUNET_assert (0 == value); + GNUNET_assert ( + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + plugin->get_auditor_progress ( + plugin->cls, + "Test2", + &value, + NULL) + ); + GNUNET_assert (value == 123); + } + { + uint64_t value; + GNUNET_assert ( + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + plugin->get_auditor_progress ( + plugin->cls, + "Test3", + &value, + NULL) + ); + GNUNET_assert (value == 245); + } + { + uint64_t value; + + /* Try fetching value that does not exist */ + GNUNET_assert ( + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + plugin->get_auditor_progress ( + plugin->cls, + "TestNX", + &value, + NULL) + ); + GNUNET_assert (0 == value); + } /* Test inserting a blank value, should tell us one result */ GNUNET_assert ( diff --git a/src/bank-lib/bank_api_admin_add_incoming.c b/src/bank-lib/bank_api_admin_add_incoming.c index ffc89ccc5..403160163 100644 --- a/src/bank-lib/bank_api_admin_add_incoming.c +++ b/src/bank-lib/bank_api_admin_add_incoming.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015--2023 Taler Systems SA + Copyright (C) 2015--2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -159,7 +159,7 @@ TALER_BANK_admin_add_incoming ( const struct TALER_BANK_AuthenticationData *auth, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *amount, - const char *debit_account, + const struct TALER_FullPayto debit_account, TALER_BANK_AdminAddIncomingCallback res_cb, void *res_cb_cls) { @@ -167,7 +167,7 @@ TALER_BANK_admin_add_incoming ( json_t *admin_obj; CURL *eh; - if (NULL == debit_account) + if (NULL == debit_account.full_payto) { GNUNET_break (0); return NULL; @@ -187,8 +187,8 @@ TALER_BANK_admin_add_incoming ( reserve_pub), TALER_JSON_pack_amount ("amount", amount), - GNUNET_JSON_pack_string ("debit_account", - debit_account)); + TALER_JSON_pack_full_payto ("debit_account", + debit_account)); if (NULL == admin_obj) { GNUNET_break (0); diff --git a/src/bank-lib/bank_api_admin_add_kycauth.c b/src/bank-lib/bank_api_admin_add_kycauth.c index 1660305b1..8f347cc30 100644 --- a/src/bank-lib/bank_api_admin_add_kycauth.c +++ b/src/bank-lib/bank_api_admin_add_kycauth.c @@ -154,7 +154,7 @@ TALER_BANK_admin_add_kycauth ( const struct TALER_BANK_AuthenticationData *auth, const union TALER_AccountPublicKeyP *account_pub, const struct TALER_Amount *amount, - const char *debit_account, + const struct TALER_FullPayto debit_account, TALER_BANK_AdminAddKycauthCallback res_cb, void *res_cb_cls) { @@ -162,7 +162,7 @@ TALER_BANK_admin_add_kycauth ( json_t *admin_obj; CURL *eh; - if (NULL == debit_account) + if (NULL == debit_account.full_payto) { GNUNET_break (0); return NULL; @@ -182,8 +182,8 @@ TALER_BANK_admin_add_kycauth ( account_pub), TALER_JSON_pack_amount ("amount", amount), - GNUNET_JSON_pack_string ("debit_account", - debit_account)); + TALER_JSON_pack_full_payto ("debit_account", + debit_account)); if (NULL == admin_obj) { GNUNET_break (0); diff --git a/src/bank-lib/bank_api_common.c b/src/bank-lib/bank_api_common.c index 2c47429ad..ffcb3ab72 100644 --- a/src/bank-lib/bank_api_common.c +++ b/src/bank-lib/bank_api_common.c @@ -54,6 +54,19 @@ TALER_BANK_setup_auth_ (CURL *easy, GNUNET_free (up); break; } + case TALER_BANK_AUTH_BEARER: + { + if ( (CURLE_OK != + curl_easy_setopt (easy, + CURLOPT_HTTPAUTH, + CURLAUTH_BEARER)) || + (CURLE_OK != + curl_easy_setopt (easy, + CURLOPT_XOAUTH2_BEARER, + auth->details.bearer.token)) ) + ret = GNUNET_SYSERR; + break; + } } return ret; } diff --git a/src/bank-lib/bank_api_credit.c b/src/bank-lib/bank_api_credit.c index dc92b064a..c461fe614 100644 --- a/src/bank-lib/bank_api_credit.c +++ b/src/bank-lib/bank_api_credit.c @@ -86,8 +86,8 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_array_const ("incoming_transactions", &history_array), - TALER_JSON_spec_payto_uri ("credit_account", - &chr.details.ok.credit_account_uri), + TALER_JSON_spec_full_payto_uri ("credit_account", + &chr.details.ok.credit_account_uri), GNUNET_JSON_spec_end () }; @@ -118,8 +118,8 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh, &td->execution_date), GNUNET_JSON_spec_uint64 ("row_id", &td->serial_id), - TALER_JSON_spec_payto_uri ("debit_account", - &td->debit_account_uri), + TALER_JSON_spec_full_payto_uri ("debit_account", + &td->debit_account_uri), GNUNET_JSON_spec_end () }; json_t *transaction = json_array_get (history_array, diff --git a/src/bank-lib/bank_api_debit.c b/src/bank-lib/bank_api_debit.c index 62bf66c0f..df9140687 100644 --- a/src/bank-lib/bank_api_debit.c +++ b/src/bank-lib/bank_api_debit.c @@ -86,8 +86,8 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_array_const ("outgoing_transactions", &history_array), - TALER_JSON_spec_payto_uri ("debit_account", - &dhr.details.ok.debit_account_uri), + TALER_JSON_spec_full_payto_uri ("debit_account", + &dhr.details.ok.debit_account_uri), GNUNET_JSON_spec_end () }; @@ -117,8 +117,8 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh, &td->serial_id), GNUNET_JSON_spec_fixed_auto ("wtid", &td->wtid), - TALER_JSON_spec_payto_uri ("credit_account", - &td->credit_account_uri), + TALER_JSON_spec_full_payto_uri ("credit_account", + &td->credit_account_uri), TALER_JSON_spec_web_url ("exchange_base_url", &td->exchange_base_url), GNUNET_JSON_spec_end () diff --git a/src/bank-lib/bank_api_parse.c b/src/bank-lib/bank_api_parse.c index 0d30e9d08..12ed2ed13 100644 --- a/src/bank-lib/bank_api_parse.c +++ b/src/bank-lib/bank_api_parse.c @@ -33,9 +33,10 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *m; enum TALER_BANK_AuthenticationMethod e; } methods[] = { - { "NONE", TALER_BANK_AUTH_NONE }, - { "BASIC", TALER_BANK_AUTH_BASIC }, - { NULL, TALER_BANK_AUTH_NONE } + { "NONE", TALER_BANK_AUTH_NONE }, + { "BASIC", TALER_BANK_AUTH_BASIC }, + { "BEARER", TALER_BANK_AUTH_BEARER }, + { NULL, TALER_BANK_AUTH_NONE } }; char *method; @@ -106,6 +107,23 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, auth->method = TALER_BANK_AUTH_BASIC; GNUNET_free (method); return GNUNET_OK; + case TALER_BANK_AUTH_BEARER: + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + section, + "TOKEN", + &auth->details.bearer.token)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + section, + "TOKEN"); + GNUNET_free (method); + GNUNET_free (auth->wire_gateway_url); + return GNUNET_SYSERR; + } + auth->method = TALER_BANK_AUTH_BEARER; + GNUNET_free (method); + return GNUNET_OK; } } } @@ -133,7 +151,15 @@ TALER_BANK_auth_free (struct TALER_BANK_AuthenticationData *auth) auth->details.basic.password = NULL; } break; + case TALER_BANK_AUTH_BEARER: + if (NULL != auth->details.bearer.token) + { + GNUNET_free (auth->details.bearer.token); + auth->details.bearer.token = NULL; + } + break; } + GNUNET_free (auth->wire_gateway_url); auth->wire_gateway_url = NULL; } diff --git a/src/bank-lib/bank_api_transfer.c b/src/bank-lib/bank_api_transfer.c index 0748a0d7e..affb8b6ce 100644 --- a/src/bank-lib/bank_api_transfer.c +++ b/src/bank-lib/bank_api_transfer.c @@ -68,15 +68,16 @@ GNUNET_NETWORK_STRUCT_END void TALER_BANK_prepare_transfer ( - const char *destination_account_payto_uri, + const struct TALER_FullPayto destination_account_payto_uri, const struct TALER_Amount *amount, const char *exchange_base_url, const struct TALER_WireTransferIdentifierRawP *wtid, void **buf, size_t *buf_size) { + const char *payto = destination_account_payto_uri.full_payto; struct WirePackP *wp; - size_t d_len = strlen (destination_account_payto_uri) + 1; + size_t d_len = strlen (payto) + 1; size_t u_len = strlen (exchange_base_url) + 1; char *end; @@ -100,7 +101,7 @@ TALER_BANK_prepare_transfer ( wp->exchange_url_len = htonl ((uint32_t) u_len); end = (char *) &wp[1]; GNUNET_memcpy (end, - destination_account_payto_uri, + payto, d_len); GNUNET_memcpy (end + d_len, exchange_base_url, diff --git a/src/bank-lib/fakebank.h b/src/bank-lib/fakebank.h index 87c7a4af1..8cbf60403 100644 --- a/src/bank-lib/fakebank.h +++ b/src/bank-lib/fakebank.h @@ -159,7 +159,7 @@ struct WithdrawalOperation uint64_t row_id; /** - * Amount transferred. + * Amount transferred, NULL if still unknown. */ struct TALER_Amount *amount; diff --git a/src/bank-lib/fakebank_bank.c b/src/bank-lib/fakebank_bank.c index 96100943c..dcbe4a26c 100644 --- a/src/bank-lib/fakebank_bank.c +++ b/src/bank-lib/fakebank_bank.c @@ -72,7 +72,7 @@ TALER_FAKEBANK_bank_main_ ( connection, MHD_HTTP_OK, GNUNET_JSON_pack_string ("version", - "4:1:4"), /* not sure, API versions are not properly marked up! */ + "4:1:4"), GNUNET_JSON_pack_string ("currency", h->currency), GNUNET_JSON_pack_string ("implementation", diff --git a/src/bank-lib/fakebank_bank_post_withdrawals_id_op.c b/src/bank-lib/fakebank_bank_post_withdrawals_id_op.c index 2adc07df0..1b81c8670 100644 --- a/src/bank-lib/fakebank_bank_post_withdrawals_id_op.c +++ b/src/bank-lib/fakebank_bank_post_withdrawals_id_op.c @@ -41,6 +41,7 @@ * @param connection the connection * @param account name of the account * @param withdrawal_id the withdrawal operation identifier + * @param body uploaded JSON body, NULL if none * @return MHD result code */ static MHD_RESULT @@ -48,10 +49,32 @@ bank_withdrawals_confirm ( struct TALER_FAKEBANK_Handle *h, struct MHD_Connection *connection, const char *account, - const char *withdrawal_id) + const char *withdrawal_id, + const json_t *body) { const struct Account *acc; struct WithdrawalOperation *wo; + struct TALER_Amount amount; + bool amount_missing = true; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_mark_optional ( + TALER_JSON_spec_amount ("amount", + h->currency, + &amount), + &amount_missing), + GNUNET_JSON_spec_end () + }; + enum GNUNET_GenericReturnValue ret; + + if ( (NULL != body) && + (GNUNET_OK != + (ret = TALER_MHD_parse_json_data (connection, + body, + spec))) ) + { + GNUNET_break_op (0); + return (GNUNET_NO == ret) ? MHD_YES : MHD_NO; + } GNUNET_assert (0 == pthread_mutex_lock (&h->big_lock)); @@ -91,14 +114,33 @@ bank_withdrawals_confirm ( TALER_EC_BANK_POST_WITHDRAWAL_OPERATION_REQUIRED, NULL); } - if (NULL == wo->amount) + if ( (NULL != wo->amount) && + (! amount_missing) && + (0 != TALER_amount_cmp (&amount, + wo->amount)) ) { GNUNET_assert (0 == pthread_mutex_unlock (&h->big_lock)); return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_BANK_POST_WITHDRAWAL_OPERATION_REQUIRED, - NULL); + MHD_HTTP_CONFLICT, + TALER_EC_BANK_CONFIRM_ABORT_CONFLICT, + "amount inconsistent"); + } + if ( (NULL == wo->amount) && + (amount_missing) ) + { + GNUNET_assert (0 == + pthread_mutex_unlock (&h->big_lock)); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_CONFLICT, + TALER_EC_BANK_CONFIRM_ABORT_CONFLICT, + "amount required"); + } + if (NULL == wo->amount) + { + GNUNET_assert (! amount_missing); + wo->amount = GNUNET_new (struct TALER_Amount); + *wo->amount = amount; } if (wo->aborted) { @@ -152,6 +194,7 @@ bank_withdrawals_confirm ( * @param connection the connection * @param account name of the account * @param withdrawal_id the withdrawal operation identifier + * @param body uploaded JSON body, NULL if none * @return MHD result code */ static MHD_RESULT @@ -159,7 +202,8 @@ bank_withdrawals_abort ( struct TALER_FAKEBANK_Handle *h, struct MHD_Connection *connection, const char *account, - const char *withdrawal_id) + const char *withdrawal_id, + const json_t *body) { struct WithdrawalOperation *wo; const struct Account *acc; @@ -226,23 +270,71 @@ TALER_FAKEBANK_bank_withdrawals_id_op_ ( size_t *upload_data_size, void **con_cls) { + struct ConnectionContext *cc = *con_cls; + json_t *json = NULL; + + if (NULL == cc) + { + cc = GNUNET_new (struct ConnectionContext); + cc->ctx_cleaner = &GNUNET_JSON_post_parser_cleanup; + *con_cls = cc; + } + if (0 != *upload_data_size) + { + enum GNUNET_JSON_PostResult pr; + + pr = GNUNET_JSON_post_parser (REQUEST_BUFFER_MAX, + connection, + &cc->ctx, + upload_data, + upload_data_size, + &json); + switch (pr) + { + case GNUNET_JSON_PR_OUT_OF_MEMORY: + GNUNET_break (0); + return MHD_NO; + case GNUNET_JSON_PR_CONTINUE: + return MHD_YES; + case GNUNET_JSON_PR_REQUEST_TOO_LARGE: + GNUNET_break (0); + return MHD_NO; + case GNUNET_JSON_PR_JSON_INVALID: + GNUNET_break (0); + return MHD_NO; + case GNUNET_JSON_PR_SUCCESS: + break; + } + } + if (0 == strcmp (op, "/confirm")) { - return bank_withdrawals_confirm (h, - connection, - account, - withdrawal_id); + MHD_RESULT res; + + res = bank_withdrawals_confirm (h, + connection, + account, + withdrawal_id, + json); + json_decref (json); + return res; } if (0 == strcmp (op, "/abort")) { - return bank_withdrawals_abort (h, - connection, - account, - withdrawal_id); + MHD_RESULT res; + + res = bank_withdrawals_abort (h, + connection, + account, + withdrawal_id, + json); + json_decref (json); + return res; } GNUNET_break_op (0); + json_decref (json); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, TALER_EC_GENERIC_ENDPOINT_UNKNOWN, diff --git a/src/bank-lib/fakebank_tbi_get_withdrawal_operation.c b/src/bank-lib/fakebank_tbi_get_withdrawal_operation.c index fd6f3b7c4..63c247db1 100644 --- a/src/bank-lib/fakebank_tbi_get_withdrawal_operation.c +++ b/src/bank-lib/fakebank_tbi_get_withdrawal_operation.c @@ -120,6 +120,8 @@ TALER_FAKEBANK_tbi_get_withdrawal_operation_ ( wc->wo->confirmation_done), GNUNET_JSON_pack_string ("status", status_string), + GNUNET_JSON_pack_string ("sender_wire", + wc->wo->debit_account->payto_uri), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("suggested_exchange", h->exchange_url)), diff --git a/src/bank-lib/fakebank_tbi_post_withdrawal_operation.c b/src/bank-lib/fakebank_tbi_post_withdrawal_operation.c index 29f1e7475..cfef06455 100644 --- a/src/bank-lib/fakebank_tbi_post_withdrawal_operation.c +++ b/src/bank-lib/fakebank_tbi_post_withdrawal_operation.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2016-2023 Taler Systems SA + (C) 2016-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -50,7 +50,7 @@ do_post_withdrawal ( struct MHD_Connection *connection, const char *wopid, const struct TALER_ReservePublicKeyP *reserve_pub, - const char *exchange_payto_uri, + const struct TALER_FullPayto exchange_payto_uri, const struct TALER_Amount *amount) { struct WithdrawalOperation *wo; @@ -233,7 +233,7 @@ TALER_FAKEBANK_tbi_post_withdrawal ( { struct TALER_ReservePublicKeyP reserve_pub; - const char *exchange_payto_url; + struct TALER_FullPayto exchange_payto_url; enum GNUNET_GenericReturnValue ret; struct TALER_Amount amount; bool amount_missing; @@ -241,8 +241,8 @@ TALER_FAKEBANK_tbi_post_withdrawal ( struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("reserve_pub", &reserve_pub), - GNUNET_JSON_spec_string ("selected_exchange", - &exchange_payto_url), + TALER_JSON_spec_full_payto_uri ("selected_exchange", + &exchange_payto_url), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_amount ("amount", h->currency, diff --git a/src/bank-lib/fakebank_twg_admin_add_incoming.c b/src/bank-lib/fakebank_twg_admin_add_incoming.c index 2db4f1fe5..885fa2949 100644 --- a/src/bank-lib/fakebank_twg_admin_add_incoming.c +++ b/src/bank-lib/fakebank_twg_admin_add_incoming.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2016-2023 Taler Systems SA + (C) 2016-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -74,7 +74,7 @@ TALER_FAKEBANK_twg_admin_add_incoming_ ( break; } { - const char *debit_account; + struct TALER_FullPayto debit_account; struct TALER_Amount amount; struct TALER_ReservePublicKeyP reserve_pub; char *debit; @@ -82,8 +82,8 @@ TALER_FAKEBANK_twg_admin_add_incoming_ ( struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("reserve_pub", &reserve_pub), - GNUNET_JSON_spec_string ("debit_account", - &debit_account), + TALER_JSON_spec_full_payto_uri ("debit_account", + &debit_account), TALER_JSON_spec_amount ("amount", h->currency, &amount), @@ -120,7 +120,7 @@ TALER_FAKEBANK_twg_admin_add_incoming_ ( connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PAYTO_URI_MALFORMED, - debit_account); + debit_account.full_payto); } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s\n", diff --git a/src/bank-lib/fakebank_twg_admin_add_kycauth.c b/src/bank-lib/fakebank_twg_admin_add_kycauth.c index 7e0a47f87..07626e06e 100644 --- a/src/bank-lib/fakebank_twg_admin_add_kycauth.c +++ b/src/bank-lib/fakebank_twg_admin_add_kycauth.c @@ -75,7 +75,7 @@ TALER_FAKEBANK_twg_admin_add_kycauth_ ( break; } { - const char *debit_account; + struct TALER_FullPayto debit_account; struct TALER_Amount amount; union TALER_AccountPublicKeyP account_pub; char *debit; @@ -83,8 +83,8 @@ TALER_FAKEBANK_twg_admin_add_kycauth_ ( struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("account_pub", &account_pub), - GNUNET_JSON_spec_string ("debit_account", - &debit_account), + TALER_JSON_spec_full_payto_uri ("debit_account", + &debit_account), TALER_JSON_spec_amount ("amount", h->currency, &amount), @@ -121,7 +121,7 @@ TALER_FAKEBANK_twg_admin_add_kycauth_ ( connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PAYTO_URI_MALFORMED, - debit_account); + debit_account.full_payto); } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Receiving kycauth wire transfer: %s->%s, subject: %s, amount: %s\n", diff --git a/src/bank-lib/fakebank_twg_transfer.c b/src/bank-lib/fakebank_twg_transfer.c index 6a22c7dad..efdecb354 100644 --- a/src/bank-lib/fakebank_twg_transfer.c +++ b/src/bank-lib/fakebank_twg_transfer.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2016-2023 Taler Systems SA + (C) 2016-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -88,7 +88,7 @@ TALER_FAKEBANK_handle_transfer_ ( { struct GNUNET_HashCode uuid; struct TALER_WireTransferIdentifierRawP wtid; - const char *credit_account; + struct TALER_FullPayto credit_account; char *credit; const char *base_url; struct TALER_Amount amount; @@ -103,8 +103,8 @@ TALER_FAKEBANK_handle_transfer_ ( &base_url), GNUNET_JSON_spec_fixed_auto ("wtid", &wtid), - GNUNET_JSON_spec_string ("credit_account", - &credit_account), + TALER_JSON_spec_full_payto_uri ("credit_account", + &credit_account), GNUNET_JSON_spec_end () }; @@ -125,7 +125,7 @@ TALER_FAKEBANK_handle_transfer_ ( connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PAYTO_URI_MALFORMED, - credit_account); + credit_account.full_payto); } ret = TALER_FAKEBANK_make_transfer_ (h, account, diff --git a/src/bank-lib/taler-exchange-wire-gateway-client.c b/src/bank-lib/taler-exchange-wire-gateway-client.c index 230cc1e33..477bb750e 100644 --- a/src/bank-lib/taler-exchange-wire-gateway-client.c +++ b/src/bank-lib/taler-exchange-wire-gateway-client.c @@ -44,12 +44,12 @@ static struct TALER_Amount amount; /** * Credit account payto://-URI. */ -static char *credit_account; +static struct TALER_FullPayto credit_account; /** * Debit account payto://-URI. */ -static char *debit_account; +static struct TALER_FullPayto debit_account; /** * Wire transfer subject. @@ -185,13 +185,13 @@ credit_history_cb (void *cls, &reply->details.ok.details[i]; /* If credit/debit accounts were specified, use as a filter */ - if ( (NULL != credit_account) && - (0 != strcasecmp (credit_account, - reply->details.ok.credit_account_uri) ) ) + if ( (NULL != credit_account.full_payto) && + (0 != TALER_full_payto_cmp (credit_account, + reply->details.ok.credit_account_uri) ) ) continue; - if ( (NULL != debit_account) && - (0 != strcasecmp (debit_account, - cd->debit_account_uri) ) ) + if ( (NULL != debit_account.full_payto) && + (0 != TALER_full_payto_cmp (debit_account, + cd->debit_account_uri) ) ) continue; switch (cd->type) { @@ -199,8 +199,8 @@ credit_history_cb (void *cls, fprintf (stdout, "%llu: %s->%s (%s) over %s at %s\n", (unsigned long long) cd->serial_id, - cd->debit_account_uri, - reply->details.ok.credit_account_uri, + cd->debit_account_uri.full_payto, + reply->details.ok.credit_account_uri.full_payto, TALER_B2S (&cd->details.reserve.reserve_pub), TALER_amount2s (&cd->amount), GNUNET_TIME_timestamp2s (cd->execution_date)); @@ -209,8 +209,8 @@ credit_history_cb (void *cls, fprintf (stdout, "%llu: %s->%s (KYC:%s) over %s at %s\n", (unsigned long long) cd->serial_id, - cd->debit_account_uri, - reply->details.ok.credit_account_uri, + cd->debit_account_uri.full_payto, + reply->details.ok.credit_account_uri.full_payto, TALER_B2S (&cd->details.kycauth.account_pub), TALER_amount2s (&cd->amount), GNUNET_TIME_timestamp2s (cd->execution_date)); @@ -303,19 +303,19 @@ debit_history_cb (void *cls, &reply->details.ok.details[i]; /* If credit/debit accounts were specified, use as a filter */ - if ( (NULL != credit_account) && - (0 != strcasecmp (credit_account, - dd->credit_account_uri) ) ) + if ( (NULL != credit_account.full_payto) && + (0 != TALER_full_payto_cmp (credit_account, + dd->credit_account_uri) ) ) continue; - if ( (NULL != debit_account) && - (0 != strcasecmp (debit_account, - reply->details.ok.debit_account_uri) ) ) + if ( (NULL != debit_account.full_payto) && + (0 != TALER_full_payto_cmp (debit_account, + reply->details.ok.debit_account_uri) ) ) continue; fprintf (stdout, "%llu: %s->%s (%s) over %s at %s\n", (unsigned long long) dd->serial_id, - reply->details.ok.debit_account_uri, - dd->credit_account_uri, + reply->details.ok.debit_account_uri.full_payto, + dd->credit_account_uri.full_payto, TALER_B2S (&dd->wtid), TALER_amount2s (&dd->amount), GNUNET_TIME_timestamp2s (dd->execution_date)); @@ -413,7 +413,7 @@ execute_wire_transfer (void) size_t buf_size; char *params; - if (NULL != debit_account) + if (NULL != debit_account.full_payto) { fprintf (stderr, "Invalid option -C specified, conflicts with -D\n"); @@ -445,7 +445,7 @@ execute_wire_transfer (void) &wtid, sizeof (wtid)); } - params = strchr (credit_account, + params = strchr (credit_account.full_payto, (unsigned char) '&'); if (NULL != params) *params = '\0'; @@ -618,6 +618,12 @@ run (void *cls, { auth.method = TALER_BANK_AUTH_BASIC; } + else if ( (NULL != auth.wire_gateway_url) && + (NULL != auth.details.bearer.token) ) + { + auth.method = TALER_BANK_AUTH_BEARER; + } + else if (NULL == auth.wire_gateway_url) { fprintf (stderr, @@ -656,12 +662,12 @@ run (void *cls, execute_debit_history (); return; } - if (NULL != credit_account) + if (NULL != credit_account.full_payto) { execute_wire_transfer (); return; } - if (NULL != debit_account) + if (NULL != debit_account.full_payto) { execute_admin_transfer (); return; @@ -700,12 +706,12 @@ main (int argc, "credit", "ACCOUNT", "payto URI of the bank account to credit (when making outgoing transfers)", - &credit_account), + &credit_account.full_payto), GNUNET_GETOPT_option_string ('D', "debit", "PAYTO-URL", "payto URI of the bank account to debit (when making incoming transfers)", - &debit_account), + &debit_account.full_payto), GNUNET_GETOPT_option_flag ('i', "credit-history", "Ask to get a list of 10 incoming transactions.", @@ -747,10 +753,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return 4; global_ret = 1; ret = GNUNET_PROGRAM_run ( argc, argv, @@ -758,7 +760,6 @@ main (int argc, gettext_noop ("Client tool of the Taler Wire Gateway"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return 3; if (GNUNET_NO == ret) diff --git a/src/benchmark/benchmark-common.conf b/src/benchmark/benchmark-common.conf index e47115a2b..89da0e4bd 100644 --- a/src/benchmark/benchmark-common.conf +++ b/src/benchmark/benchmark-common.conf @@ -57,13 +57,13 @@ PAYTO_URI = payto://iban/SANDBOXX/DE033310?receiver-name=Exchange+Company [exchange-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8080/accounts/exchange/taler-wire-gateway/" [admin-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = admin -PASSWORD = secret +PASSWORD = secret-password WIRE_GATEWAY_URL = "http://localhost:8080/accounts/exchange/taler-wire-gateway/" @@ -95,6 +95,8 @@ RAM_LIMIT=10000000 [libeufin-bank] CURRENCY = EUR +PWD_HASH_CONFIG = { "cost": 4 } +PWD_AUTH_COMPAT = yes [libeufin-nexus] DB_CONNECTION="postgresql:///talercheck" diff --git a/src/benchmark/benchmark-cs.conf b/src/benchmark/benchmark-cs.conf index 7f660ad31..82a97b7e9 100644 --- a/src/benchmark/benchmark-cs.conf +++ b/src/benchmark/benchmark-cs.conf @@ -13,4 +13,4 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = http://localhost:8082/accounts/Exchange/taler-wire-gateway/ WIRE_GATEWAY_AUTH_METHOD = "basic" USERNAME = Exchange -PASSWORD = x +PASSWORD = password diff --git a/src/benchmark/benchmark-rsa.conf b/src/benchmark/benchmark-rsa.conf index a6c1512ee..6ace6478b 100644 --- a/src/benchmark/benchmark-rsa.conf +++ b/src/benchmark/benchmark-rsa.conf @@ -13,4 +13,4 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = http://localhost:8082/accounts/Exchange/taler-wire-gateway/ WIRE_GATEWAY_AUTH_METHOD = "basic" USERNAME = Exchange -PASSWORD = x +PASSWORD = password diff --git a/src/benchmark/taler-aggregator-benchmark.c b/src/benchmark/taler-aggregator-benchmark.c index fe484e172..5fb9d1412 100644 --- a/src/benchmark/taler-aggregator-benchmark.c +++ b/src/benchmark/taler-aggregator-benchmark.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2021 Taler Systems SA + (C) 2021, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -210,7 +210,7 @@ struct Merchant /** * Account information for the merchant. */ - char *payto_uri; + struct TALER_FullPayto payto_uri; }; @@ -367,7 +367,7 @@ work (void *cls) UINT64_MAX); rnd2 = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE, UINT64_MAX); - GNUNET_asprintf (&m.payto_uri, + GNUNET_asprintf (&m.payto_uri.full_payto, "payto://x-taler-bank/localhost:8082/account-%llX-%llX", (unsigned long long) rnd1, (unsigned long long) rnd2); @@ -382,18 +382,14 @@ work (void *cls) { GNUNET_break (0); global_ret = EXIT_FAILURE; - GNUNET_free (m.payto_uri); - GNUNET_SCHEDULER_shutdown (); - return; + goto exit; } for (unsigned int i = 0; i<howmany_deposits; i++) { if (! add_deposit (&m)) { global_ret = EXIT_FAILURE; - GNUNET_SCHEDULER_shutdown (); - GNUNET_free (m.payto_uri); - return; + goto exit; } } if (0 <= @@ -401,9 +397,7 @@ work (void *cls) { if (0 == --howmany_merchants) { - GNUNET_SCHEDULER_shutdown (); - GNUNET_free (m.payto_uri); - return; + goto exit; } } else @@ -411,9 +405,14 @@ work (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to commit, will try again\n"); } - GNUNET_free (m.payto_uri); + GNUNET_free (m.payto_uri.full_payto); task = GNUNET_SCHEDULER_add_now (&work, NULL); + return; +exit: + GNUNET_SCHEDULER_shutdown (); + GNUNET_free (m.payto_uri.full_payto); + return; } @@ -451,7 +450,8 @@ run (void *cls, global_ret = EXIT_NOTCONFIGURED; return; } - plugin = TALER_EXCHANGEDB_plugin_load (cfg); + plugin = TALER_EXCHANGEDB_plugin_load (cfg, + false); if (NULL == plugin) { global_ret = EXIT_NOTCONFIGURED; diff --git a/src/exchange-tools/.gitignore b/src/exchange-tools/.gitignore index 69279d792..add509a3a 100644 --- a/src/exchange-tools/.gitignore +++ b/src/exchange-tools/.gitignore @@ -1,3 +1,4 @@ taler-exchange-offline taler-auditor-offline taler-crypto-worker +taler-exchange-kyc-trigger diff --git a/src/exchange-tools/Makefile.am b/src/exchange-tools/Makefile.am index 955544564..613a7be99 100644 --- a/src/exchange-tools/Makefile.am +++ b/src/exchange-tools/Makefile.am @@ -14,6 +14,7 @@ endif bin_PROGRAMS = \ taler-auditor-offline \ + taler-exchange-kyc-trigger \ taler-exchange-offline \ taler-exchange-dbinit @@ -31,6 +32,18 @@ taler_exchange_offline_LDADD = \ -lgnunetutil \ $(XLIB) +taler_exchange_kyc_trigger_SOURCES = \ + taler-exchange-kyc-trigger.c +taler_exchange_kyc_trigger_LDADD = \ + $(LIBGCRYPT_LIBS) \ + $(top_builddir)/src/lib/libtalerexchange.la \ + $(top_builddir)/src/util/libtalerutil.la \ + -lgnunetjson \ + -lgnunetcurl \ + -ljansson \ + -lgnunetutil \ + $(XLIB) + taler_auditor_offline_SOURCES = \ taler-auditor-offline.c taler_auditor_offline_LDADD = \ diff --git a/src/exchange-tools/taler-auditor-offline.c b/src/exchange-tools/taler-auditor-offline.c index 8c280d46b..2eb4596b8 100644 --- a/src/exchange-tools/taler-auditor-offline.c +++ b/src/exchange-tools/taler-auditor-offline.c @@ -1470,10 +1470,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; /* force linker to link against libtalerutil; if we do not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ @@ -1484,7 +1480,6 @@ main (int argc, gettext_noop ("Operations for offline signing for a Taler exchange"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index 7eb021a91..bd2c8d541 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -80,7 +80,8 @@ run (void *cls, (void) cfgfile; if (NULL == - (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (plugin = TALER_EXCHANGEDB_plugin_load (cfg, + true))) { fprintf (stderr, "Failed to initialize database plugin.\n"); @@ -195,10 +196,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; /* force linker to link against libtalerutil; if we do not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ @@ -209,7 +206,6 @@ main (int argc, gettext_noop ("Initialize Taler exchange database"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange-tools/taler-exchange-kyc-trigger.c b/src/exchange-tools/taler-exchange-kyc-trigger.c new file mode 100644 index 000000000..db3455c43 --- /dev/null +++ b/src/exchange-tools/taler-exchange-kyc-trigger.c @@ -0,0 +1,323 @@ +/* + This file is part of TALER + Copyright (C) 2020-2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file taler-exchange-kyc-trigger.c + * @brief Support for manually triggering KYC/AML processes for testing + * @author Christian Grothoff + */ +#include <platform.h> +#include <gnunet/gnunet_json_lib.h> +#include <gnunet/gnunet_util_lib.h> +#include "taler_json_lib.h" +#include "taler_exchange_service.h" + + +/** + * Our private key. + */ +static struct TALER_ReservePrivateKeyP reserve_priv; + +/** + * Our public key. + */ +static struct TALER_ReservePublicKeyP reserve_pub; + +/** + * Our context for making HTTP requests. + */ +static struct GNUNET_CURL_Context *ctx; + +/** + * Reschedule context for #ctx. + */ +static struct GNUNET_CURL_RescheduleContext *rc; + +/** + * Handle to the exchange's configuration + */ +static const struct GNUNET_CONFIGURATION_Handle *kcfg; + +/** + * Handle for exchange interaction. + */ +static struct TALER_EXCHANGE_KycWalletHandle *kwh; + +/** + * Balance threshold to report to the exchange. + */ +static struct TALER_Amount balance; + +/** + * Return value from main(). + */ +static int global_ret; + +/** + * Currency we have configured. + */ +static char *currency; + +/** + * URL of the exchange we are interacting with + * as per our configuration. + */ +static char *CFG_exchange_url; + + +/** + * Function called with the result for a wallet looking + * up its KYC payment target. + * + * @param cls closure + * @param ks the wallets KYC payment target details + */ +static void +kyc_wallet_cb ( + void *cls, + const struct TALER_EXCHANGE_WalletKycResponse *ks) +{ + kwh = NULL; + switch (ks->hr.http_status) + { + case MHD_HTTP_OK: + fprintf (stdout, + "OK, next treshold at %s\n", + TALER_amount2s (&ks->details.ok.next_threshold)); + break; + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: + { + const struct TALER_EXCHANGE_KycNeededRedirect *knr + = &ks->details.unavailable_for_legal_reasons; + char *ps; + + ps = GNUNET_STRINGS_data_to_string_alloc (&knr->h_payto, + sizeof (knr->h_payto)); + fprintf (stderr, + "KYC needed (%llu, %s) for %s\n", + (unsigned long long) knr->requirement_row, + knr->bad_kyc_auth + ? "KYC auth needed" + : "KYC auth OK", + ps); + GNUNET_free (ps); + } + break; + default: + fprintf (stdout, + "Unexpected HTTP status %u\n", + ks->hr.http_status); + break; + } + GNUNET_SCHEDULER_shutdown (); +} + + +/** + * Shutdown task. Invoked when the application is being terminated. + * + * @param cls NULL + */ +static void +do_shutdown (void *cls) +{ + (void) cls; + if (NULL != kwh) + { + TALER_EXCHANGE_kyc_wallet_cancel (kwh); + kwh = NULL; + } + if (NULL != ctx) + { + GNUNET_CURL_fini (ctx); + ctx = NULL; + } + if (NULL != rc) + { + GNUNET_CURL_gnunet_rc_destroy (rc); + rc = NULL; + } +} + + +/** + * Load the reserve key. + * + * @param do_create #GNUNET_YES if the key may be created + * @return #GNUNET_OK on success + */ +static enum GNUNET_GenericReturnValue +load_reserve_key (int do_create) +{ + char *fn; + + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_filename (kcfg, + "exchange-testing", + "RESERVE_PRIV_FILE", + &fn)) + { + enum GNUNET_GenericReturnValue ret; + + if (GNUNET_YES != + GNUNET_DISK_file_test (fn)) + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Account private key `%s' does not exist yet, creating it!\n", + fn); + ret = GNUNET_CRYPTO_eddsa_key_from_file (fn, + do_create, + &reserve_priv.eddsa_priv); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to initialize master key from file `%s': %s\n", + fn, + "could not create file"); + GNUNET_free (fn); + return GNUNET_SYSERR; + } + GNUNET_free (fn); + } + else + { + GNUNET_CRYPTO_eddsa_key_create (&reserve_priv.eddsa_priv); + } + GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv.eddsa_priv, + &reserve_pub.eddsa_pub); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Using reserve public key %s\n", + TALER_B2S (&reserve_pub)); + return GNUNET_OK; +} + + +/** + * Main function that will be run. + * + * @param cls closure + * @param args remaining command-line arguments + * @param cfgfile name of the configuration file used (for saving, can be NULL!) + * @param cfg configuration + */ +static void +run (void *cls, + char *const *args, + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + (void) cls; + (void) cfgfile; + kcfg = cfg; + + if (GNUNET_OK != + load_reserve_key (GNUNET_YES)) + { + GNUNET_break (0); + global_ret = EXIT_FAILURE; + return; + } + if (GNUNET_OK != + TALER_config_get_currency (kcfg, + ¤cy)) + { + global_ret = EXIT_NOTCONFIGURED; + return; + } + if ( (GNUNET_OK != + TALER_amount_is_valid (&balance)) || + (0 != strcmp (balance.currency, + currency)) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Invalid balance threshold `%s'\n", + TALER_amount2s (&balance)); + global_ret = EXIT_FAILURE; + return; + } + if ( (NULL == CFG_exchange_url) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (kcfg, + "exchange", + "BASE_URL", + &CFG_exchange_url)) ) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "BASE_URL"); + global_ret = EXIT_NOTCONFIGURED; + GNUNET_SCHEDULER_shutdown (); + return; + } + ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule, + &rc); + rc = GNUNET_CURL_gnunet_rc_create (ctx); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, + NULL); + kwh = TALER_EXCHANGE_kyc_wallet (ctx, + CFG_exchange_url, + &reserve_priv, + &balance, + &kyc_wallet_cb, + NULL); + if (NULL == kwh) + { + GNUNET_break (0); + GNUNET_SCHEDULER_shutdown (); + } +} + + +/** + * The main function of the taler-exchange-kyc-trigger tool. + * + * @param argc number of arguments from the command line + * @param argv command line arguments + * @return 0 ok, 1 on error + */ +int +main (int argc, + char *const *argv) +{ + struct GNUNET_GETOPT_CommandLineOption options[] = { + TALER_getopt_get_amount ('b', + "balance", + "AMOUNT", + "balance threshold to report to the exchange", + &balance), + GNUNET_GETOPT_OPTION_END + }; + enum GNUNET_GenericReturnValue ret; + + /* force linker to link against libtalerutil; if we do + not do this, the linker may "optimize" libtalerutil + away and skip #TALER_OS_init(), which we do need */ + (void) TALER_project_data_default (); + TALER_OS_init (); + ret = GNUNET_PROGRAM_run ( + argc, argv, + "taler-exchange-kyc-trigger", + gettext_noop ( + "Trigger KYC/AML measures based on high wallet balance for testing"), + options, + &run, NULL); + if (GNUNET_SYSERR == ret) + return EXIT_INVALIDARGUMENT; + if (GNUNET_NO == ret) + return EXIT_SUCCESS; + return global_ret; +} + + +/* end of taler-exchange-kyc-trigger.c */ diff --git a/src/exchange-tools/taler-exchange-offline.c b/src/exchange-tools/taler-exchange-offline.c index 023c59390..67a4e0de7 100644 --- a/src/exchange-tools/taler-exchange-offline.c +++ b/src/exchange-tools/taler-exchange-offline.c @@ -130,7 +130,7 @@ static struct TALER_MasterPrivateKeyP master_priv; /** - * Our private key, initialized in #load_offline_key(). + * Our public key, initialized in #load_offline_key(). */ static struct TALER_MasterPublicKeyP master_pub; @@ -576,7 +576,6 @@ static struct GNUNET_SCHEDULER_Task *nxt; */ static struct TALER_EXCHANGE_ManagementGetKeysHandle *mgkh; - /** * Active AML staff change requests. */ @@ -1539,7 +1538,7 @@ upload_wire_add (const char *exchange_url, { struct TALER_MasterSignatureP master_sig_add; struct TALER_MasterSignatureP master_sig_wire; - const char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_TIME_Timestamp start_time; struct WireAddRequest *war; const char *err_name; @@ -1550,8 +1549,8 @@ upload_wire_add (const char *exchange_url, const json_t *credit_restrictions; unsigned int err_line; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_web_url ("conversion_url", &conversion_url), @@ -1596,12 +1595,12 @@ upload_wire_add (const char *exchange_url, { char *wire_method; - wire_method = TALER_payto_get_method (payto_uri); + wire_method = TALER_payto_get_method (payto_uri.full_payto); if (NULL == wire_method) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "payto:// URI `%s' is malformed\n", - payto_uri); + payto_uri.full_payto); global_ret = EXIT_FAILURE; GNUNET_SCHEDULER_shutdown (); return; @@ -1688,14 +1687,14 @@ upload_wire_del (const char *exchange_url, const json_t *value) { struct TALER_MasterSignatureP master_sig; - const char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_TIME_Timestamp end_time; struct WireDelRequest *wdr; const char *err_name; unsigned int err_line; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), GNUNET_JSON_spec_timestamp ("validity_end", &end_time), GNUNET_JSON_spec_fixed_auto ("master_sig", @@ -2010,7 +2009,7 @@ upload_drain (const char *exchange_url, unsigned int err_line; struct TALER_Amount amount; struct GNUNET_TIME_Timestamp date; - const char *payto_uri; + struct TALER_FullPayto payto_uri; const char *account_section; struct DrainProfitsRequest *dpr; struct GNUNET_JSON_Specification spec[] = { @@ -2023,8 +2022,8 @@ upload_drain (const char *exchange_url, &date), GNUNET_JSON_spec_string ("account_section", &account_section), - TALER_JSON_spec_payto_uri ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), GNUNET_JSON_spec_fixed_auto ("master_sig", &master_sig), GNUNET_JSON_spec_end () @@ -3097,6 +3096,9 @@ do_add_wire (char *const *args) json_t *debit_restrictions; json_t *credit_restrictions; unsigned int num_args = 1; + struct TALER_FullPayto payto_uri = { + .full_payto = args[0] + }; if (NULL != in) { @@ -3118,12 +3120,13 @@ do_add_wire (char *const *args) load_offline_key (GNUNET_NO)) return; { - char *msg = TALER_payto_validate (args[0]); + char *msg = TALER_payto_validate (payto_uri); if (NULL != msg) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "payto URI is malformed: %s\n", + "payto URI `%s' is malformed: %s\n", + payto_uri.full_payto, msg); GNUNET_free (msg); GNUNET_SCHEDULER_shutdown (); @@ -3135,12 +3138,12 @@ do_add_wire (char *const *args) { char *wire_method; - wire_method = TALER_payto_get_method (args[0]); + wire_method = TALER_payto_get_method (payto_uri.full_payto); if (NULL == wire_method) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "payto:// URI `%s' is malformed\n", - args[0]); + payto_uri.full_payto); global_ret = EXIT_INVALIDARGUMENT; GNUNET_SCHEDULER_shutdown (); return; @@ -3260,14 +3263,14 @@ do_add_wire (char *const *args) } break; } - TALER_exchange_offline_wire_add_sign (args[0], + TALER_exchange_offline_wire_add_sign (payto_uri, conversion_url, debit_restrictions, credit_restrictions, now, &master_priv, &master_sig_add); - TALER_exchange_wire_signature_make (args[0], + TALER_exchange_wire_signature_make (payto_uri, conversion_url, debit_restrictions, credit_restrictions, @@ -3275,8 +3278,8 @@ do_add_wire (char *const *args) &master_sig_wire); output_operation (OP_ENABLE_WIRE, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - args[0]), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_array_steal ("debit_restrictions", debit_restrictions), GNUNET_JSON_pack_array_steal ("credit_restrictions", @@ -3303,13 +3306,16 @@ do_add_wire (char *const *args) * Disable wire account. * * @param args the array of command-line arguments to process next; - * args[0] must be the hash of the denomination key to revoke + * args[0] must be the payto URI of the account to disable */ static void do_del_wire (char *const *args) { struct TALER_MasterSignatureP master_sig; struct GNUNET_TIME_Timestamp now; + struct TALER_FullPayto payto_uri = { + .full_payto = args[0] + }; if (NULL != in) { @@ -3332,14 +3338,14 @@ do_del_wire (char *const *args) load_offline_key (GNUNET_NO)) return; now = GNUNET_TIME_timestamp_get (); - TALER_exchange_offline_wire_del_sign (args[0], + TALER_exchange_offline_wire_del_sign (payto_uri, now, &master_priv, &master_sig); output_operation (OP_DISABLE_WIRE, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - args[0]), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_timestamp ("validity_end", now), GNUNET_JSON_pack_data_auto ("master_sig", @@ -3586,7 +3592,7 @@ do_drain (char *const *args) struct GNUNET_TIME_Timestamp date; struct TALER_Amount amount; const char *account_section; - const char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_MasterSignatureP master_sig; char *err; @@ -3633,13 +3639,13 @@ do_drain (char *const *args) return; } account_section = args[1]; - payto_uri = args[2]; + payto_uri.full_payto = args[2]; err = TALER_payto_validate (payto_uri); if (NULL != err) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid payto://-URI `%s' specified for drain: %s\n", - payto_uri, + payto_uri.full_payto, err); GNUNET_free (err); GNUNET_SCHEDULER_shutdown (); @@ -3666,8 +3672,8 @@ do_drain (char *const *args) &wtid), GNUNET_JSON_pack_string ("account_section", account_section), - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), TALER_JSON_pack_amount ("amount", &amount), GNUNET_JSON_pack_timestamp ("date", @@ -5475,10 +5481,6 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -5486,7 +5488,6 @@ main (int argc, gettext_noop ("Operations for offline signing for a Taler exchange"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index dabd0a9a4..bc3a4e9b1 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -79,12 +79,17 @@ struct AggregationUnit /** * Wire details of the merchant. */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Selected wire target for the aggregation. */ - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_full_payto; + + /** + * Selected wire target for KYC checks. + */ + struct TALER_NormalizedPaytoHashP h_normalized_payto; /** * Exchange wire account to be used for the preparation and @@ -235,7 +240,7 @@ static void cleanup_au (struct AggregationUnit *au) { GNUNET_assert (NULL != au); - GNUNET_free (au->payto_uri); + GNUNET_free (au->payto_uri.full_payto); memset (au, 0, sizeof (*au)); @@ -324,7 +329,8 @@ parse_aggregator_config (void) } if (NULL == - (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem\n"); @@ -442,7 +448,7 @@ trigger_wire_transfer (const struct AggregationUnit *au_active) db_plugin->cls, au_active->execution_time, &au_active->wtid, - &au_active->h_payto, + &au_active->h_full_payto, au_active->wa->section_name, &au_active->final_amount); @@ -450,7 +456,7 @@ trigger_wire_transfer (const struct AggregationUnit *au_active) au_active->have_transient) qs = db_plugin->delete_aggregation_transient ( db_plugin->cls, - &au_active->h_payto, + &au_active->h_full_payto, &au_active->wtid); return qs; } @@ -485,7 +491,7 @@ return_relevant_amounts (void *cls, return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; qs = db_plugin->select_aggregation_amounts_for_kyc_check ( db_plugin->cls, - &au_active->h_payto, + &au_active->h_normalized_payto, limit, cb, cb_cls); @@ -528,7 +534,7 @@ legitimization_satisfied (struct AggregationUnit *au_active) /* FIXME: optimization potential: custom API to *just* get jrules... */ qs = db_plugin->get_kyc_rules (db_plugin->cls, - &au_active->h_payto, + &au_active->h_normalized_payto, &no_account_pub, &account_pub, &no_reserve_pub, @@ -577,7 +583,7 @@ legitimization_satisfied (struct AggregationUnit *au_active) qs = db_plugin->trigger_kyc_rule_for_account ( db_plugin->cls, au_active->payto_uri, - &au_active->h_payto, + &au_active->h_normalized_payto, NULL, &au_active->merchant_pub, jrule, @@ -623,7 +629,7 @@ do_aggregate (struct AggregationUnit *au) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No exchange account configured for `%s', please fix your setup to continue!\n", - au->payto_uri); + au->payto_uri.full_payto); global_ret = EXIT_FAILURE; return GNUNET_SYSERR; } @@ -655,9 +661,9 @@ do_aggregate (struct AggregationUnit *au) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found ready deposit for %s, aggregating by target %s\n", TALER_B2S (&au->merchant_pub), - au->payto_uri); + au->payto_uri.full_payto); qs = db_plugin->select_aggregation_transient (db_plugin->cls, - &au->h_payto, + &au->h_full_payto, &au->merchant_pub, au->wa->section_name, &au->wtid, @@ -691,7 +697,7 @@ do_aggregate (struct AggregationUnit *au) break; } qs = db_plugin->aggregate (db_plugin->cls, - &au->h_payto, + &au->h_full_payto, &au->merchant_pub, &au->wtid, &au->total_amount); @@ -741,13 +747,13 @@ do_aggregate (struct AggregationUnit *au) TALER_amount2s (&au->final_amount)); if (au->have_transient) qs = db_plugin->update_aggregation_transient (db_plugin->cls, - &au->h_payto, + &au->h_full_payto, &au->wtid, au->requirement_row, &au->total_amount); else qs = db_plugin->create_aggregation_transient (db_plugin->cls, - &au->h_payto, + &au->h_full_payto, au->wa->section_name, &au->merchant_pub, &au->wtid, @@ -903,8 +909,10 @@ run_aggregation (void *cls) break; } - TALER_payto_hash (au_active.payto_uri, - &au_active.h_payto); + TALER_full_payto_hash (au_active.payto_uri, + &au_active.h_full_payto); + TALER_full_payto_normalize_and_hash (au_active.payto_uri, + &au_active.h_normalized_payto); ret = do_aggregate (&au_active); cleanup_au (&au_active); switch (ret) @@ -1045,7 +1053,7 @@ run_shard (void *cls) static bool handle_transient_cb ( void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_Amount *total) @@ -1057,13 +1065,15 @@ handle_transient_cb ( GNUNET_break (0); return false; } - au->payto_uri = GNUNET_strdup (payto_uri); + au->payto_uri = payto_uri; + TALER_full_payto_hash (payto_uri, + &au->h_full_payto); au->wtid = *wtid; au->merchant_pub = *merchant_pub; au->trans = *total; au->have_transient = true; au->ret = do_aggregate (au); - GNUNET_free (au->payto_uri); + au->payto_uri.full_payto = NULL; return (GNUNET_OK == au->ret); } @@ -1105,7 +1115,10 @@ drain_kyc_alerts (void *cls) { qs = db_plugin->drain_kyc_alert (db_plugin->cls, 1, - &au.h_payto); + &au.h_normalized_payto); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Found %d KYC alerts\n", + (int) qs); switch (qs) { case GNUNET_DB_STATUS_HARD_ERROR: @@ -1137,7 +1150,7 @@ drain_kyc_alerts (void *cls) au.ret = GNUNET_OK; qs = db_plugin->find_aggregation_transient (db_plugin->cls, - &au.h_payto, + &au.h_normalized_payto, &handle_transient_cb, &au); switch (qs) @@ -1309,10 +1322,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1321,7 +1330,6 @@ main (int argc, "background process that aggregates and executes wire transfers"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange/taler-exchange-closer.c b/src/exchange/taler-exchange-closer.c index 4e64e2b20..a24f8387b 100644 --- a/src/exchange/taler-exchange-closer.c +++ b/src/exchange/taler-exchange-closer.c @@ -151,7 +151,8 @@ parse_closer_config (void) } if (NULL == - (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem\n"); @@ -214,7 +215,7 @@ static enum GNUNET_GenericReturnValue expired_reserve_cb (void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *left, - const char *account_payto_uri, + const struct TALER_FullPayto account_payto_uri, struct GNUNET_TIME_Timestamp expiration_date, uint64_t close_request_row) { @@ -240,7 +241,7 @@ expired_reserve_cb (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No wire account configured to deal with target URI `%s'\n", - account_payto_uri); + account_payto_uri.full_payto); global_ret = EXIT_FAILURE; GNUNET_SCHEDULER_shutdown (); return GNUNET_SYSERR; @@ -549,10 +550,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -560,7 +557,6 @@ main (int argc, gettext_noop ("background process that closes expired reserves"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange/taler-exchange-drain.c b/src/exchange/taler-exchange-drain.c index d409487c1..52de43be9 100644 --- a/src/exchange/taler-exchange-drain.c +++ b/src/exchange/taler-exchange-drain.c @@ -134,7 +134,8 @@ parse_drain_config (void) GNUNET_free (master_public_key_str); } if (NULL == - (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem\n"); @@ -188,7 +189,7 @@ run_drain (void *cls) uint64_t serial; struct TALER_WireTransferIdentifierRawP wtid; char *account_section; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_TIME_Timestamp request_timestamp; struct TALER_Amount amount; struct TALER_MasterSignatureP master_sig; @@ -265,7 +266,7 @@ run_drain (void *cls) fprintf (stdout, "We will wire %s to `%s'\n based on instructions from %s.\n", TALER_amount2s (&amount), - payto_uri, + payto_uri.full_payto, GNUNET_TIME_timestamp2s (request_timestamp)); fprintf (stdout, "Press ENTER to confirm, CTRL-D to abort.\n"); @@ -282,6 +283,7 @@ run_drain (void *cls) "Contact Taler Systems SA to cancel it for good.\n" "Exiting.\n"); db_plugin->rollback (db_plugin->cls); + GNUNET_free (payto_uri.full_payto); GNUNET_assert (NULL == task); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; @@ -305,7 +307,7 @@ run_drain (void *cls) &wtid, &buf, &buf_size); - method = TALER_payto_get_method (payto_uri); + method = TALER_payto_get_method (payto_uri.full_payto); qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, method, buf, @@ -313,6 +315,7 @@ run_drain (void *cls) GNUNET_free (method); GNUNET_free (buf); } + GNUNET_free (payto_uri.full_payto); qs = db_plugin->profit_drains_set_finished (db_plugin->cls, serial); switch (qs) @@ -407,10 +410,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -419,7 +418,6 @@ main (int argc, "process that executes a single profit drain"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange/taler-exchange-expire.c b/src/exchange/taler-exchange-expire.c index b2d34ee1c..248e4d2d4 100644 --- a/src/exchange/taler-exchange-expire.c +++ b/src/exchange/taler-exchange-expire.c @@ -137,7 +137,8 @@ static enum GNUNET_GenericReturnValue parse_expire_config (void) { if (NULL == - (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem\n"); @@ -476,10 +477,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -488,7 +485,6 @@ main (int argc, "background process that expires purses"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 58d0e035c..b3a80efa7 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -53,6 +53,7 @@ #include "taler-exchange-httpd_kyc-upload.h" #include "taler-exchange-httpd_kyc-wallet.h" #include "taler-exchange-httpd_kyc-webhook.h" +#include "taler-exchange-httpd_aml-decision.h" #include "taler-exchange-httpd_link.h" #include "taler-exchange-httpd_management.h" #include "taler-exchange-httpd_melt.h" @@ -96,7 +97,7 @@ * Above what request latency do we start to log? */ #define WARN_LATENCY GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_MILLISECONDS, 500) + GNUNET_TIME_UNIT_MILLISECONDS, 500) /** * Are clients allowed to request /keys for times other than the @@ -2381,7 +2382,8 @@ exchange_serve_process_config (const char *cfg_fn) for (unsigned int i = 0; i<MAX_DB_RETRIES; i++) { - TEH_plugin = TALER_EXCHANGEDB_plugin_load (TEH_cfg); + TEH_plugin = TALER_EXCHANGEDB_plugin_load (TEH_cfg, + false); if (NULL != TEH_plugin) break; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -2640,6 +2642,8 @@ do_shutdown (void *cls) struct MHD_Daemon *my_mhd; (void) cls; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Shutdown of taler-exchange-httpd\n"); my_mhd = TALER_MHD_daemon_stop (); TEH_resume_keys_requests (true); TEH_batch_deposit_cleanup (); @@ -2657,6 +2661,7 @@ do_shutdown (void *cls) TEH_kyc_info_cleanup (); TEH_kyc_proof_cleanup (); TEH_kyc_start_cleanup (); + TEH_aml_decision_cleanup (); TALER_KYCLOGIC_kyc_done (); if (NULL != my_mhd) { diff --git a/src/exchange/taler-exchange-httpd_age-withdraw.c b/src/exchange/taler-exchange-httpd_age-withdraw.c index e7d4b139c..d5f60a862 100644 --- a/src/exchange/taler-exchange-httpd_age-withdraw.c +++ b/src/exchange/taler-exchange-httpd_age-withdraw.c @@ -82,10 +82,10 @@ struct AgeWithdrawContext struct TALER_EXCHANGEDB_KycStatus kyc; /** - * Set to the hash of the payto account that established + * Set to the hash of the normalized payto URI that established * the reserve. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_normalized_payto; /** * value the client committed to @@ -498,7 +498,7 @@ check_kyc_result (struct AgeWithdrawContext *awc) finish_loop (awc, TEH_RESPONSE_reply_kyc_required ( awc->rc->connection, - &awc->h_payto, + &awc->h_normalized_payto, &awc->kyc, false)); return; @@ -577,7 +577,7 @@ withdraw_amount_cb ( return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; qs = TEH_plugin->select_withdraw_amounts_for_kyc_check ( TEH_plugin->cls, - &awc->h_payto, + &awc->h_normalized_payto, limit, cb, cb_cls); @@ -599,13 +599,14 @@ static void run_legi_check (struct AgeWithdrawContext *awc) { enum GNUNET_DB_QueryStatus qs; - char *payto_uri; + struct TALER_FullPayto payto_uri; + struct TALER_FullPaytoHashP h_full_payto; /* Check if the money came from a wire transfer */ qs = TEH_plugin->reserves_get_origin ( TEH_plugin->cls, &awc->commitment.reserve_pub, - &awc->h_payto, + &h_full_payto, &payto_uri); if (qs < 0) { @@ -625,19 +626,20 @@ run_legi_check (struct AgeWithdrawContext *awc) awc->phase = AWC_PHASE_PREPARE_TRANSACTION; return; } - + TALER_full_payto_normalize_and_hash (payto_uri, + &awc->h_normalized_payto); awc->lch = TEH_legitimization_check ( &awc->rc->async_scope_id, TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW, payto_uri, - &awc->h_payto, + &awc->h_normalized_payto, NULL, /* no account pub: this is about the origin account */ &withdraw_amount_cb, awc, &withdraw_legi_cb, awc); GNUNET_assert (NULL != awc->lch); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); GNUNET_CONTAINER_DLL_insert (awc_head, awc_tail, awc); diff --git a/src/exchange/taler-exchange-httpd_aml-attributes-get.c b/src/exchange/taler-exchange-httpd_aml-attributes-get.c index ee3b6de5a..1d6589c56 100644 --- a/src/exchange/taler-exchange-httpd_aml-attributes-get.c +++ b/src/exchange/taler-exchange-httpd_aml-attributes-get.c @@ -88,7 +88,7 @@ TEH_handler_aml_attributes_get ( { int64_t limit = -20; uint64_t offset; - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; if ( (NULL == args[0]) || (NULL != args[1]) ) diff --git a/src/exchange/taler-exchange-httpd_aml-decision.c b/src/exchange/taler-exchange-httpd_aml-decision.c index 897234ba5..596727d15 100644 --- a/src/exchange/taler-exchange-httpd_aml-decision.c +++ b/src/exchange/taler-exchange-httpd_aml-decision.c @@ -17,6 +17,7 @@ * @file taler-exchange-httpd_aml-decision.c * @brief Handle POST request about an AML decision. * @author Christian Grothoff + * @author Florian Dold */ #include "platform.h" #include <gnunet/gnunet_util_lib.h> @@ -28,10 +29,142 @@ #include "taler_mhd_lib.h" #include "taler_kyclogic_lib.h" #include "taler_signatures.h" +#include "taler-exchange-httpd_common_kyc.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_aml-decision.h" +/** + * Context used for processing the AML decision request. + */ +struct AmlDecisionContext +{ + + /** + * Kept in a DLL. + */ + struct AmlDecisionContext *next; + + /** + * Kept in a DLL. + */ + struct AmlDecisionContext *prev; + + /** + * HTTP status code to use with @e response. + */ + unsigned int response_code; + + /** + * Response to return, NULL if none yet. + */ + struct MHD_Response *response; + + /** + * Request we are processing. + */ + struct TEH_RequestContext *rc; + + /** + * Handle for async KYC processing. + */ + struct TEH_KycMeasureRunContext *kat; + +}; + +/** + * Kept in a DLL. + */ +static struct AmlDecisionContext *adc_head; + +/** + * Kept in a DLL. + */ +static struct AmlDecisionContext *adc_tail; + + +void +TEH_aml_decision_cleanup () +{ + struct AmlDecisionContext *adc; + + while (NULL != (adc = adc_head)) + { + MHD_resume_connection (adc->rc->connection); + GNUNET_CONTAINER_DLL_remove (adc_head, + adc_tail, + adc); + } +} + + +/** + * Function called to clean up aml decision context. + * + * @param[in,out] rc context to clean up + */ +static void +aml_decision_cleaner (struct TEH_RequestContext *rc) +{ + struct AmlDecisionContext *adc = rc->rh_ctx; + + if (NULL != adc->kat) + { + TEH_kyc_run_measure_cancel (adc->kat); + adc->kat = NULL; + } + if (NULL != adc->response) + { + MHD_destroy_response (adc->response); + adc->response = NULL; + } + GNUNET_free (adc); +} + + +/** + * Function called after the KYC-AML trigger is done. + * + * @param cls closure + * @param ec error code or 0 on success + * @param detail error message or NULL on success / no info + */ +static void +aml_trigger_callback ( + void *cls, + enum TALER_ErrorCode ec, + const char *detail) +{ + struct AmlDecisionContext *adc = cls; + + adc->kat = NULL; + GNUNET_assert (NULL == adc->response); + + if (TALER_EC_NONE != ec) + { + adc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; + adc->response = TALER_MHD_make_error ( + ec, + detail); + } + else + { + adc->response_code = MHD_HTTP_NO_CONTENT; + adc->response = MHD_create_response_from_buffer_static ( + 0, + ""); + } + + GNUNET_assert (NULL != adc->response); + + MHD_resume_connection (adc->rc->connection); + GNUNET_CONTAINER_DLL_remove (adc_head, + adc_tail, + adc); + TALER_MHD_daemon_trigger (); +} + + MHD_RESULT TEH_handler_post_aml_decision ( struct TEH_RequestContext *rc, @@ -39,15 +172,21 @@ TEH_handler_post_aml_decision ( const json_t *root) { struct MHD_Connection *connection = rc->connection; + struct AmlDecisionContext *adc = rc->rh_ctx; const char *justification; const char *new_measures = NULL; bool to_investigate; struct GNUNET_TIME_Timestamp decision_time; const json_t *new_rules; const json_t *properties = NULL; - const char *payto_uri = NULL; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPayto payto_uri = { + .full_payto = NULL + }; + struct TALER_NormalizedPaytoHashP h_payto; struct TALER_AmlOfficerSignatureP officer_sig; + struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs = NULL; + uint64_t legi_measure_serial_id = 0; + MHD_RESULT ret; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ( @@ -57,8 +196,8 @@ TEH_handler_post_aml_decision ( GNUNET_JSON_spec_string ("justification", &justification), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_string ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), NULL), GNUNET_JSON_spec_fixed_auto ("h_payto", &h_payto), @@ -79,6 +218,23 @@ TEH_handler_post_aml_decision ( struct GNUNET_TIME_Timestamp expiration_time; json_t *jmeasures = NULL; + if (NULL == adc) + { + /* Initialize context */ + adc = GNUNET_new (struct AmlDecisionContext); + adc->rc = rc; + rc->rh_ctx = adc; + rc->rh_cleaner = aml_decision_cleaner; + } + + if (NULL != adc->response) + { + ret = MHD_queue_response (rc->connection, + adc->response_code, + adc->response); + goto done; + } + { enum GNUNET_GenericReturnValue res; @@ -86,29 +242,34 @@ TEH_handler_post_aml_decision ( root, spec); if (GNUNET_SYSERR == res) - return MHD_NO; /* hard failure */ + { + ret = MHD_NO; /* hard failure */ + goto done; + } if (GNUNET_NO == res) { GNUNET_break_op (0); - return MHD_YES; /* failure */ + ret = MHD_YES /* failure */; + goto done; } } - if (NULL != payto_uri) + if (NULL != payto_uri.full_payto) { - struct TALER_PaytoHashP h_payto2; + struct TALER_NormalizedPaytoHashP h_payto2; - TALER_payto_hash (payto_uri, - &h_payto2); + TALER_full_payto_normalize_and_hash (payto_uri, + &h_payto2); if (0 != GNUNET_memcmp (&h_payto, &h_payto2)) { GNUNET_break (0); - return TALER_MHD_reply_with_error ( + ret = TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, "payto_uri"); + goto done; } } @@ -126,45 +287,44 @@ TEH_handler_post_aml_decision ( &officer_sig)) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( + ret = TALER_MHD_reply_with_error ( connection, MHD_HTTP_FORBIDDEN, TALER_EC_EXCHANGE_AML_DECISION_ADD_SIGNATURE_INVALID, NULL); + goto done; } + lrs = TALER_KYCLOGIC_rules_parse (new_rules); + if (NULL == lrs) { - struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs; + GNUNET_break_op (0); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "legitimization rule malformed"); + goto done; + } - lrs = TALER_KYCLOGIC_rules_parse (new_rules); - if (NULL == lrs) + expiration_time = TALER_KYCLOGIC_rules_get_expiration (lrs); + if (NULL != new_measures) + { + jmeasures + = TALER_KYCLOGIC_get_jmeasures (lrs, + new_measures); + if (NULL == jmeasures) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( + /* Request specified a new_measure for which the given + rule set does not work as it does not define the measure */ + ret = TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, - "legitimization rule malformed"); - } - expiration_time = TALER_KYCLOGIC_rules_get_expiration (lrs); - if (NULL != new_measures) - { - jmeasures - = TALER_KYCLOGIC_get_measures (lrs, - new_measures); - if (NULL == jmeasures) - { - GNUNET_break_op (0); - /* Request specified a new_measure for which the given - rule set does not work as it does not define the measure */ - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - "new_measures/new_rules"); - } + "new_measures/new_rules"); + goto done; } - TALER_KYCLOGIC_rules_free (lrs); } { @@ -190,53 +350,105 @@ TEH_handler_post_aml_decision ( &officer_sig, &invalid_officer, &unknown_account, - &last_date); + &last_date, + &legi_measure_serial_id); json_decref (jmeasures); if (qs <= 0) { GNUNET_break (0); - return TALER_MHD_reply_with_error ( + ret = TALER_MHD_reply_with_error ( connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_GENERIC_DB_STORE_FAILED, "insert_aml_decision"); + goto done; } if (invalid_officer) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( + ret = TALER_MHD_reply_with_error ( connection, MHD_HTTP_FORBIDDEN, TALER_EC_EXCHANGE_AML_DECISION_INVALID_OFFICER, NULL); + goto done; } if (unknown_account) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( + ret = TALER_MHD_reply_with_error ( connection, MHD_HTTP_NOT_FOUND, TALER_EC_EXCHANGE_GENERIC_BANK_ACCOUNT_UNKNOWN, "h_payto"); + goto done; } if (GNUNET_TIME_timestamp_cmp (last_date, >=, decision_time)) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( + ret = TALER_MHD_reply_with_error ( connection, MHD_HTTP_CONFLICT, TALER_EC_EXCHANGE_AML_DECISION_MORE_RECENT_PRESENT, NULL); + goto done; + } + } + /* Run instant measure if necessary */ + { + const struct TALER_KYCLOGIC_Measure *instant_ms = NULL; + + if (NULL != new_measures) + { + instant_ms = TALER_KYCLOGIC_get_instant_measure (lrs, new_measures); + } + + if (NULL != instant_ms) + { + /* We have an 'instant' measure which means we must run the + AML program immediately instead of waiting for the account owner + to select some measure and contribute their KYC data. */ + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Running instant measure after AML decision\n"); + adc->kat = TEH_kyc_run_measure_directly ( + &rc->async_scope_id, + instant_ms, + &h_payto, + &aml_trigger_callback, + adc + ); + if (NULL == adc->kat) + { + GNUNET_break (0); + ret = TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_EXCHANGE_KYC_GENERIC_AML_LOGIC_BUG, + "TEH_kyc_finished"); + goto done; + } + MHD_suspend_connection (adc->rc->connection); + GNUNET_CONTAINER_DLL_insert (adc_head, + adc_tail, + adc); + ret = MHD_YES; + goto done; } } - return TALER_MHD_reply_static ( + ret = TALER_MHD_reply_static ( connection, MHD_HTTP_NO_CONTENT, NULL, NULL, 0); + goto done; + +done: + TALER_KYCLOGIC_rules_free (lrs); + return ret; } diff --git a/src/exchange/taler-exchange-httpd_aml-decision.h b/src/exchange/taler-exchange-httpd_aml-decision.h index 10056116d..316b9dda5 100644 --- a/src/exchange/taler-exchange-httpd_aml-decision.h +++ b/src/exchange/taler-exchange-httpd_aml-decision.h @@ -58,5 +58,10 @@ TEH_handler_aml_decisions_get ( const struct TALER_AmlOfficerPublicKeyP *officer_pub, const char *const args[]); +/** + * Clean up running POST /aml/$OFFICER_PUB/decisions requests. + */ +void +TEH_aml_decision_cleanup (void); #endif diff --git a/src/exchange/taler-exchange-httpd_aml-decisions-get.c b/src/exchange/taler-exchange-httpd_aml-decisions-get.c index 9059d1437..f82a4eeac 100644 --- a/src/exchange/taler-exchange-httpd_aml-decisions-get.c +++ b/src/exchange/taler-exchange-httpd_aml-decisions-get.c @@ -56,7 +56,7 @@ record_cb ( void *cls, uint64_t row_id, const char *justification, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp decision_time, struct GNUNET_TIME_Absolute expiration_time, const json_t *jproperties, @@ -101,7 +101,7 @@ TEH_handler_aml_decisions_get ( { int64_t limit = -20; uint64_t offset; - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; bool have_payto = false; enum TALER_EXCHANGE_YesNoAll active_filter; enum TALER_EXCHANGE_YesNoAll investigation_filter; diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c b/src/exchange/taler-exchange-httpd_batch-deposit.c index abebe51ca..07651a470 100644 --- a/src/exchange/taler-exchange-httpd_batch-deposit.c +++ b/src/exchange/taler-exchange-httpd_batch-deposit.c @@ -80,7 +80,6 @@ struct BatchDepositContext */ json_t *policy_json; - /** * Response to return, if set. */ @@ -108,6 +107,12 @@ struct BatchDepositContext uint64_t policy_details_serial_id; /** + * Hash over the normalized payto://-URI of the account we are + * depositing into. + */ + struct TALER_NormalizedPaytoHashP nph; + + /** * Our timestamp (when we received the request). * Possibly updated by the transaction if the * request is idempotent (was repeated). @@ -339,7 +344,7 @@ batch_deposit_transaction (void *cls, &balance_ok, &bad_balance_coin_index, &in_conflict); - if (qs < 0) + if (qs <= 0) { if (GNUNET_DB_STATUS_SOFT_ERROR == qs) return qs; @@ -352,7 +357,7 @@ batch_deposit_transaction (void *cls, "batch-deposit"); return qs; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "do_deposit returned: %d / %s[%u] / %s\n", qs, balance_ok ? "balance ok" : "balance insufficient", @@ -507,7 +512,7 @@ bdc_phase_check_kyc_result (struct BatchDepositContext *bdc) finish_loop (bdc, TEH_RESPONSE_reply_kyc_required ( bdc->rc->connection, - &bdc->bd.wire_target_h_payto, + &bdc->nph, &bdc->kyc, bdc->bad_kyc_auth)); return; @@ -587,7 +592,7 @@ deposit_amount_cb ( return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; qs = TEH_plugin->select_deposit_amounts_for_kyc_check ( TEH_plugin->cls, - &bdc->bd.wire_target_h_payto, + &bdc->nph, limit, cb, cb_cls); @@ -613,11 +618,13 @@ bdc_phase_kyc (struct BatchDepositContext *bdc) bdc->phase++; return; } + TALER_full_payto_normalize_and_hash (bdc->bd.receiver_wire_account, + &bdc->nph); bdc->lch = TEH_legitimization_check2 ( &bdc->rc->async_scope_id, TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT, bdc->bd.receiver_wire_account, - &bdc->bd.wire_target_h_payto, + &bdc->nph, &bdc->bd.merchant_pub, &deposit_amount_cb, bdc, @@ -891,12 +898,16 @@ bdc_phase_parse (struct BatchDepositContext *bdc, const json_t *policy_json; bool no_refund_deadline = true; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_payto_uri ("merchant_payto_uri", - &bd->receiver_wire_account), + TALER_JSON_spec_full_payto_uri ("merchant_payto_uri", + &bd->receiver_wire_account), GNUNET_JSON_spec_fixed_auto ("wire_salt", &bd->wire_salt), GNUNET_JSON_spec_fixed_auto ("merchant_pub", &bd->merchant_pub), + GNUNET_JSON_spec_mark_optional ( /* since v22, we are compatible */ + GNUNET_JSON_spec_fixed_auto ("merchant_sig", + &bd->merchant_sig), + NULL), GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &bd->h_contract_terms), GNUNET_JSON_spec_mark_optional ( @@ -943,8 +954,28 @@ bdc_phase_parse (struct BatchDepositContext *bdc, return; } } + if ( (! GNUNET_is_zero (&bd->merchant_sig)) && + (GNUNET_OK != + TALER_merchant_contract_verify ( + &bd->h_contract_terms, + &bd->merchant_pub, + &bd->merchant_sig)) ) + { + GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); + finish_loop (bdc, + TALER_MHD_reply_with_error ( + bdc->rc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "merchant_sig")); + return; + } bdc->policy_json = json_incref ((json_t *) policy_json); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Batch deposit into contract %s\n", + GNUNET_h2s (&bd->h_contract_terms.hash)); /* validate merchant's wire details (as far as we can) */ { @@ -993,13 +1024,11 @@ bdc_phase_parse (struct BatchDepositContext *bdc, NULL)); return; } - TALER_payto_hash (bd->receiver_wire_account, - &bd->wire_target_h_payto); + TALER_full_payto_hash (bd->receiver_wire_account, + &bd->wire_target_h_payto); TALER_merchant_wire_signature_hash (bd->receiver_wire_account, &bd->wire_salt, &bdc->h_wire); - - bd->num_cdis = json_array_size (coins); if (0 == bd->num_cdis) { diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c b/src/exchange/taler-exchange-httpd_batch-withdraw.c index 5119a3e4b..3e4a92776 100644 --- a/src/exchange/taler-exchange-httpd_batch-withdraw.c +++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c @@ -110,7 +110,7 @@ struct BatchWithdrawContext * established the reserve, set during the @e kyc * check (if any). */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_normalized_payto; /** * Array of @e planchets_length planchets we are processing. @@ -570,7 +570,7 @@ check_kyc_result (struct BatchWithdrawContext *bwc) finish_loop (bwc, TEH_RESPONSE_reply_kyc_required ( bwc->rc->connection, - &bwc->h_payto, + &bwc->h_normalized_payto, &bwc->kyc, false)); return; @@ -649,7 +649,7 @@ withdraw_amount_cb ( return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; qs = TEH_plugin->select_withdraw_amounts_for_kyc_check ( TEH_plugin->cls, - &bwc->h_payto, + &bwc->h_normalized_payto, limit, cb, cb_cls); @@ -671,13 +671,19 @@ static void run_legi_check (struct BatchWithdrawContext *bwc) { enum GNUNET_DB_QueryStatus qs; - char *payto_uri; + struct TALER_FullPaytoHashP h_payto; + struct TALER_FullPayto payto_uri; + if (GNUNET_YES != TEH_enable_kyc) + { + bwc->phase = BWC_PHASE_PREPARE_TRANSACTION; + return; + } /* Check if the money came from a wire transfer */ qs = TEH_plugin->reserves_get_origin ( TEH_plugin->cls, &bwc->reserve_pub, - &bwc->h_payto, + &h_payto, &payto_uri); if (qs < 0) { @@ -698,18 +704,21 @@ run_legi_check (struct BatchWithdrawContext *bwc) return; } + TALER_full_payto_normalize_and_hash (payto_uri, + &bwc->h_normalized_payto); + bwc->lch = TEH_legitimization_check ( &bwc->rc->async_scope_id, TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW, payto_uri, - &bwc->h_payto, + &bwc->h_normalized_payto, NULL, /* no account pub: this is about the origin account */ &withdraw_amount_cb, bwc, &withdraw_legi_cb, bwc); GNUNET_assert (NULL != bwc->lch); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); GNUNET_CONTAINER_DLL_insert (bwc_head, bwc_tail, bwc); diff --git a/src/exchange/taler-exchange-httpd_common_kyc.c b/src/exchange/taler-exchange-httpd_common_kyc.c index c28dbb601..b8b48077e 100644 --- a/src/exchange/taler-exchange-httpd_common_kyc.c +++ b/src/exchange/taler-exchange-httpd_common_kyc.c @@ -34,8 +34,13 @@ */ #define MAX_LEGI_LOOPS 5 +/** + * Enable additional sanity-checks for debugging? + */ +#define EXTRA_CHECK 0 -struct TEH_KycAmlTrigger + +struct TEH_KycMeasureRunContext { /** @@ -46,7 +51,7 @@ struct TEH_KycAmlTrigger /** * account the operation is about */ - struct TALER_PaytoHashP account_id; + struct TALER_NormalizedPaytoHashP account_id; /** * until when is the KYC data valid @@ -76,7 +81,7 @@ struct TEH_KycAmlTrigger /** * function to call with the result */ - TEH_KycAmlTriggerCallback cb; + TEH_KycMeasureRunContextCallback cb; /** * closure for @e cb @@ -119,20 +124,12 @@ struct TEH_KycAmlTrigger uint32_t measure_index; /** - * response to return to the HTTP client - */ - struct MHD_Response *response; - - /** * Handle to an external process that evaluates the * need to run AML on the account. */ struct TALER_KYCLOGIC_AmlProgramRunnerHandle *kyc_aml; - /** - * HTTP status code of @e response - */ - unsigned int http_status; + struct GNUNET_SCHEDULER_Task *async_task; }; @@ -141,7 +138,7 @@ struct TEH_KycAmlTrigger * Function called with the result of activating a * fallback measure. * - * @param cls a `struct TEH_KycAmlTrigger *` + * @param cls a `struct TEH_KycMeasureRunContext *` * @param result true if the fallback was activated * successfully * @param requirement_row row of @@ -152,7 +149,7 @@ fallback_result_cb (void *cls, bool result, uint64_t requirement_row) { - struct TEH_KycAmlTrigger *kat = cls; + struct TEH_KycMeasureRunContext *kat = cls; struct GNUNET_AsyncScopeSave old_scope; kat->fb = NULL; @@ -162,20 +159,16 @@ fallback_result_cb (void *cls, if (result) { kat->cb (kat->cb_cls, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_MHD_make_error ( - TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, - NULL)); + TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, + NULL); } else { kat->cb (kat->cb_cls, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_MHD_make_error ( - TALER_EC_EXCHANGE_GENERIC_KYC_FALLBACK_FAILED, - kat->fallback_name)); + TALER_EC_EXCHANGE_GENERIC_KYC_FALLBACK_FAILED, + kat->fallback_name); } - TEH_kyc_finished_cancel (kat); + TEH_kyc_run_measure_cancel (kat); GNUNET_async_scope_restore (&old_scope); } @@ -183,7 +176,7 @@ fallback_result_cb (void *cls, /** * Type of a callback that receives a JSON @a result. * - * @param cls closure of type `struct TEH_KycAmlTrigger *` + * @param cls closure of type `struct TEH_KycMeasureRunContext *` * @param apr AML program result */ static void @@ -191,10 +184,10 @@ kyc_aml_finished ( void *cls, const struct TALER_KYCLOGIC_AmlProgramResult *apr) { - struct TEH_KycAmlTrigger *kat = cls; + struct TEH_KycMeasureRunContext *kat = cls; enum GNUNET_DB_QueryStatus qs; - size_t eas; - void *ea; + size_t eas = 0; + void *ea = NULL; unsigned int birthday = 0; struct GNUNET_AsyncScopeSave old_scope; @@ -215,11 +208,9 @@ kyc_aml_finished ( /* double-bad: error during error handling */ GNUNET_break (0); kat->cb (kat->cb_cls, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_MHD_make_error ( - TALER_EC_GENERIC_DB_STORE_FAILED, - "insert_kyc_failure")); - TEH_kyc_finished_cancel (kat); + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_kyc_failure"); + TEH_kyc_run_measure_cancel (kat); GNUNET_async_scope_restore (&old_scope); return; } @@ -228,11 +219,9 @@ kyc_aml_finished ( /* Not sure this can happen (fallback required?), but report AML program failure to client */ kat->cb (kat->cb_cls, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_MHD_make_error ( - TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, - NULL)); - TEH_kyc_finished_cancel (kat); + TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, + NULL); + TEH_kyc_run_measure_cancel (kat); GNUNET_async_scope_restore (&old_scope); return; } @@ -254,11 +243,9 @@ kyc_aml_finished ( { GNUNET_break (0); kat->cb (kat->cb_cls, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_MHD_make_error ( - TALER_EC_EXCHANGE_GENERIC_KYC_FALLBACK_UNKNOWN, - kat->fallback_name)); - TEH_kyc_finished_cancel (kat); + TALER_EC_EXCHANGE_GENERIC_KYC_FALLBACK_UNKNOWN, + kat->fallback_name); + TEH_kyc_run_measure_cancel (kat); GNUNET_async_scope_restore (&old_scope); return; } @@ -285,22 +272,23 @@ kyc_aml_finished ( GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to parse birthdate `%s' from KYC attributes\n", birthdate); - if (NULL != kat->response) - MHD_destroy_response (kat->response); - kat->http_status = MHD_HTTP_BAD_REQUEST; - kat->response = TALER_MHD_make_error ( - TALER_EC_GENERIC_PARAMETER_MALFORMED, - TALER_ATTRIBUTE_BIRTHDATE); - goto RETURN_RESULT; + kat->cb (kat->cb_cls, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "TALER_ATTRIBUTE_BIRTHDATE"); + goto done; } } } - TALER_CRYPTO_kyc_attributes_encrypt (&TEH_attribute_key, - kat->attributes, - &ea, - &eas); - qs = TEH_plugin->insert_kyc_attributes ( + if (NULL != kat->attributes) + { + TALER_CRYPTO_kyc_attributes_encrypt (&TEH_attribute_key, + kat->attributes, + &ea, + &eas); + } + + qs = TEH_plugin->insert_kyc_measure_result ( TEH_plugin->cls, kat->process_row, &kat->account_id, @@ -322,26 +310,23 @@ kyc_aml_finished ( "Stored encrypted KYC process #%llu attributes: %d\n", (unsigned long long) kat->process_row, qs); - if (qs <= 0) + if (qs < 0) { GNUNET_break (0); - if (NULL != kat->response) - MHD_destroy_response (kat->response); - kat->http_status - = MHD_HTTP_INTERNAL_SERVER_ERROR; - kat->response - = TALER_MHD_make_error ( - TALER_EC_GENERIC_DB_STORE_FAILED, - "do_insert_kyc_attributes"); - /* Continued below to return the response */ + kat->cb (kat->cb_cls, + TALER_EC_GENERIC_DB_STORE_FAILED, + "do_insert_kyc_measure_result"); + /* Continued below to clean up. */ } -RETURN_RESULT: - /* Finally, return result to main handler */ - kat->cb (kat->cb_cls, - kat->http_status, - kat->response); - kat->response = NULL; - TEH_kyc_finished_cancel (kat); + else + { + /* Finally, return result to main handler */ + kat->cb (kat->cb_cls, + TALER_EC_NONE, + 0); + } +done: + TEH_kyc_run_measure_cancel (kat); GNUNET_async_scope_restore (&old_scope); } @@ -477,57 +462,60 @@ add_kyc_history_entry ( } -/** - * We have finished a KYC process and obtained new - * @a attributes for a given @a account_id. - * Check with the KYC-AML trigger to see if we need - * to initiate an AML process, and store the attributes - * in the database. Then call @a cb. - * - * @param scope the HTTP request logging scope - * @param process_row legitimization process the data provided is about, - * or must be 0 if instant_ms is given - * @param instant_ms instant measure to run, used if @a process_row is 0, - * otherwise must be NULL - * @param account_id account the webhook was about - * @param provider_name name of the provider with the logic that was run - * @param provider_user_id set to user ID at the provider, or - * NULL if not supported or unknown - * @param provider_legitimization_id set to legitimization process ID at the provider, - * or NULL if not supported or unknown - * @param expiration until when is the KYC check valid - * @param attributes user attributes returned by the provider - * @param http_status HTTP status code of @a response - * @param[in] response to return to the HTTP client, can be NULL - * @param cb function to call with the result - * @param cb_cls closure for @a cb - * @return handle to cancel the operation - */ -static struct TEH_KycAmlTrigger * -TEH_kyc_finished2 ( +void +TEH_kyc_run_measure_cancel (struct TEH_KycMeasureRunContext *kat) +{ + if (NULL != kat->kyc_aml) + { + TALER_KYCLOGIC_run_aml_program_cancel (kat->kyc_aml); + kat->kyc_aml = NULL; + } + if (NULL != kat->fb) + { + TEH_kyc_fallback_cancel (kat->fb); + kat->fb = NULL; + } + if (NULL != kat->async_task) + { + GNUNET_SCHEDULER_cancel (kat->async_task); + kat->async_task = NULL; + } + GNUNET_free (kat->provider_name); + GNUNET_free (kat->provider_user_id); + GNUNET_free (kat->provider_legitimization_id); + GNUNET_free (kat->fallback_name); + json_decref (kat->jmeasures); + json_decref (kat->attributes); + json_decref (kat->aml_history); + json_decref (kat->kyc_history); + GNUNET_free (kat); +} + + +struct TEH_KycMeasureRunContext * +TEH_kyc_run_measure_for_attributes ( const struct GNUNET_AsyncScopeId *scope, uint64_t process_row, - const struct TALER_KYCLOGIC_Measure *instant_ms, - const struct TALER_PaytoHashP *account_id, - const char *provider_name, + const struct TALER_NormalizedPaytoHashP *account_id, const char *provider_user_id, const char *provider_legitimization_id, struct GNUNET_TIME_Absolute expiration, - const json_t *attributes, - unsigned int http_status, - struct MHD_Response *response, - TEH_KycAmlTriggerCallback cb, + const json_t *new_attributes, + TEH_KycMeasureRunContextCallback cb, void *cb_cls) { - struct TEH_KycAmlTrigger *kat; + /* FIXME(fdold, 2024-11-07): + Consider storing the attributes *before* we run the AMP. + Also, we're only passing *new* attributes here, but the AMP + should receive *all* attributes. */ + + struct TEH_KycMeasureRunContext *kat; enum GNUNET_DB_QueryStatus qs; - kat = GNUNET_new (struct TEH_KycAmlTrigger); + kat = GNUNET_new (struct TEH_KycMeasureRunContext); kat->scope = *scope; kat->process_row = process_row; kat->account_id = *account_id; - kat->provider_name - = GNUNET_strdup (provider_name); if (NULL != provider_user_id) kat->provider_user_id = GNUNET_strdup (provider_user_id); @@ -535,35 +523,33 @@ TEH_kyc_finished2 ( kat->provider_legitimization_id = GNUNET_strdup (provider_legitimization_id); kat->expiration = expiration; - kat->attributes = json_incref ((json_t*) attributes); - kat->http_status = http_status; - kat->response = response; kat->cb = cb; kat->cb_cls = cb_cls; - if (NULL == instant_ms) - { - qs = TEH_plugin->lookup_active_legitimization ( - TEH_plugin->cls, - process_row, - &kat->measure_index, - &kat->jmeasures); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - TEH_kyc_finished_cancel (kat); - return NULL; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - GNUNET_break (0); - TEH_kyc_finished_cancel (kat); - return NULL; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - break; - } - } kat->aml_history = json_array (); kat->kyc_history = json_array (); + kat->attributes = json_incref ((json_t*) new_attributes); + + qs = TEH_plugin->lookup_active_legitimization ( + TEH_plugin->cls, + process_row, + &kat->measure_index, + &kat->provider_name, + &kat->jmeasures); + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + TEH_kyc_run_measure_cancel (kat); + return NULL; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + GNUNET_break (0); + TEH_kyc_run_measure_cancel (kat); + return NULL; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + break; + } + qs = TEH_plugin->lookup_aml_history ( TEH_plugin->cls, account_id, @@ -574,7 +560,7 @@ TEH_kyc_finished2 ( case GNUNET_DB_STATUS_HARD_ERROR: case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); - TEH_kyc_finished_cancel (kat); + TEH_kyc_run_measure_cancel (kat); return NULL; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: /* empty history is fine! */ @@ -592,7 +578,7 @@ TEH_kyc_finished2 ( case GNUNET_DB_STATUS_HARD_ERROR: case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); - TEH_kyc_finished_cancel (kat); + TEH_kyc_run_measure_cancel (kat); return NULL; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: /* empty history is fine! */ @@ -600,97 +586,189 @@ TEH_kyc_finished2 ( case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: break; } - if (NULL == instant_ms) - { - kat->kyc_aml - = TALER_KYCLOGIC_run_aml_program ( - kat->attributes, - kat->aml_history, - kat->kyc_history, - kat->jmeasures, - kat->measure_index, - &kyc_aml_finished, - kat); - } - else - { - kat->kyc_aml - = TALER_KYCLOGIC_run_aml_program3 ( - instant_ms, - kat->attributes, - kat->aml_history, - kat->kyc_history, - &kyc_aml_finished, - kat); - } + + kat->kyc_aml + = TALER_KYCLOGIC_run_aml_program ( + kat->attributes, + kat->aml_history, + kat->kyc_history, + kat->jmeasures, + kat->measure_index, + &kyc_aml_finished, + kat); + if (NULL == kat->kyc_aml) { GNUNET_break (0); - TEH_kyc_finished_cancel (kat); + TEH_kyc_run_measure_cancel (kat); return NULL; } return kat; } -struct TEH_KycAmlTrigger * -TEH_kyc_finished ( - const struct GNUNET_AsyncScopeId *scope, - uint64_t process_row, - const struct TALER_PaytoHashP *account_id, - const char *provider_name, - const char *provider_user_id, - const char *provider_legitimization_id, - struct GNUNET_TIME_Absolute expiration, - const json_t *attributes, - unsigned int http_status, - struct MHD_Response *response, - TEH_KycAmlTriggerCallback cb, - void *cb_cls) +/** + * Helper task that asynchronously calls the result + * callback and then cleans up. + * + * @param[in] cls a `struct TEH_LegitimizationCheckHandle *` + */ +static void +async_return_measure_result (void *cls) { - return TEH_kyc_finished2 (scope, - process_row, - NULL, - account_id, - provider_name, - provider_user_id, - provider_legitimization_id, - expiration, - attributes, - http_status, - response, - cb, - cb_cls); + struct TEH_KycMeasureRunContext *kat = cls; + + kat->async_task = NULL; + kat->cb (kat->cb_cls, + TALER_EC_NONE, + NULL); + TEH_kyc_run_measure_cancel (kat); } -void -TEH_kyc_finished_cancel (struct TEH_KycAmlTrigger *kat) +struct TEH_KycMeasureRunContext * +TEH_kyc_run_measure_directly ( + const struct GNUNET_AsyncScopeId *scope, + const struct TALER_KYCLOGIC_Measure *instant_ms, + const struct TALER_NormalizedPaytoHashP *account_id, + TEH_KycMeasureRunContextCallback cb, + void *cb_cls) { - if (NULL != kat->kyc_aml) + struct TEH_KycMeasureRunContext *kat; + uint64_t legi_measure_serial_id; + bool bad_kyc_auth; + enum GNUNET_DB_QueryStatus qs; + struct TALER_FullPayto null_account = { + .full_payto = NULL + }; + + kat = GNUNET_new (struct TEH_KycMeasureRunContext); + + kat->jmeasures = TALER_KYCLOGIC_measure_to_jmeasures (instant_ms); + kat->provider_name = GNUNET_strdup ("SKIP"); + kat->measure_index = 0; + kat->scope = *scope; + kat->account_id = *account_id; + kat->expiration = GNUNET_TIME_UNIT_FOREVER_ABS; + kat->cb = cb; + kat->cb_cls = cb_cls; + + GNUNET_assert (NULL != kat->jmeasures); + + qs = TEH_plugin->trigger_kyc_rule_for_account ( + TEH_plugin->cls, + null_account, + account_id, + NULL, + NULL, + kat->jmeasures, + 0, /* no particular priority */ + &legi_measure_serial_id, + &bad_kyc_auth); + switch (qs) { - TALER_KYCLOGIC_run_aml_program_cancel (kat->kyc_aml); - kat->kyc_aml = NULL; + case GNUNET_DB_STATUS_HARD_ERROR: + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + TEH_kyc_run_measure_cancel (kat); + return NULL; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + GNUNET_break (0); + TEH_kyc_run_measure_cancel (kat); + return NULL; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + break; } - if (NULL != kat->fb) + + if (0 != strcasecmp (instant_ms->check_name, "SKIP")) { - TEH_kyc_fallback_cancel (kat->fb); - kat->fb = NULL; + /* Not an instant measure, it's enough to trigger it. + The AMP will be run later. */ + kat->async_task + = GNUNET_SCHEDULER_add_now ( + &async_return_measure_result, + kat); + return kat; } - GNUNET_free (kat->provider_name); - GNUNET_free (kat->provider_user_id); - GNUNET_free (kat->provider_legitimization_id); - GNUNET_free (kat->fallback_name); - json_decref (kat->jmeasures); - json_decref (kat->attributes); - json_decref (kat->aml_history); - json_decref (kat->kyc_history); - if (NULL != kat->response) + + qs = TEH_plugin->insert_kyc_requirement_process ( + TEH_plugin->cls, + account_id, + 0, /* measure index */ + legi_measure_serial_id, + "SKIP", + NULL, /* provider_account_id */ + NULL, /* provider_legitimziation_id */ + &kat->process_row); + if (qs < 0) + { + GNUNET_break (0); + TEH_kyc_run_measure_cancel (kat); + return NULL; + } + + kat->aml_history = json_array (); + kat->kyc_history = json_array (); + qs = TEH_plugin->lookup_aml_history ( + TEH_plugin->cls, + account_id, + &add_aml_history_entry, + kat->aml_history); + switch (qs) { - MHD_destroy_response (kat->response); - kat->response = NULL; + case GNUNET_DB_STATUS_HARD_ERROR: + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + TEH_kyc_run_measure_cancel (kat); + return NULL; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + /* empty history is fine! */ + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + break; } - GNUNET_free (kat); + qs = TEH_plugin->lookup_kyc_history ( + TEH_plugin->cls, + account_id, + &add_kyc_history_entry, + kat->kyc_history); + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + TEH_kyc_run_measure_cancel (kat); + return NULL; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + /* empty history is fine! */ + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + break; + } + { + json_t *empty_attributes = json_object (); + + /* Attributes are in the aml_history. + No new attributes from instant measure. */ + + kat->kyc_aml + = TALER_KYCLOGIC_run_aml_program3 ( + instant_ms, + empty_attributes, + kat->aml_history, + kat->kyc_history, + &kyc_aml_finished, + kat); + + json_decref (empty_attributes); + } + if (NULL == kat->kyc_aml) + { + GNUNET_break (0); + TEH_kyc_run_measure_cancel (kat); + return NULL; + } + return kat; } @@ -705,7 +783,7 @@ struct TEH_KycAmlFallback /** * Account this is for. */ - struct TALER_PaytoHashP account_id; + struct TALER_NormalizedPaytoHashP account_id; /** * Function to call when done. @@ -757,8 +835,6 @@ handle_aml_fallback_result ( const struct TALER_KYCLOGIC_AmlProgramResult *apr) { struct TEH_KycAmlFallback *fb = cls; - size_t eas; - void *ea; enum GNUNET_DB_QueryStatus qs; struct GNUNET_AsyncScopeSave old_scope; @@ -776,7 +852,7 @@ handle_aml_fallback_result ( apr->details.failure.error_message, apr->details.failure.ec)) { - /* tripple-bad: error during error handling of fallback */ + /* triple-bad: error during error handling of fallback */ GNUNET_break (0); fb->cb (fb->cb_cls, false, @@ -795,19 +871,7 @@ handle_aml_fallback_result ( return; } - { - json_t *attributes; - - /* empty attributes for fallback */ - attributes = json_object (); - GNUNET_assert (NULL != attributes); - TALER_CRYPTO_kyc_attributes_encrypt (&TEH_attribute_key, - attributes, - &ea, - &eas); - json_decref (attributes); - } - qs = TEH_plugin->insert_kyc_attributes ( + qs = TEH_plugin->insert_kyc_measure_result ( TEH_plugin->cls, fb->orig_requirement_row, &fb->account_id, @@ -822,9 +886,8 @@ handle_aml_fallback_result ( apr->details.success.to_investigate, apr->details.success.num_events, apr->details.success.events, - eas, - ea); - GNUNET_free (ea); + 0 /* enc attr size */, + NULL /* enc attr */); if (qs <= 0) { GNUNET_break (0); @@ -870,7 +933,7 @@ return_fallback_result (void *cls) struct TEH_KycAmlFallback* TEH_kyc_fallback ( const struct GNUNET_AsyncScopeId *scope, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t orig_requirement_row, const json_t *attributes, const json_t *aml_history, @@ -923,11 +986,14 @@ TEH_kyc_fallback ( json_t *jmeasures; enum GNUNET_DB_QueryStatus qs; bool bad_kyc_auth; + struct TALER_FullPayto null_account = { + .full_payto = NULL + }; - jmeasures = TALER_KYCLOGIC_check_to_measures (&kcc); + jmeasures = TALER_KYCLOGIC_check_to_jmeasures (&kcc); qs = TEH_plugin->trigger_kyc_rule_for_account ( TEH_plugin->cls, - NULL, /* account_id is already in wire targets */ + null_account, /* account_id is already in wire targets */ account_id, NULL, /* account_pub */ NULL, /* merchant_pub */ @@ -965,7 +1031,7 @@ TEH_kyc_fallback_cancel ( bool TEH_kyc_failed ( uint64_t process_row, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, const char *provider_name, const char *provider_user_id, const char *provider_legitimization_id, @@ -1012,12 +1078,12 @@ struct TEH_LegitimizationCheckHandle /** * Handle to asynchronously running instant measure. */ - struct TEH_KycAmlTrigger *kat; + struct TEH_KycMeasureRunContext *kat; /** * Payto-URI of the account. */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Amount iterator to call to check for amounts. @@ -1030,24 +1096,21 @@ struct TEH_LegitimizationCheckHandle void *ai_cls; /** - * Used to keep around the name of the AML program - * that we are running via @e aprh. - */ - char *aml_program; - - /** * Handle to AML program we are running, or NULL for none. */ - struct TALER_KYCLOGIC_AmlProgramRunnerHandle *aprh; + struct TEH_KycMeasureRunContext *measure_run_ctx; /** * Hash of @e payto_uri. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** - * Public key of the account. Associates this public - * key with the account if @e have_account_pub is true. + * Public key of the account. We should associate this public + * key with the account if @e have_account_pub is true. Do not + * confuse with @e lcr.kyc.have_account_pub which refers to us + * already having an @e lcr.kyc.account_pub in the database for + * the given @e h_payto. */ union TALER_AccountPublicKeyP account_pub; @@ -1091,12 +1154,6 @@ struct TEH_LegitimizationCheckHandle */ bool have_merchant_pub; - /** - * True if @a have_merchant_pub is true but the given - * merchant pub did not match the target_pub for the - * given @a h_payto. - */ - bool bad_kyc_auth; }; @@ -1163,22 +1220,24 @@ legitimization_check_run ( * Function called after the KYC-AML trigger is done. * * @param cls must be a `struct TEH_LegitimizationCheckHandle *` - * @param http_status final HTTP status to return - * @param[in] response final HTTP ro return + * @param ec error code or 0 on success + * @param detail error message or NULL on success / no info */ static void legi_check_aml_trigger_cb ( void *cls, - unsigned int http_status, - struct MHD_Response *response) + enum TALER_ErrorCode ec, + const char *detail) { struct TEH_LegitimizationCheckHandle *lch = cls; lch->kat = NULL; - if (NULL != response) + if (TALER_EC_NONE != ec) { - lch->lcr.http_status = http_status; - lch->lcr.response = response; + lch->lcr.http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; + lch->lcr.response = TALER_MHD_make_error ( + ec, + detail); lch->async_task = GNUNET_SCHEDULER_add_now ( &async_return_legi_result, @@ -1219,8 +1278,8 @@ static struct TEH_LegitimizationCheckHandle * setup_legitimization_check ( const struct GNUNET_AsyncScopeId *scope, enum TALER_KYCLOGIC_KycTriggerEvent et, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPublicKeyP *account_pub, TALER_KYCLOGIC_KycAmountIterator ai, void *ai_cls, @@ -1229,10 +1288,22 @@ setup_legitimization_check ( { struct TEH_LegitimizationCheckHandle *lch; +#if EXTRA_CHECK + { + struct TALER_NormalizedPaytoHashP npt; + + TALER_full_payto_normalize_and_hash (payto_uri, + &npt); + GNUNET_assert (0 == + GNUNET_memcmp (&npt, + h_payto)); + } +#endif lch = GNUNET_new (struct TEH_LegitimizationCheckHandle); lch->scope = *scope; lch->et = et; - lch->payto_uri = GNUNET_strdup (payto_uri); + lch->payto_uri.full_payto + = GNUNET_strdup (payto_uri.full_payto); lch->h_payto = *h_payto; if (NULL != account_pub) { @@ -1251,8 +1322,8 @@ struct TEH_LegitimizationCheckHandle * TEH_legitimization_check ( const struct GNUNET_AsyncScopeId *scope, enum TALER_KYCLOGIC_KycTriggerEvent et, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPublicKeyP *account_pub, TALER_KYCLOGIC_KycAmountIterator ai, void *ai_cls, @@ -1279,8 +1350,8 @@ struct TEH_LegitimizationCheckHandle * TEH_legitimization_check2 ( const struct GNUNET_AsyncScopeId *scope, enum TALER_KYCLOGIC_KycTriggerEvent et, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, const struct TALER_MerchantPublicKeyP *merchant_pub, TALER_KYCLOGIC_KycAmountIterator ai, void *ai_cls, @@ -1306,233 +1377,6 @@ TEH_legitimization_check2 ( /** - * Type of function called after AML program was run. - * - * @param cls closure - * @param apr result of the AML program. - */ -static void -legi_check_aml_program_cb ( - void *cls, - const struct TALER_KYCLOGIC_AmlProgramResult *apr) -{ - struct TEH_LegitimizationCheckHandle *lch = cls; - - lch->aprh = NULL; - switch (apr->status) - { - case TALER_KYCLOGIC_AMLR_SUCCESS: - { - enum GNUNET_DB_QueryStatus qs; - struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs; - struct GNUNET_TIME_Timestamp expiration_time; - - /* persist outcome of AML program */ - lrs = TALER_KYCLOGIC_rules_parse ( - apr->details.success.new_rules); - if (NULL == lrs) - { - GNUNET_break (0); - legi_fail ( - lch, - TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, - lch->aml_program); - return; - } - expiration_time - = TALER_KYCLOGIC_rules_get_expiration (lrs); - TALER_KYCLOGIC_rules_free (lrs); - qs = TEH_plugin->insert_programmatic_legitimization_outcome ( - TEH_plugin->cls, - &lch->h_payto, - GNUNET_TIME_timestamp_get (), - expiration_time.abs_time, - apr->details.success.account_properties, - apr->details.success.to_investigate, - apr->details.success.new_rules, - apr->details.success.num_events, - apr->details.success.events); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - legi_fail (lch, - TALER_EC_GENERIC_DB_STORE_FAILED, - "insert_programmatic_aml_decision"); - return; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - GNUNET_break (0); - legi_fail (lch, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "insert_programmatic_aml_decision"); - return; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - break; - } - /* Now run with new_rules! */ - GNUNET_free (lch->aml_program); - legitimization_check_run (lch); - return; - } - case TALER_KYCLOGIC_AMLR_FAILURE: - GNUNET_break (0); - legi_fail (lch, - TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, - lch->aml_program); - return; - } - GNUNET_break (0); -} - - -/** - * We need to run the check from @a kcc for @a lch. - * - * @param lch legitimization process handle - * @param kcc check to trigger - */ -static void -run_check ( - struct TEH_LegitimizationCheckHandle *lch, - const struct TALER_KYCLOGIC_KycCheckContext *kcc) -{ - json_t *jmeasures; - - jmeasures - = TALER_KYCLOGIC_check_to_measures (kcc); - if (NULL == kcc->check) - { - /* check was skip; directly run AML program */ - enum GNUNET_DB_QueryStatus qs; - json_t *attributes; - json_t *aml_history; - json_t *kyc_history; - - aml_history = json_array (); - kyc_history = json_array (); - qs = TEH_plugin->lookup_aml_history ( - TEH_plugin->cls, - &lch->h_payto, - &add_aml_history_entry, - aml_history); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - json_decref (aml_history); - json_decref (kyc_history); - legi_fail (lch, - TALER_EC_GENERIC_DB_FETCH_FAILED, - "lookup_aml_history"); - return; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - /* empty history is fine! */ - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - break; - } - qs = TEH_plugin->lookup_kyc_history ( - TEH_plugin->cls, - &lch->h_payto, - &add_kyc_history_entry, - kyc_history); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - json_decref (aml_history); - json_decref (kyc_history); - legi_fail (lch, - TALER_EC_GENERIC_DB_FETCH_FAILED, - "lookup_kyc_history"); - return; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - /* empty history is fine! */ - break; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - break; - } - - attributes - = json_object (); /* instant: empty attributes */ - GNUNET_assert (NULL != attributes); - lch->aml_program - = GNUNET_strdup (kcc->prog_name); - lch->aprh - = TALER_KYCLOGIC_run_aml_program ( - attributes, - aml_history, - kyc_history, - jmeasures, - 0, /* measure index */ - &legi_check_aml_program_cb, - lch); - json_decref (aml_history); - json_decref (kyc_history); - json_decref (attributes); - if (NULL == lch->aprh) - { - GNUNET_break (0); - legi_fail (lch, - TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, - NULL); - goto cleanup; - } - } - else - { - enum GNUNET_DB_QueryStatus qs; - - /* require kcc.check! */ - qs = TEH_plugin->trigger_kyc_rule_for_account ( - TEH_plugin->cls, - lch->payto_uri, - &lch->h_payto, - lch->have_account_pub ? &lch->account_pub : NULL, - lch->have_merchant_pub ? &lch->merchant_pub : NULL, - jmeasures, - 0, /* no particular priority */ - &lch->lcr.kyc.requirement_row, - &lch->lcr.bad_kyc_auth); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - legi_fail (lch, - TALER_EC_GENERIC_DB_STORE_FAILED, - "trigger_kyc_rule_for_account"); - goto cleanup; - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - GNUNET_break (0); - legi_fail (lch, - TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, - "trigger_kyc_rule_for_account"); - goto cleanup; - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - break; - } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "trigger_kyc_rule_for_account on %d/%d returned %llu/%d\n", - lch->have_account_pub, - lch->have_merchant_pub, - (unsigned long long) lch->lcr.kyc.requirement_row, - lch->lcr.bad_kyc_auth); - /* return success! */ - lch->async_task - = GNUNET_SCHEDULER_add_now ( - &async_return_legi_result, - lch); - } -cleanup: - json_decref (jmeasures); -} - - -/** * The KYC check failed because KYC auth is required * to match and it does not. * @@ -1589,14 +1433,13 @@ amount_iterator_wrapper_cb ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC: Checking amounts until %s\n", GNUNET_TIME_absolute2s (limit)); - if (lch->bad_kyc_auth) + if (lch->lcr.bad_kyc_auth) { /* We *do* have applicable KYC rules *and* the target_pub does not match the merchant_pub, so we indeed have a problem! */ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC: Mismatch between merchant_pub and target_pub is relevant!\n"); - lch->lcr.bad_kyc_auth = true; } return lch->ai (lch->ai_cls, limit, @@ -1663,6 +1506,12 @@ legitimization_check_run ( case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: break; } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "get_kyc_rules returned %d/%d/%d/%d\n", + (int) qs, + ! no_account_pub, + ! no_reserve_pub, + NULL != jrules); lch->lcr.kyc.have_account_pub = ! no_account_pub; @@ -1683,10 +1532,11 @@ legitimization_check_run ( /* We do not have custom rules, defer enforcing merchant_pub match until we actually have deposit constraints */ GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC: merchant_pub given but no known target_pub(%d)/reserve_pub(%d) match!\n", + "KYC: merchant_pub given but no known target_pub(%d)/reserve_pub(%d) match (%d)!\n", lch->lcr.kyc.have_account_pub, - lch->lcr.have_reserve_pub); - lch->bad_kyc_auth = true; + lch->lcr.have_reserve_pub, + (int) qs); + lch->lcr.bad_kyc_auth = true; } else { @@ -1697,20 +1547,31 @@ legitimization_check_run ( "KYC: merchant_pub does not match target_pub of custom rules!\n"); json_decref (jrules); fail_kyc_auth (lch); - return; + goto cleanup; } } /* parse and free jrules (if we had any) */ if (NULL != jrules) { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "KYC: have custom KYC rules for this account!\n"); lrs = TALER_KYCLOGIC_rules_parse (jrules); GNUNET_break (NULL != lrs); /* Fall back to default rules on parse error! */ json_decref (jrules); } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "KYC: default KYC rules apply to this account!\n"); + } } + /* FIXME(fdold, 2024-11-08): We are doing the same logic + here and in kyc-info, abstract it out? */ + + /* Check if ruleset is expired and we need to run the successor measure */ if (NULL != lrs) { struct GNUNET_TIME_Timestamp ts; @@ -1718,27 +1579,78 @@ legitimization_check_run ( ts = TALER_KYCLOGIC_rules_get_expiration (lrs); if (GNUNET_TIME_absolute_is_past (ts.abs_time)) { - const char *successor; - struct TALER_KYCLOGIC_KycCheckContext kcc; - - successor - = TALER_KYCLOGIC_rules_get_successor (lrs); - if (GNUNET_OK != - TALER_KYCLOGIC_requirements_to_check (lrs, - NULL, - successor, - &kcc)) + const struct TALER_KYCLOGIC_Measure *successor_measure; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Current KYC ruleset expired, running successor measure.\n"); + + successor_measure = TALER_KYCLOGIC_rules_get_successor (lrs); + if (NULL == successor_measure) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successor measure `%s' unknown, falling back to default rules!\n", - successor); + successor_measure->measure_name); TALER_KYCLOGIC_rules_free (lrs); lrs = NULL; } + else if (0 == strcmp (successor_measure->prog_name, "SKIP")) + { + lch->measure_run_ctx = TEH_kyc_run_measure_directly ( + &lch->scope, + successor_measure, + &lch->h_payto, + &legi_check_aml_trigger_cb, + lch); + if (NULL == lch->measure_run_ctx) + { + legi_fail (lch, + TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, + "successor measure"); + } + goto cleanup; + } else { - run_check (lch, - &kcc); + bool unknown_account; + struct GNUNET_TIME_Timestamp decision_time + = GNUNET_TIME_timestamp_get (); + struct GNUNET_TIME_Timestamp last_date; + json_t *succ_jmeasures = TALER_KYCLOGIC_get_jmeasures ( + lrs, + successor_measure->measure_name); + + GNUNET_assert (NULL != succ_jmeasures); + qs = TEH_plugin->insert_successor_measure ( + TEH_plugin->cls, + &lch->h_payto, + decision_time, + successor_measure->measure_name, + succ_jmeasures, + &unknown_account, + &last_date); + json_decref (succ_jmeasures); + if (qs <= 0) + { + legi_fail (lch, + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_successor_measure"); + goto cleanup; + } + if (unknown_account) + { + legi_fail (lch, + TALER_EC_EXCHANGE_GENERIC_BANK_ACCOUNT_UNKNOWN, + NULL); + goto cleanup; + } + /* We tolerate conflicting decision times for automatic decisions. */ + GNUNET_break ( + GNUNET_TIME_timestamp_cmp (last_date, + >=, + decision_time)); + /* Back to default rules. */ + TALER_KYCLOGIC_rules_free (lrs); + lrs = NULL; } } } @@ -1752,25 +1664,27 @@ legitimization_check_run ( &lch->lcr.next_threshold); if (qs < 0) { - TALER_KYCLOGIC_rules_free (lrs); + GNUNET_break (0); legi_fail (lch, TALER_EC_GENERIC_DB_FETCH_FAILED, "kyc_test_required"); - GNUNET_async_scope_restore (&old_scope); - return; + goto cleanup; } if (lch->lcr.bad_kyc_auth) { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "KYC auth required\n"); fail_kyc_auth (lch); - return; + goto cleanup; } if (NULL == requirement) { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "KYC check passed\n"); lch->lcr.kyc.ok = true; lch->lcr.expiration_date = TALER_KYCLOGIC_rules_get_expiration (lrs); - TALER_KYCLOGIC_rules_free (lrs); memset (&lch->lcr.next_threshold, 0, sizeof (struct TALER_Amount)); @@ -1779,8 +1693,7 @@ legitimization_check_run ( = GNUNET_SCHEDULER_add_now ( &async_return_legi_result, lch); - GNUNET_async_scope_restore (&old_scope); - return; + goto cleanup; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1794,37 +1707,22 @@ legitimization_check_run ( /* We have an 'instant' measure which means we must run the AML program immediately instead of waiting for the account owner to select some measure and contribute their KYC data. */ - json_t *attributes - = json_object (); /* instant: empty attributes */ - GNUNET_assert (NULL != attributes); - lch->kat - = TEH_kyc_finished2 ( - &lch->scope, - 0LL, - instant_ms, - &lch->h_payto, - "SKIP", /* provider */ - NULL, - NULL, - GNUNET_TIME_UNIT_FOREVER_ABS, - attributes, - 0, /* http status */ - NULL, /* MHD_Response */ - &legi_check_aml_trigger_cb, - lch); - json_decref (attributes); + lch->kat = TEH_kyc_run_measure_directly ( + &lch->scope, + instant_ms, + &lch->h_payto, + &legi_check_aml_trigger_cb, + lch + ); if (NULL == lch->kat) { GNUNET_break (0); legi_fail (lch, TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, NULL); - GNUNET_async_scope_restore (&old_scope); - return; } - GNUNET_async_scope_restore (&old_scope); - return; + goto cleanup; } /* No instant measure, store all measures in the database and @@ -1846,7 +1744,7 @@ legitimization_check_run ( &lch->lcr.kyc.requirement_row, &lch->lcr.bad_kyc_auth); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "trigger_kyc_rule_for_account on %d/%d returned %d/%llu/%d\n", + "trigger_kyc_rule_for_account-1 on %d/%d returned %d/%llu/%d\n", lch->have_account_pub, lch->have_merchant_pub, (int) qs, @@ -1860,24 +1758,23 @@ legitimization_check_run ( legi_fail (lch, TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, "trigger_kyc_rule_for_account"); - GNUNET_async_scope_restore (&old_scope); - return; + goto cleanup; } - TALER_KYCLOGIC_rules_free (lrs); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); legi_fail (lch, TALER_EC_GENERIC_DB_STORE_FAILED, "trigger_kyc_rule_for_account"); - GNUNET_async_scope_restore (&old_scope); - return; + goto cleanup; } /* return success! */ lch->async_task = GNUNET_SCHEDULER_add_now ( &async_return_legi_result, lch); +cleanup: + TALER_KYCLOGIC_rules_free (lrs); GNUNET_async_scope_restore (&old_scope); } @@ -1893,20 +1790,19 @@ TEH_legitimization_check_cancel ( } if (NULL != lch->kat) { - TEH_kyc_finished_cancel (lch->kat); + TEH_kyc_run_measure_cancel (lch->kat); lch->kat = NULL; } - if (NULL != lch->aprh) + if (NULL != lch->measure_run_ctx) { - TALER_KYCLOGIC_run_aml_program_cancel (lch->aprh); - lch->aprh = NULL; + TEH_kyc_run_measure_cancel (lch->measure_run_ctx); + lch->measure_run_ctx = NULL; } if (NULL != lch->lcr.response) { MHD_destroy_response (lch->lcr.response); lch->lcr.response = NULL; } - GNUNET_free (lch->payto_uri); - GNUNET_free (lch->aml_program); + GNUNET_free (lch->payto_uri.full_payto); GNUNET_free (lch); } diff --git a/src/exchange/taler-exchange-httpd_common_kyc.h b/src/exchange/taler-exchange-httpd_common_kyc.h index 57672d94e..77a80999a 100644 --- a/src/exchange/taler-exchange-httpd_common_kyc.h +++ b/src/exchange/taler-exchange-httpd_common_kyc.h @@ -31,70 +31,90 @@ /** - * Function called after the KYC-AML trigger is done. + * Function called after a measure has been run. * * @param cls closure - * @param http_status final HTTP status to return - * @param[in] response final HTTP ro return + * @param ec error code or 0 on success + * @param detail error message or NULL on success / no info */ typedef void -(*TEH_KycAmlTriggerCallback) ( +(*TEH_KycMeasureRunContextCallback) ( void *cls, - unsigned int http_status, - struct MHD_Response *response); + enum TALER_ErrorCode ec, + const char *detail); /** * Handle for an asynchronous operation to finish * a KYC process after running the AML trigger. */ -struct TEH_KycAmlTrigger; +struct TEH_KycMeasureRunContext; /** - * We have finished a KYC process and obtained new - * @a attributes for a given @a account_id. - * Check with the KYC-AML trigger to see if we need - * to initiate an AML process, and store the attributes - * in the database. Then call @a cb. + * Run measure after storing attributes from the given + * provider. + * + * Only works when a process is active. + * + * FIXME: Isn't the account_id redundant via the process_row? * * @param scope the HTTP request logging scope * @param process_row legitimization process the data provided is about - * @param account_id account the webhook was about - * @param provider_name name of the provider with the logic that was run + * @param account_id account the the data provided is about * @param provider_user_id set to user ID at the provider, or NULL if not supported or unknown * @param provider_legitimization_id set to legitimization process ID at the provider, or NULL if not supported or unknown * @param expiration until when is the KYC check valid - * @param attributes user attributes returned by the provider - * @param http_status HTTP status code of @a response - * @param[in] response to return to the HTTP client + * @param new_attributes user attributes returned by the provider * @param cb function to call with the result * @param cb_cls closure for @a cb * @return handle to cancel the operation */ -struct TEH_KycAmlTrigger * -TEH_kyc_finished ( +struct TEH_KycMeasureRunContext * +TEH_kyc_run_measure_for_attributes ( const struct GNUNET_AsyncScopeId *scope, uint64_t process_row, - const struct TALER_PaytoHashP *account_id, - const char *provider_name, + const struct TALER_NormalizedPaytoHashP *account_id, const char *provider_user_id, const char *provider_legitimization_id, struct GNUNET_TIME_Absolute expiration, - const json_t *attributes, - unsigned int http_status, - struct MHD_Response *response, - TEH_KycAmlTriggerCallback cb, + const json_t *new_attributes, + TEH_KycMeasureRunContextCallback cb, + void *cb_cls); + + +/** + * Run an measure directly. + * + * Inserts a legitimization process and measure + * into the database before running the measure program. + * + * After running the measure program, the result is stored + * in the DB. + * + * @param scope the HTTP request logging scope + * @param instant_measure instant measure to run + * @param account_id account affected by the measure + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return handle to cancel the operation + */ +struct TEH_KycMeasureRunContext * +TEH_kyc_run_measure_directly ( + const struct GNUNET_AsyncScopeId *scope, + const struct TALER_KYCLOGIC_Measure *instant_ms, + const struct TALER_NormalizedPaytoHashP *account_id, + TEH_KycMeasureRunContextCallback cb, void *cb_cls); /** - * Cancel KYC finish operation. + * Cancel running KYC measure. * * @param[in] kat operation to abort */ void -TEH_kyc_finished_cancel (struct TEH_KycAmlTrigger *kat); +TEH_kyc_run_measure_cancel (struct TEH_KycMeasureRunContext *kat); /** @@ -139,8 +159,7 @@ typedef void struct TEH_KycAmlFallback * TEH_kyc_fallback ( const struct GNUNET_AsyncScopeId *scope, - const struct TALER_PaytoHashP * - account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t orig_requirement_row, const json_t *attributes, const json_t *aml_history, @@ -176,7 +195,7 @@ TEH_kyc_fallback_cancel ( bool TEH_kyc_failed ( uint64_t process_row, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, const char *provider_name, const char *provider_user_id, const char *provider_legitimization_id, @@ -258,6 +277,9 @@ typedef void struct TEH_LegitimizationCheckHandle; +/* FIXME: add another variation of this API with a + NormalizedPayto payto_uri, as we currently 'fake' + a full payto in 3 places related to wallets! */ /** * Do legitimization check. * @@ -277,8 +299,8 @@ struct TEH_LegitimizationCheckHandle * TEH_legitimization_check ( const struct GNUNET_AsyncScopeId *scope, enum TALER_KYCLOGIC_KycTriggerEvent et, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPublicKeyP *account_pub, TALER_KYCLOGIC_KycAmountIterator ai, void *ai_cls, @@ -307,8 +329,8 @@ struct TEH_LegitimizationCheckHandle * TEH_legitimization_check2 ( const struct GNUNET_AsyncScopeId *scope, enum TALER_KYCLOGIC_KycTriggerEvent et, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, const struct TALER_MerchantPublicKeyP *merchant_pub, TALER_KYCLOGIC_KycAmountIterator ai, void *ai_cls, diff --git a/src/exchange/taler-exchange-httpd_config.h b/src/exchange/taler-exchange-httpd_config.h index 486a8b83b..e033ac29c 100644 --- a/src/exchange/taler-exchange-httpd_config.h +++ b/src/exchange/taler-exchange-httpd_config.h @@ -41,7 +41,7 @@ * * Returned via both /config and /keys endpoints. */ -#define EXCHANGE_PROTOCOL_VERSION "21:0:4" +#define EXCHANGE_PROTOCOL_VERSION "22:0:5" /** diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c index ab6798dc6..40e14e115 100644 --- a/src/exchange/taler-exchange-httpd_keys.c +++ b/src/exchange/taler-exchange-httpd_keys.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020-2023 Taler Systems SA + Copyright (C) 2020-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -41,8 +41,10 @@ /** * When do we forcefully timeout a /keys request? + * Matches the 120s hard-coded into exchange_api_handle.c */ -#define KEYS_TIMEOUT GNUNET_TIME_UNIT_MINUTES +#define KEYS_TIMEOUT \ + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) /** @@ -675,7 +677,7 @@ TEH_wire_done () */ static void add_wire_account (void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -702,8 +704,8 @@ add_wire_account (void *cls, json_array_append_new ( a, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("conversion_url", conversion_url)), diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c b/src/exchange/taler-exchange-httpd_kyc-check.c index 96b3d12f3..3bd8c1e65 100644 --- a/src/exchange/taler-exchange-httpd_kyc-check.c +++ b/src/exchange/taler-exchange-httpd_kyc-check.c @@ -63,7 +63,7 @@ struct KycPoller /** * Account for which we perform the KYC check. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * When will this request time out? @@ -220,7 +220,9 @@ TEH_handler_kyc_check ( TALER_EC_GENERIC_PATH_SEGMENT_MALFORMED, "h_payto"); } - + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Checking KYC status for normalized payto hash %s\n", + args[0]); TALER_MHD_parse_request_header_auto ( rc->connection, TALER_HTTP_HEADER_ACCOUNT_OWNER_SIGNATURE, diff --git a/src/exchange/taler-exchange-httpd_kyc-info.c b/src/exchange/taler-exchange-httpd_kyc-info.c index 1c7b31be0..ab0afe089 100644 --- a/src/exchange/taler-exchange-httpd_kyc-info.c +++ b/src/exchange/taler-exchange-httpd_kyc-info.c @@ -32,10 +32,13 @@ #include "taler-exchange-httpd_keys.h" #include "taler-exchange-httpd_kyc-info.h" #include "taler-exchange-httpd_responses.h" +#include "taler-exchange-httpd_common_kyc.h" /** - * Reserve GET request that is long-polling. + * Context for the GET /kyc-info request. + * + * Used for long-polling and other asynchronous waiting. */ struct KycPoller { @@ -86,13 +89,28 @@ struct KycPoller /** * Payto hash of the account matching @a access_token. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * True if we are still suspended. */ bool suspended; + /** + * Handle for async KYC processing. + */ + struct TEH_KycMeasureRunContext *kat; + + /** + * HTTP status code to use with @e response. + */ + unsigned int response_code; + + /** + * Response to return, NULL if none yet. + */ + struct MHD_Response *response; + }; @@ -146,6 +164,16 @@ kyp_cleanup (struct TEH_RequestContext *rc) kyp->eh); kyp->eh = NULL; } + if (NULL != kyp->response) + { + MHD_destroy_response (kyp->response); + kyp->response = NULL; + } + if (NULL != kyp->kat) + { + TEH_kyc_run_measure_cancel (kyp->kat); + kyp->kat = NULL; + } GNUNET_free (kyp); } @@ -211,7 +239,7 @@ add_response_headers (void *cls, * @param[in,out] kyp request to reply on * @param legitimization_measure_row_id part of etag to set for the response * @param legitimization_outcome_row_id part of etag to set for the response - * @param jmeasures measures to encode + * @param jmeasures a `LegitimizationMeasures` object to encode * @param jvoluntary array of voluntary measures to encode, can be NULL * @return MHD status code */ @@ -222,7 +250,7 @@ generate_reply (struct KycPoller *kyp, const json_t *jmeasures, const json_t *jvoluntary) { - const json_t *measures; + const json_t *measures; /* array of MeasureInformation */ bool is_and_combinator = false; bool verboten; struct GNUNET_JSON_Specification spec[] = { @@ -241,7 +269,7 @@ generate_reply (struct KycPoller *kyp, unsigned int eline; json_t *kris; size_t i; - json_t *mi; + json_t *mi; /* a MeasureInformation object */ ret = GNUNET_JSON_parse (jmeasures, spec, @@ -261,11 +289,16 @@ generate_reply (struct KycPoller *kyp, { const char *check_name; const char *prog_name; + const json_t *context = NULL; struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_string ("check_name", &check_name), GNUNET_JSON_spec_string ("prog_name", &prog_name), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_object_const ("context", + &context), + NULL), GNUNET_JSON_spec_end () }; json_t *kri; @@ -286,6 +319,7 @@ generate_reply (struct KycPoller *kyp, kri = TALER_KYCLOGIC_measure_to_requirement ( check_name, prog_name, + context, &kyp->access_token, i, legitimization_measure_row_id); @@ -338,6 +372,109 @@ generate_reply (struct KycPoller *kyp, } +/** + * Check if measures contain an instant + * measure. + * + * @param jmeasures measures JSON object + * @returns true if @a jmeasures contains an instant measure + */ +static bool +contains_instant_measure (const json_t *jmeasures) +{ + size_t i; + json_t *mi; /* a MeasureInformation object */ + const char *ename; + unsigned int eline; + enum GNUNET_GenericReturnValue ret; + const json_t *measures; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_array_const ("measures", + &measures), + GNUNET_JSON_spec_end () + }; + + ret = GNUNET_JSON_parse (jmeasures, + spec, + &ename, + &eline); + if (GNUNET_OK != ret) + { + GNUNET_break (0); + return false; + } + + json_array_foreach ((json_t *) measures, i, mi) + { + const char *check_name; + + struct GNUNET_JSON_Specification ispec[] = { + GNUNET_JSON_spec_string ("check_name", + &check_name), + GNUNET_JSON_spec_end () + }; + + ret = GNUNET_JSON_parse (mi, + ispec, + &ename, + &eline); + if (GNUNET_OK != ret) + { + GNUNET_break (0); + continue; + } + if (0 == strcasecmp (check_name, "SKIP")) + { + return true; + } + } + + return false; +} + + +/** + * Function called after a measure has been run. + * + * @param cls closure + * @param ec error code or 0 on success + * @param detail error message or NULL on success / no info + */ +static void +measure_run_cb ( + void *cls, + enum TALER_ErrorCode ec, + const char *detail) +{ + struct KycPoller *kyp = cls; + + GNUNET_assert (kyp->suspended); + GNUNET_assert (NULL == kyp->response); + GNUNET_assert (NULL != kyp->kat); + + kyp->kat = NULL; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Resuming after running successor measure, ec=%u\n", + (unsigned int) ec); + + if (TALER_EC_NONE != ec) + { + kyp->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; + kyp->response = TALER_MHD_make_error ( + ec, + detail); + } + + GNUNET_CONTAINER_DLL_remove (kyp_head, + kyp_tail, + kyp); + kyp->suspended = false; + MHD_resume_connection (kyp->connection); + TALER_MHD_daemon_trigger (); +} + + MHD_RESULT TEH_handler_kyc_info ( struct TEH_RequestContext *rc, @@ -350,8 +487,7 @@ TEH_handler_kyc_info ( uint64_t legitimization_outcome_last_row; json_t *jmeasures = NULL; json_t *jvoluntary = NULL; - json_t *jnew_rules; - struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs; + struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs = NULL; if (NULL == kyp) { @@ -368,11 +504,12 @@ TEH_handler_kyc_info ( sizeof (kyp->access_token))) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( + res = TALER_MHD_reply_with_error ( rc->connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, "access token"); + goto cleanup; } TALER_MHD_parse_request_timeout (rc->connection, &kyp->timeout); @@ -418,20 +555,21 @@ TEH_handler_kyc_info ( if (qs < 0) { GNUNET_break (0); - return TALER_MHD_reply_with_ec ( + res = TALER_MHD_reply_with_ec ( rc->connection, TALER_EC_GENERIC_DB_FETCH_FAILED, "lookup_h_payto_by_access_token"); + goto cleanup; } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { GNUNET_break_op (0); - return TALER_MHD_REPLY_JSON_PACK ( + res = TALER_MHD_REPLY_JSON_PACK ( rc->connection, MHD_HTTP_FORBIDDEN, TALER_JSON_pack_ec ( TALER_EC_EXCHANGE_KYC_INFO_AUTHORIZATION_FAILED)); - + goto cleanup; } if (GNUNET_TIME_absolute_is_future (kyp->timeout)) @@ -453,31 +591,146 @@ TEH_handler_kyc_info ( } } /* end of one-time initialization */ - qs = TEH_plugin->lookup_rules_by_access_token ( - TEH_plugin->cls, - &kyp->h_payto, - &jnew_rules, - &legitimization_outcome_last_row); - if (qs < 0) + if (NULL != kyp->response) { - GNUNET_break (0); - return TALER_MHD_reply_with_ec ( - rc->connection, - TALER_EC_GENERIC_DB_FETCH_FAILED, - "lookup_rules_by_access_token"); + res = MHD_queue_response (rc->connection, + kyp->response_code, + kyp->response); + goto cleanup; } - if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + + /* Get rules. */ { - /* Nothing was triggered, return the measures - that apply for any amount. */ - lrs = NULL; + json_t *jnew_rules; + qs = TEH_plugin->lookup_rules_by_access_token ( + TEH_plugin->cls, + &kyp->h_payto, + &jnew_rules, + &legitimization_outcome_last_row); + if (qs < 0) + { + GNUNET_break (0); + res = TALER_MHD_reply_with_ec ( + rc->connection, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "lookup_rules_by_access_token"); + goto cleanup; + } + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { + /* Nothing was triggered, return the measures + that apply for any amount. */ + lrs = NULL; + } + else + { + lrs = TALER_KYCLOGIC_rules_parse (jnew_rules); + GNUNET_break (NULL != lrs); + json_decref (jnew_rules); + } } - else + + /* Check if ruleset is expired and we need to run the successor measure */ + if (NULL != lrs) { - lrs = TALER_KYCLOGIC_rules_parse (jnew_rules); - GNUNET_break (NULL != lrs); - json_decref (jnew_rules); + struct GNUNET_TIME_Timestamp ts; + + ts = TALER_KYCLOGIC_rules_get_expiration (lrs); + if (GNUNET_TIME_absolute_is_past (ts.abs_time)) + { + const struct TALER_KYCLOGIC_Measure *successor_measure; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Current KYC ruleset expired, running successor measure.\n"); + + successor_measure = TALER_KYCLOGIC_rules_get_successor (lrs); + if (NULL == successor_measure) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Successor measure `%s' unknown, falling back to default rules!\n", + successor_measure->measure_name); + TALER_KYCLOGIC_rules_free (lrs); + lrs = NULL; + } + else if (0 == strcmp (successor_measure->prog_name, "SKIP")) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Running successor measure %s.\n", successor_measure-> + measure_name); + /* FIXME(fdold, 2024-01-08): Consider limiting how + often we try this, in case we run into expired rulesets + repeatedly. */ + kyp->kat = TEH_kyc_run_measure_directly ( + &rc->async_scope_id, + successor_measure, + &kyp->h_payto, + &measure_run_cb, + kyp); + if (NULL == kyp->kat) + { + GNUNET_break (0); + res = TALER_MHD_reply_with_ec ( + rc->connection, + TALER_EC_EXCHANGE_KYC_AML_PROGRAM_FAILURE, + "successor measure"); + } + kyp->suspended = true; + GNUNET_CONTAINER_DLL_insert (kyp_head, + kyp_tail, + kyp); + MHD_suspend_connection (rc->connection); + res = MHD_YES; + goto cleanup; + } + else + { + bool unknown_account; + struct GNUNET_TIME_Timestamp decision_time + = GNUNET_TIME_timestamp_get (); + struct GNUNET_TIME_Timestamp last_date; + json_t *succ_jmeasures = TALER_KYCLOGIC_get_jmeasures ( + lrs, + successor_measure->measure_name); + + GNUNET_assert (NULL != succ_jmeasures); + qs = TEH_plugin->insert_successor_measure ( + TEH_plugin->cls, + &kyp->h_payto, + decision_time, + successor_measure->measure_name, + succ_jmeasures, + &unknown_account, + &last_date); + json_decref (succ_jmeasures); + if (qs <= 0) + { + GNUNET_break (0); + res = TALER_MHD_reply_with_ec ( + rc->connection, + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_successor_measure"); + goto cleanup; + } + if (unknown_account) + { + res = TALER_MHD_reply_with_ec ( + rc->connection, + TALER_EC_EXCHANGE_GENERIC_BANK_ACCOUNT_UNKNOWN, + NULL); + goto cleanup; + } + /* We tolerate conflicting decision times for automatic decisions. */ + GNUNET_break ( + GNUNET_TIME_timestamp_cmp (last_date, + >=, + decision_time)); + /* Back to default rules. */ + TALER_KYCLOGIC_rules_free (lrs); + lrs = NULL; + } + } } + jvoluntary = TALER_KYCLOGIC_voluntary_measures (lrs); @@ -489,11 +742,11 @@ TEH_handler_kyc_info ( if (qs < 0) { GNUNET_break (0); - TALER_KYCLOGIC_rules_free (lrs); - return TALER_MHD_reply_with_ec ( + res = TALER_MHD_reply_with_ec ( rc->connection, TALER_EC_GENERIC_DB_FETCH_FAILED, "lookup_kyc_status_by_token"); + goto cleanup; } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { @@ -503,13 +756,13 @@ TEH_handler_kyc_info ( { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "No KYC requirement open\n"); - TALER_KYCLOGIC_rules_free (lrs); - return TALER_MHD_REPLY_JSON_PACK ( + res = TALER_MHD_REPLY_JSON_PACK ( rc->connection, MHD_HTTP_OK, GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_array_steal ("voluntary_measures", jvoluntary))); + goto cleanup; } qs = TEH_plugin->insert_active_legitimization_measure ( @@ -520,14 +773,13 @@ TEH_handler_kyc_info ( if (qs < 0) { GNUNET_break (0); - TALER_KYCLOGIC_rules_free (lrs); - return TALER_MHD_reply_with_ec ( + res = TALER_MHD_reply_with_ec ( rc->connection, TALER_EC_GENERIC_DB_STORE_FAILED, "insert_active_legitimization_measure"); + goto cleanup; } } - TALER_KYCLOGIC_rules_free (lrs); if ( (legitimization_measure_last_row == kyp->etag_measure_in) && (legitimization_outcome_last_row == kyp->etag_outcome_in) && GNUNET_TIME_absolute_is_future (kyp->timeout) ) @@ -544,7 +796,19 @@ TEH_handler_kyc_info ( kyp_tail, kyp); MHD_suspend_connection (rc->connection); - return MHD_YES; + res = MHD_YES; + goto cleanup; + } + /* FIXME: We should instead long-poll on the running KYC program. */ + if (contains_instant_measure (jmeasures)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Still waiting for KYC program.\n"); + res = TALER_MHD_reply_with_ec ( + rc->connection, + TALER_EC_EXCHANGE_KYC_INFO_BUSY, + "waiting for KYC program"); + goto cleanup; } if ( (legitimization_measure_last_row == kyp->etag_measure_in) && @@ -553,24 +817,27 @@ TEH_handler_kyc_info ( { char etags[128]; - json_decref (jmeasures); - json_decref (jvoluntary); GNUNET_snprintf (etags, sizeof (etags), "\"%llu-%llu\"", (unsigned long long) legitimization_measure_last_row, (unsigned long long) legitimization_outcome_last_row); - return TEH_RESPONSE_reply_not_modified ( + res = TEH_RESPONSE_reply_not_modified ( rc->connection, etags, &add_response_headers, NULL); + goto cleanup; } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Generating success reply to kyc-info query\n"); res = generate_reply (kyp, legitimization_measure_last_row, legitimization_outcome_last_row, jmeasures, jvoluntary); +cleanup: + TALER_KYCLOGIC_rules_free (lrs); json_decref (jmeasures); json_decref (jvoluntary); return res; diff --git a/src/exchange/taler-exchange-httpd_kyc-proof.c b/src/exchange/taler-exchange-httpd_kyc-proof.c index 1ba978a3a..55de59825 100644 --- a/src/exchange/taler-exchange-httpd_kyc-proof.c +++ b/src/exchange/taler-exchange-httpd_kyc-proof.c @@ -72,7 +72,7 @@ struct KycProofContext /** * KYC AML trigger operation. */ - struct TEH_KycAmlTrigger *kat; + struct TEH_KycMeasureRunContext *kat; /** * Process information about the user for the plugin from the database, can @@ -89,14 +89,29 @@ struct KycProofContext /** * Hash of payment target URI this is about. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** - * HTTP response to return. + * Final HTTP response to return. */ struct MHD_Response *response; /** + * Final HTTP response code to return. + */ + unsigned int response_code; + + /** + * HTTP response from the KYC provider plugin. + */ + struct MHD_Response *proof_response; + + /** + * HTTP response code from the KYC provider plugin. + */ + unsigned int proof_response_code; + + /** * Provider configuration section name of the logic we are running. */ const char *provider_name; @@ -107,11 +122,6 @@ struct KycProofContext uint64_t process_row; /** - * HTTP response code to return. - */ - unsigned int response_code; - - /** * True if we are suspended, */ bool suspended; @@ -131,6 +141,46 @@ static struct KycProofContext *kpc_tail; /** + * Generate HTML error for @a connection using @a template. + * + * @param connection HTTP client connection + * @param template template to expand + * @param[in,out] http_status HTTP status of the response + * @param ec Taler error code to return + * @param message extended message to return + * @return MHD response object + */ +static struct MHD_Response * +make_html_error (struct MHD_Connection *connection, + const char *template, + unsigned int *http_status, + enum TALER_ErrorCode ec, + const char *message) +{ + struct MHD_Response *response = NULL; + json_t *body; + + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("message", + message)), + TALER_JSON_pack_ec ( + ec)); + GNUNET_break ( + GNUNET_SYSERR != + TALER_TEMPLATING_build (connection, + http_status, + template, + NULL, + NULL, + body, + &response)); + json_decref (body); + return response; +} + + +/** * Resume processing the @a kpc request. * * @param kpc request to resume @@ -169,66 +219,43 @@ TEH_kyc_proof_cleanup (void) * Function called after the KYC-AML trigger is done. * * @param cls closure - * @param http_status final HTTP status to return - * @param[in] response final HTTP ro return + * @param ec error code or 0 on success + * @param detail error message or NULL on success / no info */ static void proof_finish ( void *cls, - unsigned int http_status, - struct MHD_Response *response) + enum TALER_ErrorCode ec, + const char *detail) { struct KycProofContext *kpc = cls; kpc->kat = NULL; - GNUNET_assert (NULL == kpc->response); - kpc->response_code = http_status; - kpc->response = response; + if (TALER_EC_NONE != ec) + { + kpc->response_code = TALER_ErrorCode_get_http_status (ec); + GNUNET_assert (kpc->response_code != UINT_MAX); + kpc->response = make_html_error ( + kpc->rc->connection, + "kyc-proof-internal-error", + &kpc->response_code, + ec, + detail); + } + else + { + GNUNET_assert (NULL != kpc->proof_response); + kpc->response_code = kpc->proof_response_code; + kpc->response = kpc->proof_response; + kpc->proof_response = NULL; + kpc->proof_response_code = 0; + } + GNUNET_assert (NULL != kpc->response); kpc_resume (kpc); } /** - * Generate HTML error for @a connection using @a template. - * - * @param connection HTTP client connection - * @param template template to expand - * @param[in,out] http_status HTTP status of the response - * @param ec Taler error code to return - * @param message extended message to return - * @return MHD response object - */ -static struct MHD_Response * -make_html_error (struct MHD_Connection *connection, - const char *template, - unsigned int *http_status, - enum TALER_ErrorCode ec, - const char *message) -{ - struct MHD_Response *response = NULL; - json_t *body; - - body = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("message", - message)), - TALER_JSON_pack_ec ( - ec)); - GNUNET_break ( - GNUNET_SYSERR != - TALER_TEMPLATING_build (connection, - http_status, - template, - NULL, - NULL, - body, - &response)); - json_decref (body); - return response; -} - - -/** * Respond with an HTML message on the given @a rc. * * @param[in,out] rc request to respond to @@ -292,6 +319,8 @@ proof_cb ( struct GNUNET_AsyncScopeSave old_scope; kpc->ph = NULL; + kpc->proof_response = response; + kpc->proof_response_code = http_status; GNUNET_async_scope_enter (&rc->async_scope_id, &old_scope); switch (status) @@ -300,29 +329,21 @@ proof_cb ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC process #%llu succeeded with KYC provider\n", (unsigned long long) kpc->process_row); - kpc->kat = TEH_kyc_finished ( + kpc->kat = TEH_kyc_run_measure_for_attributes ( &rc->async_scope_id, kpc->process_row, &kpc->h_payto, - kpc->provider_name, provider_user_id, provider_legitimization_id, expiration, attributes, - http_status, - response, &proof_finish, kpc); - response = NULL; /* taken over by TEH_kyc_finished */ if (NULL == kpc->kat) { - http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; - response = make_html_error ( - kpc->rc->connection, - "kyc-proof-internal-error", - &http_status, - TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION, - "[exchange] AML_KYC_TRIGGER"); + proof_finish (kpc, + TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION, + "[exchange] AML_KYC_TRIGGER"); } break; case TALER_KYCLOGIC_STATUS_FAILED: @@ -341,16 +362,11 @@ proof_cb ( char *msg; /* OAuth2 server had a problem, do NOT log this as a KYC failure */ - if (NULL != response) - MHD_destroy_response (response); GNUNET_asprintf (&msg, "Failure by KYC provider (HTTP status %u)\n", http_status); - http_status = MHD_HTTP_BAD_GATEWAY; - response = make_html_error ( - kpc->rc->connection, - "kyc-proof-internal-error", - &http_status, + proof_finish ( + kpc, TALER_EC_EXCHANGE_KYC_GENERIC_PROVIDER_UNEXPECTED_REPLY, msg); GNUNET_free (msg); @@ -367,16 +383,21 @@ proof_cb ( TALER_EC_EXCHANGE_GENERIC_KYC_FAILED)) { GNUNET_break (0); - if (NULL != response) - MHD_destroy_response (response); - http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; - response = make_html_error ( - kpc->rc->connection, - "kyc-proof-internal-error", - &http_status, + proof_finish ( + kpc, TALER_EC_GENERIC_DB_STORE_FAILED, "insert_kyc_failure"); } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "KYC process #%llu failed with status %d\n", + (unsigned long long) kpc->process_row, + status); + proof_finish (kpc, + TALER_EC_NONE, + NULL); + } } break; default: @@ -388,16 +409,6 @@ proof_cb ( (int) status); break; } - if (NULL == kpc->kat) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC process #%llu failed with status %d\n", - (unsigned long long) kpc->process_row, - status); - proof_finish (kpc, - http_status, - response); - } GNUNET_async_scope_restore (&old_scope); } @@ -419,7 +430,7 @@ clean_kpc (struct TEH_RequestContext *rc) } if (NULL != kpc->kat) { - TEH_kyc_finished_cancel (kpc->kat); + TEH_kyc_run_measure_cancel (kpc->kat); kpc->kat = NULL; } if (NULL != kpc->response) @@ -427,6 +438,11 @@ clean_kpc (struct TEH_RequestContext *rc) MHD_destroy_response (kpc->response); kpc->response = NULL; } + if (NULL != kpc->proof_response) + { + MHD_destroy_response (kpc->proof_response); + kpc->proof_response = NULL; + } GNUNET_free (kpc->provider_user_id); GNUNET_free (kpc->provider_legitimization_id); GNUNET_free (kpc); diff --git a/src/exchange/taler-exchange-httpd_kyc-start.c b/src/exchange/taler-exchange-httpd_kyc-start.c index f49f07e8a..7082c0b4d 100644 --- a/src/exchange/taler-exchange-httpd_kyc-start.c +++ b/src/exchange/taler-exchange-httpd_kyc-start.c @@ -53,7 +53,7 @@ struct KycPoller /** * Hash of the payto:// URI we are starting to the KYC for. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Kept in a DLL. @@ -425,9 +425,9 @@ TEH_handler_kyc_start ( &kyp->redirect_url); if (qs < 0) { - if (GNUNET_DB_STATUS_SOFT_ERROR == qs) - return qs; GNUNET_break (0); + /* Simple query, never should be a soft error. */ + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); return TALER_MHD_reply_with_error ( rc->connection, MHD_HTTP_INTERNAL_SERVER_ERROR, diff --git a/src/exchange/taler-exchange-httpd_kyc-upload.c b/src/exchange/taler-exchange-httpd_kyc-upload.c index 2841b94d0..7bea4768f 100644 --- a/src/exchange/taler-exchange-httpd_kyc-upload.c +++ b/src/exchange/taler-exchange-httpd_kyc-upload.c @@ -86,7 +86,7 @@ struct UploadContext /** * Handle for async KYC processing. */ - struct TEH_KycAmlTrigger *kat; + struct TEH_KycMeasureRunContext *kat; /** * Uploaded data, in JSON. @@ -239,7 +239,7 @@ upload_cleaner (struct TEH_RequestContext *rc) if (NULL != uc->kat) { - TEH_kyc_finished_cancel (uc->kat); + TEH_kyc_run_measure_cancel (uc->kat); uc->kat = NULL; } if (NULL != uc->response) @@ -334,22 +334,36 @@ post_helper (void *cls, * Function called after the KYC-AML trigger is done. * * @param cls closure - * @param http_status final HTTP status to return - * @param[in] response final HTTP ro return + * @param ec error code or 0 on success + * @param detail error message or NULL on success / no info */ static void aml_trigger_callback ( void *cls, - unsigned int http_status, - struct MHD_Response *response) + enum TALER_ErrorCode ec, + const char *detail) { struct UploadContext *uc = cls; uc->kat = NULL; GNUNET_assert (NULL == uc->response); - GNUNET_assert (NULL != response); - uc->response_code = http_status; - uc->response = response; + if (TALER_EC_NONE != ec) + { + uc->response_code = TALER_ErrorCode_get_http_status (ec); + GNUNET_assert (uc->response_code != UINT_MAX); + uc->response = TALER_MHD_make_error ( + ec, + detail); + } + else + { + uc->response_code = MHD_HTTP_NO_CONTENT; + uc->response = MHD_create_response_from_buffer_static ( + 0, + "" + ); + } + MHD_resume_connection (uc->rc->connection); GNUNET_CONTAINER_DLL_remove (uc_head, uc_tail, @@ -455,10 +469,9 @@ TEH_handler_kyc_upload ( { uint64_t legi_process_row; - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; enum GNUNET_DB_QueryStatus qs; json_t *jmeasures; - struct MHD_Response *empty_response; bool is_finished = false; size_t enc_attributes_len; void *enc_attributes; @@ -578,23 +591,16 @@ TEH_handler_kyc_upload ( "insert_kyc_requirement_process"); } - empty_response - = MHD_create_response_from_buffer_static (0, - ""); - uc->kat = TEH_kyc_finished ( + uc->kat = TEH_kyc_run_measure_for_attributes ( &rc->async_scope_id, legi_process_row, &h_payto, - "FORM", NULL /* provider account */, NULL /* provider legi ID */, GNUNET_TIME_UNIT_FOREVER_ABS, /* expiration time */ uc->result, - MHD_HTTP_NO_CONTENT, - empty_response, &aml_trigger_callback, uc); - empty_response = NULL; /* taken over by TEH_kyc_finished */ if (NULL == uc->kat) { GNUNET_break (0); diff --git a/src/exchange/taler-exchange-httpd_kyc-wallet.c b/src/exchange/taler-exchange-httpd_kyc-wallet.c index 903d87de0..f89cd4a9c 100644 --- a/src/exchange/taler-exchange-httpd_kyc-wallet.c +++ b/src/exchange/taler-exchange-httpd_kyc-wallet.c @@ -30,7 +30,6 @@ #include "taler-exchange-httpd_common_kyc.h" #include "taler-exchange-httpd_kyc-wallet.h" #include "taler-exchange-httpd_responses.h" -#include "taler-exchange-httpd_withdraw.h" /** @@ -57,7 +56,7 @@ struct KycRequestContext /** * Payto URI of the reserve. */ - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; /** * Request context. @@ -75,7 +74,7 @@ struct KycRequestContext /** * Public key of the reserve/wallet this is about. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * The wallet's public key @@ -214,7 +213,7 @@ krc_cleaner (struct TEH_RequestContext *rc) TEH_legitimization_check_cancel (krc->lch); krc->lch = NULL; } - GNUNET_free (krc->payto_uri); + GNUNET_free (krc->payto_uri.normalized_payto); GNUNET_free (krc); } @@ -274,22 +273,30 @@ TEH_handler_kyc_wallet ( krc->payto_uri = TALER_reserve_make_payto (TEH_base_url, &krc->wallet_pub.reserve_pub); - TALER_payto_hash (krc->payto_uri, - &krc->h_payto); + TALER_normalized_payto_hash (krc->payto_uri, + &krc->h_payto); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "h_payto of wallet %s is %s\n", - krc->payto_uri, + krc->payto_uri.normalized_payto, TALER_B2S (&krc->h_payto)); - krc->lch = TEH_legitimization_check ( - &rc->async_scope_id, - TALER_KYCLOGIC_KYC_TRIGGER_WALLET_BALANCE, - krc->payto_uri, - &krc->h_payto, - &krc->wallet_pub, - &balance_iterator, - krc, - &legi_result_cb, - krc); + { + struct TALER_FullPayto fake_full_payto; + + GNUNET_asprintf (&fake_full_payto.full_payto, + "%s?receiver-name=wallet", + krc->payto_uri.normalized_payto); + krc->lch = TEH_legitimization_check ( + &rc->async_scope_id, + TALER_KYCLOGIC_KYC_TRIGGER_WALLET_BALANCE, + fake_full_payto, + &krc->h_payto, + &krc->wallet_pub, + &balance_iterator, + krc, + &legi_result_cb, + krc); + GNUNET_free (fake_full_payto.full_payto); + } GNUNET_assert (NULL != krc->lch); MHD_suspend_connection (rc->connection); GNUNET_CONTAINER_DLL_insert (krc_head, diff --git a/src/exchange/taler-exchange-httpd_kyc-webhook.c b/src/exchange/taler-exchange-httpd_kyc-webhook.c index 9cdcfb66b..2b265dbef 100644 --- a/src/exchange/taler-exchange-httpd_kyc-webhook.c +++ b/src/exchange/taler-exchange-httpd_kyc-webhook.c @@ -57,7 +57,7 @@ struct KycWebhookContext /** * Handle for the KYC-AML trigger interaction. */ - struct TEH_KycAmlTrigger *kat; + struct TEH_KycMeasureRunContext *kat; /** * Plugin responsible for the webhook. @@ -81,16 +81,30 @@ struct KycWebhookContext struct TALER_KYCLOGIC_WebhookHandle *wh; /** - * HTTP response to return. + * Final HTTP response to return. */ struct MHD_Response *response; /** - * HTTP response code to return. + * Final HTTP response code to return. */ unsigned int response_code; /** + * Response from the webhook plugin. + * + * Will become the final response on successfully + * running the measure with the new attributes. + */ + struct MHD_Response *webhook_response; + + /** + * Response code to return for the webhook plugin + * response. + */ + unsigned int webhook_response_code; + + /** * #GNUNET_YES if we are suspended, * #GNUNET_NO if not. * #GNUNET_SYSERR if we had some error. @@ -150,21 +164,35 @@ TEH_kyc_webhook_cleanup (void) * Function called after the KYC-AML trigger is done. * * @param cls closure with a `struct KycWebhookContext *` - * @param http_status final HTTP status to return - * @param[in] response final HTTP ro return + * @param ec error code or 0 on success + * @param detail error message or NULL on success / no info */ static void kyc_aml_webhook_finished ( void *cls, - unsigned int http_status, - struct MHD_Response *response) + enum TALER_ErrorCode ec, + const char *detail) { struct KycWebhookContext *kwh = cls; kwh->kat = NULL; GNUNET_assert (NULL == kwh->response); - kwh->response = response; - kwh->response_code = http_status; + if (TALER_EC_NONE != ec) + { + kwh->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; + kwh->response = TALER_MHD_make_error ( + ec, + detail + ); + } + else + { + GNUNET_assert (NULL != kwh->webhook_response); + kwh->response_code = kwh->webhook_response_code; + kwh->response = kwh->webhook_response; + kwh->webhook_response = NULL; + kwh->webhook_response_code = 0; + } kwh_resume (kwh); } @@ -191,7 +219,7 @@ static void webhook_finished_cb ( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, const char *provider_name, const char *provider_user_id, const char *provider_legitimization_id, @@ -204,33 +232,30 @@ webhook_finished_cb ( struct KycWebhookContext *kwh = cls; kwh->wh = NULL; + kwh->webhook_response = response; + kwh->webhook_response_code = http_status; + switch (status) { case TALER_KYCLOGIC_STATUS_SUCCESS: - kwh->kat = TEH_kyc_finished ( + kwh->kat = TEH_kyc_run_measure_for_attributes ( &kwh->rc->async_scope_id, process_row, account_id, - provider_name, provider_user_id, provider_legitimization_id, expiration, attributes, - http_status, - response, &kyc_aml_webhook_finished, - kwh); + kwh + ); if (NULL == kwh->kat) { - if (NULL != response) - MHD_destroy_response (response); - http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; - response = TALER_MHD_make_error ( - TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION, - "[exchange] AML_KYC_TRIGGER"); - break; + kyc_aml_webhook_finished (kwh, + TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION, + "[exchange] AML_KYC_TRIGGER"); } - return; + break; case TALER_KYCLOGIC_STATUS_FAILED: case TALER_KYCLOGIC_STATUS_PROVIDER_FAILED: case TALER_KYCLOGIC_STATUS_USER_ABORTED: @@ -251,12 +276,9 @@ webhook_finished_cb ( TALER_EC_EXCHANGE_GENERIC_KYC_FAILED)) { GNUNET_break (0); - if (NULL != response) - MHD_destroy_response (response); - http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; - response = TALER_MHD_make_error ( - TALER_EC_GENERIC_DB_STORE_FAILED, - "insert_kyc_failure"); + kyc_aml_webhook_finished (kwh, + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_kyc_failure"); } break; default: @@ -267,12 +289,11 @@ webhook_finished_cb ( provider_legitimization_id, (unsigned long long) process_row, (int) status); + kyc_aml_webhook_finished (kwh, + TALER_EC_NONE, + NULL); break; } - GNUNET_break (NULL == kwh->kat); - kyc_aml_webhook_finished (kwh, - http_status, - response); } @@ -293,7 +314,7 @@ clean_kwh (struct TEH_RequestContext *rc) } if (NULL != kwh->kat) { - TEH_kyc_finished_cancel (kwh->kat); + TEH_kyc_run_measure_cancel (kwh->kat); kwh->kat = NULL; } if (NULL != kwh->response) @@ -301,6 +322,11 @@ clean_kwh (struct TEH_RequestContext *rc) MHD_destroy_response (kwh->response); kwh->response = NULL; } + if (NULL != kwh->webhook_response) + { + MHD_destroy_response (kwh->response); + kwh->webhook_response = NULL; + } GNUNET_free (kwh); } diff --git a/src/exchange/taler-exchange-httpd_management_drain.c b/src/exchange/taler-exchange-httpd_management_drain.c index 1e490d799..1935d1082 100644 --- a/src/exchange/taler-exchange-httpd_management_drain.c +++ b/src/exchange/taler-exchange-httpd_management_drain.c @@ -50,7 +50,7 @@ struct DrainContext /** * Account to credit. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Configuration section with account to debit. @@ -124,8 +124,8 @@ TEH_handler_management_post_drain ( struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("debit_account_section", &dc.account_section), - TALER_JSON_spec_payto_uri ("credit_payto_uri", - &dc.payto_uri), + TALER_JSON_spec_full_payto_uri ("credit_payto_uri", + &dc.payto_uri), GNUNET_JSON_spec_fixed_auto ("wtid", &dc.wtid), GNUNET_JSON_spec_fixed_auto ("master_sig", diff --git a/src/exchange/taler-exchange-httpd_management_wire_disable.c b/src/exchange/taler-exchange-httpd_management_wire_disable.c index e0b8a3de8..4cd0eab07 100644 --- a/src/exchange/taler-exchange-httpd_management_wire_disable.c +++ b/src/exchange/taler-exchange-httpd_management_wire_disable.c @@ -45,7 +45,7 @@ struct DelWireContext /** * Payto:// URI this is about. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Timestamp for checking against replay attacks. @@ -146,8 +146,8 @@ TEH_handler_management_post_wire_disable ( struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("master_sig_del", &awc.master_sig), - TALER_JSON_spec_payto_uri ("payto_uri", - &awc.payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &awc.payto_uri), GNUNET_JSON_spec_timestamp ("validity_end", &awc.validity_end), GNUNET_JSON_spec_end () diff --git a/src/exchange/taler-exchange-httpd_management_wire_enable.c b/src/exchange/taler-exchange-httpd_management_wire_enable.c index 472e19d3e..799181221 100644 --- a/src/exchange/taler-exchange-httpd_management_wire_enable.c +++ b/src/exchange/taler-exchange-httpd_management_wire_enable.c @@ -52,7 +52,7 @@ struct AddWireContext /** * Payto:// URI this is about. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * (optional) address of a conversion service for this account. @@ -185,8 +185,8 @@ TEH_handler_management_post_wire ( &awc.master_sig_wire), GNUNET_JSON_spec_fixed_auto ("master_sig_add", &awc.master_sig_add), - TALER_JSON_spec_payto_uri ("payto_uri", - &awc.payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &awc.payto_uri), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_web_url ("conversion_url", &awc.conversion_url), @@ -277,12 +277,12 @@ TEH_handler_management_post_wire ( { char *wire_method; - wire_method = TALER_payto_get_method (awc.payto_uri); + wire_method = TALER_payto_get_method (awc.payto_uri.full_payto); if (NULL == wire_method) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "payto:// URI `%s' is malformed\n", - awc.payto_uri); + awc.payto_uri.full_payto); GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error ( connection, diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c b/src/exchange/taler-exchange-httpd_purses_deposit.c index d518e6250..d3bfe201e 100644 --- a/src/exchange/taler-exchange-httpd_purses_deposit.c +++ b/src/exchange/taler-exchange-httpd_purses_deposit.c @@ -359,8 +359,9 @@ TEH_handler_purses_deposit ( GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TEH_currency, &pcc.deposit_total)); - pcc.num_coins = json_array_size (deposits); + pcc.num_coins = (unsigned int) json_array_size (deposits); if ( (0 == pcc.num_coins) || + (((size_t) pcc.num_coins) != json_array_size (deposits)) || (pcc.num_coins > TALER_MAX_FRESH_COINS) ) { GNUNET_break_op (0); diff --git a/src/exchange/taler-exchange-httpd_purses_get.c b/src/exchange/taler-exchange-httpd_purses_get.c index 22328fe09..b6e5673fa 100644 --- a/src/exchange/taler-exchange-httpd_purses_get.c +++ b/src/exchange/taler-exchange-httpd_purses_get.c @@ -188,11 +188,6 @@ db_event_cb (void *cls, (void) extra; (void) extra_size; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Waking up on %p - %p - %s\n", - rc, - gc, - gc->suspended ? "suspended" : "active"); if (NULL == gc) return; /* event triggered while main transaction was still running */ @@ -202,7 +197,10 @@ db_event_cb (void *cls, GNUNET_async_scope_enter (&rc->async_scope_id, &old_scope); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Resuming from long-polling on purse\n"); + "Waking up on %p - %p - %s\n", + rc, + gc, + gc->suspended ? "suspended" : "active"); TEH_check_invariants (); GNUNET_CONTAINER_DLL_remove (gc_head, gc_tail, @@ -271,8 +269,11 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc, }; GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Starting DB event listening on purse %s\n", - TALER_B2S (&gc->purse_pub)); + "Starting DB event listening on purse %s (%s)\n", + TALER_B2S (&gc->purse_pub), + gc->wait_for_merge + ? "waiting for merge" + : "waiting for deposit"); gc->eh = TEH_plugin->event_listen ( TEH_plugin->cls, GNUNET_TIME_absolute_get_remaining (gc->timeout), @@ -315,6 +316,11 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc, &gc->merge_timestamp, &purse_deleted, &purse_refunded); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "select_purse %s returned %d (%s)\n", + args[0], + (int) qs, + GNUNET_TIME_timestamp2s (gc->merge_timestamp)); switch (qs) { case GNUNET_DB_STATUS_HARD_ERROR: @@ -347,14 +353,20 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc, MHD_HTTP_GONE, purse_deleted ? TALER_EC_EXCHANGE_GENERIC_PURSE_DELETED - : TALER_EC_EXCHANGE_GENERIC_PURSE_EXPIRED, + : TALER_EC_EXCHANGE_GENERIC_PURSE_EXPIRED + , GNUNET_TIME_timestamp2s ( gc->purse_expiration)); } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Deposited amount is %s\n", - TALER_amount2s (&gc->deposited)); + "Deposited amount is %s (%d/%d/%d)\n", + TALER_amount2s (&gc->deposited), + GNUNET_TIME_absolute_is_future (gc->timeout), + GNUNET_TIME_absolute_is_never (gc->merge_timestamp.abs_time), + (0 < + TALER_amount_cmp (&gc->amount, + &gc->deposited))); if (GNUNET_TIME_absolute_is_future (gc->timeout) && ( ((gc->wait_for_merge) && GNUNET_TIME_absolute_is_never (gc->merge_timestamp.abs_time)) || diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c b/src/exchange/taler-exchange-httpd_purses_merge.c index 0f6a1e498..98d731c35 100644 --- a/src/exchange/taler-exchange-httpd_purses_merge.c +++ b/src/exchange/taler-exchange-httpd_purses_merge.c @@ -33,7 +33,6 @@ #include "taler-exchange-httpd_common_kyc.h" #include "taler-exchange-httpd_purses_merge.h" #include "taler-exchange-httpd_responses.h" -#include "taler-exchange-httpd_withdraw.h" #include "taler_exchangedb_lib.h" #include "taler-exchange-httpd_keys.h" @@ -78,7 +77,7 @@ struct PurseMergeContext * URI of the account the purse is to be merged into. * Must be of the form 'payto://taler-reserve/$EXCHANGE_URL/RESERVE_PUB'. */ - const char *payto_uri; + struct TALER_NormalizedPayto payto_uri; /** * Response to return, if set. @@ -143,7 +142,7 @@ struct PurseMergeContext /** * Hash of the @e payto_uri. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * KYC status of the operation. @@ -530,8 +529,8 @@ TEH_handler_purses_merge ( { struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &pmc->payto_uri), + TALER_JSON_spec_normalized_payto_uri ("payto_uri", + &pmc->payto_uri), GNUNET_JSON_spec_fixed_auto ("reserve_sig", &pmc->reserve_sig), GNUNET_JSON_spec_fixed_auto ("merge_sig", @@ -620,13 +619,13 @@ TEH_handler_purses_merge ( /* parse 'payto_uri' into pmc->account_pub and provider_url */ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received payto: `%s'\n", - pmc->payto_uri); - if ( (0 != strncmp (pmc->payto_uri, + pmc->payto_uri.normalized_payto); + if ( (0 != strncmp (pmc->payto_uri.normalized_payto, "payto://taler-reserve/", strlen ("payto://taler-reserve/"))) && - (0 != strncmp (pmc->payto_uri, + (0 != strncmp (pmc->payto_uri.normalized_payto, "payto://taler-reserve-http/", - strlen ("payto://taler-reserve+http/"))) ) + strlen ("payto://taler-reserve-http/"))) ) { GNUNET_break_op (0); return TALER_MHD_reply_with_error ( @@ -641,10 +640,10 @@ TEH_handler_purses_merge ( const char *host; const char *slash; - http = (0 == strncmp (pmc->payto_uri, + http = (0 == strncmp (pmc->payto_uri.normalized_payto, "payto://taler-reserve-http/", strlen ("payto://taler-reserve-http/"))); - host = &pmc->payto_uri[http + host = &pmc->payto_uri.normalized_payto[http ? strlen ("payto://taler-reserve-http/") : strlen ("payto://taler-reserve/")]; slash = strchr (host, @@ -679,8 +678,8 @@ TEH_handler_purses_merge ( "payto_uri"); } } - TALER_payto_hash (pmc->payto_uri, - &pmc->h_payto); + TALER_normalized_payto_hash (pmc->payto_uri, + &pmc->h_payto); if (0 == strcmp (pmc->provider_url, TEH_base_url)) { @@ -739,16 +738,24 @@ TEH_handler_purses_merge ( NULL); } } - pmc->lch = TEH_legitimization_check ( - &rc->async_scope_id, - TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE, - pmc->payto_uri, - &pmc->h_payto, - &pmc->account_pub, - &amount_iterator, - pmc, - &legi_result_cb, - pmc); + { + struct TALER_FullPayto fake_full_payto; + + GNUNET_asprintf (&fake_full_payto.full_payto, + "%s?receiver-name=wallet", + pmc->payto_uri.normalized_payto); + pmc->lch = TEH_legitimization_check ( + &rc->async_scope_id, + TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE, + fake_full_payto, + &pmc->h_payto, + &pmc->account_pub, + &amount_iterator, + pmc, + &legi_result_cb, + pmc); + GNUNET_free (fake_full_payto.full_payto); + } GNUNET_assert (NULL != pmc->lch); MHD_suspend_connection (rc->connection); GNUNET_CONTAINER_DLL_insert (pmc_head, diff --git a/src/exchange/taler-exchange-httpd_reserves_attest.c b/src/exchange/taler-exchange-httpd_reserves_attest.c index b3ae4828a..2ae16439e 100644 --- a/src/exchange/taler-exchange-httpd_reserves_attest.c +++ b/src/exchange/taler-exchange-httpd_reserves_attest.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA + Copyright (C) 2014-2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -53,7 +53,7 @@ struct ReserveAttestContext /** * Hash of the payto URI of this reserve. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Timestamp of the request. @@ -165,7 +165,7 @@ reply_reserve_attest_success (struct MHD_Connection *connection, */ static void kyc_process_cb (void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, struct GNUNET_TIME_Timestamp collection_time, struct GNUNET_TIME_Timestamp expiration_time, @@ -355,13 +355,13 @@ TEH_handler_reserves_attest (struct TEH_RequestContext *rc, } { - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; payto_uri = TALER_reserve_make_payto (TEH_base_url, &rsc.reserve_pub); - TALER_payto_hash (payto_uri, - &rsc.h_payto); - GNUNET_free (payto_uri); + TALER_normalized_payto_hash (payto_uri, + &rsc.h_payto); + GNUNET_free (payto_uri.normalized_payto); } if (GNUNET_OK != diff --git a/src/exchange/taler-exchange-httpd_reserves_close.c b/src/exchange/taler-exchange-httpd_reserves_close.c index bf5815f78..db3b9e851 100644 --- a/src/exchange/taler-exchange-httpd_reserves_close.c +++ b/src/exchange/taler-exchange-httpd_reserves_close.c @@ -30,7 +30,6 @@ #include "taler-exchange-httpd_common_kyc.h" #include "taler-exchange-httpd_keys.h" #include "taler-exchange-httpd_reserves_close.h" -#include "taler-exchange-httpd_withdraw.h" #include "taler-exchange-httpd_responses.h" @@ -71,7 +70,7 @@ struct ReserveCloseContext /** * Where to wire the funds, may be NULL. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Response to return. Note that the response must @@ -109,7 +108,7 @@ struct ReserveCloseContext /** * Hash of the @e payto_uri, if given (otherwise zero). */ - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; /** * KYC status for the request. @@ -119,7 +118,7 @@ struct ReserveCloseContext /** * Hash of the payto-URI that was used for the KYC decision. */ - struct TALER_PaytoHashP kyc_payto; + struct TALER_NormalizedPaytoHashP kyc_payto; /** * Query status from the amount_it() helper function. @@ -281,7 +280,9 @@ reserve_close_transaction ( { struct ReserveCloseContext *rcc = cls; enum GNUNET_DB_QueryStatus qs; - char *payto_uri = NULL; + struct TALER_FullPayto payto_uri = { + .full_payto = NULL + }; const struct TALER_WireFeeSet *wf; qs = TEH_plugin->select_reserve_close_info ( @@ -314,8 +315,8 @@ reserve_close_transaction ( break; } - if ( (NULL == rcc->payto_uri) && - (NULL == payto_uri) ) + if ( (NULL == rcc->payto_uri.full_payto) && + (NULL == payto_uri.full_payto) ) { *mhd_ret = TALER_MHD_reply_with_error ( @@ -327,17 +328,17 @@ reserve_close_transaction ( } if ( (! rcc->resumed) && - (NULL != rcc->payto_uri) && - ( (NULL == payto_uri) || - (0 != strcmp (payto_uri, - rcc->payto_uri)) ) ) + (NULL != rcc->payto_uri.full_payto) && + ( (NULL == payto_uri.full_payto) || + (0 != TALER_full_payto_cmp (payto_uri, + rcc->payto_uri)) ) ) { /* KYC check may be needed: we're not returning the money to the account that funded the reserve in the first place. */ - TALER_payto_hash (rcc->payto_uri, - &rcc->kyc_payto); + TALER_full_payto_normalize_and_hash (rcc->payto_uri, + &rcc->kyc_payto); rcc->lch = TEH_legitimization_check ( &rcc->rc->async_scope_id, TALER_KYCLOGIC_KYC_TRIGGER_RESERVE_CLOSE, @@ -357,13 +358,13 @@ reserve_close_transaction ( return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; } rcc->kyc.ok = true; - if (NULL == rcc->payto_uri) + if (NULL == rcc->payto_uri.full_payto) rcc->payto_uri = payto_uri; { char *method; - method = TALER_payto_get_method (rcc->payto_uri); + method = TALER_payto_get_method (rcc->payto_uri.full_payto); wf = TEH_wire_fees_by_time (rcc->timestamp, method); if (NULL == wf) @@ -402,8 +403,8 @@ reserve_close_transaction ( rcc->timestamp, &rcc->balance, &wf->closing); - GNUNET_free (payto_uri); - rcc->payto_uri = NULL; + GNUNET_free (payto_uri.full_payto); + rcc->payto_uri.full_payto = NULL; if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); @@ -466,8 +467,8 @@ TEH_handler_reserves_close ( GNUNET_JSON_spec_timestamp ("request_timestamp", &rcc->timestamp), GNUNET_JSON_spec_mark_optional ( - TALER_JSON_spec_payto_uri ("payto_uri", - &rcc->payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &rcc->payto_uri), NULL), GNUNET_JSON_spec_fixed_auto ("reserve_sig", &rcc->reserve_sig), @@ -511,9 +512,9 @@ TEH_handler_reserves_close ( } } - if (NULL != rcc->payto_uri) - TALER_payto_hash (rcc->payto_uri, - &rcc->h_payto); + if (NULL != rcc->payto_uri.full_payto) + TALER_full_payto_hash (rcc->payto_uri, + &rcc->h_payto); if (GNUNET_OK != TALER_wallet_reserve_close_verify ( rcc->timestamp, diff --git a/src/exchange/taler-exchange-httpd_reserves_get_attest.c b/src/exchange/taler-exchange-httpd_reserves_get_attest.c index c3cb7bc16..aba74220b 100644 --- a/src/exchange/taler-exchange-httpd_reserves_get_attest.c +++ b/src/exchange/taler-exchange-httpd_reserves_get_attest.c @@ -43,7 +43,7 @@ struct ReserveAttestContext /** * Hash of the payto URI of this reserve. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Available attributes. @@ -67,7 +67,7 @@ struct ReserveAttestContext */ static void kyc_process_cb (void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, struct GNUNET_TIME_Timestamp collection_time, struct GNUNET_TIME_Timestamp expiration_time, @@ -135,14 +135,14 @@ TEH_handler_reserves_get_attest ( args[0]); } { - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; payto_uri = TALER_reserve_make_payto (TEH_base_url, &rsc.reserve_pub); - TALER_payto_hash (payto_uri, - &rsc.h_payto); - GNUNET_free (payto_uri); + TALER_normalized_payto_hash (payto_uri, + &rsc.h_payto); + GNUNET_free (payto_uri.normalized_payto); } { enum GNUNET_DB_QueryStatus qs; diff --git a/src/exchange/taler-exchange-httpd_reserves_history.c b/src/exchange/taler-exchange-httpd_reserves_history.c index 24f836cdd..f74f41592 100644 --- a/src/exchange/taler-exchange-httpd_reserves_history.c +++ b/src/exchange/taler-exchange-httpd_reserves_history.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2023 Taler Systems SA + Copyright (C) 2014-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -63,8 +63,8 @@ compile_reserve_history ( "CREDIT"), GNUNET_JSON_pack_timestamp ("timestamp", bank->execution_date), - GNUNET_JSON_pack_string ("sender_account_url", - bank->sender_account_details), + TALER_JSON_pack_full_payto ("sender_account_url", + bank->sender_account_details), GNUNET_JSON_pack_uint64 ("wire_reference", bank->wire_reference), TALER_JSON_pack_amount ("amount", @@ -178,8 +178,8 @@ compile_reserve_history ( GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("type", "CLOSING"), - GNUNET_JSON_pack_string ("receiver_account_details", - closing->receiver_account_details), + TALER_JSON_pack_full_payto ("receiver_account_details", + closing->receiver_account_details), GNUNET_JSON_pack_data_auto ("wtid", &closing->wtid), GNUNET_JSON_pack_data_auto ("exchange_pub", diff --git a/src/exchange/taler-exchange-httpd_reserves_purse.c b/src/exchange/taler-exchange-httpd_reserves_purse.c index d5a111d5a..56207ef8c 100644 --- a/src/exchange/taler-exchange-httpd_reserves_purse.c +++ b/src/exchange/taler-exchange-httpd_reserves_purse.c @@ -32,7 +32,6 @@ #include "taler-exchange-httpd_common_kyc.h" #include "taler-exchange-httpd_reserves_purse.h" #include "taler-exchange-httpd_responses.h" -#include "taler-exchange-httpd_withdraw.h" #include "taler_exchangedb_lib.h" #include "taler-exchange-httpd_keys.h" @@ -74,7 +73,7 @@ struct ReservePurseContext /** * Payto URI for the reserve. */ - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; /** * Public key of the account (reserve) we are creating a purse for. @@ -134,7 +133,7 @@ struct ReservePurseContext /** * Hash of the @e payto_uri. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * KYC status of the operation. @@ -581,7 +580,7 @@ rpc_cleaner (struct TEH_RequestContext *rc) rpc->lch = NULL; } GNUNET_free (rpc->econtract.econtract); - GNUNET_free (rpc->payto_uri); + GNUNET_free (rpc->payto_uri.normalized_payto); GNUNET_free (rpc); } @@ -664,8 +663,8 @@ TEH_handler_reserves_purse ( rpc->payto_uri = TALER_reserve_make_payto (TEH_base_url, &rpc->account_pub.reserve_pub); - TALER_payto_hash (rpc->payto_uri, - &rpc->h_payto); + TALER_normalized_payto_hash (rpc->payto_uri, + &rpc->h_payto); TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++; @@ -683,8 +682,7 @@ TEH_handler_reserves_purse ( connection, MHD_HTTP_FORBIDDEN, TALER_EC_EXCHANGE_RESERVES_PURSE_MERGE_SIGNATURE_INVALID, - rpc->payto_uri); - GNUNET_free (rpc->payto_uri); + rpc->payto_uri.normalized_payto); return ret; } GNUNET_assert (GNUNET_OK == @@ -817,17 +815,24 @@ TEH_handler_reserves_purse ( TALER_EC_EXCHANGE_PURSE_ECONTRACT_SIGNATURE_INVALID, NULL); } - - rpc->lch = TEH_legitimization_check ( - &rpc->rc->async_scope_id, - TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE, - rpc->payto_uri, - &rpc->h_payto, - &rpc->account_pub, - &amount_iterator, - rpc, - &reserve_purse_legi_cb, - rpc); + { + struct TALER_FullPayto fake_full_payto; + + GNUNET_asprintf (&fake_full_payto.full_payto, + "%s?receiver-name=wallet", + rpc->payto_uri.normalized_payto); + rpc->lch = TEH_legitimization_check ( + &rpc->rc->async_scope_id, + TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE, + fake_full_payto, + &rpc->h_payto, + &rpc->account_pub, + &amount_iterator, + rpc, + &reserve_purse_legi_cb, + rpc); + GNUNET_free (fake_full_payto.full_payto); + } GNUNET_assert (NULL != rpc->lch); MHD_suspend_connection (rc->connection); GNUNET_CONTAINER_DLL_insert (rpc_head, diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 0405c28fd..68f29445b 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -340,7 +340,7 @@ TEH_RESPONSE_reply_purse_created ( MHD_RESULT TEH_RESPONSE_reply_kyc_required ( struct MHD_Connection *connection, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const struct TALER_EXCHANGEDB_KycStatus *kyc, bool bad_kyc_auth) { diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h index 79f505538..e6f13e419 100644 --- a/src/exchange/taler-exchange-httpd_responses.h +++ b/src/exchange/taler-exchange-httpd_responses.h @@ -98,7 +98,7 @@ TEH_RESPONSE_reply_reserve_age_restriction_required ( MHD_RESULT TEH_RESPONSE_reply_kyc_required ( struct MHD_Connection *connection, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const struct TALER_EXCHANGEDB_KycStatus *kyc, bool bad_kyc_auth); diff --git a/src/exchange/taler-exchange-httpd_transfers_get.c b/src/exchange/taler-exchange-httpd_transfers_get.c index 18d96f955..ea62ca334 100644 --- a/src/exchange/taler-exchange-httpd_transfers_get.c +++ b/src/exchange/taler-exchange-httpd_transfers_get.c @@ -93,7 +93,7 @@ static MHD_RESULT reply_transfer_details (struct MHD_Connection *connection, const struct TALER_Amount *total, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_Amount *wire_fee, struct GNUNET_TIME_Timestamp exec_time, const struct AggregatedDepositDetail *wdd_head) @@ -103,7 +103,7 @@ reply_transfer_details (struct MHD_Connection *connection, struct GNUNET_HashCode h_details; struct TALER_ExchangePublicKeyP pub; struct TALER_ExchangeSignatureP sig; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; deposits = json_array (); GNUNET_assert (NULL != deposits); @@ -169,8 +169,8 @@ reply_transfer_details (struct MHD_Connection *connection, } } - TALER_payto_hash (payto_uri, - &h_payto); + TALER_full_payto_hash (payto_uri, + &h_payto); return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, @@ -241,7 +241,7 @@ struct WtidTransactionContext /** * Where were the funds wired? */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * JSON array with details about the individual deposits. @@ -306,8 +306,8 @@ handle_deposit_data ( void *cls, uint64_t rowid, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *account_payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto account_payto_uri, + const struct TALER_FullPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp exec_time, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_DenominationPublicKey *denom_pub, @@ -392,7 +392,7 @@ handle_deposit_data ( { /* First one we encounter, setup general information in 'ctx' */ ctx->merchant_pub = *merchant_pub; - ctx->payto_uri = GNUNET_strdup (account_payto_uri); + ctx->payto_uri.full_payto = GNUNET_strdup (account_payto_uri.full_payto); ctx->exec_time = exec_time; ctx->is_valid = GNUNET_YES; if (0 > @@ -413,8 +413,8 @@ handle_deposit_data ( (it should, otherwise the deposits should not have been aggregated) */ if ( (0 != GNUNET_memcmp (&ctx->merchant_pub, merchant_pub)) || - (0 != strcmp (account_payto_uri, - ctx->payto_uri)) ) + (0 != TALER_full_payto_cmp (account_payto_uri, + ctx->payto_uri)) ) { GNUNET_break (0); ctx->is_valid = GNUNET_SYSERR; @@ -473,7 +473,7 @@ free_ctx (struct WtidTransactionContext *ctx) wdd); GNUNET_free (wdd); } - GNUNET_free (ctx->payto_uri); + GNUNET_free (ctx->payto_uri.full_payto); } @@ -543,7 +543,7 @@ get_transfer_deposits (void *cls, { char *wire_method; - wire_method = TALER_payto_get_method (ctx->payto_uri); + wire_method = TALER_payto_get_method (ctx->payto_uri.full_payto); if (NULL == wire_method) { GNUNET_break (0); diff --git a/src/exchange/taler-exchange-httpd_withdraw.h b/src/exchange/taler-exchange-httpd_withdraw.h deleted file mode 100644 index 45ac6340f..000000000 --- a/src/exchange/taler-exchange-httpd_withdraw.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -*/ -/** - * @file taler-exchange-httpd_withdraw.h - * @brief common code for withdraw requests - * @author Christian Grothoff - */ -#ifndef TALER_EXCHANGE_HTTPD_WITHDRAW_H -#define TALER_EXCHANGE_HTTPD_WITHDRAW_H - -#include <microhttpd.h> -#include "taler-exchange-httpd.h" - - -/** - * Do legitimization check for withdrawing @a withdraw_total - * from @a reserve_pub at time @a now. - * - * @param[out] kyc set to kyc status - * @param[out] h_payto set to payto hash of origin account - * @param[in,out] connection used to return hard errors - * @param[out] mhd_ret set if errors were returned - * (only on hard error) - * @param reserve_pub reserve from which we withdraw - * @param withdraw_total how much are being withdrawn - * @param now current time - * @return transaction status, error will have been - * queued if transaction status is set to hard error - */ -enum GNUNET_DB_QueryStatus -TEH_withdraw_kyc_check ( - struct TALER_EXCHANGEDB_KycStatus *kyc, - struct TALER_PaytoHashP *h_payto, - struct MHD_Connection *connection, - MHD_RESULT *mhd_ret, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_Amount *withdraw_total, - struct GNUNET_TIME_Timestamp now); - -#endif diff --git a/src/exchange/taler-exchange-router.c b/src/exchange/taler-exchange-router.c index a1a247194..306a0e1f6 100644 --- a/src/exchange/taler-exchange-router.c +++ b/src/exchange/taler-exchange-router.c @@ -198,7 +198,8 @@ parse_wirewatch_config (void) } if (NULL == - (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem\n"); @@ -426,10 +427,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -438,7 +435,6 @@ main (int argc, "background process that routes P2P transfers"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange/taler-exchange-transfer.c b/src/exchange/taler-exchange-transfer.c index 9724b41fc..6726a46dd 100644 --- a/src/exchange/taler-exchange-transfer.c +++ b/src/exchange/taler-exchange-transfer.c @@ -283,7 +283,8 @@ parse_transfer_config (void) return GNUNET_SYSERR; } if (NULL == - (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem\n"); @@ -895,10 +896,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -907,7 +904,6 @@ main (int argc, "background process that executes outgoing wire transfers"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c index 5eb54deea..c1f7f5d75 100644 --- a/src/exchange/taler-exchange-wirewatch.c +++ b/src/exchange/taler-exchange-wirewatch.c @@ -345,7 +345,8 @@ exchange_serve_process_config (void) return GNUNET_SYSERR; } if (NULL == - (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (db_plugin = TALER_EXCHANGEDB_plugin_load (cfg, + false))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem\n"); @@ -1097,10 +1098,6 @@ main (int argc, enum GNUNET_GenericReturnValue ret; longpoll_timeout = LONGPOLL_TIMEOUT; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1109,7 +1106,6 @@ main (int argc, "background process that watches for incoming wire transfers from customers"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/exchange/test_taler_exchange_httpd.conf b/src/exchange/test_taler_exchange_httpd.conf index 7e7ff8b45..f5fc5f059 100644 --- a/src/exchange/test_taler_exchange_httpd.conf +++ b/src/exchange/test_taler_exchange_httpd.conf @@ -68,7 +68,7 @@ ENABLE_CREDIT = YES [exchange-accountcredentials-1] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8082/accounts/3/taler-wire-gateway/" # Coins for the tests. diff --git a/src/exchangedb/.gitignore b/src/exchangedb/.gitignore index 42614b8e6..a0b31eaa4 100644 --- a/src/exchangedb/.gitignore +++ b/src/exchangedb/.gitignore @@ -16,3 +16,4 @@ test-exchangedb-populate-select-refunds-by-coin-postgres exchange-0004.sql exchange-0005.sql exchange-0006.sql +exchange-0007.sql diff --git a/src/exchangedb/0002-account_merges.sql b/src/exchangedb/0002-account_merges.sql index 1dd7e5bf0..aff590d41 100644 --- a/src/exchangedb/0002-account_merges.sql +++ b/src/exchangedb/0002-account_merges.sql @@ -54,6 +54,12 @@ BEGIN ,partition_suffix ); PERFORM comment_partitioned_column( + 'hash over the normalized (!) payto:// URI that identifies the receiving wallet' + ,'wallet_h_payto' + ,table_name + ,partition_suffix + ); + PERFORM comment_partitioned_column( 'signature by the reserve private key affirming the merge, of type TALER_SIGNATURE_WALLET_ACCOUNT_MERGE' ,'reserve_sig' ,table_name diff --git a/src/exchangedb/0002-kyc_alerts.sql b/src/exchangedb/0002-kyc_alerts.sql index 8e54846cf..fe5442ba4 100644 --- a/src/exchangedb/0002-kyc_alerts.sql +++ b/src/exchangedb/0002-kyc_alerts.sql @@ -22,6 +22,6 @@ CREATE TABLE kyc_alerts COMMENT ON TABLE kyc_alerts IS 'alerts about completed KYC events reliably notifying other components (even if they are not running)'; COMMENT ON COLUMN kyc_alerts.h_payto - IS 'hash of the payto://-URI for which the KYC status changed'; + IS 'hash of the normalized payto://-URI for which the KYC status changed'; COMMENT ON COLUMN kyc_alerts.trigger_type IS 'identifies the receiver of the alert, as the same h_payto may require multiple components to be notified'; diff --git a/src/exchangedb/0002-legitimization_processes.sql b/src/exchangedb/0002-legitimization_processes.sql index 3212b1c06..960e9c9a3 100644 --- a/src/exchangedb/0002-legitimization_processes.sql +++ b/src/exchangedb/0002-legitimization_processes.sql @@ -49,7 +49,7 @@ BEGIN ,shard_suffix ); PERFORM comment_partitioned_column( - 'foreign key linking the entry to the wire_targets table, NOT a primary key (multiple legitimizations are possible per wire target)' + 'hash over the normalized payto URI; foreign key linking the entry to the wire_targets table, NOT a primary key (multiple legitimizations are possible per wire target)' ,'h_payto' ,'legitimization_processes' ,shard_suffix diff --git a/src/exchangedb/0002-wire_targets.sql b/src/exchangedb/0002-wire_targets.sql index 88d67d9a5..eaf693c54 100644 --- a/src/exchangedb/0002-wire_targets.sql +++ b/src/exchangedb/0002-wire_targets.sql @@ -37,13 +37,13 @@ BEGIN ,partition_suffix ); PERFORM comment_partitioned_column( - 'Can be a regular bank account, or also be a URI identifying a reserve-account (for P2P payments)' + 'Full payto URI. Can identify a regular bank account, or also be a URI identifying a reserve-account (for P2P payments)' ,'payto_uri' ,'wire_targets' ,partition_suffix ); PERFORM comment_partitioned_column( - 'Unsalted hash of payto_uri' + 'Unsalted hash of (full) payto_uri' ,'wire_target_h_payto' ,'wire_targets' ,partition_suffix diff --git a/src/exchangedb/0005-kycauths_in.sql b/src/exchangedb/0005-kycauths_in.sql index d1fa3f536..3d3282c61 100644 --- a/src/exchangedb/0005-kycauths_in.sql +++ b/src/exchangedb/0005-kycauths_in.sql @@ -43,8 +43,11 @@ BEGIN ,table_name ,partition_suffix ); + -- FIXME: check that the *full* payto URI is indeed the best choice here, + -- given that this is mostly used for KYC, we may prefer the normalized + -- payto URI instead! Not sure, to be checked! PERFORM comment_partitioned_column( - 'Identifies the debited bank account and KYC status' + 'Identifies the debited bank account and KYC status by the hash over the full payto URI' ,'wire_source_h_payto' ,table_name ,partition_suffix diff --git a/src/exchangedb/0005-legitimization_processes.sql b/src/exchangedb/0005-legitimization_processes.sql index c1bffca7d..d8222bf6c 100644 --- a/src/exchangedb/0005-legitimization_processes.sql +++ b/src/exchangedb/0005-legitimization_processes.sql @@ -22,7 +22,7 @@ LANGUAGE plpgsql AS $$ BEGIN PERFORM create_partitioned_table( - 'ALTER TABLE legitimization_processes' + 'ALTER TABLE %I' ' ADD COLUMN legitimization_measure_serial_id BIGINT' ',ADD COLUMN measure_index INT4 DEFAULT(0)' ',ADD COLUMN error_code INT4 DEFAULT (0)' diff --git a/src/exchangedb/0007-batch_deposits.sql b/src/exchangedb/0007-batch_deposits.sql new file mode 100644 index 000000000..44c832484 --- /dev/null +++ b/src/exchangedb/0007-batch_deposits.sql @@ -0,0 +1,54 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +CREATE FUNCTION alter_table_batch_deposits7( + IN partition_suffix TEXT DEFAULT NULL +) +RETURNS VOID +LANGUAGE plpgsql +AS $$ +BEGIN + PERFORM create_partitioned_table( + 'ALTER TABLE %I' + ' ADD COLUMN merchant_sig BYTEA CHECK(LENGTH(merchant_sig)=64)' + ' DEFAULT NULL' + ';', + 'batch_deposits' + ,'' + ,partition_suffix + ); + + PERFORM comment_partitioned_column( + 'signature by the merchant over the contract terms, of purpuse TALER_SIGNATURE_MERCHANT_CONTRACT' + ,'merchant_sig' + ,'batch_deposits' + ,partition_suffix + ); +END $$; + + +INSERT INTO exchange_tables + (name + ,version + ,action + ,partitioned + ,by_range) + VALUES + ('batch_deposits7' + ,'exchange-0007' + ,'alter' + ,TRUE + ,FALSE); diff --git a/src/exchangedb/0007-legitimization_outcomes.sql b/src/exchangedb/0007-legitimization_outcomes.sql new file mode 100644 index 000000000..251fe7f12 --- /dev/null +++ b/src/exchangedb/0007-legitimization_outcomes.sql @@ -0,0 +1,43 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +CREATE FUNCTION foreign_table_legitimization_outcomes7() +RETURNS void +LANGUAGE plpgsql +AS $$ +DECLARE + table_name TEXT DEFAULT 'legitimization_outcomes'; +BEGIN + + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' DROP CONSTRAINT ' || table_name || '_foreign_key_h_payto'); +END +$$; + + +INSERT INTO exchange_tables + (name + ,version + ,action + ,partitioned + ,by_range) + VALUES + ('legitimization_outcomes7' + ,'exchange-0007' + ,'foreign' + ,TRUE + ,FALSE); diff --git a/src/exchangedb/0007-wire_targets.sql b/src/exchangedb/0007-wire_targets.sql new file mode 100644 index 000000000..e9ee9bd1e --- /dev/null +++ b/src/exchangedb/0007-wire_targets.sql @@ -0,0 +1,72 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +CREATE FUNCTION alter_table_wire_targets7() +RETURNS VOID +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE FORMAT ( + 'ALTER TABLE wire_targets' + ' ADD COLUMN h_normalized_payto BYTEA CHECK(LENGTH(h_normalized_payto)=32)' + ' DEFAULT NULL' + ';' + ); + + PERFORM comment_partitioned_column( + 'hash over the normalized payto URI for this account; used for KYC operations; NULL if not available (due to DB migration not initializing this value)' + ,'h_normalized_payto' + ,'wire_targets' + ,NULL + ); +END $$; + + +CREATE FUNCTION constrain_table_wire_targets7( + IN partition_suffix TEXT +) +RETURNS void +LANGUAGE plpgsql +AS $$ +DECLARE + table_name TEXT DEFAULT 'wire_targets'; +BEGIN + table_name = concat_ws('_', table_name, partition_suffix); + EXECUTE FORMAT ( + 'CREATE INDEX ' || table_name || '_normalized_h_payto_index ' + 'ON ' || table_name || ' ' + '(h_normalized_payto);' + ); +END +$$; + +INSERT INTO exchange_tables + (name + ,version + ,action + ,partitioned + ,by_range) + VALUES + ('wire_targets7' + ,'exchange-0007' + ,'alter' + ,TRUE + ,FALSE), + ('wire_targets7' + ,'exchange-0007' + ,'constrain' + ,TRUE + ,FALSE); diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index 5472f41f5..138c0882d 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -26,7 +26,8 @@ sqlinputs = \ exchange-0003.sql.in \ exchange-0004.sql.in \ exchange-0005.sql.in \ - exchange-0006.sql.in + exchange-0006.sql.in \ + exchange-0007.sql.in sql_DATA = \ benchmark-0001.sql \ @@ -38,6 +39,7 @@ sql_DATA = \ exchange-0004.sql \ exchange-0005.sql \ exchange-0006.sql \ + exchange-0007.sql \ drop.sql \ procedures.sql @@ -53,6 +55,7 @@ CLEANFILES = \ exchange-0004.sql \ exchange-0005.sql \ exchange-0006.sql \ + exchange-0007.sql \ procedures.sql procedures.sql: procedures.sql.in exchange_do_*.sql @@ -85,6 +88,11 @@ exchange-0006.sql: exchange-0006.sql.in 0006-*.sql gcc -E -P -undef - < exchange-0006.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ chmod ugo-w $@ +exchange-0007.sql: exchange-0007.sql.in 0007-*.sql + chmod +w $@ 2> /dev/null || true + gcc -E -P -undef - < exchange-0007.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ + chmod ugo-w $@ + check_SCRIPTS = \ test_idempotency.sh @@ -108,7 +116,6 @@ endif libtaler_plugin_exchangedb_postgres_la_SOURCES = \ plugin_exchangedb_common.c plugin_exchangedb_common.h \ - pg_setup_wire_target.h pg_setup_wire_target.c \ pg_compute_shard.h pg_compute_shard.c \ plugin_exchangedb_postgres.c plugin_exchangedb_postgres.h \ pg_helper.h \ @@ -138,7 +145,6 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \ pg_insert_drain_profit.h pg_insert_drain_profit.c \ pg_insert_kyc_failure.h pg_insert_kyc_failure.c \ pg_inject_auditor_triggers.h pg_inject_auditor_triggers.c \ - pg_insert_programmatic_legitimization_outcome.h pg_insert_programmatic_legitimization_outcome.c \ pg_create_tables.h pg_create_tables.c \ pg_event_listen.h pg_event_listen.c \ pg_event_listen_cancel.h pg_event_listen_cancel.c \ @@ -180,7 +186,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \ pg_have_deposit2.h pg_have_deposit2.c \ pg_aggregate.h pg_aggregate.c \ pg_create_aggregation_transient.h pg_create_aggregation_transient.c \ - pg_insert_kyc_attributes.h pg_insert_kyc_attributes.c \ + pg_insert_kyc_measure_result.h pg_insert_kyc_measure_result.c \ pg_select_kyc_attributes.h pg_select_kyc_attributes.c \ pg_insert_aml_officer.h pg_insert_aml_officer.c \ pg_test_aml_officer.h pg_test_aml_officer.c \ @@ -188,8 +194,8 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \ pg_lookup_pending_legitimization.h pg_lookup_pending_legitimization.c \ pg_lookup_completed_legitimization.h pg_lookup_completed_legitimization.c \ pg_lookup_active_legitimization.h pg_lookup_active_legitimization.c \ - pg_trigger_aml_process.h pg_trigger_aml_process.c \ pg_insert_aml_decision.h pg_insert_aml_decision.c \ + pg_insert_successor_measure.h pg_insert_successor_measure.c \ pg_select_aggregation_transient.h pg_select_aggregation_transient.c \ pg_find_aggregation_transient.h pg_find_aggregation_transient.c \ pg_update_aggregation_transient.h pg_update_aggregation_transient.c \ @@ -308,11 +314,6 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \ pg_lookup_kyc_requirement_by_row.h pg_lookup_kyc_requirement_by_row.c \ pg_select_reserve_open_above_serial_id.c pg_select_reserve_open_above_serial_id.h -# pg_select_justification_for_missing_wire.h pg_select_justification_for_missing_wire.c -# pg_select_aml_process.h pg_select_aml_process.c -# pg_select_aml_history.h pg_select_aml_history.c -# pg_select_aml_threshold.h pg_select_aml_threshold.c - libtaler_plugin_exchangedb_postgres_la_LDFLAGS = \ $(TALER_PLUGIN_LDFLAGS) diff --git a/src/exchangedb/exchange-0007.sql.in b/src/exchangedb/exchange-0007.sql.in new file mode 100644 index 000000000..9a03e2fa1 --- /dev/null +++ b/src/exchangedb/exchange-0007.sql.in @@ -0,0 +1,27 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +BEGIN; + +SELECT _v.register_patch('exchange-0007', NULL, NULL); +SET search_path TO exchange; + +#include "0007-wire_targets.sql" +#include "0007-legitimization_outcomes.sql" +#include "0007-batch_deposits.sql" + + +COMMIT; diff --git a/src/exchangedb/exchange_do_age_withdraw.sql b/src/exchangedb/exchange_do_age_withdraw.sql index 89a291445..058531feb 100644 --- a/src/exchangedb/exchange_do_age_withdraw.sql +++ b/src/exchangedb/exchange_do_age_withdraw.sql @@ -53,8 +53,8 @@ SELECT current_balance ,birthday ,gc_date INTO reserve - FROM exchange.reserves - WHERE reserves.reserve_pub=rpub; + FROM reserves + WHERE reserve_pub=rpub; IF NOT FOUND THEN @@ -124,10 +124,10 @@ UPDATE reserves SET gc_date=min_reserve_gc ,current_balance=balance WHERE - reserves.reserve_pub=rpub; + reserve_pub=rpub; -- Write the commitment into the age-withdraw table -INSERT INTO exchange.age_withdraw +INSERT INTO age_withdraw (h_commitment ,max_age ,amount_with_fee diff --git a/src/exchangedb/exchange_do_check_deposit_idempotent.sql b/src/exchangedb/exchange_do_check_deposit_idempotent.sql index 1e7414dc0..04d6b9ee6 100644 --- a/src/exchangedb/exchange_do_check_deposit_idempotent.sql +++ b/src/exchangedb/exchange_do_check_deposit_idempotent.sql @@ -13,7 +13,9 @@ -- You should have received a copy of the GNU General Public License along with -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -CREATE OR REPLACE FUNCTION exchange_do_check_deposit_idempotent( + +DROP FUNCTION IF EXISTS exchange_do_check_deposit_idempotent; +CREATE FUNCTION exchange_do_check_deposit_idempotent( -- For batch_deposits IN in_shard INT8, IN in_merchant_pub BYTEA, @@ -27,8 +29,6 @@ CREATE OR REPLACE FUNCTION exchange_do_check_deposit_idempotent( IN in_wire_target_h_payto BYTEA, IN in_policy_details_serial_id INT8, -- can be NULL IN in_policy_blocked BOOLEAN, - -- For wire_targets - IN in_receiver_wire_account TEXT, -- For coin_deposits IN ina_coin_pub BYTEA[], IN ina_coin_sig BYTEA[], @@ -57,8 +57,7 @@ out_exchange_timestamp = in_exchange_timestamp; SELECT wire_target_serial_id INTO wtsi FROM wire_targets - WHERE wire_target_h_payto=in_wire_target_h_payto - AND payto_uri=in_receiver_wire_account; + WHERE wire_target_h_payto=in_wire_target_h_payto; IF NOT FOUND THEN diff --git a/src/exchangedb/exchange_do_deposit.sql b/src/exchangedb/exchange_do_deposit.sql index c89e9e470..8ada2c497 100644 --- a/src/exchangedb/exchange_do_deposit.sql +++ b/src/exchangedb/exchange_do_deposit.sql @@ -13,10 +13,13 @@ -- You should have received a copy of the GNU General Public License along with -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -CREATE OR REPLACE FUNCTION exchange_do_deposit( + +DROP FUNCTION IF EXISTS exchange_do_deposit; +CREATE FUNCTION exchange_do_deposit( -- For batch_deposits IN in_shard INT8, IN in_merchant_pub BYTEA, + IN in_merchant_sig BYTEA, IN in_wallet_timestamp INT8, IN in_exchange_timestamp INT8, IN in_refund_deadline INT8, @@ -25,6 +28,7 @@ CREATE OR REPLACE FUNCTION exchange_do_deposit( IN in_wallet_data_hash BYTEA, -- can be NULL IN in_wire_salt BYTEA, IN in_wire_target_h_payto BYTEA, + IN in_h_normalized_payto BYTEA, IN in_policy_details_serial_id INT8, -- can be NULL IN in_policy_blocked BOOLEAN, -- For wire_targets @@ -57,9 +61,11 @@ BEGIN -- First, get or create the 'wtsi' INSERT INTO wire_targets (wire_target_h_payto + ,h_normalized_payto ,payto_uri) VALUES (in_wire_target_h_payto + ,in_h_normalized_payto ,in_receiver_wire_account) ON CONFLICT DO NOTHING -- for CONFLICT ON (wire_target_h_payto) RETURNING @@ -83,6 +89,7 @@ END IF; INSERT INTO batch_deposits (shard ,merchant_pub + ,merchant_sig ,wallet_timestamp ,exchange_timestamp ,refund_deadline @@ -97,6 +104,7 @@ INSERT INTO batch_deposits VALUES (in_shard ,in_merchant_pub + ,in_merchant_sig ,in_wallet_timestamp ,in_exchange_timestamp ,in_refund_deadline diff --git a/src/exchangedb/exchange_do_insert_active_legitimization_measure.sql b/src/exchangedb/exchange_do_insert_active_legitimization_measure.sql index 649ed4685..ce554dee7 100644 --- a/src/exchangedb/exchange_do_insert_active_legitimization_measure.sql +++ b/src/exchangedb/exchange_do_insert_active_legitimization_measure.sql @@ -36,7 +36,7 @@ INSERT INTO legitimization_measures ,display_priority) VALUES (in_access_token - ,in_decision_time + ,in_start_time ,in_jmeasures ,1) RETURNING diff --git a/src/exchangedb/exchange_do_insert_aml_decision.sql b/src/exchangedb/exchange_do_insert_aml_decision.sql index 401d6e23e..dec1c3ab9 100644 --- a/src/exchangedb/exchange_do_insert_aml_decision.sql +++ b/src/exchangedb/exchange_do_insert_aml_decision.sql @@ -17,7 +17,8 @@ DROP FUNCTION IF EXISTS exchange_do_insert_aml_decision; CREATE FUNCTION exchange_do_insert_aml_decision( IN in_payto_uri TEXT, -- can be NULL! - IN in_h_payto BYTEA, + IN in_h_normalized_payto BYTEA, + IN in_h_full_payto BYTEA, -- can be NULL! IN in_decision_time INT8, IN in_expiration_time INT8, IN in_properties TEXT, -- can be NULL @@ -31,7 +32,8 @@ CREATE FUNCTION exchange_do_insert_aml_decision( IN in_notify_s TEXT, OUT out_invalid_officer BOOLEAN, OUT out_account_unknown BOOLEAN, - OUT out_last_date INT8) + OUT out_last_date INT8, + OUT out_legitimization_measure_serial_id INT8) LANGUAGE plpgsql AS $$ DECLARE @@ -40,7 +42,7 @@ DECLARE BEGIN out_account_unknown=FALSE; - +out_legitimization_measure_serial_id=0; -- Check officer is eligible to make decisions. PERFORM @@ -60,9 +62,9 @@ out_invalid_officer=FALSE; SELECT decision_time INTO out_last_date FROM legitimization_outcomes - WHERE h_payto=in_h_payto + WHERE h_payto=in_h_normalized_payto AND is_active - ORDER BY decision_time DESC; + ORDER BY decision_time DESC, outcome_serial_id DESC; IF FOUND THEN @@ -73,7 +75,7 @@ THEN END IF; UPDATE legitimization_outcomes SET is_active=FALSE - WHERE h_payto=in_h_payto + WHERE h_payto=in_h_normalized_payto AND is_active; ELSE out_last_date = 0; @@ -82,7 +84,7 @@ END IF; SELECT access_token INTO my_access_token FROM wire_targets - WHERE wire_target_h_payto=in_h_payto; + WHERE h_normalized_payto=in_h_normalized_payto; IF NOT FOUND THEN @@ -95,30 +97,27 @@ THEN INSERT INTO wire_targets (wire_target_h_payto + ,h_normalized_payto ,payto_uri) VALUES - (in_h_payto + (in_h_full_payto + ,in_h_normalized_payto ,in_payto_uri) RETURNING access_token INTO my_access_token; END IF; --- AML decision: mark all active measures finished! -UPDATE legitimization_measures - SET is_finished=TRUE - WHERE access_token=my_access_token - AND NOT is_finished; - -- Did KYC measures get prescribed? IF in_jmeasures IS NOT NULL THEN -- First check if a perfectly equivalent legi measure -- already exists, to avoid creating tons of duplicates. - PERFORM + SELECT legitimization_measure_serial_id + INTO out_legitimization_measure_serial_id FROM legitimization_measures - WHERE access_token=my_access_token - AND jmeasures=in_jmeasures - AND NOT is_finished; + WHERE access_token=my_access_token + AND jmeasures=in_jmeasures + AND NOT is_finished; IF NOT FOUND THEN @@ -132,15 +131,25 @@ THEN (my_access_token ,in_decision_time ,in_jmeasures - ,1); + ,1) + RETURNING + legitimization_measure_serial_id + INTO + out_legitimization_measure_serial_id; END IF; - -- end if for where we had in_jmeasures END IF; +-- AML decision: mark all other active measures finished! +UPDATE legitimization_measures + SET is_finished=TRUE + WHERE access_token=my_access_token + AND NOT is_finished + AND legitimization_measure_serial_id != out_legitimization_measure_serial_id; + UPDATE legitimization_outcomes SET is_active=FALSE - WHERE h_payto=in_h_payto + WHERE h_payto=in_h_normalized_payto -- this clause is a minor optimization to avoid -- updating outcomes that have long expired. AND expiration_time >= in_decision_time; @@ -155,7 +164,7 @@ INSERT INTO legitimization_outcomes ,jnew_rules ) VALUES - (in_h_payto + (in_h_normalized_payto ,in_decision_time ,in_expiration_time ,in_properties @@ -176,7 +185,7 @@ INSERT INTO aml_history ,decider_pub ,decider_sig ) VALUES - (in_h_payto + (in_h_normalized_payto ,my_outcome_serial_id ,in_justification ,in_decider_pub @@ -188,7 +197,7 @@ INSERT INTO kyc_alerts (h_payto ,trigger_type) VALUES - (in_h_payto,1) + (in_h_normalized_payto,1) ON CONFLICT DO NOTHING; EXECUTE FORMAT ( @@ -199,5 +208,5 @@ EXECUTE FORMAT ( END $$; -COMMENT ON FUNCTION exchange_do_insert_aml_decision(TEXT, BYTEA, INT8, INT8, TEXT, TEXT, BOOLEAN, TEXT, TEXT, TEXT, BYTEA, BYTEA, TEXT) +COMMENT ON FUNCTION exchange_do_insert_aml_decision(TEXT, BYTEA, BYTEA, INT8, INT8, TEXT, TEXT, BOOLEAN, TEXT, TEXT, TEXT, BYTEA, BYTEA, TEXT) IS 'Checks whether the AML officer is eligible to make AML decisions and if so inserts the decision into the table'; diff --git a/src/exchangedb/exchange_do_insert_kyc_attributes.sql b/src/exchangedb/exchange_do_insert_kyc_measure_result.sql index e04775b83..d9e8b4399 100644 --- a/src/exchangedb/exchange_do_insert_kyc_attributes.sql +++ b/src/exchangedb/exchange_do_insert_kyc_measure_result.sql @@ -14,8 +14,8 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -DROP FUNCTION IF EXISTS exchange_do_insert_kyc_attributes; -CREATE FUNCTION exchange_do_insert_kyc_attributes( +DROP FUNCTION IF EXISTS exchange_do_insert_kyc_measure_result; +CREATE FUNCTION exchange_do_insert_kyc_measure_result( IN in_process_row INT8, IN in_h_payto BYTEA, IN in_birthday INT4, @@ -68,20 +68,24 @@ RETURNING INTO my_trigger_outcome_serial; -INSERT INTO kyc_attributes - (h_payto - ,collection_time - ,expiration_time - ,encrypted_attributes - ,legitimization_serial - ,trigger_outcome_serial - ) VALUES - (in_h_payto - ,in_collection_time_ts - ,in_expiration_time_ts - ,in_enc_attributes - ,in_process_row - ,my_trigger_outcome_serial); +IF (in_process_row IS NOT NULL) AND + (in_enc_attributes IS NOT NULL) +THEN + INSERT INTO kyc_attributes + (h_payto + ,collection_time + ,expiration_time + ,encrypted_attributes + ,legitimization_serial + ,trigger_outcome_serial + ) VALUES + (in_h_payto + ,in_collection_time_ts + ,in_expiration_time_ts + ,in_enc_attributes + ,in_process_row + ,my_trigger_outcome_serial); +END IF; UPDATE legitimization_processes SET provider_user_id=in_provider_account_id @@ -107,7 +111,10 @@ UPDATE reserves WHERE (reserve_pub IN (SELECT reserve_pub FROM reserves_in - WHERE wire_source_h_payto=in_h_payto) ) + WHERE wire_source_h_payto IN + (SELECT wire_source_h_payto + FROM wire_targets + WHERE h_normalized_payto=in_h_payto) ) ) -- The next 3 clauses primarily serve to limit -- unnecessary updates for reserves we do not -- care about anymore. @@ -141,5 +148,5 @@ INSERT INTO kyc_alerts END $$; -COMMENT ON FUNCTION exchange_do_insert_kyc_attributes(INT8, BYTEA, INT4, TEXT, TEXT, TEXT, INT8, INT8, INT8, TEXT, TEXT, TEXT[], BYTEA, BOOL, TEXT) +COMMENT ON FUNCTION exchange_do_insert_kyc_measure_result(INT8, BYTEA, INT4, TEXT, TEXT, TEXT, INT8, INT8, INT8, TEXT, TEXT, TEXT[], BYTEA, BOOL, TEXT) IS 'Inserts new KYC attributes and updates the status of the legitimization process and the AML status for the account'; diff --git a/src/exchangedb/exchange_do_insert_programmatic_legitimization_outcome.sql b/src/exchangedb/exchange_do_insert_programmatic_legitimization_outcome.sql deleted file mode 100644 index ef0cb8fdb..000000000 --- a/src/exchangedb/exchange_do_insert_programmatic_legitimization_outcome.sql +++ /dev/null @@ -1,177 +0,0 @@ --- --- This file is part of TALER --- Copyright (C) 2023, 2024 Taler Systems SA --- --- TALER is free software; you can redistribute it and/or modify it under the --- terms of the GNU General Public License as published by the Free Software --- Foundation; either version 3, or (at your option) any later version. --- --- TALER is distributed in the hope that it will be useful, but WITHOUT ANY --- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR --- A PARTICULAR PURPOSE. See the GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License along with --- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> --- - -DROP FUNCTION IF EXISTS exchange_do_insert_programmatic_legitimization_outcome; -CREATE OR REPLACE FUNCTION exchange_do_insert_programmatic_legitimization_outcome( - IN in_h_payto BYTEA, - IN in_decision_time INT8, - IN in_expiration_time INT8, - IN in_properties TEXT, - IN in_new_rules TEXT, - IN in_to_investigate BOOLEAN, - IN ina_events TEXT[], - IN in_notify_s TEXT, - OUT out_account_unknown BOOLEAN) -LANGUAGE plpgsql -AS $$ -DECLARE - my_outcome_serial_id INT8; - my_access_token BYTEA; - my_max_dp INT4; - my_i INT4; - ini_event TEXT; -BEGIN - -out_account_unknown=FALSE; - --- Note: in_payto_uri is allowed to be NULL *if* --- in_h_payto is already in wire_targets -SELECT access_token - INTO my_access_token - FROM wire_targets - WHERE wire_target_h_payto=in_h_payto; - --- Very strange, should never happen that we --- take an AML decision on an unknown account! -IF NOT FOUND -THEN - out_account_unknown=TRUE; - RETURN; -END IF; -out_account_unknown=FALSE; - --- Did KYC measures get prescribed? -IF in_jmeasures IS NULL -THEN - -- AML decision without measure: mark all - -- active measures finished! - UPDATE legitimization_measures - SET is_finished=TRUE - WHERE access_token=my_access_token - AND NOT is_finished; -ELSE - -- Find current maximum DP - SELECT COALESCE(MAX(display_priority),0) - INTO my_max_dp - FROM legitimization_measures - WHERE access_token=my_access_token - AND NOT is_finished; - - -- First check if a perfectly equivalent legi measure - -- already exists, to avoid creating tons of duplicates. - UPDATE legitimization_measures - SET display_priority=GREATEST(my_max_dp,display_priority) - WHERE access_token=my_access_token - AND jmeasures=in_jmeasures - AND NOT is_finished; - - IF NOT FOUND - THEN - -- Enable new legitimization measure - INSERT INTO legitimization_measures - (access_token - ,start_time - ,jmeasures - ,display_priority) - VALUES - (my_access_token - ,in_decision_time - ,in_jmeasures - ,my_max_dp + 1); - END IF; - - -- end if for where we had non-NULL in_jmeasures -END IF; - -UPDATE legitimization_outcomes - SET is_active=FALSE - WHERE h_payto=in_h_payto - -- this clause is a minor optimization to avoid - -- updating outcomes that have long expired. - AND expiration_time >= in_decision_time; - -INSERT INTO legitimization_outcomes - (h_payto - ,decision_time - ,expiration_time - ,jproperties - ,new_measure_name - ,to_investigate - ,jnew_rules - ) - VALUES - (in_h_payto - ,in_decision_time - ,in_expiration_time - ,in_properties - ,in_new_measure_name - ,in_to_investigate - ,in_new_rules - ) - RETURNING - outcome_serial_id - INTO - my_outcome_serial_id; - --- FIXME: do we want/need programmatic --- decisions in the AML history? We --- have no justification or decider, --- so IF we would need to change the table --- significantly, which may break other things... - ---INSERT INTO aml_history --- (h_payto --- ,outcome_serial_id --- ,justification --- ,decider_pub --- ,decider_sig --- ) VALUES --- (in_h_payto --- ,my_outcome_serial_id --- ,in_justification --- ,in_decider_pub --- ,in_decider_sig --- ); - --- wake up taler-exchange-aggregator -INSERT INTO kyc_alerts - (h_payto - ,trigger_type) - VALUES - (in_h_payto,1) - ON CONFLICT DO NOTHING; - - -FOR i IN 1..COALESCE(array_length(ina_events,1),0) -LOOP - ini_event = ina_events[i]; - INSERT INTO kyc_events - (event_timestamp - ,event_type) - VALUES - (in_collection_time_ts - ,ini_event); -END LOOP; - -EXECUTE FORMAT ( - 'NOTIFY %s' - ,in_notify_s); - -END $$; - - -COMMENT ON FUNCTION exchange_do_insert_programmatic_legitimization_outcome(BYTEA, INT8, INT8, TEXT, TEXT, BOOLEAN, TEXT[], TEXT) - IS 'Inserts an AML decision that was taken automatically by an AML program into the database'; diff --git a/src/exchangedb/exchange_do_insert_successor_measure.sql b/src/exchangedb/exchange_do_insert_successor_measure.sql new file mode 100644 index 000000000..60895cef2 --- /dev/null +++ b/src/exchangedb/exchange_do_insert_successor_measure.sql @@ -0,0 +1,157 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2023, 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +DROP FUNCTION IF EXISTS exchange_do_insert_successor_measure; +CREATE FUNCTION exchange_do_insert_successor_measure( + IN in_h_normalized_payto BYTEA, + IN in_decision_time INT8, + IN in_expiration_time INT8, + IN in_new_measure_name TEXT, -- can be NULL + IN in_jmeasures TEXT, -- can be NULL + OUT out_last_date INT8, + OUT out_account_unknown BOOLEAN, + OUT out_legitimization_measure_serial_id INT8 +) +LANGUAGE plpgsql +AS $$ +DECLARE + my_outcome_serial_id INT8; + my_access_token BYTEA; +BEGIN + +out_account_unknown=FALSE; +out_legitimization_measure_serial_id=0; + +-- Check no more recent decision exists. +SELECT decision_time + INTO out_last_date + FROM legitimization_outcomes + WHERE h_payto=in_h_normalized_payto + AND is_active + ORDER BY decision_time DESC, outcome_serial_id DESC; + +IF FOUND +THEN + IF out_last_date >= in_decision_time + THEN + -- Refuse to insert older decision. + RETURN; + END IF; + UPDATE legitimization_outcomes + SET is_active=FALSE + WHERE h_payto=in_h_normalized_payto + AND is_active; +ELSE + out_last_date = 0; +END IF; + +SELECT access_token + INTO my_access_token + FROM wire_targets + WHERE h_normalized_payto=in_h_normalized_payto; + +IF NOT FOUND +THEN + IF in_payto_uri IS NULL + THEN + -- AML decision on an unknown account without payto_uri => fail. + out_account_unknown=TRUE; + RETURN; + END IF; + + INSERT INTO wire_targets + (wire_target_h_payto + ,h_normalized_payto + ,payto_uri) + VALUES + (in_h_full_payto + ,in_h_normalized_payto + ,in_payto_uri) + RETURNING access_token + INTO my_access_token; +END IF; + + +-- First check if a perfectly equivalent legi measure +-- already exists, to avoid creating tons of duplicates. +SELECT legitimization_measure_serial_id + INTO out_legitimization_measure_serial_id + FROM legitimization_measures + WHERE access_token=my_access_token + AND jmeasures=in_jmeasures + AND NOT is_finished; + +IF NOT FOUND +THEN + -- Enable new legitimization measure + INSERT INTO legitimization_measures + (access_token + ,start_time + ,jmeasures + ,display_priority) + VALUES + (my_access_token + ,in_decision_time + ,in_jmeasures + ,1) + RETURNING + legitimization_measure_serial_id + INTO + out_legitimization_measure_serial_id; +END IF; + +-- AML decision: mark all other active measures finished! +UPDATE legitimization_measures + SET is_finished=TRUE + WHERE access_token=my_access_token + AND NOT is_finished + AND legitimization_measure_serial_id != out_legitimization_measure_serial_id; + +UPDATE legitimization_outcomes + SET is_active=FALSE + WHERE h_payto=in_h_normalized_payto + -- this clause is a minor optimization to avoid + -- updating outcomes that have long expired. + AND expiration_time >= in_decision_time; + +INSERT INTO legitimization_outcomes + (h_payto + ,decision_time + ,expiration_time + ,jproperties + ,new_measure_name + ,to_investigate + ,jnew_rules + ) + VALUES + (in_h_normalized_payto + ,in_decision_time + ,in_expiration_time + ,'{}' + ,in_new_measure_name + ,FALSE + ,NULL + ) + RETURNING + outcome_serial_id + INTO + my_outcome_serial_id; + +END $$; + + +COMMENT ON FUNCTION exchange_do_insert_successor_measure(BYTEA, INT8, INT8, TEXT, TEXT) + IS 'Checks whether the AML officer is eligible to make AML decisions and if so inserts the decision into the table'; diff --git a/src/exchangedb/exchange_do_kycauth_in_insert.sql b/src/exchangedb/exchange_do_kycauth_in_insert.sql index 206c80f1a..a127c0de8 100644 --- a/src/exchangedb/exchange_do_kycauth_in_insert.sql +++ b/src/exchangedb/exchange_do_kycauth_in_insert.sql @@ -21,6 +21,7 @@ CREATE PROCEDURE exchange_do_kycauth_in_insert( IN in_wire_reference INT8, IN in_credit taler_amount, IN in_wire_source_h_payto BYTEA, + IN in_h_normalized_payto BYTEA, IN in_payto_uri TEXT, IN in_exchange_account_name TEXT, IN in_execution_date INT8, @@ -60,10 +61,12 @@ BEGIN THEN INSERT INTO wire_targets (wire_target_h_payto + ,h_normalized_payto ,payto_uri ,target_pub ) VALUES ( in_wire_source_h_payto + ,in_h_normalized_payto ,in_payto_uri ,in_account_pub); END IF; diff --git a/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql b/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql index e9a22aa84..c36f0be6f 100644 --- a/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql +++ b/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql @@ -18,7 +18,7 @@ DROP FUNCTION IF EXISTS exchange_do_lookup_kyc_requirement_by_row; CREATE FUNCTION exchange_do_lookup_kyc_requirement_by_row( - IN in_h_payto BYTEA, + IN in_h_normalized_payto BYTEA, OUT out_account_pub BYTEA, -- NULL allowed OUT out_reserve_pub BYTEA, -- NULL allowed OUT out_access_token BYTEA, -- NULL if 'out_not_found' @@ -38,7 +38,7 @@ SELECT access_token ,target_pub INTO my_wtrec FROM wire_targets - WHERE wire_target_h_payto=in_h_payto; + WHERE h_normalized_payto=in_h_normalized_payto; IF NOT FOUND THEN @@ -66,7 +66,7 @@ SELECT jnew_rules ,to_investigate INTO my_lorec FROM legitimization_outcomes - WHERE h_payto=in_h_payto + WHERE h_payto=in_h_normalized_payto AND is_active; IF FOUND @@ -80,8 +80,15 @@ END IF; SELECT reserve_pub INTO out_reserve_pub FROM reserves_in - WHERE wire_source_h_payto=in_h_payto + WHERE wire_source_h_payto + IN (SELECT wire_source_h_payto + FROM wire_targets + WHERE h_normalized_payto=in_h_normalized_payto) ORDER BY execution_date DESC LIMIT 1; +-- FIXME: may want to turn this around and pass *in* the +-- reserve_pub as an argument and then not LIMIT 1 but check +-- if any reserve_pub ever matched (and just return a BOOL +-- to indicate if the kyc-auth is OK). END $$; diff --git a/src/exchangedb/exchange_do_purse_merge.sql b/src/exchangedb/exchange_do_purse_merge.sql index 946fd7e97..25b752fcd 100644 --- a/src/exchangedb/exchange_do_purse_merge.sql +++ b/src/exchangedb/exchange_do_purse_merge.sql @@ -39,7 +39,7 @@ DECLARE DECLARE rval RECORD; DECLARE - reserve RECORD; + reserve_bal RECORD; DECLARE balance taler_amount; BEGIN @@ -64,7 +64,7 @@ ELSE partner_serial_id INTO my_partner_serial_id - FROM exchange.partners + FROM partners WHERE partner_base_url=in_partner_url AND start_date <= in_merge_timestamp AND end_date > in_merge_timestamp; @@ -204,28 +204,28 @@ ELSE my_amount.val = my_amount.val + my_amount.frac / 100000000; my_amount.frac = my_amount.frac % 100000000; - SELECT * - INTO reserve - FROM exchange.reserves - WHERE reserve_pub=in_reserve_pub; + SELECT current_balance + INTO reserve_bal + FROM reserves + WHERE reserve_pub=in_reserve_pub; - balance = reserve.current_balance; - balance.frac=balance.frac+my_amount.frac - - CASE - WHEN balance.frac + my_amount.frac >= 100000000 - THEN 100000000 - ELSE 0 - END; + balance = reserve_bal.current_balance; balance.val=balance.val+my_amount.val + CASE WHEN balance.frac + my_amount.frac >= 100000000 THEN 1 ELSE 0 END; + balance.frac=balance.frac+my_amount.frac + - CASE + WHEN balance.frac + my_amount.frac >= 100000000 + THEN 100000000 + ELSE 0 + END; - UPDATE exchange.reserves - SET current_balance=balance - WHERE reserve_pub=in_reserve_pub; + UPDATE reserves + SET current_balance=balance + WHERE reserve_pub=in_reserve_pub; END IF; diff --git a/src/exchangedb/exchange_do_reserves_in_insert.sql b/src/exchangedb/exchange_do_reserves_in_insert.sql index 1be06f063..93d4bb1d4 100644 --- a/src/exchangedb/exchange_do_reserves_in_insert.sql +++ b/src/exchangedb/exchange_do_reserves_in_insert.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2023 Taler Systems SA +-- Copyright (C) 2014--2024 Taler Systems SA -- -- TALER is free software; you can redistribute it and/or modify it under the -- terms of the GNU General Public License as published by the Free Software @@ -15,7 +15,8 @@ -- -CREATE OR REPLACE FUNCTION exchange_do_array_reserves_insert( +DROP FUNCTION IF EXISTS exchange_do_array_reserves_insert; +CREATE FUNCTION exchange_do_array_reserves_insert( IN in_gc_date INT8, IN in_reserve_expiration INT8, IN ina_reserve_pub BYTEA[], @@ -24,6 +25,7 @@ CREATE OR REPLACE FUNCTION exchange_do_array_reserves_insert( IN ina_exchange_account_name TEXT[], IN ina_execution_date INT8[], IN ina_wire_source_h_payto BYTEA[], + IN ina_h_normalized_payto BYTEA[], IN ina_payto_uri TEXT[], IN ina_notify TEXT[]) RETURNS SETOF exchange_do_array_reserve_insert_return_type @@ -40,6 +42,7 @@ DECLARE ini_exchange_account_name TEXT; ini_execution_date INT8; ini_wire_source_h_payto BYTEA; + ini_h_normalized_payto BYTEA; ini_payto_uri TEXT; ini_notify TEXT; BEGIN @@ -52,6 +55,7 @@ BEGIN ini_exchange_account_name = ina_exchange_account_name[i]; ini_execution_date = ina_execution_date[i]; ini_wire_source_h_payto = ina_wire_source_h_payto[i]; + ini_h_normalized_payto = ina_h_normalized_payto[i]; ini_payto_uri = ina_payto_uri[i]; ini_notify = ina_notify[i]; @@ -59,9 +63,11 @@ BEGIN INSERT INTO wire_targets (wire_target_h_payto + ,h_normalized_payto ,payto_uri ) VALUES ( ini_wire_source_h_payto + ,ini_h_normalized_payto ,ini_payto_uri ) ON CONFLICT DO NOTHING; diff --git a/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql b/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql index 414ac51ff..4d9fa79b0 100644 --- a/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql +++ b/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2022 Taler Systems SA +-- Copyright (C) 2014--2024 Taler Systems SA -- -- TALER is free software; you can redistribute it and/or modify it under the -- terms of the GNU General Public License as published by the Free Software @@ -17,10 +17,11 @@ DROP FUNCTION IF EXISTS exchange_do_trigger_kyc_rule_for_account; CREATE FUNCTION exchange_do_trigger_kyc_rule_for_account( - IN in_h_payto BYTEA, - IN in_account_pub BYTEA, -- can be NULL + IN in_h_normalized_payto BYTEA, + IN in_account_pub BYTEA, -- can be NULL, if given, should be SET IN in_merchant_pub BYTEA, -- can be NULL IN in_payto_uri TEXT, -- can be NULL + IN in_h_full_payto BYTEA, IN in_now INT8, IN in_jmeasures TEXT, IN in_display_priority INT4, @@ -36,7 +37,7 @@ DECLARE my_reserve_pub BYTEA; BEGIN -- Note: in_payto_uri is allowed to be NULL *if* --- in_h_payto is already in wire_targets +-- in_h_normalized_payto is already in wire_targets SELECT @@ -45,24 +46,26 @@ SELECT INTO my_rec FROM wire_targets - WHERE wire_target_h_payto=in_h_payto; + WHERE h_normalized_payto=in_h_normalized_payto; IF FOUND THEN -- Extract details, determine if KYC auth matches. my_access_token = my_rec.access_token; my_account_pub = my_rec.target_pub; - out_bad_kyc_auth = COALESCE ((my_account_pub = in_merchant_pub), TRUE); + out_bad_kyc_auth = COALESCE ((my_account_pub != in_merchant_pub), TRUE); ELSE -- No constraint on merchant_pub, just create -- the wire_target. INSERT INTO wire_targets (payto_uri ,wire_target_h_payto + ,h_normalized_payto ,target_pub) VALUES (in_payto_uri - ,in_h_payto + ,in_h_full_payto + ,in_h_normalized_payto ,in_account_pub) RETURNING access_token @@ -72,22 +75,22 @@ END IF; IF out_bad_kyc_auth THEN - -- Check most recent reserve_in wire transfer, we also - -- allow that reserve public key for authentication! - SELECT reserve_pub - INTO my_reserve_pub - FROM reserves_in - WHERE wire_source_h_payto=in_h_payto - ORDER BY execution_date DESC - LIMIT 1; + -- Check reserve_in wire transfers, we also + -- allow those reserve public keys for authentication! + PERFORM FROM reserves_in + WHERE wire_source_h_payto IN ( + SELECT wire_target_h_payto + FROM wire_targets + WHERE h_normalized_payto=in_h_normalized_payto + ) + AND reserve_pub = in_merchant_pub + ORDER BY execution_date DESC; IF FOUND THEN - IF in_merchant_pub = my_reserve_pub - THEN - out_bad_kyc_auth = FALSE; - END IF; + out_bad_kyc_auth = FALSE; END IF; END IF; + -- First check if a perfectly equivalent legi measure -- already exists, to avoid creating tons of duplicates. UPDATE legitimization_measures @@ -114,6 +117,13 @@ THEN legitimization_measure_serial_id INTO out_legitimization_measure_serial_id; + + -- mark all other active measures finished! + UPDATE legitimization_measures + SET is_finished=TRUE + WHERE access_token=my_access_token + AND NOT is_finished + AND legitimization_measure_serial_id != out_legitimization_measure_serial_id; END IF; EXECUTE FORMAT ( diff --git a/src/exchangedb/exchangedb_accounts.c b/src/exchangedb/exchangedb_accounts.c index 3f0e47afb..615433957 100644 --- a/src/exchangedb/exchangedb_accounts.c +++ b/src/exchangedb/exchangedb_accounts.c @@ -101,17 +101,18 @@ TALER_EXCHANGEDB_find_account_by_method (const char *method) const struct TALER_EXCHANGEDB_AccountInfo * -TALER_EXCHANGEDB_find_account_by_payto_uri (const char *url) +TALER_EXCHANGEDB_find_account_by_payto_uri ( + const struct TALER_FullPayto url) { char *method; const struct TALER_EXCHANGEDB_AccountInfo *ai; - method = TALER_payto_get_method (url); + method = TALER_payto_get_method (url.full_payto); if (NULL == method) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid payto:// URL `%s'\n", - url); + url.full_payto); return NULL; } ai = TALER_EXCHANGEDB_find_account_by_method (method); diff --git a/src/exchangedb/exchangedb_plugin.c b/src/exchangedb/exchangedb_plugin.c index 68a916b4e..747a2ad1b 100644 --- a/src/exchangedb/exchangedb_plugin.c +++ b/src/exchangedb/exchangedb_plugin.c @@ -25,7 +25,8 @@ struct TALER_EXCHANGEDB_Plugin * -TALER_EXCHANGEDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) +TALER_EXCHANGEDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg, + bool skip_preflight) { char *plugin_name; char *lib_name; @@ -52,6 +53,15 @@ TALER_EXCHANGEDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) plugin->library_name = lib_name; else GNUNET_free (lib_name); + if ( (! skip_preflight) && + (GNUNET_OK != + plugin->preflight (plugin->cls)) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Database not ready. Try running taler-exchange-dbinit!\n"); + TALER_EXCHANGEDB_plugin_unload (plugin); + return NULL; + } return plugin; } diff --git a/src/exchangedb/perf_deposits_get_ready.c b/src/exchangedb/perf_deposits_get_ready.c index 1cb8c595a..316f45e6c 100644 --- a/src/exchangedb/perf_deposits_get_ready.c +++ b/src/exchangedb/perf_deposits_get_ready.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2023 Taler Systems SA + Copyright (C) 2014-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -216,7 +216,8 @@ run (void *cls) struct TALER_EXCHANGEDB_CoinDepositInformation); if (NULL == - (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (plugin = TALER_EXCHANGEDB_plugin_load (cfg, + true))) { GNUNET_break (0); result = 77; @@ -354,8 +355,8 @@ run (void *cls) depos[i].amount_with_fee = value; bd.refund_deadline = deadline; bd.wire_deadline = deadline; - bd.receiver_wire_account = - "payto://iban/DE67830654080004822650?receiver-name=Test"; + bd.receiver_wire_account.full_payto = + (char *) "payto://iban/DE67830654080004822650?receiver-name=Test"; TALER_merchant_wire_signature_hash ( bd.receiver_wire_account, &bd.wire_salt, @@ -448,7 +449,7 @@ run (void *cls) struct GNUNET_TIME_Absolute time; struct GNUNET_TIME_Relative duration; struct TALER_MerchantPublicKeyP merchant_pub; - char *payto_uri; + struct TALER_FullPayto payto_uri; enum GNUNET_DB_QueryStatus qs; time = GNUNET_TIME_absolute_get (); @@ -466,6 +467,7 @@ run (void *cls) duration.rel_value_us); GNUNET_assert (sqrs + duration_sq >= sqrs); sqrs += duration_sq; + GNUNET_free (payto_uri.full_payto); } /* evaluation of performance */ diff --git a/src/exchangedb/perf_get_link_data.c b/src/exchangedb/perf_get_link_data.c index f2c612e16..4e00d0a0b 100644 --- a/src/exchangedb/perf_get_link_data.c +++ b/src/exchangedb/perf_get_link_data.c @@ -225,7 +225,8 @@ run (void *cls) struct TALER_EXCHANGEDB_Refresh); if (NULL == - (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (plugin = TALER_EXCHANGEDB_plugin_load (cfg, + true))) { GNUNET_break (0); result = 77; diff --git a/src/exchangedb/perf_reserves_in_insert.c b/src/exchangedb/perf_reserves_in_insert.c index 09c4a43c5..6e3837fc7 100644 --- a/src/exchangedb/perf_reserves_in_insert.c +++ b/src/exchangedb/perf_reserves_in_insert.c @@ -33,24 +33,25 @@ static int result; * Report line of error if @a cond is true, and jump to label "drop". */ #define FAILIF(cond) \ - do { \ - if (! (cond)) {break;} \ - GNUNET_break (0); \ - goto drop; \ - } while (0) + do { \ + if (! (cond)) {break;} \ + GNUNET_break (0); \ + goto drop; \ + } while (0) /** * Initializes @a ptr with random data. */ #define RND_BLK(ptr) \ - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr)) + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (* \ + ptr)) /** * Initializes @a ptr with zeros. */ #define ZR_BLK(ptr) \ - memset (ptr, 0, sizeof (*ptr)) + memset (ptr, 0, sizeof (*ptr)) /** * How many rounds do we average over? @@ -85,7 +86,8 @@ run (void *cls) unsigned long long sqrs[sizeof (batches) / sizeof(*batches)]; if (NULL == - (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (plugin = TALER_EXCHANGEDB_plugin_load (cfg, + true))) { GNUNET_break (0); result = 77; @@ -123,7 +125,9 @@ run (void *cls) now = GNUNET_TIME_absolute_get (); ts = GNUNET_TIME_timestamp_get (); { - const char *sndr = "payto://x-taler-bank/localhost:8080/1"; + struct TALER_FullPayto sndr = { + .full_payto = (char *) "payto://x-taler-bank/localhost:8080/1" + }; struct TALER_ReservePublicKeyP reserve_pubs[lcm]; struct TALER_EXCHANGEDB_ReserveInInfo reserves[lcm]; enum GNUNET_DB_QueryStatus results[lcm]; diff --git a/src/exchangedb/perf_select_refunds_by_coin.c b/src/exchangedb/perf_select_refunds_by_coin.c index 6b9592919..fc22652b6 100644 --- a/src/exchangedb/perf_select_refunds_by_coin.c +++ b/src/exchangedb/perf_select_refunds_by_coin.c @@ -240,7 +240,8 @@ run (void *cls) ZR_BLK (&cbc); if (NULL == - (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (plugin = TALER_EXCHANGEDB_plugin_load (cfg, + true))) { GNUNET_break (0); result = 77; @@ -358,8 +359,8 @@ run (void *cls) .wallet_timestamp = ts, .refund_deadline = deadline, .wire_deadline = deadline, - .receiver_wire_account - = "payto://iban/DE67830654080004822650?receiver-name=Test" + .receiver_wire_account.full_payto + = (char *) "payto://iban/DE67830654080004822650?receiver-name=Test" }; if (i >= ROUNDS) diff --git a/src/exchangedb/pg_aggregate.c b/src/exchangedb/pg_aggregate.c index ba03e4a9c..da4a7f346 100644 --- a/src/exchangedb/pg_aggregate.c +++ b/src/exchangedb/pg_aggregate.c @@ -31,7 +31,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_aggregate ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_WireTransferIdentifierRawP *wtid, struct TALER_Amount *total) diff --git a/src/exchangedb/pg_aggregate.h b/src/exchangedb/pg_aggregate.h index 1f986ef9e..66e77c2ba 100644 --- a/src/exchangedb/pg_aggregate.h +++ b/src/exchangedb/pg_aggregate.h @@ -38,7 +38,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_aggregate ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_WireTransferIdentifierRawP *wtid, struct TALER_Amount *total); diff --git a/src/exchangedb/pg_create_aggregation_transient.c b/src/exchangedb/pg_create_aggregation_transient.c index 4ab537d3a..2d864ce70 100644 --- a/src/exchangedb/pg_create_aggregation_transient.c +++ b/src/exchangedb/pg_create_aggregation_transient.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_create_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const char *exchange_account_section, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_WireTransferIdentifierRawP *wtid, diff --git a/src/exchangedb/pg_create_aggregation_transient.h b/src/exchangedb/pg_create_aggregation_transient.h index 2f0a348b2..22e52f882 100644 --- a/src/exchangedb/pg_create_aggregation_transient.h +++ b/src/exchangedb/pg_create_aggregation_transient.h @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_create_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const char *exchange_account_section, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_WireTransferIdentifierRawP *wtid, diff --git a/src/exchangedb/pg_create_tables.c b/src/exchangedb/pg_create_tables.c index 8788f0018..03a8db756 100644 --- a/src/exchangedb/pg_create_tables.c +++ b/src/exchangedb/pg_create_tables.c @@ -60,6 +60,7 @@ TEH_PG_create_tables (void *cls, struct GNUNET_PQ_Context *tconn; tconn = pg->conn; + pg->prep_gen++; pg->conn = conn; PREPARE (pg, "create_tables", @@ -71,7 +72,10 @@ TEH_PG_create_tables (void *cls, GNUNET_PQ_eval_prepared_non_select (conn, "create_tables", params)) + { + GNUNET_break (0); ret = GNUNET_SYSERR; + } } GNUNET_PQ_disconnect (conn); return ret; diff --git a/src/exchangedb/pg_delete_aggregation_transient.c b/src/exchangedb/pg_delete_aggregation_transient.c index 63c5c0a23..6ac350884 100644 --- a/src/exchangedb/pg_delete_aggregation_transient.c +++ b/src/exchangedb/pg_delete_aggregation_transient.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_delete_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_WireTransferIdentifierRawP *wtid) { struct PostgresClosure *pg = cls; diff --git a/src/exchangedb/pg_delete_aggregation_transient.h b/src/exchangedb/pg_delete_aggregation_transient.h index f74b0179e..dfd666507 100644 --- a/src/exchangedb/pg_delete_aggregation_transient.h +++ b/src/exchangedb/pg_delete_aggregation_transient.h @@ -37,7 +37,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_delete_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_WireTransferIdentifierRawP *wtid); #endif diff --git a/src/exchangedb/pg_do_check_deposit_idempotent.c b/src/exchangedb/pg_do_check_deposit_idempotent.c index 8a15200e0..21e56660b 100644 --- a/src/exchangedb/pg_do_check_deposit_idempotent.c +++ b/src/exchangedb/pg_do_check_deposit_idempotent.c @@ -39,6 +39,7 @@ TEH_PG_do_check_deposit_idempotent ( const struct TALER_CoinSpendPublicKeyP *coin_pubs[GNUNET_NZL (bd->num_cdis)]; const struct TALER_CoinSpendSignatureP *coin_sigs[GNUNET_NZL (bd->num_cdis)]; struct TALER_Amount amounts_with_fee[GNUNET_NZL (bd->num_cdis)]; + struct TALER_NormalizedPaytoHashP h_normalized_payto; struct GNUNET_PQ_QueryParam params[] = { /* data for batch_deposits */ GNUNET_PQ_query_param_uint64 (&deposit_shard), @@ -57,8 +58,6 @@ TEH_PG_do_check_deposit_idempotent ( ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_uint64 (&bd->policy_details_serial_id), GNUNET_PQ_query_param_bool (bd->policy_blocked), - /* to create entry in wire_targets */ - GNUNET_PQ_query_param_string (bd->receiver_wire_account), /* arrays for coin_deposits */ GNUNET_PQ_query_param_array_ptrs_auto_from_type (bd->num_cdis, coin_pubs, @@ -83,6 +82,8 @@ TEH_PG_do_check_deposit_idempotent ( }; enum GNUNET_DB_QueryStatus qs; + TALER_full_payto_normalize_and_hash (bd->receiver_wire_account, + &h_normalized_payto); for (unsigned int i = 0; i < bd->num_cdis; i++) { const struct TALER_EXCHANGEDB_CoinDepositInformation *cdi @@ -102,7 +103,7 @@ TEH_PG_do_check_deposit_idempotent ( " out_exchange_timestamp AS exchange_timestamp" ",out_is_idempotent AS is_idempotent" " FROM exchange_do_check_deposit_idempotent" - " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16);"); + " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15);"); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "call_check_deposit_idempotent", params, diff --git a/src/exchangedb/pg_do_deposit.c b/src/exchangedb/pg_do_deposit.c index 0ba45b628..da8ddf793 100644 --- a/src/exchangedb/pg_do_deposit.c +++ b/src/exchangedb/pg_do_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022-2023 Taler Systems SA + Copyright (C) 2022-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -41,10 +41,14 @@ TEH_PG_do_deposit ( const struct TALER_CoinSpendPublicKeyP *coin_pubs[GNUNET_NZL (bd->num_cdis)]; const struct TALER_CoinSpendSignatureP *coin_sigs[GNUNET_NZL (bd->num_cdis)]; struct TALER_Amount amounts_with_fee[GNUNET_NZL (bd->num_cdis)]; + struct TALER_NormalizedPaytoHashP h_normalized_payto; struct GNUNET_PQ_QueryParam params[] = { /* data for batch_deposits */ GNUNET_PQ_query_param_uint64 (&deposit_shard), GNUNET_PQ_query_param_auto_from_type (&bd->merchant_pub), + GNUNET_is_zero (&bd->merchant_sig) + ? GNUNET_PQ_query_param_null () + : GNUNET_PQ_query_param_auto_from_type (&bd->merchant_sig), GNUNET_PQ_query_param_timestamp (&bd->wallet_timestamp), GNUNET_PQ_query_param_timestamp (exchange_timestamp), GNUNET_PQ_query_param_timestamp (&bd->refund_deadline), @@ -55,12 +59,13 @@ TEH_PG_do_deposit ( : GNUNET_PQ_query_param_auto_from_type (&bd->wallet_data_hash), GNUNET_PQ_query_param_auto_from_type (&bd->wire_salt), GNUNET_PQ_query_param_auto_from_type (&bd->wire_target_h_payto), + GNUNET_PQ_query_param_auto_from_type (&h_normalized_payto), (0 == bd->policy_details_serial_id) ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_uint64 (&bd->policy_details_serial_id), GNUNET_PQ_query_param_bool (bd->policy_blocked), /* to create entry in wire_targets */ - GNUNET_PQ_query_param_string (bd->receiver_wire_account), + GNUNET_PQ_query_param_string (bd->receiver_wire_account.full_payto), /* arrays for coin_deposits */ GNUNET_PQ_query_param_array_ptrs_auto_from_type (bd->num_cdis, coin_pubs, @@ -89,6 +94,8 @@ TEH_PG_do_deposit ( }; enum GNUNET_DB_QueryStatus qs; + TALER_full_payto_normalize_and_hash (bd->receiver_wire_account, + &h_normalized_payto); for (unsigned int i = 0; i < bd->num_cdis; i++) { const struct TALER_EXCHANGEDB_CoinDepositInformation *cdi @@ -109,7 +116,8 @@ TEH_PG_do_deposit ( ",out_insufficient_balance_coin_index AS insufficient_balance_coin_index" ",out_conflict AS conflicted" " FROM exchange_do_deposit" - " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16);"); + " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18);") + ; qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "call_deposit", params, diff --git a/src/exchangedb/pg_do_purse_merge.c b/src/exchangedb/pg_do_purse_merge.c index 5a174ed02..4bf785cc4 100644 --- a/src/exchangedb/pg_do_purse_merge.c +++ b/src/exchangedb/pg_do_purse_merge.c @@ -40,7 +40,7 @@ TEH_PG_do_purse_merge ( bool *in_conflict) { struct PostgresClosure *pg = cls; - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; struct GNUNET_TIME_Timestamp expiration = GNUNET_TIME_relative_to_timestamp (pg->legal_reserve_expiration_time); struct GNUNET_PQ_QueryParam params[] = { @@ -67,13 +67,13 @@ TEH_PG_do_purse_merge ( }; { - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; payto_uri = TALER_reserve_make_payto (pg->exchange_url, reserve_pub); - TALER_payto_hash (payto_uri, - &h_payto); - GNUNET_free (payto_uri); + TALER_normalized_payto_hash (payto_uri, + &h_payto); + GNUNET_free (payto_uri.normalized_payto); } PREPARE (pg, "call_purse_merge", diff --git a/src/exchangedb/pg_do_reserve_purse.c b/src/exchangedb/pg_do_reserve_purse.c index e03e23fec..6c887745f 100644 --- a/src/exchangedb/pg_do_reserve_purse.c +++ b/src/exchangedb/pg_do_reserve_purse.c @@ -24,6 +24,8 @@ #include "taler_pq_lib.h" #include "pg_do_reserve_purse.h" #include "pg_helper.h" + + /** * Function called insert request to merge a purse into a reserve by the * respective purse merge key. The purse must not have been merged into a @@ -56,7 +58,7 @@ TEH_PG_do_reserve_purse ( { struct PostgresClosure *pg = cls; struct TALER_Amount zero_fee; - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; struct GNUNET_TIME_Timestamp reserve_expiration = GNUNET_TIME_absolute_to_timestamp ( GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), @@ -93,18 +95,17 @@ TEH_PG_do_reserve_purse ( }; { - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; payto_uri = TALER_reserve_make_payto (pg->exchange_url, reserve_pub); - TALER_payto_hash (payto_uri, - &h_payto); - GNUNET_free (payto_uri); + TALER_normalized_payto_hash (payto_uri, + &h_payto); + GNUNET_free (payto_uri.normalized_payto); } GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (pg->currency, &zero_fee)); - /* Used in #postgres_do_reserve_purse() */ PREPARE (pg, "call_reserve_purse", "SELECT" diff --git a/src/exchangedb/pg_drain_kyc_alert.c b/src/exchangedb/pg_drain_kyc_alert.c index 4388334e9..ada2dc1a3 100644 --- a/src/exchangedb/pg_drain_kyc_alert.c +++ b/src/exchangedb/pg_drain_kyc_alert.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_drain_kyc_alert (void *cls, uint32_t trigger_type, - struct TALER_PaytoHashP *h_payto) + struct TALER_NormalizedPaytoHashP *h_payto) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { diff --git a/src/exchangedb/pg_drain_kyc_alert.h b/src/exchangedb/pg_drain_kyc_alert.h index 7425f472d..4a1b1e0b3 100644 --- a/src/exchangedb/pg_drain_kyc_alert.h +++ b/src/exchangedb/pg_drain_kyc_alert.h @@ -35,6 +35,6 @@ enum GNUNET_DB_QueryStatus TEH_PG_drain_kyc_alert (void *cls, uint32_t trigger_type, - struct TALER_PaytoHashP *h_payto); + struct TALER_NormalizedPaytoHashP *h_payto); #endif diff --git a/src/exchangedb/pg_find_aggregation_transient.c b/src/exchangedb/pg_find_aggregation_transient.c index b931188a8..813b3a81a 100644 --- a/src/exchangedb/pg_find_aggregation_transient.c +++ b/src/exchangedb/pg_find_aggregation_transient.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -72,7 +72,7 @@ get_transients_cb (void *cls, for (unsigned int i = 0; i<num_results; i++) { struct TALER_Amount amount; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_WireTransferIdentifierRawP wtid; struct TALER_MerchantPublicKeyP merchant_pub; struct GNUNET_PQ_ResultSpec rs[] = { @@ -81,7 +81,7 @@ get_transients_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("wtid_raw", &wtid), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &amount), GNUNET_PQ_result_spec_end @@ -102,7 +102,7 @@ get_transients_cb (void *cls, &wtid, &merchant_pub, &amount); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); if (! cont) break; } @@ -112,7 +112,7 @@ get_transients_cb (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_find_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_TransientAggregationCallback cb, void *cb_cls) { @@ -132,13 +132,14 @@ TEH_PG_find_aggregation_transient ( PREPARE (pg, "find_transient_aggregations", "SELECT" - " amount" - " ,wtid_raw" - " ,merchant_pub" - " ,payto_uri" - " FROM aggregation_transient atr" - " JOIN wire_targets wt USING (wire_target_h_payto)" - " WHERE atr.wire_target_h_payto=$1;"); + " atr.amount" + " ,atr.wtid_raw" + " ,atr.merchant_pub" + " ,wt.payto_uri" + " FROM wire_targets wt" + " JOIN aggregation_transient atr" + " USING (wire_target_h_payto)" + " WHERE wt.h_normalized_payto=$1;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "find_transient_aggregations", params, diff --git a/src/exchangedb/pg_find_aggregation_transient.h b/src/exchangedb/pg_find_aggregation_transient.h index c7ba4ea38..2475dec3c 100644 --- a/src/exchangedb/pg_find_aggregation_transient.h +++ b/src/exchangedb/pg_find_aggregation_transient.h @@ -36,7 +36,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_find_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_TransientAggregationCallback cb, void *cb_cls); diff --git a/src/exchangedb/pg_get_coin_transactions.c b/src/exchangedb/pg_get_coin_transactions.c index 5a9157dcd..69de91117 100644 --- a/src/exchangedb/pg_get_coin_transactions.c +++ b/src/exchangedb/pg_get_coin_transactions.c @@ -117,7 +117,8 @@ add_coin_deposit (void *cls, GNUNET_PQ_result_spec_auto_from_type ("wire_salt", &deposit->wire_salt), GNUNET_PQ_result_spec_string ("payto_uri", - &deposit->receiver_wire_account), + &deposit->receiver_wire_account.full_payto + ), GNUNET_PQ_result_spec_auto_from_type ("coin_sig", &deposit->csig), GNUNET_PQ_result_spec_uint64 ("coin_deposit_serial_id", @@ -786,7 +787,7 @@ handle_history_entry (void *cls, (int) qs, (unsigned long long) serial_id, table_name); - if (0 >= qs) + if (0 > qs) chc->failed = true; break; } diff --git a/src/exchangedb/pg_get_drain_profit.c b/src/exchangedb/pg_get_drain_profit.c index 75fccefcd..bbfdf9a01 100644 --- a/src/exchangedb/pg_get_drain_profit.c +++ b/src/exchangedb/pg_get_drain_profit.c @@ -32,7 +32,7 @@ TEH_PG_get_drain_profit ( const struct TALER_WireTransferIdentifierRawP *wtid, uint64_t *serial, char **account_section, - char **payto_uri, + struct TALER_FullPayto *payto_uri, struct GNUNET_TIME_Timestamp *request_timestamp, struct TALER_Amount *amount, struct TALER_MasterSignatureP *master_sig) @@ -48,7 +48,7 @@ TEH_PG_get_drain_profit ( GNUNET_PQ_result_spec_string ("account_section", account_section), GNUNET_PQ_result_spec_string ("payto_uri", - payto_uri), + &payto_uri->full_payto), GNUNET_PQ_result_spec_timestamp ("trigger_date", request_timestamp), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", diff --git a/src/exchangedb/pg_get_drain_profit.h b/src/exchangedb/pg_get_drain_profit.h index dd05d8afd..37595815d 100644 --- a/src/exchangedb/pg_get_drain_profit.h +++ b/src/exchangedb/pg_get_drain_profit.h @@ -44,7 +44,7 @@ TEH_PG_get_drain_profit ( const struct TALER_WireTransferIdentifierRawP *wtid, uint64_t *serial, char **account_section, - char **payto_uri, + struct TALER_FullPayto *payto_uri, struct GNUNET_TIME_Timestamp *request_timestamp, struct TALER_Amount *amount, struct TALER_MasterSignatureP *master_sig); diff --git a/src/exchangedb/pg_get_expired_reserves.c b/src/exchangedb/pg_get_expired_reserves.c index be9ece98a..2bb4da5fc 100644 --- a/src/exchangedb/pg_get_expired_reserves.c +++ b/src/exchangedb/pg_get_expired_reserves.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -68,20 +68,19 @@ reserve_expired_cb (void *cls, { struct ExpiredReserveContext *erc = cls; struct PostgresClosure *pg = erc->pg; - enum GNUNET_GenericReturnValue ret; + enum GNUNET_GenericReturnValue ret = GNUNET_OK; - ret = GNUNET_OK; for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_TIME_Timestamp exp_date; - char *account_details; + struct TALER_FullPayto account_details; struct TALER_ReservePublicKeyP reserve_pub; struct TALER_Amount remaining_balance; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_timestamp ("expiration_date", &exp_date), GNUNET_PQ_result_spec_string ("account_details", - &account_details), + &account_details.full_payto), GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &reserve_pub), TALER_PQ_result_spec_amount ("current_balance", @@ -114,10 +113,11 @@ reserve_expired_cb (void *cls, enum GNUNET_DB_QueryStatus -TEH_PG_get_expired_reserves (void *cls, - struct GNUNET_TIME_Timestamp now, - TALER_EXCHANGEDB_ReserveExpiredCallback rec, - void *rec_cls) +TEH_PG_get_expired_reserves ( + void *cls, + struct GNUNET_TIME_Timestamp now, + TALER_EXCHANGEDB_ReserveExpiredCallback rec, + void *rec_cls) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -135,27 +135,26 @@ TEH_PG_get_expired_reserves (void *cls, PREPARE (pg, "get_expired_reserves", "WITH ed AS MATERIALIZED ( " - " SELECT * " - " FROM reserves " + " SELECT expiration_date" + " ,wire_source_h_payto" + " ,current_balance" + " ,r.reserve_pub" + " FROM reserves r" + " JOIN reserves_in" + " USING (reserve_pub)" " WHERE expiration_date <= $1 " " AND ((current_balance).val != 0 OR (current_balance).frac != 0) " " ORDER BY expiration_date ASC " " LIMIT 1 " ") " - "SELECT " - " ed.expiration_date " - " ,payto_uri AS account_details " - " ,ed.reserve_pub " - " ,current_balance " - "FROM ( " - " SELECT " - " * " - " FROM reserves_in " - " WHERE reserve_pub = ( " - " SELECT reserve_pub FROM ed) " - " ) ri " - "JOIN wire_targets wt ON (ri.wire_source_h_payto = wt.wire_target_h_payto) " - "JOIN ed ON (ri.reserve_pub = ed.reserve_pub);"); + "SELECT" + " wt.payto_uri AS account_details" + " ,ed.expiration_date" + " ,ed.reserve_pub" + " ,ed.current_balance" + " FROM wire_targets wt" + " JOIN ed" + " ON (ed.wire_source_h_payto=wt.wire_target_h_payto);"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "get_expired_reserves", params, diff --git a/src/exchangedb/pg_get_kyc_rules.c b/src/exchangedb/pg_get_kyc_rules.c index 8f7967273..db07f98c1 100644 --- a/src/exchangedb/pg_get_kyc_rules.c +++ b/src/exchangedb/pg_get_kyc_rules.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_get_kyc_rules ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, bool *no_account_pub, union TALER_AccountPublicKeyP *account_pub, bool *no_reserve_pub, @@ -79,8 +79,8 @@ TEH_PG_get_kyc_rules ( " LEFT JOIN reserves_in ri" " ON (ri.wire_source_h_payto = wt.wire_target_h_payto)" " LEFT JOIN legitimization_outcomes lo" - " ON (lo.h_payto = wt.wire_target_h_payto)" - " WHERE wt.wire_target_h_payto=$1" + " ON (lo.h_payto = wt.h_normalized_payto)" + " WHERE wt.h_normalized_payto=$1" " AND COALESCE(lo.expiration_time >= $2, TRUE)" " AND COALESCE(lo.is_active, TRUE)" " ORDER BY ri.execution_date DESC" diff --git a/src/exchangedb/pg_get_kyc_rules.h b/src/exchangedb/pg_get_kyc_rules.h index 9473fdc2c..b56fad24e 100644 --- a/src/exchangedb/pg_get_kyc_rules.h +++ b/src/exchangedb/pg_get_kyc_rules.h @@ -45,7 +45,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_get_kyc_rules ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, bool *no_account_pub, union TALER_AccountPublicKeyP *account_pub, bool *no_reserve_pub, diff --git a/src/exchangedb/pg_get_pending_kyc_requirement_process.c b/src/exchangedb/pg_get_pending_kyc_requirement_process.c index ddb353e1e..925364c4b 100644 --- a/src/exchangedb/pg_get_pending_kyc_requirement_process.c +++ b/src/exchangedb/pg_get_pending_kyc_requirement_process.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_get_pending_kyc_requirement_process ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, char **redirect_url) { diff --git a/src/exchangedb/pg_get_pending_kyc_requirement_process.h b/src/exchangedb/pg_get_pending_kyc_requirement_process.h index d2561a6da..aad49b0f0 100644 --- a/src/exchangedb/pg_get_pending_kyc_requirement_process.h +++ b/src/exchangedb/pg_get_pending_kyc_requirement_process.h @@ -38,7 +38,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_get_pending_kyc_requirement_process ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, char **redirect_url); diff --git a/src/exchangedb/pg_get_ready_deposit.c b/src/exchangedb/pg_get_ready_deposit.c index d8344faf1..18dc02b58 100644 --- a/src/exchangedb/pg_get_ready_deposit.c +++ b/src/exchangedb/pg_get_ready_deposit.c @@ -31,7 +31,7 @@ TEH_PG_get_ready_deposit (void *cls, uint64_t start_shard_row, uint64_t end_shard_row, struct TALER_MerchantPublicKeyP *merchant_pub, - char **payto_uri) + struct TALER_FullPayto *payto_uri) { struct PostgresClosure *pg = cls; struct GNUNET_TIME_Absolute now @@ -46,7 +46,7 @@ TEH_PG_get_ready_deposit (void *cls, GNUNET_PQ_result_spec_auto_from_type ("merchant_pub", merchant_pub), GNUNET_PQ_result_spec_string ("payto_uri", - payto_uri), + &payto_uri->full_payto), GNUNET_PQ_result_spec_end }; const char *query = "deposits_get_ready"; diff --git a/src/exchangedb/pg_get_ready_deposit.h b/src/exchangedb/pg_get_ready_deposit.h index b1dd7a968..7e9714ce8 100644 --- a/src/exchangedb/pg_get_ready_deposit.h +++ b/src/exchangedb/pg_get_ready_deposit.h @@ -24,6 +24,8 @@ #include "taler_util.h" #include "taler_json_lib.h" #include "taler_exchangedb_plugin.h" + + /** * Obtain information about deposits that are ready to be executed. Such * deposits must not be marked as "done", the execution time must be @@ -41,6 +43,6 @@ TEH_PG_get_ready_deposit (void *cls, uint64_t start_shard_row, uint64_t end_shard_row, struct TALER_MerchantPublicKeyP *merchant_pub, - char **payto_uri); + struct TALER_FullPayto *payto_uri); #endif diff --git a/src/exchangedb/pg_get_reserve_history.c b/src/exchangedb/pg_get_reserve_history.c index 1f1ca95b5..331d016aa 100644 --- a/src/exchangedb/pg_get_reserve_history.c +++ b/src/exchangedb/pg_get_reserve_history.c @@ -138,7 +138,7 @@ add_bank_to_exchange (void *cls, GNUNET_PQ_result_spec_timestamp ("execution_date", &bt->execution_date), GNUNET_PQ_result_spec_string ("sender_account_details", - &bt->sender_account_details), + &bt->sender_account_details.full_payto), GNUNET_PQ_result_spec_end }; @@ -321,7 +321,8 @@ add_exchange_to_bank (void *cls, GNUNET_PQ_result_spec_timestamp ("execution_date", &closing->execution_date), GNUNET_PQ_result_spec_string ("receiver_account", - &closing->receiver_account_details), + &closing->receiver_account_details. + full_payto), GNUNET_PQ_result_spec_auto_from_type ("wtid", &closing->wtid), GNUNET_PQ_result_spec_end @@ -517,12 +518,12 @@ add_close_requests (void *cls, crq = GNUNET_new (struct TALER_EXCHANGEDB_CloseRequest); { - char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_timestamp ("close_timestamp", &crq->request_timestamp), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_auto_from_type ("reserve_sig", &crq->reserve_sig), GNUNET_PQ_result_spec_end @@ -538,9 +539,9 @@ add_close_requests (void *cls, rhc->failed = true; return; } - TALER_payto_hash (payto_uri, - &crq->target_account_h_payto); - GNUNET_free (payto_uri); + TALER_full_payto_hash (payto_uri, + &crq->target_account_h_payto); + GNUNET_free (payto_uri.full_payto); } crq->reserve_pub = *rhc->reserve_pub; tail = append_rh (rhc); diff --git a/src/exchangedb/pg_get_unfinished_close_requests.c b/src/exchangedb/pg_get_unfinished_close_requests.c index 990e8e00e..2881ceaf1 100644 --- a/src/exchangedb/pg_get_unfinished_close_requests.c +++ b/src/exchangedb/pg_get_unfinished_close_requests.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -68,13 +68,12 @@ reserve_cb (void *cls, { struct CloseReserveContext *erc = cls; struct PostgresClosure *pg = erc->pg; - enum GNUNET_GenericReturnValue ret; + enum GNUNET_GenericReturnValue ret = GNUNET_OK; - ret = GNUNET_OK; for (unsigned int i = 0; i<num_results; i++) { struct GNUNET_TIME_Timestamp exp_date; - char *account_details; + struct TALER_FullPayto account_details; struct TALER_ReservePublicKeyP reserve_pub; struct TALER_Amount remaining_balance; uint64_t close_request_row; @@ -82,7 +81,7 @@ reserve_cb (void *cls, GNUNET_PQ_result_spec_timestamp ("expiration_date", &exp_date), GNUNET_PQ_result_spec_string ("account_details", - &account_details), + &account_details.full_payto), GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &reserve_pub), TALER_PQ_RESULT_SPEC_AMOUNT ("close", @@ -137,7 +136,7 @@ TEH_PG_get_unfinished_close_requests ( "get_unfinished_close_requests", "UPDATE close_requests AS rc" " SET done=TRUE" - " WHERE done=FALSE" + " WHERE NOT done" " RETURNING" " reserve_pub" " ,close_request_serial_id" @@ -145,7 +144,8 @@ TEH_PG_get_unfinished_close_requests ( " ,close" " ,(SELECT payto_uri" " FROM reserves_in ri" - " JOIN wire_targets wt ON (ri.wire_source_h_payto = wt.wire_target_h_payto)" + " JOIN wire_targets wt" + " ON (ri.wire_source_h_payto = wt.wire_target_h_payto)" " WHERE ri.reserve_pub=rc.reserve_pub)" " AS account_details;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, diff --git a/src/exchangedb/pg_get_wire_accounts.c b/src/exchangedb/pg_get_wire_accounts.c index 9770be719..d9b6cf645 100644 --- a/src/exchangedb/pg_get_wire_accounts.c +++ b/src/exchangedb/pg_get_wire_accounts.c @@ -65,7 +65,7 @@ get_wire_accounts_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { - char *payto_uri; + struct TALER_FullPayto payto_uri; char *conversion_url = NULL; json_t *debit_restrictions = NULL; json_t *credit_restrictions = NULL; @@ -74,7 +74,7 @@ get_wire_accounts_cb (void *cls, int64_t priority; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_string ("conversion_url", &conversion_url), diff --git a/src/exchangedb/pg_get_wire_hash_for_contract.c b/src/exchangedb/pg_get_wire_hash_for_contract.c index afd659b18..d19baf23a 100644 --- a/src/exchangedb/pg_get_wire_hash_for_contract.c +++ b/src/exchangedb/pg_get_wire_hash_for_contract.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2023 Taler Systems SA + Copyright (C) 2023, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -41,13 +41,13 @@ TEH_PG_get_wire_hash_for_contract ( GNUNET_PQ_query_param_auto_from_type (h_contract_terms), GNUNET_PQ_query_param_end }; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_WireSaltP wire_salt; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("wire_salt", &wire_salt), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_end }; diff --git a/src/exchangedb/pg_have_deposit2.c b/src/exchangedb/pg_have_deposit2.c index e00ad7490..42ec24e81 100644 --- a/src/exchangedb/pg_have_deposit2.c +++ b/src/exchangedb/pg_have_deposit2.c @@ -61,7 +61,7 @@ TEH_PG_have_deposit2 ( GNUNET_PQ_result_spec_auto_from_type ("wire_salt", &deposit2.wire_salt), GNUNET_PQ_result_spec_string ("receiver_wire_account", - &deposit2.receiver_wire_account), + &deposit2.receiver_wire_account.full_payto), GNUNET_PQ_result_spec_end }; enum GNUNET_DB_QueryStatus qs; @@ -101,7 +101,7 @@ TEH_PG_have_deposit2 ( TALER_merchant_wire_signature_hash (deposit2.receiver_wire_account, &deposit2.wire_salt, &h_wire2); - GNUNET_free (deposit2.receiver_wire_account); + GNUNET_free (deposit2.receiver_wire_account.full_payto); /* Now we check that the other information in @a deposit also matches, and if not report inconsistencies. */ if ( (GNUNET_TIME_timestamp_cmp (refund_deadline, diff --git a/src/exchangedb/pg_insert_active_legitimization_measure.c b/src/exchangedb/pg_insert_active_legitimization_measure.c index 0e6757b76..33c702ef4 100644 --- a/src/exchangedb/pg_insert_active_legitimization_measure.c +++ b/src/exchangedb/pg_insert_active_legitimization_measure.c @@ -53,7 +53,7 @@ TEH_PG_insert_active_legitimization_measure ( "SELECT" " out_legitimization_measure_serial_id" " FROM exchange_do_insert_active_legitimization_measure" - "($1, $2);"); + "($1, $2, $3);"); return GNUNET_PQ_eval_prepared_singleton_select ( pg->conn, "do_insert_active_legitimization_measure", diff --git a/src/exchangedb/pg_insert_aml_decision.c b/src/exchangedb/pg_insert_aml_decision.c index 4da711577..7109eaa75 100644 --- a/src/exchangedb/pg_insert_aml_decision.c +++ b/src/exchangedb/pg_insert_aml_decision.c @@ -30,8 +30,8 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_aml_decision ( void *cls, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp decision_time, struct GNUNET_TIME_Timestamp expiration_time, const json_t *properties, @@ -44,7 +44,8 @@ TEH_PG_insert_aml_decision ( const struct TALER_AmlOfficerSignatureP *decider_sig, bool *invalid_officer, bool *unknown_account, - struct GNUNET_TIME_Timestamp *last_date) + struct GNUNET_TIME_Timestamp *last_date, + uint64_t *legitimization_measure_serial_id) { struct PostgresClosure *pg = cls; struct TALER_KycCompletedEventP rep = { @@ -52,26 +53,30 @@ TEH_PG_insert_aml_decision ( .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), .h_payto = *h_payto }; + struct TALER_FullPaytoHashP h_full_payto; char *notify_s = GNUNET_PQ_get_event_notify_channel (&rep.header); struct GNUNET_PQ_QueryParam params[] = { - NULL == payto_uri - ? GNUNET_PQ_query_param_null () - : GNUNET_PQ_query_param_string (payto_uri), + NULL == payto_uri.full_payto + ? GNUNET_PQ_query_param_null () + : GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_auto_from_type (h_payto), + NULL == payto_uri.full_payto + ? GNUNET_PQ_query_param_null () + : GNUNET_PQ_query_param_auto_from_type (&h_full_payto), GNUNET_PQ_query_param_timestamp (&decision_time), GNUNET_PQ_query_param_timestamp (&expiration_time), NULL != properties - ? TALER_PQ_query_param_json (properties) - : GNUNET_PQ_query_param_null (), + ? TALER_PQ_query_param_json (properties) + : GNUNET_PQ_query_param_null (), TALER_PQ_query_param_json (new_rules), GNUNET_PQ_query_param_bool (to_investigate), NULL != new_measure_name - ? GNUNET_PQ_query_param_string (new_measure_name) - : GNUNET_PQ_query_param_null (), + ? GNUNET_PQ_query_param_string (new_measure_name) + : GNUNET_PQ_query_param_null (), NULL != jmeasures - ? TALER_PQ_query_param_json (jmeasures) - : GNUNET_PQ_query_param_null (), + ? TALER_PQ_query_param_json (jmeasures) + : GNUNET_PQ_query_param_null (), GNUNET_PQ_query_param_string (justification), GNUNET_PQ_query_param_auto_from_type (decider_pub), GNUNET_PQ_query_param_auto_from_type (decider_sig), @@ -85,18 +90,24 @@ TEH_PG_insert_aml_decision ( unknown_account), GNUNET_PQ_result_spec_timestamp ("out_last_date", last_date), + GNUNET_PQ_result_spec_uint64 ("out_legitimization_measure_serial_id", + legitimization_measure_serial_id), GNUNET_PQ_result_spec_end }; enum GNUNET_DB_QueryStatus qs; + if (NULL != payto_uri.full_payto) + TALER_full_payto_hash (payto_uri, + &h_full_payto); PREPARE (pg, "do_insert_aml_decision", "SELECT" " out_invalid_officer" ",out_account_unknown" ",out_last_date" + ",out_legitimization_measure_serial_id" " FROM exchange_do_insert_aml_decision" - "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13);"); + "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);"); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "do_insert_aml_decision", params, diff --git a/src/exchangedb/pg_insert_aml_decision.h b/src/exchangedb/pg_insert_aml_decision.h index 15441b4d4..b23958f18 100644 --- a/src/exchangedb/pg_insert_aml_decision.h +++ b/src/exchangedb/pg_insert_aml_decision.h @@ -49,13 +49,15 @@ * @param[out] unknown_account set to TRUE if @a h_payto does not refer to a known account and @a jmeasures was given * @param[out] last_date set to the previous decision time; * the INSERT is not performed if @a last_date is not before @a decision_time + * @param[out] legitimization_measure_serial_id serial ID of the legitimization measures + * of the decision * @return database transaction status */ enum GNUNET_DB_QueryStatus TEH_PG_insert_aml_decision ( void *cls, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp decision_time, struct GNUNET_TIME_Timestamp expiration_time, const json_t *properties, @@ -68,7 +70,8 @@ TEH_PG_insert_aml_decision ( const struct TALER_AmlOfficerSignatureP *decider_sig, bool *invalid_officer, bool *unknown_account, - struct GNUNET_TIME_Timestamp *last_date); + struct GNUNET_TIME_Timestamp *last_date, + uint64_t *legitimization_measure_serial_id); #endif diff --git a/src/exchangedb/pg_insert_close_request.c b/src/exchangedb/pg_insert_close_request.c index b4bc5f4a7..c9d3bdc76 100644 --- a/src/exchangedb/pg_insert_close_request.c +++ b/src/exchangedb/pg_insert_close_request.c @@ -30,7 +30,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_close_request ( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_ReserveSignatureP *reserve_sig, struct GNUNET_TIME_Timestamp request_timestamp, const struct TALER_Amount *balance, @@ -45,7 +45,7 @@ TEH_PG_insert_close_request ( balance), TALER_PQ_query_param_amount (pg->conn, closing_fee), - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_end }; diff --git a/src/exchangedb/pg_insert_close_request.h b/src/exchangedb/pg_insert_close_request.h index c014a10b9..c18d938ed 100644 --- a/src/exchangedb/pg_insert_close_request.h +++ b/src/exchangedb/pg_insert_close_request.h @@ -42,7 +42,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_close_request ( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_ReserveSignatureP *reserve_sig, struct GNUNET_TIME_Timestamp request_timestamp, const struct TALER_Amount *balance, diff --git a/src/exchangedb/pg_insert_drain_profit.c b/src/exchangedb/pg_insert_drain_profit.c index a0de02e9b..0df872d73 100644 --- a/src/exchangedb/pg_insert_drain_profit.c +++ b/src/exchangedb/pg_insert_drain_profit.c @@ -25,12 +25,13 @@ #include "pg_insert_drain_profit.h" #include "pg_helper.h" + enum GNUNET_DB_QueryStatus TEH_PG_insert_drain_profit ( void *cls, const struct TALER_WireTransferIdentifierRawP *wtid, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp request_timestamp, const struct TALER_Amount *amount, const struct TALER_MasterSignatureP *master_sig) @@ -39,7 +40,7 @@ TEH_PG_insert_drain_profit ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (wtid), GNUNET_PQ_query_param_string (account_section), - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_timestamp (&request_timestamp), TALER_PQ_query_param_amount (pg->conn, amount), diff --git a/src/exchangedb/pg_insert_drain_profit.h b/src/exchangedb/pg_insert_drain_profit.h index 90183d850..71ea5b46c 100644 --- a/src/exchangedb/pg_insert_drain_profit.h +++ b/src/exchangedb/pg_insert_drain_profit.h @@ -42,7 +42,7 @@ TEH_PG_insert_drain_profit ( void *cls, const struct TALER_WireTransferIdentifierRawP *wtid, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp request_timestamp, const struct TALER_Amount *amount, const struct TALER_MasterSignatureP *master_sig); diff --git a/src/exchangedb/pg_insert_kyc_failure.c b/src/exchangedb/pg_insert_kyc_failure.c index 22f67ac4e..a6c75bc8a 100644 --- a/src/exchangedb/pg_insert_kyc_failure.c +++ b/src/exchangedb/pg_insert_kyc_failure.c @@ -31,7 +31,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_kyc_failure ( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, diff --git a/src/exchangedb/pg_insert_kyc_failure.h b/src/exchangedb/pg_insert_kyc_failure.h index 120718feb..e81d3dcc5 100644 --- a/src/exchangedb/pg_insert_kyc_failure.h +++ b/src/exchangedb/pg_insert_kyc_failure.h @@ -43,7 +43,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_kyc_failure ( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, diff --git a/src/exchangedb/pg_insert_kyc_attributes.c b/src/exchangedb/pg_insert_kyc_measure_result.c index e7a0c12bd..24e78f014 100644 --- a/src/exchangedb/pg_insert_kyc_attributes.c +++ b/src/exchangedb/pg_insert_kyc_measure_result.c @@ -14,23 +14,23 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ /** - * @file exchangedb/pg_insert_kyc_attributes.c - * @brief Implementation of the insert_kyc_attributes function for Postgres + * @file exchangedb/pg_insert_kyc_measure_result.c + * @brief Implementation of the insert_kyc_measure_result function for Postgres * @author Christian Grothoff */ #include "platform.h" #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" -#include "pg_insert_kyc_attributes.h" +#include "pg_insert_kyc_measure_result.h" #include "pg_helper.h" enum GNUNET_DB_QueryStatus -TEH_PG_insert_kyc_attributes ( +TEH_PG_insert_kyc_measure_result ( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint32_t birthday, struct GNUNET_TIME_Timestamp collection_time, const char *provider_name, @@ -56,7 +56,9 @@ TEH_PG_insert_kyc_attributes ( char *kyc_completed_notify_s = GNUNET_PQ_get_event_notify_channel (&rep.header); struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&process_row), + (0 == process_row) + ? GNUNET_PQ_query_param_null () + : GNUNET_PQ_query_param_uint64 (&process_row), GNUNET_PQ_query_param_auto_from_type (h_payto), GNUNET_PQ_query_param_uint32 (&birthday), GNUNET_PQ_query_param_string (provider_name), @@ -76,8 +78,10 @@ TEH_PG_insert_kyc_attributes ( GNUNET_PQ_query_param_array_ptrs_string (num_events, events, pg->conn), - GNUNET_PQ_query_param_fixed_size (enc_attributes, - enc_attributes_size), + (NULL == enc_attributes) + ? GNUNET_PQ_query_param_null () + : GNUNET_PQ_query_param_fixed_size (enc_attributes, + enc_attributes_size), GNUNET_PQ_query_param_bool (to_investigate), GNUNET_PQ_query_param_string (kyc_completed_notify_s), GNUNET_PQ_query_param_end @@ -95,15 +99,14 @@ TEH_PG_insert_kyc_attributes ( kyc_completed_notify_s); GNUNET_break (NULL != new_rules); GNUNET_break (NULL != h_payto); - GNUNET_break (NULL != enc_attributes); PREPARE (pg, - "insert_kyc_attributes", + "insert_kyc_measure_result", "SELECT " " out_ok" - " FROM exchange_do_insert_kyc_attributes " + " FROM exchange_do_insert_kyc_measure_result " "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);"); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "insert_kyc_attributes", + "insert_kyc_measure_result", params, rs); GNUNET_PQ_cleanup_query_params_closures (params); diff --git a/src/exchangedb/pg_insert_kyc_attributes.h b/src/exchangedb/pg_insert_kyc_measure_result.h index e33f3a152..eed72dc14 100644 --- a/src/exchangedb/pg_insert_kyc_attributes.h +++ b/src/exchangedb/pg_insert_kyc_measure_result.h @@ -14,8 +14,8 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ /** - * @file exchangedb/pg_insert_kyc_attributes.h - * @brief implementation of the insert_kyc_attributes function for Postgres + * @file exchangedb/pg_insert_kyc_measure_result.h + * @brief implementation of the insert_kyc_measure_result function for Postgres * @author Christian Grothoff */ #ifndef PG_INSERT_KYC_ATTRIBUTES_H @@ -49,10 +49,10 @@ * @return database transaction status */ enum GNUNET_DB_QueryStatus -TEH_PG_insert_kyc_attributes ( +TEH_PG_insert_kyc_measure_result ( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint32_t birthday, struct GNUNET_TIME_Timestamp collection_time, const char *provider_name, diff --git a/src/exchangedb/pg_insert_kyc_requirement_process.c b/src/exchangedb/pg_insert_kyc_requirement_process.c index bbb2efc9c..13a94219d 100644 --- a/src/exchangedb/pg_insert_kyc_requirement_process.c +++ b/src/exchangedb/pg_insert_kyc_requirement_process.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_kyc_requirement_process ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint32_t measure_index, uint64_t legitimization_measure_serial_id, const char *provider_name, diff --git a/src/exchangedb/pg_insert_kyc_requirement_process.h b/src/exchangedb/pg_insert_kyc_requirement_process.h index 2181813fc..2996d2cef 100644 --- a/src/exchangedb/pg_insert_kyc_requirement_process.h +++ b/src/exchangedb/pg_insert_kyc_requirement_process.h @@ -45,7 +45,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_kyc_requirement_process ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint32_t measure_index, uint64_t legitimization_measure_serial_id, const char *provider_name, diff --git a/src/exchangedb/pg_insert_programmatic_legitimization_outcome.h b/src/exchangedb/pg_insert_programmatic_legitimization_outcome.h deleted file mode 100644 index 17ced6503..000000000 --- a/src/exchangedb/pg_insert_programmatic_legitimization_outcome.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_insert_programmatic_legitimization_outcome.h - * @brief implementation of the insert_programmatic_legitimization_outcome function for Postgres - * @author Christian Grothoff - */ -#ifndef PG_INSERT_PROGRAMMATIC_LEGITIMIZATION_OUTCOME_H -#define PG_INSERT_PROGRAMMATIC_LEGITIMIZATION_OUTCOME_H - -#include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_exchangedb_plugin.h" - - -/** - * Store automated legitimization outcome. - * - * @param cls closure - * @param h_payto account for which the attribute data is stored - * @param decision_time when was the decision taken - * @param expiration_time when does the data expire - * @param account_properties new account properties - * @param to_investigate true to flag account for investigation - * @param new_rules new KYC rules to apply to the account - * @param num_events length of the @a events array - * @param events array of KYC events to trigger - * @return database transaction status - */ -enum GNUNET_DB_QueryStatus -TEH_PG_insert_programmatic_legitimization_outcome ( - void *cls, - const struct TALER_PaytoHashP *h_payto, - struct GNUNET_TIME_Timestamp decision_time, - struct GNUNET_TIME_Absolute expiration_time, - const json_t *account_properties, - bool to_investigate, - const json_t *new_rules, - unsigned int num_events, - const char **events); - -#endif diff --git a/src/exchangedb/pg_insert_records_by_table.c b/src/exchangedb/pg_insert_records_by_table.c index 344c7d84c..3353cd0fc 100644 --- a/src/exchangedb/pg_insert_records_by_table.c +++ b/src/exchangedb/pg_insert_records_by_table.c @@ -168,12 +168,14 @@ static enum GNUNET_DB_QueryStatus irbt_cb_table_wire_targets (struct PostgresClosure *pg, const struct TALER_EXCHANGEDB_TableData *td) { - struct TALER_PaytoHashP payto_hash; + struct TALER_NormalizedPaytoHashP normalized_payto_hash; + struct TALER_FullPaytoHashP full_payto_hash; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&td->serial), - GNUNET_PQ_query_param_auto_from_type (&payto_hash), + GNUNET_PQ_query_param_auto_from_type (&full_payto_hash), + GNUNET_PQ_query_param_auto_from_type (&normalized_payto_hash), GNUNET_PQ_query_param_string ( - td->details.wire_targets.payto_uri), + td->details.wire_targets.full_payto_uri.full_payto), GNUNET_PQ_query_param_auto_from_type ( &td->details.wire_targets.access_token), td->details.wire_targets.no_account @@ -183,19 +185,23 @@ irbt_cb_table_wire_targets (struct PostgresClosure *pg, GNUNET_PQ_query_param_end }; - TALER_payto_hash ( - td->details.wire_targets.payto_uri, - &payto_hash); + TALER_full_payto_hash ( + td->details.wire_targets.full_payto_uri, + &full_payto_hash); + TALER_full_payto_normalize_and_hash ( + td->details.wire_targets.full_payto_uri, + &normalized_payto_hash); PREPARE (pg, "insert_into_table_wire_targets", "INSERT INTO wire_targets" "(wire_target_serial_id" ",wire_target_h_payto" + ",h_normalized_payto" ",payto_uri" ",access_token" ",target_pub" ") VALUES " - "($1, $2, $3, $4, $5);"); + "($1, $2, $3, $4, $5, $6);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "insert_into_table_wire_targets", params); @@ -1782,7 +1788,7 @@ irbt_cb_table_close_requests (struct PostgresClosure *pg, pg->conn, &td->details.close_requests.close_fee), GNUNET_PQ_query_param_string ( - td->details.close_requests.payto_uri), + td->details.close_requests.payto_uri.full_payto), GNUNET_PQ_query_param_end }; @@ -2019,7 +2025,7 @@ irbt_cb_table_profit_drains (struct PostgresClosure *pg, GNUNET_PQ_query_param_string ( td->details.profit_drains.account_section), GNUNET_PQ_query_param_string ( - td->details.profit_drains.payto_uri), + td->details.profit_drains.payto_uri.full_payto), GNUNET_PQ_query_param_timestamp ( &td->details.profit_drains.trigger_date), TALER_PQ_query_param_amount ( diff --git a/src/exchangedb/pg_insert_reserve_closed.c b/src/exchangedb/pg_insert_reserve_closed.c index 6644fb892..b1b0986e8 100644 --- a/src/exchangedb/pg_insert_reserve_closed.c +++ b/src/exchangedb/pg_insert_reserve_closed.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -32,7 +32,7 @@ TEH_PG_insert_reserve_closed ( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, struct GNUNET_TIME_Timestamp execution_date, - const char *receiver_account, + const struct TALER_FullPayto receiver_account, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee, @@ -41,10 +41,10 @@ TEH_PG_insert_reserve_closed ( struct PostgresClosure *pg = cls; struct TALER_EXCHANGEDB_Reserve reserve; enum GNUNET_DB_QueryStatus qs; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; - TALER_payto_hash (receiver_account, - &h_payto); + TALER_full_payto_hash (receiver_account, + &h_payto); { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (reserve_pub), diff --git a/src/exchangedb/pg_insert_reserve_closed.h b/src/exchangedb/pg_insert_reserve_closed.h index 2ac1a6e30..57ebe5631 100644 --- a/src/exchangedb/pg_insert_reserve_closed.h +++ b/src/exchangedb/pg_insert_reserve_closed.h @@ -24,6 +24,8 @@ #include "taler_util.h" #include "taler_json_lib.h" #include "taler_exchangedb_plugin.h" + + /** * Insert reserve close operation into database. * @@ -42,7 +44,7 @@ TEH_PG_insert_reserve_closed ( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, struct GNUNET_TIME_Timestamp execution_date, - const char *receiver_account, + const struct TALER_FullPayto receiver_account, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee, diff --git a/src/exchangedb/pg_insert_programmatic_legitimization_outcome.c b/src/exchangedb/pg_insert_successor_measure.c index 1e2b0ac15..554154de4 100644 --- a/src/exchangedb/pg_insert_programmatic_legitimization_outcome.c +++ b/src/exchangedb/pg_insert_successor_measure.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2024 Taler Systems SA + Copyright (C) 2022, 2023, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -14,29 +14,28 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ /** - * @file exchangedb/pg_insert_programmatic_legitimization_outcome.c - * @brief Implementation of the insert_programmatic_legitimization_outcome function for Postgres - * @author Christian Grothoff + * @file exchangedb/pg_insert_succesor_measure.c + * @brief Implementation of the insert_succesor_measure function for Postgres + * @author Florian Dold */ #include "platform.h" #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" -#include "pg_insert_programmatic_legitimization_outcome.h" +#include "pg_insert_successor_measure.h" #include "pg_helper.h" +#include <gnunet/gnunet_pq_lib.h> enum GNUNET_DB_QueryStatus -TEH_PG_insert_programmatic_legitimization_outcome ( +TEH_PG_insert_successor_measure ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp decision_time, - struct GNUNET_TIME_Absolute expiration_time, - const json_t *account_properties, - bool to_investigate, - const json_t *new_rules, - unsigned int num_events, - const char **events) + const char *new_measure_name, + const json_t *jmeasures, + bool *unknown_account, + struct GNUNET_TIME_Timestamp *last_date) { struct PostgresClosure *pg = cls; struct TALER_KycCompletedEventP rep = { @@ -44,49 +43,46 @@ TEH_PG_insert_programmatic_legitimization_outcome ( .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), .h_payto = *h_payto }; - + /* We're reverting back to default rules => never expires.*/ + struct GNUNET_TIME_Timestamp expiration_time = { + .abs_time = GNUNET_TIME_UNIT_FOREVER_ABS, + }; char *notify_s = GNUNET_PQ_get_event_notify_channel (&rep.header); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (h_payto), GNUNET_PQ_query_param_timestamp (&decision_time), - GNUNET_PQ_query_param_absolute_time (&expiration_time), - NULL != account_properties - ? TALER_PQ_query_param_json (account_properties) - : GNUNET_PQ_query_param_null (), - TALER_PQ_query_param_json (new_rules), - GNUNET_PQ_query_param_bool (to_investigate), - GNUNET_PQ_query_param_array_ptrs_string (num_events, - events, - pg->conn), - GNUNET_PQ_query_param_string (notify_s), + GNUNET_PQ_query_param_timestamp (&expiration_time), + NULL != new_measure_name + ? GNUNET_PQ_query_param_string (new_measure_name) + : GNUNET_PQ_query_param_null (), + NULL != jmeasures + ? TALER_PQ_query_param_json (jmeasures) + : GNUNET_PQ_query_param_null (), GNUNET_PQ_query_param_end }; - bool unknown_account; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_bool ("out_account_unknown", - &unknown_account), + unknown_account), + GNUNET_PQ_result_spec_timestamp ("out_last_date", + last_date), GNUNET_PQ_result_spec_end }; enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "do_insert_programmatic_legitimization_outcome", + "do_insert_successor_measure", "SELECT" " out_account_unknown" - " FROM exchange_do_insert_programmatic_legitimization_decision" - "($1, $2, $3, $4, $5, $6, $7, $8);"); - qs = GNUNET_PQ_eval_prepared_singleton_select ( - pg->conn, - "do_insert_programmatic_legitimization_outcome", - params, - rs); - GNUNET_PQ_cleanup_query_params_closures (params); + ",out_last_date" + ",out_legitimization_measure_serial_id" + " FROM exchange_do_insert_successor_measure" + "($1, $2, $3, $4, $5);"); + qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "do_insert_successor_measure", + params, + rs); GNUNET_free (notify_s); GNUNET_PQ_event_do_poll (pg->conn); - if (qs <= 0) - return qs; - if (unknown_account) - return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; return qs; } diff --git a/src/auditordb/pg_delete_deposit_confirmations.h b/src/exchangedb/pg_insert_successor_measure.h index 5f7700ba1..e817822aa 100644 --- a/src/auditordb/pg_delete_deposit_confirmations.h +++ b/src/exchangedb/pg_insert_successor_measure.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2024 Taler Systems SA + Copyright (C) 2022, 2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -14,28 +14,26 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ /** - * @file auditordb/pg_delete_deposit_confirmations.h - * @brief implementation of the delete_deposit_confirmation function for Postgres - * @author Nicola Eigel + * @file exchangedb/pg_insert_successor_measure.h + * @brief implementation of the insert_successor_measure function for Postgres + * @author Florian Dold */ -#ifndef PG_DELETE_DEPOSIT_CONFIRMATIONS_H -#define PG_DELETE_DEPOSIT_CONFIRMATIONS_H +#ifndef PG_INSERT_SUCCESSOR_MEASURE_H +#define PG_INSERT_SUCCESSOR_MEASURE_H #include "taler_util.h" #include "taler_json_lib.h" -#include "taler_auditordb_plugin.h" +#include "taler_exchangedb_plugin.h" -/** - * Delete a row from the deposit confirmations table. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param row_id row to delete - * @return query transaction status - */ enum GNUNET_DB_QueryStatus -TAH_PG_delete_deposit_confirmation ( +TEH_PG_insert_successor_measure ( void *cls, - uint64_t row_id); + const struct TALER_NormalizedPaytoHashP *h_payto, + struct GNUNET_TIME_Timestamp decision_time, + const char *new_measure_name, + const json_t *jmeasures, + bool *unknown_account, + struct GNUNET_TIME_Timestamp *last_date); #endif diff --git a/src/exchangedb/pg_insert_wire.c b/src/exchangedb/pg_insert_wire.c index b1364cbb3..fa0e11dca 100644 --- a/src/exchangedb/pg_insert_wire.c +++ b/src/exchangedb/pg_insert_wire.c @@ -27,19 +27,20 @@ enum GNUNET_DB_QueryStatus -TEH_PG_insert_wire (void *cls, - const char *payto_uri, - const char *conversion_url, - const json_t *debit_restrictions, - const json_t *credit_restrictions, - struct GNUNET_TIME_Timestamp start_date, - const struct TALER_MasterSignatureP *master_sig, - const char *bank_label, - int64_t priority) +TEH_PG_insert_wire ( + void *cls, + const struct TALER_FullPayto payto_uri, + const char *conversion_url, + const json_t *debit_restrictions, + const json_t *credit_restrictions, + struct GNUNET_TIME_Timestamp start_date, + const struct TALER_MasterSignatureP *master_sig, + const char *bank_label, + int64_t priority) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), NULL == conversion_url ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string (conversion_url), diff --git a/src/exchangedb/pg_insert_wire.h b/src/exchangedb/pg_insert_wire.h index 7a5e4caca..ce61efd39 100644 --- a/src/exchangedb/pg_insert_wire.h +++ b/src/exchangedb/pg_insert_wire.h @@ -24,6 +24,8 @@ #include "taler_util.h" #include "taler_json_lib.h" #include "taler_exchangedb_plugin.h" + + /** * Insert information about an wire account used by this exchange. * @@ -42,7 +44,7 @@ */ enum GNUNET_DB_QueryStatus TEH_PG_insert_wire (void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, diff --git a/src/exchangedb/pg_iterate_kyc_reference.c b/src/exchangedb/pg_iterate_kyc_reference.c index 686dbc5ed..4c57e8fb2 100644 --- a/src/exchangedb/pg_iterate_kyc_reference.c +++ b/src/exchangedb/pg_iterate_kyc_reference.c @@ -98,7 +98,7 @@ iterate_kyc_reference_cb (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_iterate_kyc_reference ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_LegitimizationProcessCallback lpc, void *lpc_cls) { diff --git a/src/exchangedb/pg_iterate_kyc_reference.h b/src/exchangedb/pg_iterate_kyc_reference.h index 0242fdcf1..8e1c93b81 100644 --- a/src/exchangedb/pg_iterate_kyc_reference.h +++ b/src/exchangedb/pg_iterate_kyc_reference.h @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_iterate_kyc_reference ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_LegitimizationProcessCallback lpc, void *lpc_cls); diff --git a/src/exchangedb/pg_iterate_reserve_close_info.c b/src/exchangedb/pg_iterate_reserve_close_info.c index 6b4e72d69..2584014ce 100644 --- a/src/exchangedb/pg_iterate_reserve_close_info.c +++ b/src/exchangedb/pg_iterate_reserve_close_info.c @@ -93,7 +93,7 @@ iterate_reserve_close_info_cb (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_iterate_reserve_close_info ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls) @@ -116,7 +116,11 @@ TEH_PG_iterate_reserve_close_info ( " amount" ",execution_date" " FROM reserves_close" - " WHERE wire_target_h_payto=$1" + " WHERE wire_target_h_payto IN (" + " SELECT wire_target_h_payto" + " FROM wire_targets" + " WHERE h_normalized_payto=$1" + " )" " AND execution_date >= $2" " ORDER BY execution_date DESC"); return GNUNET_PQ_eval_prepared_multi_select ( diff --git a/src/exchangedb/pg_iterate_reserve_close_info.h b/src/exchangedb/pg_iterate_reserve_close_info.h index 34692e656..55cd5f487 100644 --- a/src/exchangedb/pg_iterate_reserve_close_info.h +++ b/src/exchangedb/pg_iterate_reserve_close_info.h @@ -40,7 +40,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_iterate_reserve_close_info ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); diff --git a/src/exchangedb/pg_kyc_provider_account_lookup.c b/src/exchangedb/pg_kyc_provider_account_lookup.c index 847f8e713..fb0350508 100644 --- a/src/exchangedb/pg_kyc_provider_account_lookup.c +++ b/src/exchangedb/pg_kyc_provider_account_lookup.c @@ -31,7 +31,7 @@ TEH_PG_kyc_provider_account_lookup ( void *cls, const char *provider_name, const char *provider_legitimization_id, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, uint64_t *process_row) { struct PostgresClosure *pg = cls; diff --git a/src/exchangedb/pg_kyc_provider_account_lookup.h b/src/exchangedb/pg_kyc_provider_account_lookup.h index bafc42b6f..61939ba84 100644 --- a/src/exchangedb/pg_kyc_provider_account_lookup.h +++ b/src/exchangedb/pg_kyc_provider_account_lookup.h @@ -42,7 +42,7 @@ TEH_PG_kyc_provider_account_lookup ( void *cls, const char *provider_name, const char *provider_legitimization_id, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, uint64_t *process_row); #endif diff --git a/src/exchangedb/pg_kycauth_in_insert.c b/src/exchangedb/pg_kycauth_in_insert.c index 2f2ebcec9..04b63f129 100644 --- a/src/exchangedb/pg_kycauth_in_insert.c +++ b/src/exchangedb/pg_kycauth_in_insert.c @@ -32,21 +32,23 @@ TEH_PG_kycauth_in_insert ( const union TALER_AccountPublicKeyP *account_pub, const struct TALER_Amount *credit_amount, struct GNUNET_TIME_Timestamp execution_date, - const char *debit_account_uri, + const struct TALER_FullPayto debit_account_uri, const char *section_name, uint64_t serial_id) { struct PostgresClosure *pg = cls; - struct TALER_PaytoHashP h_payto; - - TALER_payto_hash (debit_account_uri, - &h_payto); + struct TALER_NormalizedPaytoHashP h_normalized_payto; + struct TALER_FullPaytoHashP h_full_payto; + TALER_full_payto_hash (debit_account_uri, + &h_full_payto); + TALER_full_payto_normalize_and_hash (debit_account_uri, + &h_normalized_payto); { struct TALER_KycCompletedEventP rep = { .header.size = htons (sizeof (rep)), .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), - .h_payto = h_payto + .h_payto = h_normalized_payto }; char *notify_s = GNUNET_PQ_get_event_notify_channel (&rep.header); @@ -55,8 +57,9 @@ TEH_PG_kycauth_in_insert ( GNUNET_PQ_query_param_uint64 (&serial_id), TALER_PQ_query_param_amount (pg->conn, credit_amount), - GNUNET_PQ_query_param_auto_from_type (&h_payto), - GNUNET_PQ_query_param_string (debit_account_uri), + GNUNET_PQ_query_param_auto_from_type (&h_full_payto), + GNUNET_PQ_query_param_auto_from_type (&h_normalized_payto), + GNUNET_PQ_query_param_string (debit_account_uri.full_payto), GNUNET_PQ_query_param_string (section_name), GNUNET_PQ_query_param_timestamp (&execution_date), GNUNET_PQ_query_param_string (notify_s), @@ -68,7 +71,7 @@ TEH_PG_kycauth_in_insert ( "kycauth_in_insert", "CALL" " exchange_do_kycauth_in_insert" - " ($1,$2,$3,$4,$5,$6,$7,$8);"); + " ($1,$2,$3,$4,$5,$6,$7,$8,$9);"); qs = GNUNET_PQ_eval_prepared_non_select ( pg->conn, "kycauth_in_insert", diff --git a/src/exchangedb/pg_kycauth_in_insert.h b/src/exchangedb/pg_kycauth_in_insert.h index 0dcad04be..f48c2041b 100644 --- a/src/exchangedb/pg_kycauth_in_insert.h +++ b/src/exchangedb/pg_kycauth_in_insert.h @@ -44,7 +44,7 @@ TEH_PG_kycauth_in_insert ( const union TALER_AccountPublicKeyP *account_pub, const struct TALER_Amount *credit_amount, struct GNUNET_TIME_Timestamp execution_date, - const char *debit_account_uri, + const struct TALER_FullPayto debit_account_uri, const char *section_name, uint64_t serial_id); diff --git a/src/exchangedb/pg_lookup_active_legitimization.c b/src/exchangedb/pg_lookup_active_legitimization.c index 38c95fd4d..9b294420b 100644 --- a/src/exchangedb/pg_lookup_active_legitimization.c +++ b/src/exchangedb/pg_lookup_active_legitimization.c @@ -31,6 +31,7 @@ TEH_PG_lookup_active_legitimization ( void *cls, uint64_t legitimization_process_serial_id, uint32_t *measure_index, + char **provider_name, json_t **jmeasures) { struct PostgresClosure *pg = cls; @@ -45,6 +46,9 @@ TEH_PG_lookup_active_legitimization ( GNUNET_PQ_result_spec_uint32 ( "measure_index", measure_index), + GNUNET_PQ_result_spec_string ( + "provider_name", + provider_name), GNUNET_PQ_result_spec_end }; @@ -53,6 +57,7 @@ TEH_PG_lookup_active_legitimization ( "SELECT " " lm.jmeasures" ",lp.measure_index" + ",lp.provider_name" " FROM legitimization_processes lp" " JOIN legitimization_measures lm" " USING (legitimization_measure_serial_id)" diff --git a/src/exchangedb/pg_lookup_active_legitimization.h b/src/exchangedb/pg_lookup_active_legitimization.h index f7bce41cb..52e508e9b 100644 --- a/src/exchangedb/pg_lookup_active_legitimization.h +++ b/src/exchangedb/pg_lookup_active_legitimization.h @@ -34,6 +34,7 @@ * row in legitimization_processes table to access * @param[out] measure_index set to the measure the * process is trying to satisfy + * @param[out] provider_name name of the provider, must be freed by caller * @param[out] jmeasures set to the legitimization * measures that were put on the account * @return database transaction status @@ -43,6 +44,7 @@ TEH_PG_lookup_active_legitimization ( void *cls, uint64_t legitimization_process_serial_id, uint32_t *measure_index, + char **provider_name, json_t **jmeasures); diff --git a/src/exchangedb/pg_lookup_aml_history.c b/src/exchangedb/pg_lookup_aml_history.c index 4a38f8bd7..da7c153ca 100644 --- a/src/exchangedb/pg_lookup_aml_history.c +++ b/src/exchangedb/pg_lookup_aml_history.c @@ -124,7 +124,7 @@ handle_aml_entry (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_lookup_aml_history ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlHistoryCallback cb, void *cb_cls) { @@ -154,7 +154,7 @@ TEH_PG_lookup_aml_history ( " JOIN legitimization_outcomes lo" " USING (outcome_serial_id)" " WHERE ah.h_payto=$1" - " ORDER BY decision_time DESC;"); + " ORDER BY decision_time DESC, outcome_serial_id DESC;"); qs = GNUNET_PQ_eval_prepared_multi_select ( pg->conn, "lookup_aml_history", diff --git a/src/exchangedb/pg_lookup_aml_history.h b/src/exchangedb/pg_lookup_aml_history.h index db146e937..e66e9f19b 100644 --- a/src/exchangedb/pg_lookup_aml_history.h +++ b/src/exchangedb/pg_lookup_aml_history.h @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_aml_history ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlHistoryCallback cb, void *cb_cls); diff --git a/src/exchangedb/pg_lookup_completed_legitimization.c b/src/exchangedb/pg_lookup_completed_legitimization.c index 3a500dc32..b1ce3a252 100644 --- a/src/exchangedb/pg_lookup_completed_legitimization.c +++ b/src/exchangedb/pg_lookup_completed_legitimization.c @@ -32,7 +32,7 @@ TEH_PG_lookup_completed_legitimization ( uint64_t legitimization_measure_serial_id, uint32_t measure_index, struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, json_t **jmeasures, bool *is_finished, size_t *encrypted_attributes_len, @@ -73,7 +73,7 @@ TEH_PG_lookup_completed_legitimization ( "lookup_completed_legitimization", "SELECT " " lm.jmeasures" - ",wt.wire_target_h_payto" + ",wt.h_normalized_payto" ",lm.access_token" ",lm.is_finished" ",ka.encrypted_attributes" diff --git a/src/exchangedb/pg_lookup_completed_legitimization.h b/src/exchangedb/pg_lookup_completed_legitimization.h index 1bc16c2ac..3754df11d 100644 --- a/src/exchangedb/pg_lookup_completed_legitimization.h +++ b/src/exchangedb/pg_lookup_completed_legitimization.h @@ -55,7 +55,7 @@ TEH_PG_lookup_completed_legitimization ( uint64_t legitimization_measure_serial_id, uint32_t measure_index, struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, json_t **jmeasures, bool *is_finished, size_t *encrypted_attributes_len, diff --git a/src/exchangedb/pg_lookup_h_payto_by_access_token.c b/src/exchangedb/pg_lookup_h_payto_by_access_token.c index 072d6fbb8..79a516bf8 100644 --- a/src/exchangedb/pg_lookup_h_payto_by_access_token.c +++ b/src/exchangedb/pg_lookup_h_payto_by_access_token.c @@ -30,7 +30,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_h_payto_by_access_token ( void *cls, const struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto) + struct TALER_NormalizedPaytoHashP *h_payto) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -39,7 +39,7 @@ TEH_PG_lookup_h_payto_by_access_token ( }; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ( - "wire_target_h_payto", + "h_normalized_payto", h_payto), GNUNET_PQ_result_spec_end }; @@ -47,7 +47,7 @@ TEH_PG_lookup_h_payto_by_access_token ( PREPARE (pg, "lookup_h_payto_by_access_token", "SELECT " - " wire_target_h_payto" + " h_normalized_payto" " FROM wire_targets" " WHERE (access_token = $1);"); return GNUNET_PQ_eval_prepared_singleton_select ( diff --git a/src/exchangedb/pg_lookup_h_payto_by_access_token.h b/src/exchangedb/pg_lookup_h_payto_by_access_token.h index afcac09cf..10e4e076b 100644 --- a/src/exchangedb/pg_lookup_h_payto_by_access_token.h +++ b/src/exchangedb/pg_lookup_h_payto_by_access_token.h @@ -40,6 +40,6 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_h_payto_by_access_token ( void *cls, const struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto); + struct TALER_NormalizedPaytoHashP *h_payto); #endif diff --git a/src/exchangedb/pg_lookup_kyc_history.c b/src/exchangedb/pg_lookup_kyc_history.c index c5bc87d88..8f0533d73 100644 --- a/src/exchangedb/pg_lookup_kyc_history.c +++ b/src/exchangedb/pg_lookup_kyc_history.c @@ -144,7 +144,7 @@ handle_kyc_entry (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_lookup_kyc_history ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_KycHistoryCallback cb, void *cb_cls) { diff --git a/src/exchangedb/pg_lookup_kyc_history.h b/src/exchangedb/pg_lookup_kyc_history.h index 1c47366a5..c5ba486c9 100644 --- a/src/exchangedb/pg_lookup_kyc_history.h +++ b/src/exchangedb/pg_lookup_kyc_history.h @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_kyc_history ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_KycHistoryCallback cb, void *cb_cls); diff --git a/src/exchangedb/pg_lookup_kyc_process_by_account.c b/src/exchangedb/pg_lookup_kyc_process_by_account.c index ce86bdc0c..b96a561f4 100644 --- a/src/exchangedb/pg_lookup_kyc_process_by_account.c +++ b/src/exchangedb/pg_lookup_kyc_process_by_account.c @@ -30,7 +30,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_kyc_process_by_account ( void *cls, const char *provider_name, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t *process_row, struct GNUNET_TIME_Absolute *expiration, char **provider_account_id, diff --git a/src/exchangedb/pg_lookup_kyc_process_by_account.h b/src/exchangedb/pg_lookup_kyc_process_by_account.h index 1068380e9..4f3cedc13 100644 --- a/src/exchangedb/pg_lookup_kyc_process_by_account.h +++ b/src/exchangedb/pg_lookup_kyc_process_by_account.h @@ -42,7 +42,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_kyc_process_by_account ( void *cls, const char *provider_name, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t *process_row, struct GNUNET_TIME_Absolute *expiration, char **provider_account_id, diff --git a/src/exchangedb/pg_lookup_kyc_requirement_by_row.c b/src/exchangedb/pg_lookup_kyc_requirement_by_row.c index 66d083b8d..f884fb195 100644 --- a/src/exchangedb/pg_lookup_kyc_requirement_by_row.c +++ b/src/exchangedb/pg_lookup_kyc_requirement_by_row.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_kyc_requirement_by_row ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, union TALER_AccountPublicKeyP *account_pub, struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_AccountAccessTokenP *access_token, diff --git a/src/exchangedb/pg_lookup_kyc_requirement_by_row.h b/src/exchangedb/pg_lookup_kyc_requirement_by_row.h index 8bf6c38d9..38c58ba67 100644 --- a/src/exchangedb/pg_lookup_kyc_requirement_by_row.h +++ b/src/exchangedb/pg_lookup_kyc_requirement_by_row.h @@ -50,7 +50,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_kyc_requirement_by_row ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, union TALER_AccountPublicKeyP *account_pub, struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_AccountAccessTokenP *access_token, diff --git a/src/exchangedb/pg_lookup_pending_legitimization.c b/src/exchangedb/pg_lookup_pending_legitimization.c index 8475d3963..7c5a036d5 100644 --- a/src/exchangedb/pg_lookup_pending_legitimization.c +++ b/src/exchangedb/pg_lookup_pending_legitimization.c @@ -31,7 +31,7 @@ TEH_PG_lookup_pending_legitimization ( void *cls, uint64_t legitimization_measure_serial_id, struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, json_t **jmeasures, bool *is_finished) { @@ -45,7 +45,7 @@ TEH_PG_lookup_pending_legitimization ( "jmeasures", jmeasures), GNUNET_PQ_result_spec_auto_from_type ( - "wire_target_h_payto", + "h_normalized_payto", h_payto), GNUNET_PQ_result_spec_auto_from_type ( "access_token", @@ -60,7 +60,7 @@ TEH_PG_lookup_pending_legitimization ( "lookup_pending_legitimization", "SELECT " " lm.jmeasures" - ",wt.wire_target_h_payto" + ",wt.h_normalized_payto" ",lm.access_token" ",lm.is_finished" " FROM legitimization_measures lm" diff --git a/src/exchangedb/pg_lookup_pending_legitimization.h b/src/exchangedb/pg_lookup_pending_legitimization.h index eaf6a60d7..1c39370a6 100644 --- a/src/exchangedb/pg_lookup_pending_legitimization.h +++ b/src/exchangedb/pg_lookup_pending_legitimization.h @@ -47,7 +47,7 @@ TEH_PG_lookup_pending_legitimization ( void *cls, uint64_t legitimization_measure_serial_id, struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, json_t **jmeasures, bool *is_finished); diff --git a/src/exchangedb/pg_lookup_records_by_table.c b/src/exchangedb/pg_lookup_records_by_table.c index e8c6f8fa1..cbc0d1a72 100644 --- a/src/exchangedb/pg_lookup_records_by_table.c +++ b/src/exchangedb/pg_lookup_records_by_table.c @@ -223,7 +223,7 @@ lrbt_cb_table_wire_targets (void *cls, &td.details.wire_targets.no_account), GNUNET_PQ_result_spec_string ( "payto_uri", - &td.details.wire_targets.payto_uri), + &td.details.wire_targets.full_payto_uri.full_payto), GNUNET_PQ_result_spec_end }; @@ -2197,7 +2197,7 @@ lrbt_cb_table_close_requests (void *cls, &td.details.close_requests.close_fee), GNUNET_PQ_result_spec_string ( "payto_uri", - &td.details.close_requests.payto_uri), + &td.details.close_requests.payto_uri.full_payto), GNUNET_PQ_result_spec_end }; @@ -2505,7 +2505,7 @@ lrbt_cb_table_profit_drains (void *cls, &td.details.profit_drains.account_section), GNUNET_PQ_result_spec_string ( "payto_uri", - &td.details.profit_drains.payto_uri), + &td.details.profit_drains.payto_uri.full_payto), GNUNET_PQ_result_spec_timestamp ( "trigger_date", &td.details.profit_drains.trigger_date), diff --git a/src/exchangedb/pg_lookup_rules_by_access_token.c b/src/exchangedb/pg_lookup_rules_by_access_token.c index 0bfdeb5d2..59899e256 100644 --- a/src/exchangedb/pg_lookup_rules_by_access_token.c +++ b/src/exchangedb/pg_lookup_rules_by_access_token.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_rules_by_access_token ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, json_t **jnew_rules, uint64_t *rowid) { @@ -59,7 +59,8 @@ TEH_PG_lookup_rules_by_access_token ( " WHERE h_payto=$1" " AND expiration_time>$2" " AND is_active" - " ORDER BY expiration_time DESC" + " ORDER BY expiration_time DESC," + " outcome_serial_id DESC" " LIMIT 1;"); now = GNUNET_TIME_absolute_get (); return GNUNET_PQ_eval_prepared_singleton_select ( diff --git a/src/exchangedb/pg_lookup_rules_by_access_token.h b/src/exchangedb/pg_lookup_rules_by_access_token.h index e1824382c..e8fdf8af6 100644 --- a/src/exchangedb/pg_lookup_rules_by_access_token.h +++ b/src/exchangedb/pg_lookup_rules_by_access_token.h @@ -37,7 +37,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_rules_by_access_token ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, json_t **jnew_rules, uint64_t *rowid); diff --git a/src/exchangedb/pg_lookup_transfer_by_deposit.c b/src/exchangedb/pg_lookup_transfer_by_deposit.c index d326feff7..e16c62482 100644 --- a/src/exchangedb/pg_lookup_transfer_by_deposit.c +++ b/src/exchangedb/pg_lookup_transfer_by_deposit.c @@ -49,7 +49,7 @@ TEH_PG_lookup_transfer_by_deposit ( GNUNET_PQ_query_param_auto_from_type (merchant_pub), GNUNET_PQ_query_param_end }; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_WireSaltP wire_salt; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("wtid_raw", @@ -57,7 +57,7 @@ TEH_PG_lookup_transfer_by_deposit ( GNUNET_PQ_result_spec_auto_from_type ("wire_salt", &wire_salt), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_timestamp ("execution_date", exec_time), TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", @@ -143,7 +143,7 @@ TEH_PG_lookup_transfer_by_deposit ( GNUNET_PQ_result_spec_auto_from_type ("wire_salt", &wire_salt), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", amount_with_fee), TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit", diff --git a/src/exchangedb/pg_lookup_wire_timestamp.c b/src/exchangedb/pg_lookup_wire_timestamp.c index 17dffc706..cbc4688a7 100644 --- a/src/exchangedb/pg_lookup_wire_timestamp.c +++ b/src/exchangedb/pg_lookup_wire_timestamp.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -28,12 +28,12 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_wire_timestamp (void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp *last_date) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -42,7 +42,6 @@ TEH_PG_lookup_wire_timestamp (void *cls, GNUNET_PQ_result_spec_end }; - PREPARE (pg, "lookup_wire_timestamp", "SELECT" diff --git a/src/exchangedb/pg_lookup_wire_timestamp.h b/src/exchangedb/pg_lookup_wire_timestamp.h index f2ee117de..e043be93a 100644 --- a/src/exchangedb/pg_lookup_wire_timestamp.h +++ b/src/exchangedb/pg_lookup_wire_timestamp.h @@ -24,6 +24,8 @@ #include "taler_util.h" #include "taler_json_lib.h" #include "taler_exchangedb_plugin.h" + + /** * Check the last date an exchange wire account was modified. * @@ -34,7 +36,7 @@ */ enum GNUNET_DB_QueryStatus TEH_PG_lookup_wire_timestamp (void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp *last_date); #endif diff --git a/src/exchangedb/pg_lookup_wire_transfer.c b/src/exchangedb/pg_lookup_wire_transfer.c index 7ab023fe7..299b9daf5 100644 --- a/src/exchangedb/pg_lookup_wire_transfer.c +++ b/src/exchangedb/pg_lookup_wire_transfer.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022-2023 Taler Systems SA + Copyright (C) 2022-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -74,20 +74,20 @@ handle_wt_result (void *cls, uint64_t rowid; struct TALER_PrivateContractHashP h_contract_terms; struct TALER_CoinSpendPublicKeyP coin_pub; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; struct TALER_MerchantPublicKeyP merchant_pub; struct GNUNET_TIME_Timestamp exec_time; struct TALER_Amount amount_with_fee; struct TALER_Amount deposit_fee; struct TALER_DenominationPublicKey denom_pub; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("aggregation_serial_id", &rowid), GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms", &h_contract_terms), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_auto_from_type ("wire_target_h_payto", &h_payto), TALER_PQ_result_spec_denom_pub ("denom_pub", diff --git a/src/exchangedb/pg_preflight.c b/src/exchangedb/pg_preflight.c index c30a9651e..2640b1243 100644 --- a/src/exchangedb/pg_preflight.c +++ b/src/exchangedb/pg_preflight.c @@ -27,6 +27,69 @@ #include "plugin_exchangedb_postgres.h" +/** + * Connect to the database if the connection does not exist yet + * and check that we are ready to operate. + * + * @param pg the plugin-specific state + * @return #GNUNET_OK on success + */ +static enum GNUNET_GenericReturnValue +internal_setup (struct PostgresClosure *pg) +{ + if (NULL == pg->conn) + { +#if AUTO_EXPLAIN + /* Enable verbose logging to see where queries do not + properly use indices */ + struct GNUNET_PQ_ExecuteStatement es[] = { + GNUNET_PQ_make_try_execute ("LOAD 'auto_explain';"), + GNUNET_PQ_make_try_execute ("SET auto_explain.log_min_duration=50;"), + GNUNET_PQ_make_try_execute ("SET auto_explain.log_timing=TRUE;"), + GNUNET_PQ_make_try_execute ("SET auto_explain.log_analyze=TRUE;"), + /* https://wiki.postgresql.org/wiki/Serializable suggests to really + force the default to 'serializable' if SSI is to be used. */ + GNUNET_PQ_make_try_execute ( + "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), + GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), + GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), + GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"), + /* Mergejoin causes issues, see Postgres #18380 */ + GNUNET_PQ_make_try_execute ("SET enable_mergejoin=OFF;"), + GNUNET_PQ_EXECUTE_STATEMENT_END + }; +#else + struct GNUNET_PQ_ExecuteStatement es[] = { + GNUNET_PQ_make_try_execute ( + "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), + GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), + GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), + /* Mergejoin causes issues, see Postgres #18380 */ + GNUNET_PQ_make_try_execute ("SET enable_mergejoin=OFF;"), + GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"), + GNUNET_PQ_EXECUTE_STATEMENT_END + }; +#endif + struct GNUNET_PQ_Context *db_conn; + + db_conn = GNUNET_PQ_connect_with_cfg2 (pg->cfg, + "exchangedb-postgres", + "exchange-", /* load_path_suffix */ + es, + NULL /* prepared statements */, + GNUNET_PQ_FLAG_CHECK_CURRENT); + if (NULL == db_conn) + return GNUNET_SYSERR; + + pg->prep_gen++; + pg->conn = db_conn; + } + if (NULL == pg->transaction_name) + GNUNET_PQ_reconnect_if_down (pg->conn); + return GNUNET_OK; +} + + enum GNUNET_GenericReturnValue TEH_PG_preflight (void *cls) { @@ -37,7 +100,7 @@ TEH_PG_preflight (void *cls) }; if (GNUNET_OK != - TEH_PG_internal_setup (pg)) + internal_setup (pg)) return GNUNET_SYSERR; if (NULL == pg->transaction_name) return GNUNET_OK; /* all good */ diff --git a/src/exchangedb/pg_profit_drains_get_pending.c b/src/exchangedb/pg_profit_drains_get_pending.c index c844a3f38..be5843269 100644 --- a/src/exchangedb/pg_profit_drains_get_pending.c +++ b/src/exchangedb/pg_profit_drains_get_pending.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -25,13 +25,14 @@ #include "pg_profit_drains_get_pending.h" #include "pg_helper.h" + enum GNUNET_DB_QueryStatus TEH_PG_profit_drains_get_pending ( void *cls, uint64_t *serial, struct TALER_WireTransferIdentifierRawP *wtid, char **account_section, - char **payto_uri, + struct TALER_FullPayto *payto_uri, struct GNUNET_TIME_Timestamp *request_timestamp, struct TALER_Amount *amount, struct TALER_MasterSignatureP *master_sig) @@ -48,7 +49,7 @@ TEH_PG_profit_drains_get_pending ( GNUNET_PQ_result_spec_string ("account_section", account_section), GNUNET_PQ_result_spec_string ("payto_uri", - payto_uri), + &payto_uri->full_payto), GNUNET_PQ_result_spec_timestamp ("trigger_date", request_timestamp), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", diff --git a/src/exchangedb/pg_profit_drains_get_pending.h b/src/exchangedb/pg_profit_drains_get_pending.h index cd793a129..327719ef8 100644 --- a/src/exchangedb/pg_profit_drains_get_pending.h +++ b/src/exchangedb/pg_profit_drains_get_pending.h @@ -44,7 +44,7 @@ TEH_PG_profit_drains_get_pending ( uint64_t *serial, struct TALER_WireTransferIdentifierRawP *wtid, char **account_section, - char **payto_uri, + struct TALER_FullPayto *payto_uri, struct GNUNET_TIME_Timestamp *request_timestamp, struct TALER_Amount *amount, struct TALER_MasterSignatureP *master_sig); diff --git a/src/exchangedb/pg_reserves_get_origin.c b/src/exchangedb/pg_reserves_get_origin.c index 81049c883..e9eedabcc 100644 --- a/src/exchangedb/pg_reserves_get_origin.c +++ b/src/exchangedb/pg_reserves_get_origin.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -30,8 +30,8 @@ enum GNUNET_DB_QueryStatus TEH_PG_reserves_get_origin ( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_PaytoHashP *h_payto, - char **payto_uri) + struct TALER_FullPaytoHashP *h_payto, + struct TALER_FullPayto *payto_uri) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -44,7 +44,7 @@ TEH_PG_reserves_get_origin ( h_payto), GNUNET_PQ_result_spec_string ( "payto_uri", - payto_uri), + &payto_uri->full_payto), GNUNET_PQ_result_spec_end }; diff --git a/src/exchangedb/pg_reserves_get_origin.h b/src/exchangedb/pg_reserves_get_origin.h index 927c8c139..6c248f8d1 100644 --- a/src/exchangedb/pg_reserves_get_origin.h +++ b/src/exchangedb/pg_reserves_get_origin.h @@ -37,7 +37,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_reserves_get_origin ( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_PaytoHashP *h_payto, - char **payto_uri); + struct TALER_FullPaytoHashP *h_payto, + struct TALER_FullPayto *payto_uri); #endif diff --git a/src/exchangedb/pg_reserves_in_insert.c b/src/exchangedb/pg_reserves_in_insert.c index 95e488771..c372f7719 100644 --- a/src/exchangedb/pg_reserves_in_insert.c +++ b/src/exchangedb/pg_reserves_in_insert.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022-2023 Taler Systems SA + Copyright (C) 2022-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -30,9 +30,6 @@ #include "pg_commit.h" #include "pg_preflight.h" #include "pg_rollback.h" -#include "pg_reserves_get.h" -#include "pg_reserves_update.h" -#include "pg_setup_wire_target.h" #include "pg_event_notify.h" @@ -141,7 +138,10 @@ TEH_PG_reserves_in_insert ( struct PostgresClosure *pg = cls; unsigned int dups = 0; - struct TALER_PaytoHashP h_paytos[GNUNET_NZL (reserves_length)]; + struct TALER_FullPaytoHashP h_full_paytos[ + GNUNET_NZL (reserves_length)]; + struct TALER_NormalizedPaytoHashP h_normalized_paytos[ + GNUNET_NZL (reserves_length)]; char *notify_s[GNUNET_NZL (reserves_length)]; struct TALER_ReservePublicKeyP reserve_pubs[GNUNET_NZL (reserves_length)]; struct TALER_Amount balances[GNUNET_NZL (reserves_length)]; @@ -163,13 +163,15 @@ TEH_PG_reserves_in_insert ( { const struct TALER_EXCHANGEDB_ReserveInInfo *reserve = &reserves[i]; - TALER_payto_hash (reserve->sender_account_details, - &h_paytos[i]); + TALER_full_payto_hash (reserve->sender_account_details, + &h_full_paytos[i]); + TALER_full_payto_normalize_and_hash (reserve->sender_account_details, + &h_normalized_paytos[i]); notify_s[i] = compute_notify_on_reserve (reserve->reserve_pub); reserve_pubs[i] = *reserve->reserve_pub; balances[i] = *reserve->balance; execution_times[i] = reserve->execution_time; - sender_account_details[i] = reserve->sender_account_details; + sender_account_details[i] = reserve->sender_account_details.full_payto; exchange_account_names[i] = reserve->exchange_account_name; wire_references[i] = reserve->wire_reference; } @@ -196,7 +198,7 @@ TEH_PG_reserves_in_insert ( " transaction_duplicate" ",ruuid" " FROM exchange_do_array_reserves_insert" - " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);"); + " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);"); { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_timestamp (&gc), @@ -221,7 +223,11 @@ TEH_PG_reserves_in_insert ( pg->conn), GNUNET_PQ_query_param_array_auto_from_type ( reserves_length, - h_paytos, + h_full_paytos, + pg->conn), + GNUNET_PQ_query_param_array_auto_from_type ( + reserves_length, + h_normalized_paytos, pg->conn), GNUNET_PQ_query_param_array_ptrs_string ( reserves_length, @@ -318,7 +324,7 @@ TEH_PG_reserves_in_insert ( TALER_PQ_query_param_amount (pg->conn, &balances[i]), GNUNET_PQ_query_param_string (exchange_account_names[i]), - GNUNET_PQ_query_param_auto_from_type (&h_paytos[i]), + GNUNET_PQ_query_param_auto_from_type (&h_full_paytos[i]), GNUNET_PQ_query_param_string (notify_s[i]), GNUNET_PQ_query_param_end }; diff --git a/src/exchangedb/pg_select_aggregation_amounts_for_kyc_check.c b/src/exchangedb/pg_select_aggregation_amounts_for_kyc_check.c index 0d5d0ee25..455c458eb 100644 --- a/src/exchangedb/pg_select_aggregation_amounts_for_kyc_check.c +++ b/src/exchangedb/pg_select_aggregation_amounts_for_kyc_check.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -113,7 +113,7 @@ get_kyc_amounts_cb (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_select_aggregation_amounts_for_kyc_check ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls) @@ -138,8 +138,12 @@ TEH_PG_select_aggregation_amounts_for_kyc_check ( " amount" ",execution_date AS date" " FROM wire_out" - " WHERE wire_target_h_payto=$1" - " AND execution_date >= $2" + " WHERE wire_target_h_payto IN" + " (SELECT wire_target_h_payto" + " FROM wire_targets" + " WHERE h_normalized_payto=$1" + " )" + " AND execution_date >= $2" " ORDER BY execution_date DESC"); qs = GNUNET_PQ_eval_prepared_multi_select ( diff --git a/src/exchangedb/pg_select_aggregation_amounts_for_kyc_check.h b/src/exchangedb/pg_select_aggregation_amounts_for_kyc_check.h index b91740581..3bd34c058 100644 --- a/src/exchangedb/pg_select_aggregation_amounts_for_kyc_check.h +++ b/src/exchangedb/pg_select_aggregation_amounts_for_kyc_check.h @@ -40,7 +40,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_aggregation_amounts_for_kyc_check ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); diff --git a/src/exchangedb/pg_select_aggregation_transient.c b/src/exchangedb/pg_select_aggregation_transient.c index f9b6193ed..e9b78e802 100644 --- a/src/exchangedb/pg_select_aggregation_transient.c +++ b/src/exchangedb/pg_select_aggregation_transient.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_account_section, struct TALER_WireTransferIdentifierRawP *wtid, diff --git a/src/exchangedb/pg_select_aggregation_transient.h b/src/exchangedb/pg_select_aggregation_transient.h index fd82a97aa..e137652e2 100644 --- a/src/exchangedb/pg_select_aggregation_transient.h +++ b/src/exchangedb/pg_select_aggregation_transient.h @@ -39,9 +39,11 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_account_section, struct TALER_WireTransferIdentifierRawP *wtid, struct TALER_Amount *total); + + #endif diff --git a/src/exchangedb/pg_select_aml_attributes.c b/src/exchangedb/pg_select_aml_attributes.c index 6aeb74ffd..4572945f7 100644 --- a/src/exchangedb/pg_select_aml_attributes.c +++ b/src/exchangedb/pg_select_aml_attributes.c @@ -109,7 +109,7 @@ handle_aml_attributes (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_select_aml_attributes ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t offset, int64_t limit, TALER_EXCHANGEDB_AmlAttributeCallback cb, diff --git a/src/exchangedb/pg_select_aml_attributes.h b/src/exchangedb/pg_select_aml_attributes.h index d207c41e1..785f995dd 100644 --- a/src/exchangedb/pg_select_aml_attributes.h +++ b/src/exchangedb/pg_select_aml_attributes.h @@ -41,7 +41,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_aml_attributes ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t offset, int64_t limit, TALER_EXCHANGEDB_AmlAttributeCallback cb, diff --git a/src/exchangedb/pg_select_aml_decisions.c b/src/exchangedb/pg_select_aml_decisions.c index 4c488b352..7ee577d42 100644 --- a/src/exchangedb/pg_select_aml_decisions.c +++ b/src/exchangedb/pg_select_aml_decisions.c @@ -71,7 +71,7 @@ handle_aml_result (void *cls, for (unsigned int i = 0; i<num_results; i++) { - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; uint64_t rowid; char *justification = NULL; struct GNUNET_TIME_Timestamp decision_time; @@ -135,7 +135,7 @@ handle_aml_result (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_select_aml_decisions ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, enum TALER_EXCHANGE_YesNoAll investigation_only, enum TALER_EXCHANGE_YesNoAll active_only, uint64_t offset, diff --git a/src/exchangedb/pg_select_aml_decisions.h b/src/exchangedb/pg_select_aml_decisions.h index 6780f2816..771f86bb7 100644 --- a/src/exchangedb/pg_select_aml_decisions.h +++ b/src/exchangedb/pg_select_aml_decisions.h @@ -43,7 +43,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_aml_decisions ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, enum TALER_EXCHANGE_YesNoAll investigation_only, enum TALER_EXCHANGE_YesNoAll active_only, uint64_t offset, diff --git a/src/exchangedb/pg_select_aml_history.c b/src/exchangedb/pg_select_aml_history.c deleted file mode 100644 index 0461e0d9b..000000000 --- a/src/exchangedb/pg_select_aml_history.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_select_aml_history.c - * @brief Implementation of the select_aml_history function for Postgres - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_error_codes.h" -#include "taler_dbevents.h" -#include "taler_pq_lib.h" -#include "pg_select_aml_history.h" -#include "pg_helper.h" - - -/** - * Closure for #handle_aml_result. - */ -struct AmlHistoryResultContext -{ - /** - * Function to call on each result. - */ - TALER_EXCHANGEDB_AmlHistoryCallback cb; - - /** - * Closure for @e cb. - */ - void *cb_cls; - - /** - * Plugin context. - */ - struct PostgresClosure *pg; - - /** - * Set to #GNUNET_SYSERR on serious errors. - */ - enum GNUNET_GenericReturnValue status; -}; - - -/** - * Function to be called with the results of a SELECT statement - * that has returned @a num_results results. Helper function - * for #TEH_PG_select_aml_history(). - * - * @param cls closure of type `struct AmlHistoryResultContext *` - * @param result the postgres result - * @param num_results the number of results in @a result - */ -static void -handle_aml_result (void *cls, - PGresult *result, - unsigned int num_results) -{ - struct AmlHistoryResultContext *ctx = cls; - struct PostgresClosure *pg = ctx->pg; - - for (unsigned int i = 0; i<num_results; i++) - { - struct TALER_Amount new_threshold; - uint32_t ns; - struct GNUNET_TIME_Timestamp decision_time; - char *justification; - struct TALER_AmlOfficerPublicKeyP decider_pub; - struct TALER_AmlOfficerSignatureP decider_sig; - struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT ("new_threshold", - &new_threshold), - GNUNET_PQ_result_spec_uint32 ("new_status", - &ns), - GNUNET_PQ_result_spec_timestamp ("decision_time", - &decision_time), - GNUNET_PQ_result_spec_string ("justification", - &justification), - GNUNET_PQ_result_spec_auto_from_type ("decider_pub", - &decider_pub), - GNUNET_PQ_result_spec_auto_from_type ("decider_sig", - &decider_sig), - GNUNET_PQ_result_spec_end - }; - - if (GNUNET_OK != - GNUNET_PQ_extract_result (result, - rs, - i)) - { - GNUNET_break (0); - ctx->status = GNUNET_SYSERR; - return; - } - ctx->cb (ctx->cb_cls, - &new_threshold, - (enum TALER_AmlDecisionState) ns, - decision_time, - justification, - &decider_pub, - &decider_sig); - GNUNET_PQ_cleanup_result (rs); - } -} - - -enum GNUNET_DB_QueryStatus -TEH_PG_select_aml_history ( - void *cls, - const struct TALER_PaytoHashP *h_payto, - TALER_EXCHANGEDB_AmlHistoryCallback cb, - void *cb_cls) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (h_payto), - GNUNET_PQ_query_param_end - }; - struct AmlHistoryResultContext ctx = { - .cb = cb, - .cb_cls = cb_cls, - .pg = pg, - .status = GNUNET_OK - }; - enum GNUNET_DB_QueryStatus qs; - - PREPARE (pg, - "lookup_aml_history", - "SELECT" - " new_threshold" - ",new_status" - ",decision_time" - ",justification" - ",decider_pub" - ",decider_sig" - " FROM aml_history" - " WHERE h_payto=$1;"); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "lookup_aml_history", - params, - &handle_aml_result, - &ctx); - if (GNUNET_OK != ctx.status) - return GNUNET_DB_STATUS_HARD_ERROR; - return qs; -} diff --git a/src/exchangedb/pg_select_aml_history.h b/src/exchangedb/pg_select_aml_history.h deleted file mode 100644 index 78569947f..000000000 --- a/src/exchangedb/pg_select_aml_history.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_select_aml_history.h - * @brief implementation of the select_aml_history function for Postgres - * @author Christian Grothoff - */ -#ifndef PG_SELECT_AML_HISTORY_H -#define PG_SELECT_AML_HISTORY_H - -#include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_exchangedb_plugin.h" - - -/** - * Lookup AML decision history for a particular account. - * - * @param cls closure - * @param h_payto which account should we return the AML decision history for - * @param cb callback to invoke on each match - * @param cb_cls closure for @a cb - * @return database transaction status - */ -enum GNUNET_DB_QueryStatus -TEH_PG_select_aml_history ( - void *cls, - const struct TALER_PaytoHashP *h_payto, - TALER_EXCHANGEDB_AmlHistoryCallback cb, - void *cb_cls); - - -#endif diff --git a/src/exchangedb/pg_select_aml_process.c b/src/exchangedb/pg_select_aml_process.c deleted file mode 100644 index c34cae4bb..000000000 --- a/src/exchangedb/pg_select_aml_process.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_select_aml_process.c - * @brief Implementation of the select_aml_process function for Postgres - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_error_codes.h" -#include "taler_dbevents.h" -#include "taler_pq_lib.h" -#include "pg_select_aml_process.h" -#include "pg_helper.h" - - -/** - * Closure for #handle_aml_result. - */ -struct AmlProcessResultContext -{ - /** - * Function to call on each result. - */ - TALER_EXCHANGEDB_AmlStatusCallback cb; - - /** - * Closure for @e cb. - */ - void *cb_cls; - - /** - * Plugin context. - */ - struct PostgresClosure *pg; - - /** - * Set to #GNUNET_SYSERR on serious errors. - */ - enum GNUNET_GenericReturnValue status; -}; - - -/** - * Function to be called with the results of a SELECT statement - * that has returned @a num_results results. Helper function - * for #TEH_PG_select_aml_process(). - * - * @param cls closure of type `struct AmlProcessResultContext *` - * @param result the postgres result - * @param num_results the number of results in @a result - */ -static void -handle_aml_result (void *cls, - PGresult *result, - unsigned int num_results) -{ - struct AmlProcessResultContext *ctx = cls; - struct PostgresClosure *pg = ctx->pg; - - for (unsigned int i = 0; i<num_results; i++) - { - struct TALER_PaytoHashP h_payto; - struct TALER_Amount threshold; - uint64_t rowid; - uint32_t sv; - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("aml_status_serial_id", - &rowid), - GNUNET_PQ_result_spec_auto_from_type ("h_payto", - &h_payto), - TALER_PQ_RESULT_SPEC_AMOUNT ("threshold", - &threshold), - GNUNET_PQ_result_spec_uint32 ("status", - &sv), - GNUNET_PQ_result_spec_end - }; - - if (GNUNET_OK != - GNUNET_PQ_extract_result (result, - rs, - i)) - { - GNUNET_break (0); - ctx->status = GNUNET_SYSERR; - return; - } - ctx->cb (ctx->cb_cls, - rowid, - &h_payto, - &threshold, - (enum TALER_AmlDecisionState) sv); - GNUNET_PQ_cleanup_result (rs); - } -} - - -enum GNUNET_DB_QueryStatus -TEH_PG_select_aml_process ( - void *cls, - enum TALER_AmlDecisionState decision, - uint64_t row_off, - uint64_t limit, - bool forward, - TALER_EXCHANGEDB_AmlStatusCallback cb, - void *cb_cls) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint32 (&decision), - GNUNET_PQ_query_param_uint64 (&row_off), - GNUNET_PQ_query_param_uint64 (&limit), - GNUNET_PQ_query_param_end - }; - struct AmlProcessResultContext ctx = { - .cb = cb, - .cb_cls = cb_cls, - .pg = pg, - .status = GNUNET_OK - }; - enum GNUNET_DB_QueryStatus qs; - const char *stmt = forward - ? "select_aml_process_inc" - : "select_aml_process_dec"; - - PREPARE (pg, - "select_aml_process_inc", - "SELECT" - " aml_status_serial_id" - ",h_payto" - ",threshold" - ",status" - " FROM aml_status" - " WHERE aml_status_serial_id > $2" - " AND status = $1" - " ORDER BY aml_status_serial_id ASC" - " LIMIT $3"); - PREPARE (pg, - "select_aml_process_dec", - "SELECT" - " aml_status_serial_id" - ",h_payto" - ",threshold" - ",status" - " FROM aml_status" - " WHERE aml_status_serial_id < $2" - " AND status = $1" - " ORDER BY aml_status_serial_id DESC" - " LIMIT $3"); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - stmt, - params, - &handle_aml_result, - &ctx); - if (GNUNET_OK != ctx.status) - return GNUNET_DB_STATUS_HARD_ERROR; - return qs; -} diff --git a/src/exchangedb/pg_select_aml_process.h b/src/exchangedb/pg_select_aml_process.h deleted file mode 100644 index 648cace2e..000000000 --- a/src/exchangedb/pg_select_aml_process.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_select_aml_process.h - * @brief implementation of the select_aml_process function for Postgres - * @author Christian Grothoff - */ -#ifndef PG_SELECT_AML_PROCESS_H -#define PG_SELECT_AML_PROCESS_H - -#include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_exchangedb_plugin.h" - - -/** - * Lookup AML decisions that have a particular state. - * - * @param cls closure - * @param decision which decision states to filter by - * @param row_off offset to start from - * @param limit how many rows to return at most - * @param forward true to go forward in time, false to go backwards - * @param cb callback to invoke on each match - * @param cb_cls closure for @a cb - * @return database transaction status - */ -enum GNUNET_DB_QueryStatus -TEH_PG_select_aml_process ( - void *cls, - enum TALER_AmlDecisionState decision, - uint64_t row_off, - uint64_t limit, - bool forward, - TALER_EXCHANGEDB_AmlStatusCallback cb, - void *cb_cls); - - -#endif diff --git a/src/exchangedb/pg_select_aml_threshold.c b/src/exchangedb/pg_select_aml_threshold.c deleted file mode 100644 index 23286f029..000000000 --- a/src/exchangedb/pg_select_aml_threshold.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2023 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_select_aml_threshold.c - * @brief Implementation of the select_aml_threshold function for Postgres - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_error_codes.h" -#include "taler_dbevents.h" -#include "taler_pq_lib.h" -#include "pg_select_aml_threshold.h" -#include "pg_helper.h" - - -enum GNUNET_DB_QueryStatus -TEH_PG_select_aml_threshold ( - void *cls, - const struct TALER_PaytoHashP *h_payto, - enum TALER_AmlDecisionState *decision, - struct TALER_EXCHANGEDB_KycStatus *kyc, - struct TALER_Amount *threshold) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (h_payto), - GNUNET_PQ_query_param_end - }; - uint32_t status32 = TALER_AML_NORMAL; - struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT ("threshold", - threshold), - GNUNET_PQ_result_spec_uint32 ("status", - &status32), - GNUNET_PQ_result_spec_uint64 ("kyc_requirement", - &kyc->requirement_row), - GNUNET_PQ_result_spec_end - }; - enum GNUNET_DB_QueryStatus qs; - - PREPARE (pg, - "select_aml_threshold", - "SELECT" - " threshold" - ",status" - ",kyc_requirement" - " FROM aml_status" - " WHERE h_payto=$1;"); - qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "select_aml_threshold", - params, - rs); - *decision = (enum TALER_AmlDecisionState) status32; - kyc->ok = (TALER_AML_FROZEN != *decision) - || (0 != kyc->requirement_row); - return qs; -} diff --git a/src/exchangedb/pg_select_aml_threshold.h b/src/exchangedb/pg_select_aml_threshold.h deleted file mode 100644 index 8f0e3bcfc..000000000 --- a/src/exchangedb/pg_select_aml_threshold.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2023 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_select_aml_threshold.h - * @brief implementation of the select_aml_threshold function for Postgres - * @author Christian Grothoff - */ -#ifndef PG_SELECT_AML_THRESHOLD_H -#define PG_SELECT_AML_THRESHOLD_H - -#include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_exchangedb_plugin.h" - - -/** - * Obtain the current AML threshold set for an account. - * - * @param cls closure - * @param h_payto account for which the AML threshold is stored - * @param[out] decision set to current AML decision - * @param[out] kyc set to KYC requirements imposed by AML, if any - * @param[out] threshold set to the existing threshold - * @return database transaction status, 0 if no threshold was set - */ -enum GNUNET_DB_QueryStatus -TEH_PG_select_aml_threshold ( - void *cls, - const struct TALER_PaytoHashP *h_payto, - enum TALER_AmlDecisionState *decision, - struct TALER_EXCHANGEDB_KycStatus *kyc, - struct TALER_Amount *threshold); - - -#endif diff --git a/src/exchangedb/pg_select_batch_deposits_missing_wire.c b/src/exchangedb/pg_select_batch_deposits_missing_wire.c index 8f966326a..38ec8e4bb 100644 --- a/src/exchangedb/pg_select_batch_deposits_missing_wire.c +++ b/src/exchangedb/pg_select_batch_deposits_missing_wire.c @@ -71,7 +71,7 @@ missing_wire_cb (void *cls, { uint64_t batch_deposit_serial_id; struct GNUNET_TIME_Timestamp deadline; - struct TALER_PaytoHashP wire_target_h_payto; + struct TALER_FullPaytoHashP wire_target_h_payto; struct TALER_Amount total_amount; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("batch_deposit_serial_id", diff --git a/src/exchangedb/pg_select_coin_deposits_above_serial_id.c b/src/exchangedb/pg_select_coin_deposits_above_serial_id.c index 000b908ed..2747b9dcc 100644 --- a/src/exchangedb/pg_select_coin_deposits_above_serial_id.c +++ b/src/exchangedb/pg_select_coin_deposits_above_serial_id.c @@ -108,7 +108,7 @@ coin_deposit_serial_helper_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("wire_salt", &deposit.wire_salt), GNUNET_PQ_result_spec_string ("receiver_wire_account", - &deposit.receiver_wire_account), + &deposit.receiver_wire_account.full_payto), GNUNET_PQ_result_spec_bool ("done", &done), GNUNET_PQ_result_spec_uint64 ("coin_deposit_serial_id", diff --git a/src/exchangedb/pg_select_deposit_amounts_for_kyc_check.c b/src/exchangedb/pg_select_deposit_amounts_for_kyc_check.c index c34fd1da5..29bf606de 100644 --- a/src/exchangedb/pg_select_deposit_amounts_for_kyc_check.c +++ b/src/exchangedb/pg_select_deposit_amounts_for_kyc_check.c @@ -111,7 +111,7 @@ get_kyc_amounts_cb (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_select_deposit_amounts_for_kyc_check ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls) @@ -138,7 +138,11 @@ TEH_PG_select_deposit_amounts_for_kyc_check ( " FROM batch_deposits bd" " JOIN coin_deposits cd" " USING (batch_deposit_serial_id)" - " WHERE wire_target_h_payto=$1" + " WHERE wire_target_h_payto IN (" + " SELECT wire_target_h_payto" + " FROM wire_targets" + " WHERE h_normalized_payto=$1" + " )" " AND bd.exchange_timestamp >= $2" " ORDER BY bd.exchange_timestamp DESC"); qs = GNUNET_PQ_eval_prepared_multi_select ( diff --git a/src/exchangedb/pg_select_deposit_amounts_for_kyc_check.h b/src/exchangedb/pg_select_deposit_amounts_for_kyc_check.h index 7e4ab31b2..5cc2c2c60 100644 --- a/src/exchangedb/pg_select_deposit_amounts_for_kyc_check.h +++ b/src/exchangedb/pg_select_deposit_amounts_for_kyc_check.h @@ -42,7 +42,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_deposit_amounts_for_kyc_check ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); diff --git a/src/exchangedb/pg_select_justification_for_missing_wire.c b/src/exchangedb/pg_select_justification_for_missing_wire.c deleted file mode 100644 index 77d5b4de7..000000000 --- a/src/exchangedb/pg_select_justification_for_missing_wire.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022-2023 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_select_batch_deposits_missing_wire.c - * @brief Implementation of the select_batch_deposits_missing_wire function for Postgres - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_error_codes.h" -#include "taler_dbevents.h" -#include "taler_pq_lib.h" -#include "pg_select_batch_deposits_missing_wire.h" -#include "pg_helper.h" - - -enum GNUNET_DB_QueryStatus -TEH_PG_select_justification_for_missing_wire ( - void *cls, - const struct TALER_PaytoHashP *wire_target_h_payto, - char **payto_uri, - char **kyc_pending, - enum TALER_AmlDecisionState *status, - struct TALER_Amount *aml_limit) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_TIME_Absolute now - = GNUNET_TIME_absolute_get (); - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (wire_target_h_payto), - GNUNET_PQ_query_param_absolute_time (&now), - GNUNET_PQ_query_param_end - }; - uint32_t aml_status32; - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_string ("payto_uri", - payto_uri), - NULL), - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_string ("kyc_pending", - kyc_pending), - NULL), - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_uint32 ("aml_status", - &aml_status32), - NULL), - GNUNET_PQ_result_spec_allow_null ( - TALER_PQ_RESULT_SPEC_AMOUNT ("aml_limit", - aml_limit), - NULL), - GNUNET_PQ_result_spec_end - }; - enum GNUNET_DB_QueryStatus qs; - - PREPARE (pg, - "deposits_get_overdue", - "SELECT" - " out_payto_uri AS payto_uri" - ",out_kyc_pending AS kyc_pending" - ",out_deadline AS deadline" - ",out_aml_status AS aml_status" - ",out_aml_limit AS aml_limit" - " FROM exchange_do_select_justification_missing_wire" - " ($1, $2);"); - memset (aml_limit, - 0, - sizeof (*aml_limit)); - qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "", - params, - rs); - if (qs <= 0) - return qs; - *status = (enum TALER_AmlDecisionState) aml_status32; - return qs; -} diff --git a/src/exchangedb/pg_select_justification_for_missing_wire.h b/src/exchangedb/pg_select_justification_for_missing_wire.h deleted file mode 100644 index 7f73eb511..000000000 --- a/src/exchangedb/pg_select_justification_for_missing_wire.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_select_justification_for_missing_wire.h - * @brief implementation of the select_justification_for_missing_wire function for Postgres - * @author Christian Grothoff - */ -#ifndef PG_SELECT_JUSTIFICATION_FOR_MISSING_WIRE_H -#define PG_SELECT_JUSTIFICATION_FOR_MISSING_WIRE_H - -#include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_exchangedb_plugin.h" - -/** - * Select all of those justifications for why we might not have - * done a wire transfer from in the database for a particular target account. - * - * @param cls closure - * @param wire_target_h_payto effected target account - * @param[out] payto_uri target account URI, set to NULL if unknown - * @param[out] kyc_pending set to string describing missing KYC data - * @param[out] status set to AML status - * @param[out] aml_limit set to AML limit, or invalid amount for none - * @return transaction status code - */ -enum GNUNET_DB_QueryStatus -TEH_PG_select_justification_for_missing_wire ( - void *cls, - const struct TALER_PaytoHashP *wire_target_h_payto, - char **payto_uri, - char **kyc_pending, - enum TALER_AmlDecisionState *status, - struct TALER_Amount *aml_limit); - -#endif diff --git a/src/exchangedb/pg_select_kyc_attributes.c b/src/exchangedb/pg_select_kyc_attributes.c index 41a96b0e3..37f1489ae 100644 --- a/src/exchangedb/pg_select_kyc_attributes.c +++ b/src/exchangedb/pg_select_kyc_attributes.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -49,7 +49,7 @@ struct GetAttributesContext /** * Key of our query. */ - const struct TALER_PaytoHashP *h_payto; + const struct TALER_NormalizedPaytoHashP *h_payto; /** * Flag set to #GNUNET_OK as long as everything is fine. @@ -117,7 +117,7 @@ get_attributes_cb (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_select_kyc_attributes ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AttributeCallback cb, void *cb_cls) { diff --git a/src/exchangedb/pg_select_kyc_attributes.h b/src/exchangedb/pg_select_kyc_attributes.h index 7458aefe8..33163dca6 100644 --- a/src/exchangedb/pg_select_kyc_attributes.h +++ b/src/exchangedb/pg_select_kyc_attributes.h @@ -38,7 +38,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_kyc_attributes ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AttributeCallback cb, void *cb_cls); diff --git a/src/exchangedb/pg_select_merge_amounts_for_kyc_check.c b/src/exchangedb/pg_select_merge_amounts_for_kyc_check.c index 8df91a398..3d795b5e0 100644 --- a/src/exchangedb/pg_select_merge_amounts_for_kyc_check.c +++ b/src/exchangedb/pg_select_merge_amounts_for_kyc_check.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -112,7 +112,7 @@ get_kyc_amounts_cb (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_select_merge_amounts_for_kyc_check ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls) diff --git a/src/exchangedb/pg_select_merge_amounts_for_kyc_check.h b/src/exchangedb/pg_select_merge_amounts_for_kyc_check.h index 5d0a96359..ead8e3f55 100644 --- a/src/exchangedb/pg_select_merge_amounts_for_kyc_check.h +++ b/src/exchangedb/pg_select_merge_amounts_for_kyc_check.h @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_merge_amounts_for_kyc_check ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); diff --git a/src/exchangedb/pg_select_reserve_close_info.c b/src/exchangedb/pg_select_reserve_close_info.c index fff07944b..6194e1ed3 100644 --- a/src/exchangedb/pg_select_reserve_close_info.c +++ b/src/exchangedb/pg_select_reserve_close_info.c @@ -31,7 +31,7 @@ TEH_PG_select_reserve_close_info ( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_Amount *balance, - char **payto_uri) + struct TALER_FullPayto *payto_uri) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -43,7 +43,7 @@ TEH_PG_select_reserve_close_info ( pg->currency, balance), GNUNET_PQ_result_spec_string ("payto_uri", - payto_uri), + &payto_uri->full_payto), GNUNET_PQ_result_spec_end }; diff --git a/src/exchangedb/pg_select_reserve_close_info.h b/src/exchangedb/pg_select_reserve_close_info.h index 2b90ffd05..d42a7eb38 100644 --- a/src/exchangedb/pg_select_reserve_close_info.h +++ b/src/exchangedb/pg_select_reserve_close_info.h @@ -43,7 +43,7 @@ TEH_PG_select_reserve_close_info ( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_Amount *balance, - char **payto_uri); + struct TALER_FullPayto *payto_uri); #endif diff --git a/src/exchangedb/pg_select_reserve_closed_above_serial_id.c b/src/exchangedb/pg_select_reserve_closed_above_serial_id.c index 9f239fe40..2b5267b4c 100644 --- a/src/exchangedb/pg_select_reserve_closed_above_serial_id.c +++ b/src/exchangedb/pg_select_reserve_closed_above_serial_id.c @@ -74,7 +74,7 @@ reserve_closed_serial_helper_cb (void *cls, { uint64_t rowid; struct TALER_ReservePublicKeyP reserve_pub; - char *receiver_account; + struct TALER_FullPayto receiver_account; struct TALER_WireTransferIdentifierRawP wtid; struct TALER_Amount amount_with_fee; struct TALER_Amount closing_fee; @@ -90,7 +90,7 @@ reserve_closed_serial_helper_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("wtid", &wtid), GNUNET_PQ_result_spec_string ("receiver_account", - &receiver_account), + &receiver_account.full_payto), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &amount_with_fee), TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", @@ -146,8 +146,6 @@ TEH_PG_select_reserve_closed_above_serial_id ( }; enum GNUNET_DB_QueryStatus qs; - /* Used in #postgres_select_reserve_closed_above_serial_id() to - obtain information about closed reserves */ PREPARE ( pg, "reserves_close_get_incr", diff --git a/src/exchangedb/pg_select_reserves_in_above_serial_id.c b/src/exchangedb/pg_select_reserves_in_above_serial_id.c index 34e1969aa..c21354b39 100644 --- a/src/exchangedb/pg_select_reserves_in_above_serial_id.c +++ b/src/exchangedb/pg_select_reserves_in_above_serial_id.c @@ -73,7 +73,7 @@ reserves_in_serial_helper_cb (void *cls, { struct TALER_ReservePublicKeyP reserve_pub; struct TALER_Amount credit; - char *sender_account_details; + struct TALER_FullPayto sender_account_details; struct GNUNET_TIME_Timestamp execution_date; uint64_t rowid; uint64_t wire_reference; @@ -87,7 +87,7 @@ reserves_in_serial_helper_cb (void *cls, GNUNET_PQ_result_spec_timestamp ("execution_date", &execution_date), GNUNET_PQ_result_spec_string ("sender_account_details", - &sender_account_details), + &sender_account_details.full_payto), GNUNET_PQ_result_spec_uint64 ("reserve_in_serial_id", &rowid), GNUNET_PQ_result_spec_end diff --git a/src/exchangedb/pg_select_reserves_in_above_serial_id_by_account.c b/src/exchangedb/pg_select_reserves_in_above_serial_id_by_account.c index 1c7bc15a0..a6ffffc12 100644 --- a/src/exchangedb/pg_select_reserves_in_above_serial_id_by_account.c +++ b/src/exchangedb/pg_select_reserves_in_above_serial_id_by_account.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -74,7 +74,7 @@ reserves_in_serial_helper_cb (void *cls, { struct TALER_ReservePublicKeyP reserve_pub; struct TALER_Amount credit; - char *sender_account_details; + struct TALER_FullPayto sender_account_details; struct GNUNET_TIME_Timestamp execution_date; uint64_t rowid; uint64_t wire_reference; @@ -88,7 +88,7 @@ reserves_in_serial_helper_cb (void *cls, GNUNET_PQ_result_spec_timestamp ("execution_date", &execution_date), GNUNET_PQ_result_spec_string ("sender_account_details", - &sender_account_details), + &sender_account_details.full_payto), GNUNET_PQ_result_spec_uint64 ("reserve_in_serial_id", &rowid), GNUNET_PQ_result_spec_end @@ -157,11 +157,12 @@ TEH_PG_select_reserves_in_above_serial_id_by_account ( " WHERE reserve_in_serial_id>=$1" " AND exchange_account_section=$2" " ORDER BY reserve_in_serial_id ASC;"); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "audit_reserves_in_get_transactions_incr_by_account", - params, - &reserves_in_serial_helper_cb, - &risc); + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + "audit_reserves_in_get_transactions_incr_by_account", + params, + &reserves_in_serial_helper_cb, + &risc); if (GNUNET_OK != risc.status) return GNUNET_DB_STATUS_HARD_ERROR; return qs; diff --git a/src/exchangedb/pg_select_wire_out_above_serial_id.c b/src/exchangedb/pg_select_wire_out_above_serial_id.c index 8668c429d..1315070cc 100644 --- a/src/exchangedb/pg_select_wire_out_above_serial_id.c +++ b/src/exchangedb/pg_select_wire_out_above_serial_id.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -74,7 +74,7 @@ wire_out_serial_helper_cb (void *cls, uint64_t rowid; struct GNUNET_TIME_Timestamp date; struct TALER_WireTransferIdentifierRawP wtid; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_Amount amount; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("wireout_uuid", @@ -84,7 +84,7 @@ wire_out_serial_helper_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("wtid_raw", &wtid), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &amount), GNUNET_PQ_result_spec_end @@ -132,7 +132,7 @@ TEH_PG_select_wire_out_above_serial_id ( .status = GNUNET_OK }; enum GNUNET_DB_QueryStatus qs; - /* Used in #postgres_select_wire_out_above_serial_id() */ + PREPARE (pg, "audit_get_wire_incr", "SELECT" @@ -142,8 +142,8 @@ TEH_PG_select_wire_out_above_serial_id ( ",payto_uri" ",amount" " FROM wire_out" - " JOIN wire_targets" - " USING (wire_target_h_payto)" + " JOIN wire_targets" + " USING (wire_target_h_payto)" " WHERE wireout_uuid>=$1" " ORDER BY wireout_uuid ASC;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, diff --git a/src/exchangedb/pg_select_wire_out_above_serial_id_by_account.c b/src/exchangedb/pg_select_wire_out_above_serial_id_by_account.c index 3448c5a49..e94b82ec6 100644 --- a/src/exchangedb/pg_select_wire_out_above_serial_id_by_account.c +++ b/src/exchangedb/pg_select_wire_out_above_serial_id_by_account.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -74,7 +74,7 @@ wire_out_serial_helper_cb (void *cls, uint64_t rowid; struct GNUNET_TIME_Timestamp date; struct TALER_WireTransferIdentifierRawP wtid; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_Amount amount; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("wireout_uuid", @@ -84,7 +84,7 @@ wire_out_serial_helper_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("wtid_raw", &wtid), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &amount), GNUNET_PQ_result_spec_end diff --git a/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.c b/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.c index 71ed81833..2e3c1a9a3 100644 --- a/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.c +++ b/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -113,7 +113,7 @@ get_kyc_amounts_cb (void *cls, enum GNUNET_DB_QueryStatus TEH_PG_select_withdraw_amounts_for_kyc_check ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls) @@ -142,7 +142,11 @@ TEH_PG_select_withdraw_amounts_for_kyc_check ( " ON (rh.reserve_pub = ri.reserve_pub)" " JOIN reserves_out ro" " ON (ro.reserve_out_serial_id = rh.serial_id)" - " WHERE ri.wire_source_h_payto=$1" + " WHERE ri.wire_source_h_payto IN (" + " SELECT wire_target_h_payto" + " FROM wire_targets" + " WHERE h_normalized_payto=$1" + " )" " AND rh.table_name='reserves_out'" " AND ro.execution_date >= $2" " ORDER BY rh.reserve_history_serial_id DESC"); diff --git a/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.h b/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.h index 9a780adbe..cd843d973 100644 --- a/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.h +++ b/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.h @@ -40,7 +40,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_select_withdraw_amounts_for_kyc_check ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); diff --git a/src/exchangedb/pg_setup_wire_target.c b/src/exchangedb/pg_setup_wire_target.c deleted file mode 100644 index ed6fbe338..000000000 --- a/src/exchangedb/pg_setup_wire_target.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_setup_wire_target.c - * @brief Implementation of the setup_wire_target function for Postgres - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_error_codes.h" -#include "taler_dbevents.h" -#include "taler_pq_lib.h" -#include "pg_setup_wire_target.h" - - -enum GNUNET_DB_QueryStatus -TEH_PG_setup_wire_target ( - struct PostgresClosure *pg, - const char *payto_uri, - struct TALER_PaytoHashP *h_payto) -{ - struct GNUNET_PQ_QueryParam iparams[] = { - GNUNET_PQ_query_param_auto_from_type (h_payto), - GNUNET_PQ_query_param_string (payto_uri), - GNUNET_PQ_query_param_end - }; - - TALER_payto_hash (payto_uri, - h_payto); - - PREPARE (pg, - "insert_kyc_status", - "INSERT INTO wire_targets" - " (wire_target_h_payto" - " ,payto_uri" - " ) VALUES " - " ($1, $2)" - " ON CONFLICT DO NOTHING"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "insert_kyc_status", - iparams); -} diff --git a/src/exchangedb/pg_setup_wire_target.h b/src/exchangedb/pg_setup_wire_target.h deleted file mode 100644 index 77512a600..000000000 --- a/src/exchangedb/pg_setup_wire_target.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_setup_wire_target.h - * @brief implementation of the setup_wire_target function for Postgres - * @author Christian Grothoff - */ -#ifndef PG_SETUP_WIRE_TARGET_H -#define PG_SETUP_WIRE_TARGET_H - -#include "taler_util.h" -#include "taler_json_lib.h" -#include "pg_helper.h" -#include "taler_exchangedb_plugin.h" - -/** - * Setup new wire target for @a payto_uri. - * - * @param pg the plugin-specific state - * @param payto_uri the payto URI to check - * @param[out] h_payto set to the hash of @a payto_uri - * @return transaction status - */ -enum GNUNET_DB_QueryStatus -TEH_PG_setup_wire_target ( - struct PostgresClosure *pg, - const char *payto_uri, - struct TALER_PaytoHashP *h_payto); - -#endif diff --git a/src/exchangedb/pg_store_wire_transfer_out.c b/src/exchangedb/pg_store_wire_transfer_out.c index 337dc5855..19d40901e 100644 --- a/src/exchangedb/pg_store_wire_transfer_out.c +++ b/src/exchangedb/pg_store_wire_transfer_out.c @@ -25,12 +25,13 @@ #include "pg_store_wire_transfer_out.h" #include "pg_helper.h" + enum GNUNET_DB_QueryStatus TEH_PG_store_wire_transfer_out ( void *cls, struct GNUNET_TIME_Timestamp date, const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const char *exchange_account_section, const struct TALER_Amount *amount) { diff --git a/src/exchangedb/pg_store_wire_transfer_out.h b/src/exchangedb/pg_store_wire_transfer_out.h index 79950e65a..8c79ea4ef 100644 --- a/src/exchangedb/pg_store_wire_transfer_out.h +++ b/src/exchangedb/pg_store_wire_transfer_out.h @@ -41,7 +41,7 @@ TEH_PG_store_wire_transfer_out ( void *cls, struct GNUNET_TIME_Timestamp date, const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const char *exchange_account_section, const struct TALER_Amount *amount); diff --git a/src/exchangedb/pg_trigger_aml_process.c b/src/exchangedb/pg_trigger_aml_process.c deleted file mode 100644 index 7534fe3df..000000000 --- a/src/exchangedb/pg_trigger_aml_process.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_trigger_aml_process.c - * @brief Implementation of the trigger_aml_process function for Postgres - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_error_codes.h" -#include "taler_dbevents.h" -#include "taler_pq_lib.h" -#include "pg_trigger_aml_process.h" -#include "pg_helper.h" - - -enum GNUNET_DB_QueryStatus -TEH_PG_trigger_aml_process ( - void *cls, - const struct TALER_PaytoHashP *h_payto, - const struct TALER_Amount *threshold_crossed) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (h_payto), - TALER_PQ_query_param_amount (pg->conn, - threshold_crossed), - GNUNET_PQ_query_param_end - }; - - PREPARE (pg, - "trigger_aml_process", - "INSERT INTO aml_status" - "(h_payto" - ",threshold" - ",status)" - " VALUES" - " ($1, $2, 1)" // 1: decision needed - " ON CONFLICT (h_payto) DO" - " UPDATE SET" - " threshold=$2" - " ,status=aml_status.status | 1;"); // do not clear 'frozen' status - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "trigger_aml_process", - params); -} diff --git a/src/exchangedb/pg_trigger_aml_process.h b/src/exchangedb/pg_trigger_aml_process.h deleted file mode 100644 index 2283571af..000000000 --- a/src/exchangedb/pg_trigger_aml_process.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ -/** - * @file exchangedb/pg_trigger_aml_process.h - * @brief implementation of the trigger_aml_process function for Postgres - * @author Christian Grothoff - */ -#ifndef PG_TRIGGER_AML_PROCESS_H -#define PG_TRIGGER_AML_PROCESS_H - -#include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_exchangedb_plugin.h" - - -/** - * Trigger AML process, an account has crossed the threshold. Inserts or - * updates the AML status. - * - * @param cls closure - * @param h_payto account for which the attribute data is stored - * @param threshold_crossed existing threshold that was crossed - * @return database transaction status - */ -enum GNUNET_DB_QueryStatus -TEH_PG_trigger_aml_process ( - void *cls, - const struct TALER_PaytoHashP *h_payto, - const struct TALER_Amount *threshold_crossed); - - -#endif diff --git a/src/exchangedb/pg_trigger_kyc_rule_for_account.c b/src/exchangedb/pg_trigger_kyc_rule_for_account.c index e6f5ffcf9..d2594c64d 100644 --- a/src/exchangedb/pg_trigger_kyc_rule_for_account.c +++ b/src/exchangedb/pg_trigger_kyc_rule_for_account.c @@ -29,8 +29,8 @@ enum GNUNET_DB_QueryStatus TEH_PG_trigger_kyc_rule_for_account ( void *cls, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPublicKeyP *set_account_pub, const struct TALER_MerchantPublicKeyP *check_merchant_pub, const json_t *jmeasures, @@ -48,6 +48,7 @@ TEH_PG_trigger_kyc_rule_for_account ( }; char *notify_str = GNUNET_PQ_get_event_notify_channel (&rep.header); + struct TALER_FullPaytoHashP h_full_payto; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (h_payto), NULL == set_account_pub @@ -56,9 +57,12 @@ TEH_PG_trigger_kyc_rule_for_account ( NULL == check_merchant_pub ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_auto_from_type (check_merchant_pub), - NULL == payto_uri + NULL == payto_uri.full_payto ? GNUNET_PQ_query_param_null () - : GNUNET_PQ_query_param_string (payto_uri), + : GNUNET_PQ_query_param_string (payto_uri.full_payto), + NULL == payto_uri.full_payto + ? GNUNET_PQ_query_param_null () + : GNUNET_PQ_query_param_auto_from_type (&h_full_payto), GNUNET_PQ_query_param_absolute_time (&now), TALER_PQ_query_param_json (jmeasures), GNUNET_PQ_query_param_uint32 (&display_priority), @@ -84,8 +88,10 @@ TEH_PG_trigger_kyc_rule_for_account ( " ,out_bad_kyc_auth" " AS bad_kyc_auth" " FROM exchange_do_trigger_kyc_rule_for_account" - "($1, $2, $3, $4, $5, $6, $7, $8);"); - + "($1, $2, $3, $4, $5, $6, $7, $8, $9);"); + if (NULL != payto_uri.full_payto) + TALER_full_payto_hash (payto_uri, + &h_full_payto); qs = GNUNET_PQ_eval_prepared_singleton_select ( pg->conn, "trigger_kyc_rule_for_account", diff --git a/src/exchangedb/pg_trigger_kyc_rule_for_account.h b/src/exchangedb/pg_trigger_kyc_rule_for_account.h index 56ee0ca8b..a0f11a4b8 100644 --- a/src/exchangedb/pg_trigger_kyc_rule_for_account.h +++ b/src/exchangedb/pg_trigger_kyc_rule_for_account.h @@ -49,8 +49,8 @@ enum GNUNET_DB_QueryStatus TEH_PG_trigger_kyc_rule_for_account ( void *cls, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPublicKeyP *set_account_pub, const struct TALER_MerchantPublicKeyP *check_merchant_pub, const json_t *jmeasures, diff --git a/src/exchangedb/pg_update_aggregation_transient.c b/src/exchangedb/pg_update_aggregation_transient.c index 38b65316e..406fb839d 100644 --- a/src/exchangedb/pg_update_aggregation_transient.c +++ b/src/exchangedb/pg_update_aggregation_transient.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_update_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_WireTransferIdentifierRawP *wtid, uint64_t kyc_requirement_row, const struct TALER_Amount *total) diff --git a/src/exchangedb/pg_update_aggregation_transient.h b/src/exchangedb/pg_update_aggregation_transient.h index c444e85bb..7ef07d8f2 100644 --- a/src/exchangedb/pg_update_aggregation_transient.h +++ b/src/exchangedb/pg_update_aggregation_transient.h @@ -24,6 +24,8 @@ #include "taler_util.h" #include "taler_json_lib.h" #include "taler_exchangedb_plugin.h" + + /** * Update existing entry in the transient aggregation table. * @a h_payto is only needed for query performance. @@ -38,7 +40,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_update_aggregation_transient ( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_WireTransferIdentifierRawP *wtid, uint64_t kyc_requirement_row, const struct TALER_Amount *total); diff --git a/src/exchangedb/pg_update_kyc_process_by_row.c b/src/exchangedb/pg_update_kyc_process_by_row.c index ec0ef24bc..14f773081 100644 --- a/src/exchangedb/pg_update_kyc_process_by_row.c +++ b/src/exchangedb/pg_update_kyc_process_by_row.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -31,7 +31,7 @@ TEH_PG_update_kyc_process_by_row ( void *cls, uint64_t process_row, const char *provider_name, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_account_id, const char *provider_legitimization_id, const char *redirect_url, diff --git a/src/exchangedb/pg_update_kyc_process_by_row.h b/src/exchangedb/pg_update_kyc_process_by_row.h index 86e82ed30..4f1f9c2b6 100644 --- a/src/exchangedb/pg_update_kyc_process_by_row.h +++ b/src/exchangedb/pg_update_kyc_process_by_row.h @@ -47,7 +47,7 @@ TEH_PG_update_kyc_process_by_row ( void *cls, uint64_t process_row, const char *provider_name, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_account_id, const char *provider_legitimization_id, const char *redirect_url, diff --git a/src/exchangedb/pg_update_wire.c b/src/exchangedb/pg_update_wire.c index 5c4bb9045..b5041fa49 100644 --- a/src/exchangedb/pg_update_wire.c +++ b/src/exchangedb/pg_update_wire.c @@ -27,20 +27,21 @@ enum GNUNET_DB_QueryStatus -TEH_PG_update_wire (void *cls, - const char *payto_uri, - const char *conversion_url, - const json_t *debit_restrictions, - const json_t *credit_restrictions, - struct GNUNET_TIME_Timestamp change_date, - const struct TALER_MasterSignatureP *master_sig, - const char *bank_label, - int64_t priority, - bool enabled) +TEH_PG_update_wire ( + void *cls, + const struct TALER_FullPayto payto_uri, + const char *conversion_url, + const json_t *debit_restrictions, + const json_t *credit_restrictions, + struct GNUNET_TIME_Timestamp change_date, + const struct TALER_MasterSignatureP *master_sig, + const char *bank_label, + int64_t priority, + bool enabled) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_bool (enabled), NULL == conversion_url ? GNUNET_PQ_query_param_null () diff --git a/src/exchangedb/pg_update_wire.h b/src/exchangedb/pg_update_wire.h index a596a0802..4d3f22f79 100644 --- a/src/exchangedb/pg_update_wire.h +++ b/src/exchangedb/pg_update_wire.h @@ -44,7 +44,7 @@ */ enum GNUNET_DB_QueryStatus TEH_PG_update_wire (void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, diff --git a/src/exchangedb/pg_wad_in_insert.c b/src/exchangedb/pg_wad_in_insert.c index 95d792b14..805784904 100644 --- a/src/exchangedb/pg_wad_in_insert.c +++ b/src/exchangedb/pg_wad_in_insert.c @@ -32,7 +32,7 @@ TEH_PG_wad_in_insert ( const char *origin_exchange_url, const struct TALER_Amount *amount, struct GNUNET_TIME_Timestamp execution_date, - const char *debit_account_uri, + const struct TALER_FullPayto debit_account_uri, const char *section_name, uint64_t serial_id) { diff --git a/src/exchangedb/pg_wad_in_insert.h b/src/exchangedb/pg_wad_in_insert.h index d6c2b25c4..0b5a229ef 100644 --- a/src/exchangedb/pg_wad_in_insert.h +++ b/src/exchangedb/pg_wad_in_insert.h @@ -45,7 +45,7 @@ TEH_PG_wad_in_insert ( const char *origin_exchange_url, const struct TALER_Amount *amount, struct GNUNET_TIME_Timestamp execution_date, - const char *debit_account_uri, + const struct TALER_FullPayto debit_account_uri, const char *section_name, uint64_t serial_id); diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c index 562710eaa..3141c9ab2 100644 --- a/src/exchangedb/plugin_exchangedb_common.c +++ b/src/exchangedb/plugin_exchangedb_common.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015, 2016, 2020 Taler Systems SA + Copyright (C) 2015, 2016, 2020, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -38,7 +38,7 @@ TEH_COMMON_free_reserve_history ( struct TALER_EXCHANGEDB_BankTransfer *bt; bt = rh->details.bank; - GNUNET_free (bt->sender_account_details); + GNUNET_free (bt->sender_account_details.full_payto); GNUNET_free (bt); break; } @@ -65,7 +65,7 @@ TEH_COMMON_free_reserve_history ( struct TALER_EXCHANGEDB_ClosingTransfer *closing; closing = rh->details.closing; - GNUNET_free (closing->receiver_account_details); + GNUNET_free (closing->receiver_account_details.full_payto); GNUNET_free (closing); break; } @@ -128,7 +128,7 @@ TEH_COMMON_free_coin_transaction_list ( struct TALER_EXCHANGEDB_DepositListEntry *deposit; deposit = tl->details.deposit; - GNUNET_free (deposit->receiver_wire_account); + GNUNET_free (deposit->receiver_wire_account.full_payto); GNUNET_free (deposit); break; } diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index b5d410fc1..c30a0e478 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -49,7 +49,6 @@ #include "pg_get_unfinished_close_requests.h" #include "pg_insert_close_request.h" #include "pg_insert_records_by_table.h" -#include "pg_insert_programmatic_legitimization_outcome.h" #include "pg_insert_reserve_open_deposit.h" #include "pg_get_pending_kyc_requirement_process.h" #include "pg_iterate_kyc_reference.h" @@ -221,16 +220,15 @@ #include "pg_select_purse_by_merge_pub.h" #include "pg_set_purse_balance.h" #include "pg_reserves_update.h" -#include "pg_setup_wire_target.h" #include "pg_compute_shard.h" -#include "pg_insert_kyc_attributes.h" +#include "pg_insert_kyc_measure_result.h" #include "pg_select_kyc_attributes.h" #include "pg_insert_aml_officer.h" #include "pg_test_aml_officer.h" #include "pg_lookup_aml_officer.h" -#include "pg_trigger_aml_process.h" #include "pg_lookup_kyc_requirement_by_row.h" #include "pg_insert_aml_decision.h" +#include "pg_insert_successor_measure.h" #include "pg_batch_ensure_coin_known.h" #include "plugin_exchangedb_postgres.h" @@ -261,67 +259,6 @@ /** - * Connect to the database if the connection does not exist yet. - * - * @param pg the plugin-specific state - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -TEH_PG_internal_setup (struct PostgresClosure *pg) -{ - if (NULL == pg->conn) - { -#if AUTO_EXPLAIN - /* Enable verbose logging to see where queries do not - properly use indices */ - struct GNUNET_PQ_ExecuteStatement es[] = { - GNUNET_PQ_make_try_execute ("LOAD 'auto_explain';"), - GNUNET_PQ_make_try_execute ("SET auto_explain.log_min_duration=50;"), - GNUNET_PQ_make_try_execute ("SET auto_explain.log_timing=TRUE;"), - GNUNET_PQ_make_try_execute ("SET auto_explain.log_analyze=TRUE;"), - /* https://wiki.postgresql.org/wiki/Serializable suggests to really - force the default to 'serializable' if SSI is to be used. */ - GNUNET_PQ_make_try_execute ( - "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), - GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), - GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), - GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"), - /* Mergejoin causes issues, see Postgres #18380 */ - GNUNET_PQ_make_try_execute ("SET enable_mergejoin=OFF;"), - GNUNET_PQ_EXECUTE_STATEMENT_END - }; -#else - struct GNUNET_PQ_ExecuteStatement es[] = { - GNUNET_PQ_make_try_execute ( - "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), - GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), - GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), - /* Mergejoin causes issues, see Postgres #18380 */ - GNUNET_PQ_make_try_execute ("SET enable_mergejoin=OFF;"), - GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"), - GNUNET_PQ_EXECUTE_STATEMENT_END - }; -#endif - struct GNUNET_PQ_Context *db_conn; - - db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg, - "exchangedb-postgres", - NULL, - es, - NULL); - if (NULL == db_conn) - return GNUNET_SYSERR; - - pg->prep_gen++; - pg->conn = db_conn; - } - if (NULL == pg->transaction_name) - GNUNET_PQ_reconnect_if_down (pg->conn); - return GNUNET_OK; -} - - -/** * Initialize Postgres database subsystem. * * @param cls a configuration instance @@ -430,15 +367,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) GNUNET_free (pg); return NULL; } - if (GNUNET_OK != - TEH_PG_internal_setup (pg)) - { - GNUNET_free (pg->exchange_url); - GNUNET_free (pg->currency); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; - } plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin); plugin->cls = pg; plugin->do_reserve_open @@ -787,8 +715,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) = &TEH_PG_abort_shard; plugin->insert_kyc_failure = &TEH_PG_insert_kyc_failure; - plugin->insert_programmatic_legitimization_outcome - = &TEH_PG_insert_programmatic_legitimization_outcome; plugin->complete_shard = &TEH_PG_complete_shard; plugin->release_revolving_shard @@ -807,8 +733,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) = &TEH_PG_set_purse_balance; plugin->get_pending_kyc_requirement_process = &TEH_PG_get_pending_kyc_requirement_process; - plugin->insert_kyc_attributes - = &TEH_PG_insert_kyc_attributes; + plugin->insert_kyc_measure_result + = &TEH_PG_insert_kyc_measure_result; plugin->select_kyc_attributes = &TEH_PG_select_kyc_attributes; plugin->insert_aml_officer @@ -819,8 +745,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) = &TEH_PG_lookup_aml_officer; plugin->insert_active_legitimization_measure = &TEH_PG_insert_active_legitimization_measure; - plugin->trigger_aml_process - = &TEH_PG_trigger_aml_process; plugin->insert_aml_decision = &TEH_PG_insert_aml_decision; plugin->lookup_kyc_requirement_by_row @@ -833,6 +757,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) = &TEH_PG_batch_ensure_coin_known; plugin->inject_auditor_triggers = &TEH_PG_inject_auditor_triggers; + plugin->insert_successor_measure + = &TEH_PG_insert_successor_measure; return plugin; } diff --git a/src/exchangedb/procedures.sql.in b/src/exchangedb/procedures.sql.in index 0c25e8f5d..bd6dd27fa 100644 --- a/src/exchangedb/procedures.sql.in +++ b/src/exchangedb/procedures.sql.in @@ -44,8 +44,9 @@ SET search_path TO exchange; #include "exchange_do_reserve_open.sql" #include "exchange_do_insert_or_update_policy_details.sql" #include "exchange_do_insert_aml_decision.sql" +#include "exchange_do_insert_successor_measure.sql" #include "exchange_do_insert_aml_officer.sql" -#include "exchange_do_insert_kyc_attributes.sql" +#include "exchange_do_insert_kyc_measure_result.sql" #include "exchange_do_reserves_in_insert.sql" #include "exchange_do_batch_reserves_update.sql" #include "exchange_do_get_link_data.sql" @@ -53,7 +54,6 @@ SET search_path TO exchange; #include "exchange_do_kycauth_in_insert.sql" #include "exchange_do_trigger_kyc_rule_for_account.sql" #include "exchange_do_lookup_kyc_requirement_by_row.sql" -#include "exchange_do_insert_programmatic_legitimization_outcome.sql" #include "exchange_do_insert_active_legitimization_measure.sql" #include "exchange_do_select_aggregations_above_serial.sql" diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 93eed3e52..b63a7ce8d 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -523,8 +523,8 @@ static void cb_wt_never (void *cls, uint64_t serial_id, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *account_payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto account_payto_uri, + const struct TALER_FullPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp exec_time, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_DenominationPublicKey *denom_pub, @@ -565,8 +565,8 @@ static void cb_wt_check (void *cls, uint64_t rowid, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *account_payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto account_payto_uri, + const struct TALER_FullPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp exec_time, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_DenominationPublicKey *denom_pub, @@ -580,7 +580,7 @@ cb_wt_check (void *cls, GNUNET_assert (cls == &cb_wt_never); GNUNET_assert (0 == GNUNET_memcmp (merchant_pub, &merchant_pub_wt)); - GNUNET_assert (0 == strcmp (account_payto_uri, + GNUNET_assert (0 == strcmp (account_payto_uri.full_payto, "payto://iban/DE67830654080004822650?receiver-name=Test")); GNUNET_assert (GNUNET_TIME_timestamp_cmp (exec_time, ==, @@ -599,7 +599,7 @@ cb_wt_check (void *cls, /** * Here we store the hash of the payto URI. */ -static struct TALER_PaytoHashP global_wire_target_h_payto; +static struct TALER_FullPaytoHashP global_wire_target_h_payto; /** @@ -693,7 +693,7 @@ audit_reserve_in_cb (void *cls, uint64_t rowid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *credit, - const char *sender_account_details, + const struct TALER_FullPayto sender_account_details, uint64_t wire_reference, struct GNUNET_TIME_Timestamp execution_date) { @@ -907,7 +907,7 @@ audit_wire_cb (void *cls, uint64_t rowid, struct GNUNET_TIME_Timestamp date, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_Amount *amount) { (void) cls; @@ -937,11 +937,11 @@ static enum GNUNET_GenericReturnValue test_wire_out (const struct TALER_EXCHANGEDB_BatchDeposit *bd) { const struct TALER_EXCHANGEDB_CoinDepositInformation *deposit = &bd->cdis[0]; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; GNUNET_assert (0 < bd->num_cdis); - TALER_payto_hash (bd->receiver_wire_account, - &h_payto); + TALER_full_payto_hash (bd->receiver_wire_account, + &h_payto); auditor_row_cnt = 0; memset (&wire_out_wtid, 41, @@ -1126,7 +1126,7 @@ wire_missing_cb ( void *cls, uint64_t batch_deposit_serial_id, const struct TALER_Amount *total_amount, - const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_FullPaytoHashP *wire_target_h_payto, struct GNUNET_TIME_Timestamp deadline) { const struct TALER_EXCHANGEDB_CoinDepositInformation *deposit = cls; @@ -1193,8 +1193,12 @@ run (void *cls) struct TALER_CoinSpendPublicKeyP cpub2; struct TALER_MerchantPublicKeyP mpub2; struct TALER_EXCHANGEDB_Refund refund; - const char *sndr = "payto://x-taler-bank/localhost:8080/1"; - const char *rcvr = "payto://x-taler-bank/localhost:8080/2"; + const struct TALER_FullPayto sndr = { + (char *) "payto://x-taler-bank/localhost:8080/1?receiver-name=1" + }; + const struct TALER_FullPayto rcvr = { + (char *) "payto://x-taler-bank/localhost:8080/2?receiver-name=1" + }; const uint32_t num_partitions = 10; unsigned int matched; enum GNUNET_DB_QueryStatus qs; @@ -1219,7 +1223,7 @@ run (void *cls) memset (&bd, 0, sizeof (bd)); - bd.receiver_wire_account = (char *) rcvr; + bd.receiver_wire_account = rcvr; bd.cdis = &deposit; bd.num_cdis = 1; memset (&salt, @@ -1231,7 +1235,8 @@ run (void *cls) ZR_BLK (&cbc); ZR_BLK (&cbc2); if (NULL == - (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) + (plugin = TALER_EXCHANGEDB_plugin_load (cfg, + true))) { result = 77; return; @@ -1518,7 +1523,7 @@ run (void *cls) bool balance_ok; uint32_t bad_balance_idx; bool in_conflict; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; RND_BLK (&h_payto); bd.refund_deadline @@ -1910,8 +1915,9 @@ run (void *cls) /* this is the amount we transferred twice*/ FAILIF (1 != bt->amount.value); FAILIF (1000 != bt->amount.fraction); - FAILIF (0 != strcmp (CURRENCY, bt->amount.currency)); - FAILIF (NULL == bt->sender_account_details); + FAILIF (0 != strcmp (CURRENCY, + bt->amount.currency)); + FAILIF (NULL == bt->sender_account_details.full_payto); break; case TALER_EXCHANGEDB_RO_WITHDRAW_COIN: withdraw = rh_head->details.withdraw; @@ -2142,10 +2148,10 @@ run (void *cls) RND_BLK (&bd.merchant_pub); RND_BLK (&bd.h_contract_terms); RND_BLK (&bd.wire_salt); - bd.receiver_wire_account = - "payto://iban/DE67830654080004822650?receiver-name=Test"; + bd.receiver_wire_account.full_payto = + (char *) "payto://iban/DE67830654080004822650?receiver-name=Test"; TALER_merchant_wire_signature_hash ( - "payto://iban/DE67830654080004822650?receiver-name=Test", + bd.receiver_wire_account, &bd.wire_salt, &h_wire_wt); deposit.amount_with_fee = value; @@ -2176,8 +2182,8 @@ run (void *cls) uint32_t bad_idx; bool ctr_conflict; - TALER_payto_hash (bd.receiver_wire_account, - &bd.wire_target_h_payto); + TALER_full_payto_hash (bd.receiver_wire_account, + &bd.wire_target_h_payto); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->do_deposit (plugin->cls, &bd, @@ -2221,7 +2227,7 @@ run (void *cls) sleep (2); /* give deposit time to be ready */ { struct TALER_MerchantPublicKeyP merchant_pub2; - char *payto_uri2; + struct TALER_FullPayto payto_uri2; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_ready_deposit (plugin->cls, @@ -2231,11 +2237,11 @@ run (void *cls) &payto_uri2)); FAILIF (0 != GNUNET_memcmp (&merchant_pub2, &bd.merchant_pub)); - FAILIF (0 != strcmp (payto_uri2, - bd.receiver_wire_account)); - TALER_payto_hash (payto_uri2, - &global_wire_target_h_payto); - GNUNET_free (payto_uri2); + FAILIF (0 != TALER_full_payto_cmp (payto_uri2, + bd.receiver_wire_account)); + TALER_full_payto_hash (payto_uri2, + &global_wire_target_h_payto); + GNUNET_free (payto_uri2.full_payto); } { diff --git a/src/include/taler_auditordb_lib.h b/src/include/taler_auditordb_lib.h index f64aef8c2..49f3bc011 100644 --- a/src/include/taler_auditordb_lib.h +++ b/src/include/taler_auditordb_lib.h @@ -30,28 +30,117 @@ enum TALER_AUDITORDB_DeletableSuppressableTables * For auditor_amount_arithmetic_inconsistency table. */ TALER_AUDITORDB_AMOUNT_ARITHMETIC_INCONSISTENCY, + + /** + * For auditor_closure_lags table. + */ TALER_AUDITORDB_CLOSURE_LAGS, + + /** + * For auditor_progress table. + */ TALER_AUDITORDB_PROGRESS, + + /** + * For auditor_bad_sig_losses table. + */ TALER_AUDITORDB_BAD_SIG_LOSSES, + + /** + * For auditor_coin_inconsistency table. + */ TALER_AUDITORDB_COIN_INCONSISTENCY, + + /** + * For auditor_denomination_key_validity_withdraw_inconsistency table. + */ TALER_AUDITORDB_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY, + + /** + * For auditor_denomination_pending table. + */ TALER_AUDITORDB_DENOMINATION_PENDING, + + /** + * For auditor_denominations_without_sig table. + */ TALER_AUDITORDB_DENOMINATIONS_WITHOUT_SIG, + + /** + * For auditor_deposit_confirmation table. + */ TALER_AUDITORDB_DEPOSIT_CONFIRMATION, + + /** + * For auditor_emergency table. + */ TALER_AUDITORDB_EMERGENCY, + + /** + * For auditor_emergency_by_count table. + */ TALER_AUDITORDB_EMERGENCY_BY_COUNT, + + /** + * For auditor_fee_time_inconsistency table. + */ TALER_AUDITORDB_FEE_TIME_INCONSISTENCY, + + /** + * For auditor_misattribution_in_inconsistency table. + */ TALER_AUDITORDB_MISATTRIBUTION_IN_INCONSISTENCY, + + /** + * For auditor_purse_not_closed_inconsistency table. + */ TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCY, + + /** + * For auditor_refreshes_hanging table. + */ TALER_AUDITORDB_REFRESHES_HANGING, + + /** + * For auditor_reserve_balance_insufficient_inconsistency table. + */ TALER_AUDITORDB_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY, + + /** + * For auditor_reserve_balance_summary_wrong_inconsistency table. + */ TALER_AUDITORDB_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY, + + /** + * For auditor_reserve_in_inconsistency table. + */ TALER_AUDITORDB_RESERVE_IN_INCONSISTENCY, + + /** + * For auditor_reserve_not_closed_inconsistency table. + */ TALER_AUDITORDB_RESERVE_NOT_CLOSED_INCONSISTENCY, + + /** + * For auditor_row_inconsistency table. + */ TALER_AUDITORDB_ROW_INCONSISTENCY, + + /** + * For auditor_row_minor_inconsistency table. + */ TALER_AUDITORDB_ROW_MINOR_INCONSISTENCY, + + /** + * For auditor_wire_format_inconsistency table. + */ TALER_AUDITORDB_WIRE_FORMAT_INCONSISTENCY, + + /** + * For auditor_wire_out_inconsistency table. + */ TALER_AUDITORDB_WIRE_OUT_INCONSISTENCY, + /** * Terminal. */ @@ -62,10 +151,14 @@ enum TALER_AUDITORDB_DeletableSuppressableTables * Initialize the plugin. * * @param cfg configuration to use + * @param skip_preflight true if we should skip the usual + * preflight check which assures us that the DB is actually + * operational; only taler-auditor-dbinit should use true here. * @return NULL on failure */ struct TALER_AUDITORDB_Plugin * -TALER_AUDITORDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg); +TALER_AUDITORDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg, + bool skip_preflight); /** diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 6b1b2e3eb..87f886512 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -279,7 +279,7 @@ struct TALER_AUDITORDB_ClosureLags struct TALER_Amount amount; struct GNUNET_TIME_Absolute deadline; struct TALER_WireTransferIdentifierRawP wtid; - char *account; + struct TALER_FullPayto account; bool suppressed; }; @@ -392,7 +392,7 @@ struct TALER_AUDITORDB_ReserveInInconsistency struct TALER_Amount amount_wired; struct TALER_ReservePublicKeyP reserve_pub; struct GNUNET_TIME_Absolute timestamp; - char *account; + struct TALER_FullPayto account; char *diagnostic; bool suppressed; @@ -692,7 +692,7 @@ struct TALER_AUDITORDB_Reserves struct TALER_Amount open_fee_balance; struct TALER_Amount history_fee_balance; struct GNUNET_TIME_Absolute expiration_date; - char *origin_account; + struct TALER_FullPayto origin_account; bool suppressed; }; @@ -768,7 +768,7 @@ struct TALER_AUDITORDB_WireFormatInconsistency struct TALER_AUDITORDB_WireOutInconsistency { uint64_t row_id; - char *destination_account; + struct TALER_FullPayto destination_account; char *diagnostic; uint64_t wire_out_row_id; struct TALER_Amount expected; @@ -837,7 +837,7 @@ typedef void void *cls, uint64_t batch_deposit_serial_id, const struct TALER_Amount *total_amount, - const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_FullPaytoHashP *wire_target_h_payto, struct GNUNET_TIME_Timestamp deadline); @@ -929,7 +929,6 @@ typedef enum GNUNET_GenericReturnValue typedef enum GNUNET_GenericReturnValue (*TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback)( void *cls, - uint64_t serial_id, const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc); typedef enum GNUNET_GenericReturnValue @@ -969,7 +968,7 @@ struct TALER_AUDITORDB_Plugin * #GNUNET_SYSERR if we have no DB connection */ enum GNUNET_GenericReturnValue - (*preflight)(void *cls); + (*preflight)(void *cls); /** @@ -1026,8 +1025,8 @@ struct TALER_AUDITORDB_Plugin * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ enum GNUNET_GenericReturnValue - (*drop_tables)(void *cls, - bool drop_exchangelist); + (*drop_tables)(void *cls, + bool drop_exchangelist); /** @@ -1039,9 +1038,9 @@ struct TALER_AUDITORDB_Plugin * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ enum GNUNET_GenericReturnValue - (*create_tables)(void *cls, - bool support_partitions, - uint32_t num_partitions); + (*create_tables)(void *cls, + bool support_partitions, + uint32_t num_partitions); /** @@ -1051,7 +1050,7 @@ struct TALER_AUDITORDB_Plugin * @return #GNUNET_OK on success */ enum GNUNET_GenericReturnValue - (*start)(void *cls); + (*start)(void *cls); /** @@ -1061,7 +1060,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*commit)(void *cls); + (*commit)(void *cls); /** @@ -1082,7 +1081,7 @@ struct TALER_AUDITORDB_Plugin * #GNUNET_SYSERR on DB errors */ enum GNUNET_GenericReturnValue - (*gc)(void *cls); + (*gc)(void *cls); /** @@ -1096,7 +1095,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_auditor_progress)( + (*insert_auditor_progress)( void *cls, const char *progress_key, uint64_t progress_offset, @@ -1113,7 +1112,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_auditor_progress)( + (*update_auditor_progress)( void *cls, const char *progress_key, uint64_t progress_offset, @@ -1129,10 +1128,10 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_auditor_progress)(void *cls, - const char *progress_key, - uint64_t *progress_offset, - ...); + (*get_auditor_progress)(void *cls, + const char *progress_key, + uint64_t *progress_offset, + ...); /** @@ -1146,10 +1145,10 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_balance)(void *cls, - const char *balance_key, - const struct TALER_Amount *balance_value, - ...); + (*insert_balance)(void *cls, + const char *balance_key, + const struct TALER_Amount *balance_value, + ...); /** @@ -1163,10 +1162,10 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_balance)(void *cls, - const char *balance_key, - const struct TALER_Amount *balance_amount, - ...); + (*update_balance)(void *cls, + const char *balance_key, + const struct TALER_Amount *balance_amount, + ...); /** @@ -1179,10 +1178,10 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_balance)(void *cls, - const char *balance_key, - struct TALER_Amount *balance_value, - ...); + (*get_balance)(void *cls, + const char *balance_key, + struct TALER_Amount *balance_value, + ...); /** @@ -1195,7 +1194,7 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*get_balances)( + (*get_balances)( void *cls, const char *balance_key, TALER_AUDITORDB_BalancesCallback cb, @@ -1211,7 +1210,7 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*get_progress_points)( + (*get_progress_points)( void *cls, const char *progress_key, TALER_AUDITORDB_ProgressPointsCallback cb, @@ -1225,7 +1224,7 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*insert_exchange_signkey)( + (*insert_exchange_signkey)( void *cls, const struct TALER_AUDITORDB_ExchangeSigningKey *sk); @@ -1238,7 +1237,7 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*insert_deposit_confirmation)( + (*insert_deposit_confirmation)( void *cls, const struct TALER_AUDITORDB_DepositConfirmation *dc); @@ -1255,7 +1254,7 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*get_deposit_confirmations)( + (*get_deposit_confirmations)( void *cls, int64_t limit, uint64_t offset, @@ -1264,18 +1263,6 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); - /** - * Delete information about a deposit confirmation from the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param row_id row to delete - * @return query result status - */ - enum GNUNET_DB_QueryStatus - (*delete_deposit_confirmation)( - void *cls, - uint64_t row_id); - // MARK: CRUD /** @@ -1290,7 +1277,7 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*get_amount_arithmetic_inconsistency)( + (*get_amount_arithmetic_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1299,7 +1286,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_coin_inconsistency)( + (*get_coin_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1308,7 +1295,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_row_inconsistency)( + (*get_row_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1317,7 +1304,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_emergency)( + (*get_emergency)( void *cls, int64_t limit, uint64_t offset, @@ -1326,7 +1313,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_emergency_by_count)( + (*get_emergency_by_count)( void *cls, int64_t limit, uint64_t offset, @@ -1335,7 +1322,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_denomination_key_validity_withdraw_inconsistency)( + (*get_denomination_key_validity_withdraw_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1344,7 +1331,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_purse_not_closed_inconsistencies)( + (*get_purse_not_closed_inconsistencies)( void *cls, int64_t limit, uint64_t offset, @@ -1353,7 +1340,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_reserve_balance_insufficient_inconsistency)( + (*get_reserve_balance_insufficient_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1362,7 +1349,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_bad_sig_losses)( + (*get_bad_sig_losses)( void *cls, int64_t limit, uint64_t offset, @@ -1373,7 +1360,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_auditor_closure_lags)( + (*get_auditor_closure_lags)( void *cls, int64_t limit, uint64_t offset, @@ -1382,7 +1369,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_refreshes_hanging)( + (*get_refreshes_hanging)( void *cls, int64_t limit, uint64_t offset, @@ -1398,62 +1385,62 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*delete_amount_arithmetic_inconsistency)( + (*delete_amount_arithmetic_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_coin_inconsistency)( + (*delete_coin_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_row_inconsistency)( + (*delete_row_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_emergency)( + (*delete_emergency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_emergency_by_count)( + (*delete_emergency_by_count)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_denomination_key_validity_withdraw_inconsistency)( + (*delete_denomination_key_validity_withdraw_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_purse_not_closed_inconsistencies)( + (*delete_purse_not_closed_inconsistencies)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_reserve_balance_insufficient_inconsistency)( + (*delete_reserve_balance_insufficient_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_bad_sig_losses)( + (*delete_bad_sig_losses)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_auditor_closure_lags)( + (*delete_auditor_closure_lags)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_progress)( + (*delete_progress)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*delete_refreshes_hanging)( + (*delete_refreshes_hanging)( void *cls, uint64_t row_id); @@ -1466,68 +1453,63 @@ struct TALER_AUDITORDB_Plugin * @return query result status */ enum GNUNET_DB_QueryStatus - (*insert_amount_arithmetic_inconsistency)( + (*insert_amount_arithmetic_inconsistency)( void *cls, const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc); enum GNUNET_DB_QueryStatus - (*insert_coin_inconsistency)( + (*insert_coin_inconsistency)( void *cls, const struct TALER_AUDITORDB_CoinInconsistency *dc); enum GNUNET_DB_QueryStatus - (*insert_row_inconsistency)( + (*insert_row_inconsistency)( void *cls, const struct TALER_AUDITORDB_RowInconsistency *dc); enum GNUNET_DB_QueryStatus - (*insert_emergency)( + (*insert_emergency)( void *cls, const struct TALER_AUDITORDB_Emergency *dc); enum GNUNET_DB_QueryStatus - (*insert_emergency_by_count)( + (*insert_emergency_by_count)( void *cls, const struct TALER_AUDITORDB_EmergenciesByCount *dc); enum GNUNET_DB_QueryStatus - (*insert_denomination_key_validity_withdraw_inconsistency)( + (*insert_denomination_key_validity_withdraw_inconsistency)( void *cls, const struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc); enum GNUNET_DB_QueryStatus - (*insert_purse_not_closed_inconsistencies)( + (*insert_purse_not_closed_inconsistencies)( void *cls, const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc); enum GNUNET_DB_QueryStatus - (*insert_reserve_balance_insufficient_inconsistency)( + (*insert_reserve_balance_insufficient_inconsistency)( void *cls, const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc); enum GNUNET_DB_QueryStatus - (*insert_bad_sig_losses)( + (*insert_bad_sig_losses)( void *cls, const struct TALER_AUDITORDB_BadSigLosses *dc); enum GNUNET_DB_QueryStatus - (*insert_auditor_closure_lags)( + (*insert_auditor_closure_lags)( void *cls, const struct TALER_AUDITORDB_ClosureLags *dc); enum GNUNET_DB_QueryStatus - (*insert_refreshes_hanging)( + (*insert_refreshes_hanging)( void *cls, const struct TALER_AUDITORDB_RefreshesHanging *dc); enum GNUNET_DB_QueryStatus - (*update_bad_sig_losses)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*update_generic_suppressed)( + (*update_generic_suppressed)( void *cls, enum TALER_AUDITORDB_DeletableSuppressableTables table, uint64_t row_id, @@ -1540,70 +1522,7 @@ struct TALER_AUDITORDB_Plugin uint64_t row_id); enum GNUNET_DB_QueryStatus - (*update_emergency_by_count)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*update_row_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*update_purse_not_closed_inconsistencies)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*update_reserve_balance_insufficient_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*update_coin_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*update_denomination_key_validity_withdraw_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*update_refreshes_hanging)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*update_emergency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*update_closure_lags)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*update_amount_arithmetic_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*update_deposit_confirmations)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*get_reserve_in_inconsistency)( + (*get_reserve_in_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1613,25 +1532,18 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_reserve_in_inconsistency)( + (*delete_reserve_in_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_reserve_in_inconsistency)( + (*insert_reserve_in_inconsistency)( void *cls, const struct TALER_AUDITORDB_ReserveInInconsistency *dc); - enum GNUNET_DB_QueryStatus - (*update_reserve_in_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*get_reserve_not_closed_inconsistency)( + (*get_reserve_not_closed_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1641,25 +1553,18 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_reserve_not_closed_inconsistency)( + (*delete_reserve_not_closed_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_reserve_not_closed_inconsistency)( + (*insert_reserve_not_closed_inconsistency)( void *cls, const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc); - - enum GNUNET_DB_QueryStatus - (*update_reserve_not_closed_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*get_denominations_without_sigs)( + (*get_denominations_without_sigs)( void *cls, int64_t limit, uint64_t offset, @@ -1669,25 +1574,18 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_denominations_without_sigs)( + (*delete_denominations_without_sigs)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_denominations_without_sigs)( + (*insert_denominations_without_sigs)( void *cls, const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc); - - enum GNUNET_DB_QueryStatus - (*update_denominations_without_sigs)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*get_misattribution_in_inconsistency)( + (*get_misattribution_in_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1697,25 +1595,18 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_misattribution_in_inconsistency)( + (*delete_misattribution_in_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_misattribution_in_inconsistency)( + (*insert_misattribution_in_inconsistency)( void *cls, const struct TALER_AUDITORDB_MisattributionInInconsistency *dc); - - enum GNUNET_DB_QueryStatus - (*update_misattribution_in_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*get_reserves)( + (*get_reserves)( void *cls, int64_t limit, uint64_t offset, @@ -1723,7 +1614,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_purses)( + (*get_purses)( void *cls, int64_t limit, uint64_t offset, @@ -1732,12 +1623,12 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_purses)( + (*delete_purses)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*get_denomination_pending)( + (*get_denomination_pending)( void *cls, int64_t limit, uint64_t offset, @@ -1745,22 +1636,17 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*delete_denomination_pending)( + (*delete_denomination_pending)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_denomination_pending)( + (*insert_denomination_pending)( void *cls, const struct TALER_AUDITORDB_DenominationPending *dc); enum GNUNET_DB_QueryStatus - (*update_denomination_pending)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*get_exchange_signkeys)( + (*get_exchange_signkeys)( void *cls, int64_t limit, uint64_t offset, @@ -1769,7 +1655,7 @@ struct TALER_AUDITORDB_Plugin void *cb_cls); enum GNUNET_DB_QueryStatus - (*get_wire_format_inconsistency)( + (*get_wire_format_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1779,25 +1665,18 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_wire_format_inconsistency)( + (*delete_wire_format_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_wire_format_inconsistency)( + (*insert_wire_format_inconsistency)( void *cls, const struct TALER_AUDITORDB_WireFormatInconsistency *dc); - - enum GNUNET_DB_QueryStatus - (*update_wire_format_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*get_wire_out_inconsistency)( + (*get_wire_out_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1807,29 +1686,23 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_wire_out_inconsistency)( + (*delete_wire_out_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_wire_out_inconsistency)( + (*insert_wire_out_inconsistency)( void *cls, const struct TALER_AUDITORDB_WireOutInconsistency *dc); enum GNUNET_DB_QueryStatus - (*delete_wire_out_inconsistency_if_matching)( + (*delete_wire_out_inconsistency_if_matching)( void *cls, const struct TALER_AUDITORDB_WireOutInconsistency *dc); enum GNUNET_DB_QueryStatus - (*update_wire_out_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*get_reserve_balance_summary_wrong_inconsistency)( + (*get_reserve_balance_summary_wrong_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1839,25 +1712,18 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_reserve_balance_summary_wrong_inconsistency)( + (*delete_reserve_balance_summary_wrong_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_reserve_balance_summary_wrong_inconsistency)( + (*insert_reserve_balance_summary_wrong_inconsistency)( void *cls, const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc); - enum GNUNET_DB_QueryStatus - (*update_reserve_balance_summary_wrong_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - - enum GNUNET_DB_QueryStatus - (*get_row_minor_inconsistencies)( + (*get_row_minor_inconsistencies)( void *cls, int64_t limit, uint64_t offset, @@ -1867,25 +1733,18 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_row_minor_inconsistencies)( + (*delete_row_minor_inconsistencies)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_row_minor_inconsistencies)( + (*insert_row_minor_inconsistencies)( void *cls, const struct TALER_AUDITORDB_RowMinorInconsistencies *dc); - - enum GNUNET_DB_QueryStatus - (*update_row_minor_inconsistencies)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - - enum GNUNET_DB_QueryStatus - (*get_fee_time_inconsistency)( + (*get_fee_time_inconsistency)( void *cls, int64_t limit, uint64_t offset, @@ -1895,22 +1754,16 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus - (*delete_fee_time_inconsistency)( + (*delete_fee_time_inconsistency)( void *cls, uint64_t row_id); enum GNUNET_DB_QueryStatus - (*insert_fee_time_inconsistency)( + (*insert_fee_time_inconsistency)( void *cls, const struct TALER_AUDITORDB_FeeTimeInconsistency *dc); - - enum GNUNET_DB_QueryStatus - (*update_fee_time_inconsistency)( - void *cls, - const struct TALER_AUDITORDB_Generic_Update *gu); - /** * Insert information about a reserve. There must not be an * existing record for the reserve. @@ -1923,12 +1776,12 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_reserve_info)( + (*insert_reserve_info)( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, struct GNUNET_TIME_Timestamp expiration_date, - const char *origin_account); + const struct TALER_FullPayto origin_account); /** @@ -1942,7 +1795,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_reserve_info)( + (*update_reserve_info)( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, @@ -1961,13 +1814,13 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_reserve_info)( + (*get_reserve_info)( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, uint64_t *rowid, struct TALER_AUDITORDB_ReserveFeeBalance *rfb, struct GNUNET_TIME_Timestamp *expiration_date, - char **sender_account); + struct TALER_FullPayto *sender_account); /** @@ -1978,8 +1831,8 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*del_reserve_info)(void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub); + (*del_reserve_info)(void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub); /** @@ -1993,10 +1846,10 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_pending_deposit)( + (*insert_pending_deposit)( void *cls, uint64_t batch_deposit_serial_id, - const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_FullPaytoHashP *wire_target_h_payto, const struct TALER_Amount *total_amount, struct GNUNET_TIME_Timestamp deadline); @@ -2011,7 +1864,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*delete_pending_deposit)( + (*delete_pending_deposit)( void *cls, uint64_t batch_deposit_serial_id); @@ -2026,7 +1879,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*select_pending_deposits)( + (*select_pending_deposits)( void *cls, struct GNUNET_TIME_Absolute deadline, TALER_AUDITORDB_WireMissingCallback cb, @@ -2044,7 +1897,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_purse_info)( + (*insert_purse_info)( void *cls, const struct TALER_PurseContractPublicKeyP *purse_pub, const struct TALER_Amount *balance, @@ -2061,7 +1914,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_purse_info)( + (*update_purse_info)( void *cls, const struct TALER_PurseContractPublicKeyP *purse_pub, const struct TALER_Amount *balance); @@ -2078,7 +1931,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_purse_info)( + (*get_purse_info)( void *cls, const struct TALER_PurseContractPublicKeyP *purse_pub, uint64_t *rowid, @@ -2094,7 +1947,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*delete_purse_info)( + (*delete_purse_info)( void *cls, const struct TALER_PurseContractPublicKeyP *purse_pub); @@ -2108,7 +1961,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*select_purse_expired)( + (*select_purse_expired)( void *cls, TALER_AUDITORDB_ExpiredPurseCallback cb, void *cb_cls); @@ -2124,7 +1977,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_denomination_balance)( + (*insert_denomination_balance)( void *cls, const struct TALER_DenominationHashP *denom_pub_hash, const struct TALER_AUDITORDB_DenominationCirculationData *dcd); @@ -2140,7 +1993,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_denomination_balance)( + (*update_denomination_balance)( void *cls, const struct TALER_DenominationHashP *denom_pub_hash, const struct TALER_AUDITORDB_DenominationCirculationData *dcd); @@ -2153,7 +2006,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*del_denomination_balance)( + (*del_denomination_balance)( void *cls, const struct TALER_DenominationHashP *denom_pub_hash); @@ -2167,7 +2020,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_denomination_balance)( + (*get_denomination_balance)( void *cls, const struct TALER_DenominationHashP *denom_pub_hash, struct TALER_AUDITORDB_DenominationCirculationData *dcd); @@ -2187,7 +2040,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_historic_denom_revenue)( + (*insert_historic_denom_revenue)( void *cls, const struct TALER_DenominationHashP *denom_pub_hash, struct GNUNET_TIME_Timestamp revenue_timestamp, @@ -2204,7 +2057,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*select_historic_denom_revenue)( + (*select_historic_denom_revenue)( void *cls, int64_t limit, uint64_t offset, @@ -2222,7 +2075,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_historic_reserve_revenue)( + (*insert_historic_reserve_revenue)( void *cls, struct GNUNET_TIME_Timestamp start_time, struct GNUNET_TIME_Timestamp end_time, @@ -2238,7 +2091,7 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*select_historic_reserve_revenue)( + (*select_historic_reserve_revenue)( void *cls, int64_t limit, uint64_t offset, diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h index 5cf7d8ca9..a891c5b7c 100644 --- a/src/include/taler_bank_service.h +++ b/src/include/taler_bank_service.h @@ -48,6 +48,11 @@ enum TALER_BANK_AuthenticationMethod * Basic authentication with cleartext username and password. */ TALER_BANK_AUTH_BASIC, + + /** + * Bearer token authentication. + */ + TALER_BANK_AUTH_BEARER, }; @@ -90,6 +95,18 @@ struct TALER_BANK_AuthenticationData char *password; } basic; + /** + * Details for #TALER_BANK_AUTH_BEARER. + */ + struct + { + /** + * Token to use. + */ + char *token; + + } bearer; + } details; }; @@ -187,7 +204,7 @@ TALER_BANK_admin_add_incoming ( const struct TALER_BANK_AuthenticationData *auth, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *amount, - const char *debit_account, + const struct TALER_FullPayto debit_account, TALER_BANK_AdminAddIncomingCallback res_cb, void *res_cb_cls); @@ -293,7 +310,7 @@ TALER_BANK_admin_add_kycauth ( const struct TALER_BANK_AuthenticationData *auth, const union TALER_AccountPublicKeyP *account_pub, const struct TALER_Amount *amount, - const char *debit_account, + const struct TALER_FullPayto debit_account, TALER_BANK_AdminAddKycauthCallback res_cb, void *res_cb_cls); @@ -325,7 +342,7 @@ TALER_BANK_admin_add_kycauth_cancel ( */ void TALER_BANK_prepare_transfer ( - const char *destination_account_payto_uri, + const struct TALER_FullPayto destination_account_payto_uri, const struct TALER_Amount *amount, const char *exchange_base_url, const struct TALER_WireTransferIdentifierRawP *wtid, @@ -502,7 +519,7 @@ struct TALER_BANK_CreditDetails /** * payto://-URL of the source account that send the funds. */ - const char *debit_account_uri; + struct TALER_FullPayto debit_account_uri; /** * Details that depend on the @e type. @@ -597,7 +614,7 @@ struct TALER_BANK_CreditHistoryResponse /** * payto://-URL of the target account that received the funds. */ - const char *credit_account_uri; + struct TALER_FullPayto credit_account_uri; /** * Array of transactions received. @@ -711,7 +728,7 @@ struct TALER_BANK_DebitDetails /** * payto://-URI of the target account that received the funds. */ - const char *credit_account_uri; + struct TALER_FullPayto credit_account_uri; }; @@ -754,7 +771,7 @@ struct TALER_BANK_DebitHistoryResponse /** * payto://-URI of the source account that send the funds. */ - const char *debit_account_uri; + struct TALER_FullPayto debit_account_uri; /** * Array of transactions initiated. diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 29796cadc..52dbb75d1 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -824,10 +824,49 @@ struct TALER_MerchantWireHashP /** - * Hash used to represent the unsalted hash of a + * payto:// URI representing a bank account, excluding receiver name + * (and also otherwise normalized, so without BIC, etc.). + */ +struct TALER_NormalizedPayto +{ + /** + * Actual string value. + */ + char *normalized_payto; +}; + + +/** + * payto:// URI representing a bank account, including receiver name, + * not normalized. + */ +struct TALER_FullPayto +{ + /** + * Actual string value. + */ + char *full_payto; +}; + + +/** + * Hash used to represent the unsalted hash of a full + * payto:// URI representing a bank account. + */ +struct TALER_FullPaytoHashP +{ + /** + * Actual hash value. + */ + struct GNUNET_ShortHashCode hash; +}; + + +/** + * Hash used to represent the unsalted hash of a normalized * payto:// URI representing a bank account. */ -struct TALER_PaytoHashP +struct TALER_NormalizedPaytoHashP { /** * Actual hash value. @@ -1828,14 +1867,25 @@ TALER_kyc_measure_authorization_hash ( /** - * Compute the hash of a payto URI. + * Compute the hash of a full payto URI. + * + * @param fpayto URI to hash + * @param[out] h_fpayto where to write the hash + */ +void +TALER_full_payto_hash (const struct TALER_FullPayto fpayto, + struct TALER_FullPaytoHashP *h_fpayto); + + +/** + * Compute the hash of a normalized payto URI. * * @param payto URI to hash - * @param[out] h_payto where to write the hash + * @param[out] h_npayto where to write the hash */ void -TALER_payto_hash (const char *payto, - struct TALER_PaytoHashP *h_payto); +TALER_normalized_payto_hash (const struct TALER_NormalizedPayto npayto, + struct TALER_NormalizedPaytoHashP *h_npayto); /** @@ -2668,7 +2718,7 @@ TALER_officer_aml_query_verify ( * @param new_rules new KYC rules to apply to the account * Must be a "LegitimizationRuleSet". * @param properties properties of the account, can be NULL - * @param new_check new KYC check to run, NULL for none + * @param new_measures new measures to apply immediately, NULL for none * @param to_investigate true if the account should be investigated by AML staff * @param officer_priv private key of AML officer * @param[out] officer_sig where to write the signature @@ -2677,10 +2727,10 @@ void TALER_officer_aml_decision_sign ( const char *justification, struct GNUNET_TIME_Timestamp decision_time, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const json_t *new_rules, const json_t *properties, - const char *new_check, + const char *new_measures, bool to_investigate, const struct TALER_AmlOfficerPrivateKeyP *officer_priv, struct TALER_AmlOfficerSignatureP *officer_sig); @@ -2695,7 +2745,7 @@ TALER_officer_aml_decision_sign ( * decision is about * @param new_rules new KYC rules to apply to the account * @param properties properties of the account, can be NULL - * @param new_check new KYC check to run, NULL for none + * @param new_measures new measures to apply immediately, NULL for none * @param to_investigate true if the account should be investigated by AML staff * @param officer_pub public key of AML officer * @param officer_sig signature to verify @@ -2705,10 +2755,10 @@ enum GNUNET_GenericReturnValue TALER_officer_aml_decision_verify ( const char *justification, struct GNUNET_TIME_Timestamp decision_time, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const json_t *new_rules, const json_t *properties, - const char *new_check, + const char *new_measures, bool to_investigate, const struct TALER_AmlOfficerPublicKeyP *officer_pub, const struct TALER_AmlOfficerSignatureP *officer_sig); @@ -3464,7 +3514,7 @@ TALER_wallet_purse_deposit_verify ( */ void TALER_wallet_purse_merge_sign ( - const char *reserve_uri, + const struct TALER_NormalizedPayto reserve_uri, struct GNUNET_TIME_Timestamp merge_timestamp, const struct TALER_PurseContractPublicKeyP *purse_pub, const struct TALER_PurseMergePrivateKeyP *merge_priv, @@ -3483,7 +3533,7 @@ TALER_wallet_purse_merge_sign ( */ enum GNUNET_GenericReturnValue TALER_wallet_purse_merge_verify ( - const char *reserve_uri, + const struct TALER_NormalizedPayto reserve_uri, struct GNUNET_TIME_Timestamp merge_timestamp, const struct TALER_PurseContractPublicKeyP *purse_pub, const struct TALER_PurseMergePublicKeyP *merge_pub, @@ -3675,7 +3725,7 @@ TALER_wallet_reserve_open_deposit_verify ( void TALER_wallet_reserve_close_sign ( struct GNUNET_TIME_Timestamp request_timestamp, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_ReservePrivateKeyP *reserve_priv, struct TALER_ReserveSignatureP *reserve_sig); @@ -3693,7 +3743,7 @@ TALER_wallet_reserve_close_sign ( enum GNUNET_GenericReturnValue TALER_wallet_reserve_close_verify ( struct GNUNET_TIME_Timestamp request_timestamp, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_ReserveSignatureP *reserve_sig); @@ -4524,48 +4574,6 @@ TALER_exchange_online_key_set_verify ( /** - * Create account KYC setup success signature. - * - * @param scb function to call to create the signature - * @param h_payto target of the KYC account - * @param kyc JSON data describing which KYC checks - * were satisfied - * @param timestamp time when the KYC was confirmed - * @param[out] pub where to write the public key - * @param[out] sig where to write the signature - * @return #TALER_EC_NONE on success - */ -enum TALER_ErrorCode -TALER_exchange_online_account_setup_success_sign ( - TALER_ExchangeSignCallback scb, - const struct TALER_PaytoHashP *h_payto, - const json_t *kyc, - struct GNUNET_TIME_Timestamp timestamp, - struct TALER_ExchangePublicKeyP *pub, - struct TALER_ExchangeSignatureP *sig); - - -/** - * Verify account KYC setup success signature. - * - * @param h_payto target of the KYC account - * @param kyc JSON data describing which KYC checks - * were satisfied - * @param timestamp time when the KYC was confirmed - * @param pub where to write the public key - * @param sig where to write the signature - * @return #GNUNET_OK if the signature is valid - */ -enum GNUNET_GenericReturnValue -TALER_exchange_online_account_setup_success_verify ( - const struct TALER_PaytoHashP *h_payto, - const json_t *kyc, - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_ExchangePublicKeyP *pub, - const struct TALER_ExchangeSignatureP *sig); - - -/** * Hash normalized @a j JSON object or array and * store the result in @a hc. * @@ -4617,7 +4625,7 @@ TALER_exchange_online_wire_deposit_sign ( const struct TALER_Amount *total, const struct TALER_Amount *wire_fee, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *payto, + const struct TALER_FullPayto payto, const struct GNUNET_HashCode *h_details, struct TALER_ExchangePublicKeyP *pub, struct TALER_ExchangeSignatureP *sig); @@ -4640,7 +4648,7 @@ TALER_exchange_online_wire_deposit_verify ( const struct TALER_Amount *total, const struct TALER_Amount *wire_fee, const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct GNUNET_HashCode *h_details, const struct TALER_ExchangePublicKeyP *pub, const struct TALER_ExchangeSignatureP *sig); @@ -4884,7 +4892,7 @@ TALER_exchange_online_reserve_closed_sign ( struct GNUNET_TIME_Timestamp timestamp, const struct TALER_Amount *closing_amount, const struct TALER_Amount *closing_fee, - const char *payto, + const struct TALER_FullPayto payto, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_ExchangePublicKeyP *pub, @@ -4909,7 +4917,7 @@ TALER_exchange_online_reserve_closed_verify ( struct GNUNET_TIME_Timestamp timestamp, const struct TALER_Amount *closing_amount, const struct TALER_Amount *closing_fee, - const char *payto, + const struct TALER_FullPayto payto, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_ExchangePublicKeyP *pub, @@ -5483,7 +5491,7 @@ TALER_exchange_offline_profit_drain_sign ( struct GNUNET_TIME_Timestamp date, const struct TALER_Amount *amount, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig); @@ -5508,7 +5516,7 @@ TALER_exchange_offline_profit_drain_verify ( struct GNUNET_TIME_Timestamp date, const struct TALER_Amount *amount, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig); @@ -5799,7 +5807,7 @@ TALER_exchange_offline_global_fee_verify ( */ void TALER_exchange_offline_wire_add_sign ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -5822,7 +5830,7 @@ TALER_exchange_offline_wire_add_sign ( */ enum GNUNET_GenericReturnValue TALER_exchange_offline_wire_add_verify ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -5841,7 +5849,7 @@ TALER_exchange_offline_wire_add_verify ( */ void TALER_exchange_offline_wire_del_sign ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp now, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig); @@ -5858,7 +5866,7 @@ TALER_exchange_offline_wire_del_sign ( */ enum GNUNET_GenericReturnValue TALER_exchange_offline_wire_del_verify ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp sign_time, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig); @@ -5877,7 +5885,7 @@ TALER_exchange_offline_wire_del_verify ( */ enum GNUNET_GenericReturnValue TALER_exchange_wire_signature_check ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -5897,7 +5905,7 @@ TALER_exchange_wire_signature_check ( */ void TALER_exchange_wire_signature_make ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -5915,9 +5923,10 @@ TALER_exchange_wire_signature_make ( * @param[out] hc set to the hash */ void -TALER_merchant_wire_signature_hash (const char *payto_uri, - const struct TALER_WireSaltP *salt, - struct TALER_MerchantWireHashP *hc); +TALER_merchant_wire_signature_hash ( + const struct TALER_FullPayto payto_uri, + const struct TALER_WireSaltP *salt, + struct TALER_MerchantWireHashP *hc); /** @@ -5931,7 +5940,7 @@ TALER_merchant_wire_signature_hash (const char *payto_uri, */ enum GNUNET_GenericReturnValue TALER_merchant_wire_signature_check ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_WireSaltP *salt, const struct TALER_MerchantPublicKeyP *merch_pub, const struct TALER_MerchantSignatureP *merch_sig); @@ -5947,7 +5956,7 @@ TALER_merchant_wire_signature_check ( */ void TALER_merchant_wire_signature_make ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_WireSaltP *salt, const struct TALER_MerchantPrivateKeyP *merch_priv, struct TALER_MerchantSignatureP *merch_sig); @@ -5986,14 +5995,29 @@ TALER_merchant_pay_verify ( * Sign contract sent by the merchant to the wallet. * * @param h_contract_terms hash of the contract terms - * @param merch_priv private key to sign with - * @param[out] merch_sig where to write the signature + * @param merchant_priv private key to sign with + * @param[out] merchant_sig where to write the signature */ void TALER_merchant_contract_sign ( const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_MerchantPrivateKeyP *merch_priv, - struct GNUNET_CRYPTO_EddsaSignature *merch_sig); + const struct TALER_MerchantPrivateKeyP *merchant_priv, + struct TALER_MerchantSignatureP *merchant_sig); + + +/** + * Verify contract signature sent by the merchant to the wallet. + * + * @param h_contract_terms hash of the contract terms + * @param merchant_pub public key of the merchant + * @param merchant_sig signature to check + * @return #GNUNET_OK if the signature is valid + */ +enum GNUNET_GenericReturnValue +TALER_merchant_contract_verify ( + const struct TALER_PrivateContractHashP *h_contract_terms, + const struct TALER_MerchantPublicKeyP *merchant_pub, + struct TALER_MerchantSignatureP *merchant_sig); /* **************** /management/extensions offline signing **************** */ diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 4e925bfe5..c561e0e8f 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -36,7 +36,7 @@ * Version of the Taler Exchange API, in hex. * Thus 0.8.4-1 = 0x00080401. */ -#define TALER_EXCHANGE_API_VERSION 0x00100005 +#define TALER_EXCHANGE_API_VERSION 0x00100006 /** * Information returned when a client needs to pass @@ -48,7 +48,7 @@ struct TALER_EXCHANGE_KycNeededRedirect /** * Hash of the payto-URI of the account to KYC; */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Public key needed to access the KYC state of @@ -371,10 +371,10 @@ struct TALER_EXCHANGE_AccountRestriction struct { /** - * Regular expression that the payto://-URI of the partner account must - * follow. The regular expression should follow posix-egrep, but - * without support for character classes, GNU extensions, - * back-references or intervals. See + * Regular expression that the normalized payto://-URI of the partner + * account must follow. The regular expression should follow + * posix-egrep, but without support for character classes, GNU + * extensions, back-references or intervals. See * https://www.gnu.org/software/findutils/manual/html_node/find_html/posix_002degrep-regular-expression-syntax.html * for a description of the posix-egrep syntax. Applications may support * regexes with additional features, but exchanges must not use such @@ -406,7 +406,7 @@ struct TALER_EXCHANGE_WireAccount /** * payto://-URI of the exchange. */ - char *payto_uri; + struct TALER_FullPayto fpayto_uri; /** * URL of a conversion service in case using this account is subject to @@ -1037,7 +1037,7 @@ enum GNUNET_GenericReturnValue TALER_EXCHANGE_test_account_allowed ( const struct TALER_EXCHANGE_WireAccount *account, bool check_credit, - const char *payto_uri); + const struct TALER_NormalizedPayto payto_uri); /** @@ -1246,6 +1246,12 @@ struct TALER_EXCHANGE_DepositContractDetail struct TALER_MerchantPublicKeyP merchant_pub; /** + * The signature of the merchant (used to show that the merchant indeed + * agree to the deposit). + */ + struct TALER_MerchantSignatureP merchant_sig; + + /** * Salt used to hash the @e merchant_payto_uri. */ struct TALER_WireSaltP wire_salt; @@ -1281,7 +1287,7 @@ struct TALER_EXCHANGE_DepositContractDetail * The merchant’s account details, in the payto://-format supported by the * exchange. */ - const char *merchant_payto_uri; + struct TALER_FullPayto merchant_payto_uri; /** * Policy extension specific details about the deposit relevant to the exchange. @@ -1347,9 +1353,35 @@ struct TALER_EXCHANGE_BatchDepositResult struct { /** - * The coin that had a conflict. - */ - struct TALER_CoinSpendPublicKeyP coin_pub; + * Details depending on the @e hr.ec. + */ + union + { + struct + { + /** + * The coin that had a conflict. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + } insufficient_funds; + + struct + { + /** + * The coin that had a conflict. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + } coin_conflicting_age_hash; + + struct + { + /** + * The coin that had a conflict. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + } coin_conflicting_denomination_key; + + } details; } conflict; @@ -2167,7 +2199,7 @@ struct TALER_EXCHANGE_ReserveHistoryEntry /** * Sender account payto://-URL of the incoming transfer. */ - char *sender_url; + struct TALER_FullPayto sender_url; /** * Information that uniquely identifies the wire transfer. @@ -2259,7 +2291,7 @@ struct TALER_EXCHANGE_ReserveHistoryEntry /** * Receiver account information for the outgoing wire transfer as a payto://-URI. */ - const char *receiver_account_details; + struct TALER_FullPayto receiver_account_details; /** * Wire transfer details for the outgoing wire transfer. @@ -2409,7 +2441,7 @@ struct TALER_EXCHANGE_ReserveHistoryEntry * for the closure, or all zeros for the reserve * origin account. */ - struct TALER_PaytoHashP target_account_h_payto; + struct TALER_FullPaytoHashP target_account_h_payto; } close_request; @@ -3930,7 +3962,7 @@ struct TALER_EXCHANGE_TransferData /** * hash of the payto:// URI the transfer went to */ - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; /** * time when the exchange claims to have performed the wire transfer @@ -4496,7 +4528,7 @@ struct TALER_EXCHANGE_KycCheckHandle * TALER_EXCHANGE_kyc_check ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPrivateKeyP *pk, enum TALER_EXCHANGE_KycLongPollTarget lpt, struct GNUNET_TIME_Relative timeout, @@ -4830,7 +4862,7 @@ struct TALER_EXCHANGE_KycProofHandle * TALER_EXCHANGE_kyc_proof ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *logic, const char *args, TALER_EXCHANGE_KycProofCallback cb, @@ -5423,7 +5455,7 @@ TALER_EXCHANGE_management_drain_profits ( const struct TALER_Amount *amount, struct GNUNET_TIME_Timestamp date, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_MasterSignatureP *master_sig, TALER_EXCHANGE_ManagementDrainProfitsCallback cb, void *cb_cls); @@ -6088,7 +6120,7 @@ struct TALER_EXCHANGE_AmlDecision /** * Account the decision was made for. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * RowID of this decision. @@ -6203,7 +6235,7 @@ struct TALER_EXCHANGE_LookupAmlDecisions * TALER_EXCHANGE_lookup_aml_decisions ( struct GNUNET_CURL_Context *ctx, const char *exchange_url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, enum TALER_EXCHANGE_YesNoAll investigation_only, enum TALER_EXCHANGE_YesNoAll active_only, uint64_t offset, @@ -6324,7 +6356,7 @@ struct TALER_EXCHANGE_LookupKycAttributes * TALER_EXCHANGE_lookup_kyc_attributes ( struct GNUNET_CURL_Context *ctx, const char *exchange_url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t offset, int64_t limit, const struct TALER_AmlOfficerPrivateKeyP *officer_priv, @@ -6478,8 +6510,8 @@ struct TALER_EXCHANGE_AddAmlDecision * TALER_EXCHANGE_post_aml_decision ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, - const char *payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp decision_time, const char *successor_measure, const char *new_measures, @@ -6759,7 +6791,7 @@ struct TALER_EXCHANGE_ManagementWireEnableHandle * TALER_EXCHANGE_management_enable_wire ( struct GNUNET_CURL_Context *ctx, const char *url, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -6815,7 +6847,7 @@ struct TALER_EXCHANGE_ManagementWireDisableHandle; * Inform the exchange that a wire account should be disabled. * * @param ctx the context - * @param url HTTP base URL for the exchange + * @param exchange_url HTTP base URL for the exchange * @param payto_uri RFC 8905 URI of the exchange's bank account * @param validity_end when was this decided? * @param master_sig signature affirming the wire addition @@ -6827,8 +6859,8 @@ struct TALER_EXCHANGE_ManagementWireDisableHandle; struct TALER_EXCHANGE_ManagementWireDisableHandle * TALER_EXCHANGE_management_disable_wire ( struct GNUNET_CURL_Context *ctx, - const char *url, - const char *payto_uri, + const char *exchange_url, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp validity_end, const struct TALER_MasterSignatureP *master_sig, TALER_EXCHANGE_ManagementWireDisableCallback cb, @@ -8198,7 +8230,7 @@ TALER_EXCHANGE_reserves_close ( struct GNUNET_CURL_Context *ctx, const char *url, const struct TALER_ReservePrivateKeyP *reserve_priv, - const char *target_payto_uri, + const struct TALER_FullPayto target_payto_uri, TALER_EXCHANGE_ReservesCloseCallback cb, void *cb_cls); diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h index d93cf9d6c..825578c95 100644 --- a/src/include/taler_exchangedb_lib.h +++ b/src/include/taler_exchangedb_lib.h @@ -32,20 +32,25 @@ * Initialize the plugin. * * @param cfg configuration to use + * @param skip_preflight true if we should skip the usual + * preflight check which assures us that the DB is actually + * operational; only taler-exchange-dbinit should use true here. * @return NULL on failure */ struct TALER_EXCHANGEDB_Plugin * -TALER_EXCHANGEDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg); +TALER_EXCHANGEDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg, + bool skip_preflight); /** * Shutdown the plugin. * - * @param plugin plugin to unload + * @param[in] plugin plugin to unload */ void TALER_EXCHANGEDB_plugin_unload (struct TALER_EXCHANGEDB_Plugin *plugin); + /** * Information about an account from the configuration. */ @@ -146,7 +151,8 @@ TALER_EXCHANGEDB_find_account_by_method (const char *method); * @return NULL on error */ const struct TALER_EXCHANGEDB_AccountInfo * -TALER_EXCHANGEDB_find_account_by_payto_uri (const char *url); +TALER_EXCHANGEDB_find_account_by_payto_uri ( + const struct TALER_FullPayto url); /** diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index ea5c0b560..88d05ce24 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -240,7 +240,7 @@ struct TALER_KycCompletedEventP /** * Hash of payto://-URI for which the KYC state changed. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; }; @@ -382,7 +382,7 @@ struct TALER_EXCHANGEDB_TableData struct { - char *payto_uri; + struct TALER_FullPayto full_payto_uri; struct TALER_AccountAccessTokenP access_token; union TALER_AccountPublicKeyP target_pub; bool no_account; @@ -398,7 +398,7 @@ struct TALER_EXCHANGEDB_TableData struct { - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; struct GNUNET_TIME_Timestamp decision_time; struct GNUNET_TIME_Timestamp expiration_time; json_t *properties; @@ -408,7 +408,7 @@ struct TALER_EXCHANGEDB_TableData struct { - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; struct GNUNET_TIME_Timestamp start_time; struct GNUNET_TIME_Timestamp expiration_time; uint64_t legitimization_measure_serial_id; @@ -421,7 +421,7 @@ struct TALER_EXCHANGEDB_TableData struct { - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; uint64_t legitimization_serial; struct GNUNET_TIME_Timestamp collection_time; struct GNUNET_TIME_Timestamp expiration_time; @@ -432,7 +432,7 @@ struct TALER_EXCHANGEDB_TableData struct { - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; uint64_t outcome_serial_id; char *justification; struct TALER_AmlOfficerPublicKeyP decider_pub; @@ -466,7 +466,7 @@ struct TALER_EXCHANGEDB_TableData { uint64_t wire_reference; struct TALER_Amount credit; - struct TALER_PaytoHashP sender_account_h_payto; + struct TALER_FullPaytoHashP sender_account_h_payto; char *exchange_account_section; struct GNUNET_TIME_Timestamp execution_date; struct TALER_ReservePublicKeyP reserve_pub; @@ -476,7 +476,7 @@ struct TALER_EXCHANGEDB_TableData { uint64_t wire_reference; struct TALER_Amount credit; - struct TALER_PaytoHashP sender_account_h_payto; + struct TALER_FullPaytoHashP sender_account_h_payto; char *exchange_account_section; struct GNUNET_TIME_Timestamp execution_date; union TALER_AccountPublicKeyP account_pub; @@ -506,7 +506,7 @@ struct TALER_EXCHANGEDB_TableData struct TALER_ReservePublicKeyP reserve_pub; struct GNUNET_TIME_Timestamp execution_date; struct TALER_WireTransferIdentifierRawP wtid; - struct TALER_PaytoHashP sender_account_h_payto; + struct TALER_FullPaytoHashP sender_account_h_payto; struct TALER_Amount amount; struct TALER_Amount closing_fee; } reserves_close; @@ -600,7 +600,7 @@ struct TALER_EXCHANGEDB_TableData struct GNUNET_HashCode wallet_data_hash; bool no_wallet_data_hash; struct TALER_WireSaltP wire_salt; - struct TALER_PaytoHashP wire_target_h_payto; + struct TALER_FullPaytoHashP wire_target_h_payto; bool policy_blocked; uint64_t policy_details_serial_id; bool no_policy_details; @@ -627,7 +627,7 @@ struct TALER_EXCHANGEDB_TableData { struct GNUNET_TIME_Timestamp execution_date; struct TALER_WireTransferIdentifierRawP wtid_raw; - struct TALER_PaytoHashP wire_target_h_payto; + struct TALER_FullPaytoHashP wire_target_h_payto; char *exchange_account_section; struct TALER_Amount amount; } wire_out; @@ -753,7 +753,7 @@ struct TALER_EXCHANGEDB_TableData struct TALER_ReservePublicKeyP reserve_pub; struct TALER_ReserveSignatureP reserve_sig; struct TALER_PurseContractPublicKeyP purse_pub; - struct TALER_PaytoHashP wallet_h_payto; + struct TALER_NormalizedPaytoHashP wallet_h_payto; } account_merges; struct @@ -771,7 +771,7 @@ struct TALER_EXCHANGEDB_TableData struct TALER_ReserveSignatureP reserve_sig; struct TALER_Amount close; struct TALER_Amount close_fee; - char *payto_uri; + struct TALER_FullPayto payto_uri; } close_requests; struct @@ -824,7 +824,7 @@ struct TALER_EXCHANGEDB_TableData { struct TALER_WireTransferIdentifierRawP wtid; char *account_section; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_TIME_Timestamp trigger_date; struct TALER_Amount amount; struct TALER_MasterSignatureP master_sig; @@ -922,7 +922,7 @@ struct TALER_EXCHANGEDB_BankTransfer * Detailed wire information about the sending account * in "payto://" format. */ - char *sender_account_details; + struct TALER_FullPayto sender_account_details; /** * Data uniquely identifying the wire transfer (wire transfer-type specific) @@ -963,7 +963,7 @@ struct TALER_EXCHANGEDB_ClosingTransfer * Detailed wire information about the receiving account * in payto://-format. */ - char *receiver_account_details; + struct TALER_FullPayto receiver_account_details; /** * Detailed wire transfer information that uniquely identifies the @@ -1608,7 +1608,7 @@ struct TALER_EXCHANGEDB_CloseRequest * for the closure, or all zeros for the reserve * origin account. */ - struct TALER_PaytoHashP target_account_h_payto; + struct TALER_FullPaytoHashP target_account_h_payto; /** * Signature by the reserve approving the history request. @@ -1780,6 +1780,12 @@ struct TALER_EXCHANGEDB_BatchDeposit struct TALER_MerchantPublicKeyP merchant_pub; /** + * Signature of the merchant over the contract, of purpose + * #TALER_SIGNATURE_MERCHANT_CONTRACT. + */ + struct TALER_MerchantSignatureP merchant_sig; + + /** * Hash over the proposal data between merchant and customer * (remains unknown to the Exchange). */ @@ -1793,7 +1799,7 @@ struct TALER_EXCHANGEDB_BatchDeposit /** * Unsalted hash over @e receiver_wire_account. */ - struct TALER_PaytoHashP wire_target_h_payto; + struct TALER_FullPaytoHashP wire_target_h_payto; /** * Salt used by the merchant to compute "h_wire". @@ -1839,7 +1845,7 @@ struct TALER_EXCHANGEDB_BatchDeposit * Information about the receiver for executing the transaction. URI in * payto://-format. */ - const char *receiver_wire_account; + struct TALER_FullPayto receiver_wire_account; /** * Array about the coins that are being deposited. @@ -1962,7 +1968,7 @@ struct TALER_EXCHANGEDB_Deposit * Information about the receiver for executing the transaction. URI in * payto://-format. */ - char *receiver_wire_account; + struct TALER_FullPayto receiver_wire_account; /** * True if @e policy_json was provided @@ -2076,7 +2082,7 @@ struct TALER_EXCHANGEDB_DepositListEntry * Detailed information about the receiver for executing the transaction. * URL in payto://-format. */ - char *receiver_wire_account; + struct TALER_FullPayto receiver_wire_account; /** * true, if age commitment is not applicable @@ -2659,7 +2665,7 @@ typedef void typedef void (*TALER_EXCHANGEDB_AttributeCallback)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, struct GNUNET_TIME_Timestamp collection_time, struct GNUNET_TIME_Timestamp expiration_time, @@ -2989,7 +2995,7 @@ struct TALER_EXCHANGEDB_ReserveInInfo const struct TALER_ReservePublicKeyP *reserve_pub; const struct TALER_Amount *balance; struct GNUNET_TIME_Timestamp execution_time; - const char *sender_account_details; + struct TALER_FullPayto sender_account_details; const char *exchange_account_name; uint64_t wire_reference; }; @@ -3076,7 +3082,7 @@ typedef enum GNUNET_GenericReturnValue uint64_t rowid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *credit, - const char *sender_account_details, + const struct TALER_FullPayto sender_account_details, uint64_t wire_reference, struct GNUNET_TIME_Timestamp execution_date); @@ -3097,7 +3103,7 @@ typedef enum GNUNET_GenericReturnValue typedef void (*TALER_EXCHANGEDB_WireAccountCallback)( void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -3271,8 +3277,8 @@ typedef void void *cls, uint64_t rowid, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *account_payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto account_payto_uri, + const struct TALER_FullPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp exec_time, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_DenominationPublicKey *denom_pub, @@ -3299,7 +3305,7 @@ typedef enum GNUNET_GenericReturnValue uint64_t rowid, struct GNUNET_TIME_Timestamp date, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_Amount *amount); @@ -3317,7 +3323,7 @@ typedef enum GNUNET_GenericReturnValue typedef bool (*TALER_EXCHANGEDB_TransientAggregationCallback)( void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_Amount *total); @@ -3451,7 +3457,7 @@ typedef enum GNUNET_GenericReturnValue const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, - const char *receiver_account, + const struct TALER_FullPayto receiver_account, const struct TALER_WireTransferIdentifierRawP *wtid, uint64_t close_request_row); @@ -3487,7 +3493,7 @@ typedef enum GNUNET_GenericReturnValue void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *left, - const char *account_details, + const struct TALER_FullPayto account_details, struct GNUNET_TIME_Timestamp expiration_date, uint64_t close_request_row); @@ -3530,7 +3536,7 @@ typedef void void *cls, uint64_t batch_deposit_serial_id, const struct TALER_Amount *total_amount, - const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_FullPaytoHashP *wire_target_h_payto, struct GNUNET_TIME_Timestamp deadline); @@ -3616,7 +3622,7 @@ typedef void void *cls, uint64_t row_id, const char *justification, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp decision_time, struct GNUNET_TIME_Absolute expiration_time, const json_t *jproperties, @@ -3941,8 +3947,8 @@ struct TALER_EXCHANGEDB_Plugin (*reserves_get_origin)( void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_PaytoHashP *h_payto, - char **payto_uri); + struct TALER_FullPaytoHashP *h_payto, + struct TALER_FullPayto *payto_uri); /** @@ -3956,7 +3962,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*drain_kyc_alert)(void *cls, uint32_t trigger_type, - struct TALER_PaytoHashP *h_payto); + struct TALER_NormalizedPaytoHashP *h_payto); /** @@ -3996,7 +4002,7 @@ struct TALER_EXCHANGEDB_Plugin const union TALER_AccountPublicKeyP *account_pub, const struct TALER_Amount *credit_amount, struct GNUNET_TIME_Timestamp execution_date, - const char *debit_account_uri, + const struct TALER_FullPayto debit_account_uri, const char *section_name, uint64_t serial_id); @@ -4020,7 +4026,7 @@ struct TALER_EXCHANGEDB_Plugin const char *origin_exchange_url, const struct TALER_Amount *amount, struct GNUNET_TIME_Timestamp execution_date, - const char *debit_account_uri, + const struct TALER_FullPayto debit_account_uri, const char *section_name, uint64_t serial_id); @@ -4678,7 +4684,7 @@ struct TALER_EXCHANGEDB_Plugin uint64_t start_shard_row, uint64_t end_shard_row, struct TALER_MerchantPublicKeyP *merchant_pub, - char **payto_uri); + struct TALER_FullPayto *payto_uri); /** @@ -4695,7 +4701,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*aggregate)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_WireTransferIdentifierRawP *wtid, struct TALER_Amount *total); @@ -4716,7 +4722,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*create_aggregation_transient)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const char *exchange_account_section, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_WireTransferIdentifierRawP *wtid, @@ -4738,7 +4744,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_aggregation_transient)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_account_section, struct TALER_WireTransferIdentifierRawP *wtid, @@ -4757,7 +4763,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*find_aggregation_transient)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_TransientAggregationCallback cb, void *cb_cls); @@ -4776,7 +4782,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*update_aggregation_transient)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_WireTransferIdentifierRawP *wtid, uint64_t kyc_requirement_row, const struct TALER_Amount *total); @@ -4794,7 +4800,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*delete_aggregation_transient)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_WireTransferIdentifierRawP *wtid); @@ -5188,7 +5194,7 @@ struct TALER_EXCHANGEDB_Plugin void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_Amount *balance, - char **payto_uri); + struct TALER_FullPayto *payto_uri); /** @@ -5215,7 +5221,7 @@ struct TALER_EXCHANGEDB_Plugin struct GNUNET_TIME_Timestamp *request_timestamp, struct TALER_Amount *close_balance, struct TALER_Amount *close_fee, - char **payto_uri); + struct TALER_FullPayto *payto_uri); /** @@ -5224,7 +5230,6 @@ struct TALER_EXCHANGEDB_Plugin * * @param cls closure * @param h_payto which target account is this about? - * @param h_payto account identifier * @param time_limit oldest transaction that could be relevant * @param kac function to call for each applicable amount, in reverse chronological order (or until @a kac aborts by returning anything except #GNUNET_OK). * @param kac_cls closure for @a kac @@ -5233,7 +5238,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*iterate_reserve_close_info)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); @@ -5257,9 +5262,8 @@ struct TALER_EXCHANGEDB_Plugin void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, struct GNUNET_TIME_Timestamp execution_date, - const char *receiver_account, - const struct - TALER_WireTransferIdentifierRawP *wtid, + const struct TALER_FullPayto receiver_account, + const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee, uint64_t close_request_row); @@ -5355,7 +5359,7 @@ struct TALER_EXCHANGEDB_Plugin void *cls, struct GNUNET_TIME_Timestamp date, const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const char *exchange_account_section, const struct TALER_Amount *amount); @@ -5840,8 +5844,8 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_justification_for_missing_wire)( void *cls, - const struct TALER_PaytoHashP *wire_target_h_payto, - char **payto_uri, + const struct TALER_FullPaytoHashP *wire_target_h_payto, + struct TALER_FullPayto *payto_uri, json_t **jproperties, json_t **jrules); @@ -5931,7 +5935,7 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*lookup_wire_timestamp)(void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp *last_date); @@ -5953,7 +5957,7 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_wire)(void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -5981,7 +5985,7 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*update_wire)(void *cls, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -6812,7 +6816,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*insert_close_request)(void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_ReserveSignatureP *reserve_sig, struct GNUNET_TIME_Timestamp request_timestamp, const struct TALER_Amount *balance, @@ -6835,7 +6839,7 @@ struct TALER_EXCHANGEDB_Plugin (*insert_drain_profit)(void *cls, const struct TALER_WireTransferIdentifierRawP *wtid, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp request_timestamp, const struct TALER_Amount *amount, const struct TALER_MasterSignatureP *master_sig); @@ -6859,7 +6863,7 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_WireTransferIdentifierRawP *wtid, uint64_t *serial, char **account_section, - char **payto_uri, + struct TALER_FullPayto *payto_uri, struct GNUNET_TIME_Timestamp *request_timestamp, struct TALER_Amount *amount, struct TALER_MasterSignatureP *master_sig); @@ -6884,7 +6888,7 @@ struct TALER_EXCHANGEDB_Plugin uint64_t *serial, struct TALER_WireTransferIdentifierRawP *wtid, char **account_section, - char **payto_uri, + struct TALER_FullPayto *payto_uri, struct GNUNET_TIME_Timestamp *request_timestamp, struct TALER_Amount *amount, struct TALER_MasterSignatureP *master_sig); @@ -6926,8 +6930,8 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*trigger_kyc_rule_for_account)( void *cls, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPublicKeyP *set_account_pub, const struct TALER_MerchantPublicKeyP *check_merchant_pub, const json_t *jmeasures, @@ -6955,7 +6959,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*insert_kyc_requirement_process)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint32_t measure_index, uint64_t legitimization_measure_serial_id, const char *provider_name, @@ -6976,7 +6980,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*get_pending_kyc_requirement_process)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, char **redirect_url); @@ -7003,7 +7007,7 @@ struct TALER_EXCHANGEDB_Plugin void *cls, uint64_t process_row, const char *provider_name, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_account_id, const char *provider_legitimization_id, const char *redirect_url, @@ -7037,7 +7041,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*lookup_kyc_requirement_by_row)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, union TALER_AccountPublicKeyP *account_pub, struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_AccountAccessTokenP *access_token, @@ -7075,7 +7079,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*lookup_rules_by_access_token)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, json_t **jnew_rules, uint64_t *rowid); @@ -7096,7 +7100,7 @@ struct TALER_EXCHANGEDB_Plugin (*lookup_kyc_process_by_account)( void *cls, const char *provider_name, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t *process_row, struct GNUNET_TIME_Absolute *expiration, char **provider_account_id, @@ -7104,8 +7108,7 @@ struct TALER_EXCHANGEDB_Plugin /** - * Lookup an - * @a h_payto by @a provider_legitimization_id. + * Lookup an @a h_payto by @a provider_legitimization_id. * * @param cls closure * @param provider_name @@ -7119,7 +7122,7 @@ struct TALER_EXCHANGEDB_Plugin void *cls, const char *provider_name, const char *provider_legitimization_id, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, uint64_t *process_row); @@ -7142,7 +7145,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*get_kyc_rules)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, bool *no_account_pub, union TALER_AccountPublicKeyP *account_pub, bool *no_reserve_pub, @@ -7163,7 +7166,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*iterate_kyc_reference)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_LegitimizationProcessCallback lpc, void *lpc_cls); @@ -7182,7 +7185,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_withdraw_amounts_for_kyc_check)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); @@ -7202,7 +7205,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_aggregation_amounts_for_kyc_check)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); @@ -7222,7 +7225,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_merge_amounts_for_kyc_check)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); @@ -7244,40 +7247,13 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_deposit_amounts_for_kyc_check)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Absolute time_limit, TALER_EXCHANGEDB_KycAmountCallback kac, void *kac_cls); /** - * Store automated legitimization outcome. - * - * @param cls closure - * @param h_payto account for which the attribute data is stored - * @param decision_time when was the decision taken - * @param expiration_time when does the data expire - * @param account_properties new account properties - * @param to_investigate true to flag account for investigation - * @param new_rules new KYC rules to apply to the account - * @param num_events length of the @a events array - * @param events array of KYC events to trigger - * @return database transaction status - */ - enum GNUNET_DB_QueryStatus - (*insert_programmatic_legitimization_outcome)( - void *cls, - const struct TALER_PaytoHashP *h_payto, - struct GNUNET_TIME_Timestamp decision_time, - struct GNUNET_TIME_Absolute expiration_time, - const json_t *account_properties, - bool to_investigate, - const json_t *new_rules, - unsigned int num_events, - const char **events); - - - /** * Store KYC attribute data, update KYC process status and * AML status for the given account. * @@ -7300,10 +7276,10 @@ struct TALER_EXCHANGEDB_Plugin * @return database transaction status */ enum GNUNET_DB_QueryStatus - (*insert_kyc_attributes)( + (*insert_kyc_measure_result)( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint32_t birthday, struct GNUNET_TIME_Timestamp collection_time, const char *provider_name, @@ -7320,6 +7296,20 @@ struct TALER_EXCHANGEDB_Plugin /** + * Revert account back to default rules and insert successor measure. + */ + enum GNUNET_DB_QueryStatus + (*insert_successor_measure)( + void *cls, + const struct TALER_NormalizedPaytoHashP *h_payto, + struct GNUNET_TIME_Timestamp decision_time, + const char *new_measure_name, + const json_t *jmeasures, + bool *unknown_account, + struct GNUNET_TIME_Timestamp *last_date); + + + /** * Lookup KYC attribute data for a specific account. * * @param cls closure @@ -7331,7 +7321,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_kyc_attributes)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AttributeCallback cb, void *cb_cls); @@ -7397,25 +7387,6 @@ struct TALER_EXCHANGEDB_Plugin bool *read_only, struct GNUNET_TIME_Absolute *last_change); -#if 0 - /** - * Obtain the current AML threshold set for an account. - * - * @param cls closure - * @param h_payto account for which the AML threshold is stored - * @param[out] decision set to current AML decision - * @param[out] threshold set to the existing threshold - * @return database transaction status, 0 if no threshold was set - */ - enum GNUNET_DB_QueryStatus - (*select_aml_threshold)( - void *cls, - const struct TALER_PaytoHashP *h_payto, - enum TALER_AmlDecisionState *decision, - struct TALER_EXCHANGEDB_KycStatus *kyc, - struct TALER_Amount *threshold); -#endif - /** * Obtain the AML statistics for a given key and @@ -7438,22 +7409,6 @@ struct TALER_EXCHANGEDB_Plugin /** - * Trigger AML process, an account has crossed the threshold. Inserts or - * updates the AML status. - * - * @param cls closure - * @param h_payto account for which the attribute data is stored - * @param threshold_crossed existing threshold that was crossed - * @return database transaction status - */ - enum GNUNET_DB_QueryStatus - (*trigger_aml_process)( - void *cls, - const struct TALER_PaytoHashP *h_payto, - const struct TALER_Amount *threshold_crossed); - - - /** * Lookup AML decisions that have a particular state. * * @param cls closure @@ -7470,7 +7425,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_aml_decisions)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, enum TALER_EXCHANGE_YesNoAll investigation_only, enum TALER_EXCHANGE_YesNoAll active_only, uint64_t offset, @@ -7494,7 +7449,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*select_aml_attributes)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t offset, int64_t limit, TALER_EXCHANGEDB_AmlAttributeCallback cb, @@ -7515,7 +7470,7 @@ struct TALER_EXCHANGEDB_Plugin (*lookup_h_payto_by_access_token)( void *cls, const struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto); + struct TALER_NormalizedPaytoHashP *h_payto); /** @@ -7539,7 +7494,7 @@ struct TALER_EXCHANGEDB_Plugin void *cls, uint64_t legitimization_measure_serial_id, struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, json_t **jmeasures, bool *is_finished); @@ -7573,7 +7528,7 @@ struct TALER_EXCHANGEDB_Plugin uint64_t legitimization_measure_serial_id, uint32_t measure_index, struct TALER_AccountAccessTokenP *access_token, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, json_t **jmeasures, bool *is_finished, size_t *encrypted_attributes_len, @@ -7593,7 +7548,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*lookup_aml_history)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlHistoryCallback cb, void *cb_cls); @@ -7611,7 +7566,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*lookup_kyc_history)( void *cls, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_KycHistoryCallback cb, void *cb_cls); @@ -7624,6 +7579,7 @@ struct TALER_EXCHANGEDB_Plugin * row in legitimization_processes table to access * @param[out] measure_index set to the measure the * process is trying to satisfy + * @param[out] provider_name name of the provider, must be freed by caller * @param[out] jmeasures set to the legitimization * measures that were put on the account * @return database transaction status @@ -7633,6 +7589,7 @@ struct TALER_EXCHANGEDB_Plugin void *cls, uint64_t legitimization_process_serial_id, uint32_t *measure_index, + char **provider_name, json_t **jmeasures); @@ -7679,13 +7636,15 @@ struct TALER_EXCHANGEDB_Plugin * @param[out] unknown_account set to TRUE if @a h_payto does not refer to a known account and @a jmeasures was given * @param[out] last_date set to the previous decision time; * the INSERT is not performed if @a last_date is not before @a decision_time + * @param[out] legitimization_measure_serial_id serial ID of the legitimization measures + * of the decision * @return database transaction status */ enum GNUNET_DB_QueryStatus (*insert_aml_decision)( void *cls, - const char *payto_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp decision_time, struct GNUNET_TIME_Timestamp expiration_time, const json_t *properties, @@ -7698,7 +7657,8 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_AmlOfficerSignatureP *decider_sig, bool *invalid_officer, bool *unknown_account, - struct GNUNET_TIME_Timestamp *last_date); + struct GNUNET_TIME_Timestamp *last_date, + uint64_t *legitimization_measure_serial_id); /** @@ -7718,7 +7678,7 @@ struct TALER_EXCHANGEDB_Plugin (*insert_kyc_failure)( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index 5e78ab44d..cd747d94a 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -184,6 +184,34 @@ TALER_JSON_pack_amount ( /** * Generate packer instruction for a JSON field of type + * full payto. + * + * @param name name of the field to add to the object + * @param payto payto URI to pack + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_full_payto ( + const char *name, + const struct TALER_FullPayto payto); + + +/** + * Generate packer instruction for a JSON field of type + * normalized payto. + * + * @param name name of the field to add to the object + * @param payto payto URI to pack + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_normalized_payto ( + const char *name, + const struct TALER_NormalizedPayto payto); + + +/** + * Generate packer instruction for a JSON field of type * encrypted contract. * * @param name name of the field to add to the object @@ -443,7 +471,7 @@ TALER_JSON_spec_web_url (const char *field, /** - * Generate line in parser specification for + * Generate line in parser specification for full * "payto://" URIs. * * @param field name of the field @@ -451,8 +479,23 @@ TALER_JSON_spec_web_url (const char *field, * @return corresponding field spec */ struct GNUNET_JSON_Specification -TALER_JSON_spec_payto_uri (const char *field, - const char **payto_uri); +TALER_JSON_spec_full_payto_uri ( + const char *field, + struct TALER_FullPayto *payto_uri); + + +/** + * Generate line in parser specification for normalized + * "payto://" URIs. + * + * @param field name of the field + * @param[out] payto_uri RFC 8905 URI to initialize + * @return corresponding field spec + */ +struct GNUNET_JSON_Specification +TALER_JSON_spec_normalized_payto_uri ( + const char *field, + struct TALER_NormalizedPayto *payto_uri); /** @@ -861,7 +904,7 @@ TALER_JSON_wire_to_method ( * * @return NULL on error */ -char * +struct TALER_FullPayto TALER_JSON_wire_to_payto ( const json_t *wire_s); @@ -929,7 +972,7 @@ typedef void * @param cb function to call on the result * @param cb_cls closure for @a cb * @param binary name of the binary to execute - * @param ... NULL-terminated list of arguments for the @a binary, + * @param argv NULL-terminated list of arguments for the @a binary, * usually starting with again the name of the binary * @return handle to cancel the operation (and kill the helper) */ @@ -939,7 +982,7 @@ TALER_JSON_external_conversion_start ( TALER_JSON_JsonCallback cb, void *cb_cls, const char *binary, - ...); + const char **argv); /** * Abort external conversion, killing the process and preventing diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h index fdfd5e283..009c436b7 100644 --- a/src/include/taler_kyclogic_lib.h +++ b/src/include/taler_kyclogic_lib.h @@ -108,6 +108,38 @@ enum TALER_KYCLOGIC_CheckType /** + * KYC measure that can be taken. + */ +struct TALER_KYCLOGIC_Measure +{ + /** + * Name of the KYC measure. + */ + char *measure_name; + + /** + * Name of the KYC check. + */ + char *check_name; + + /** + * Name of the AML program. + */ + char *prog_name; + + /** + * Context for the check. Can be NULL. + */ + json_t *context; + + /** + * Can this measure be triggered voluntarily? + */ + bool voluntary; +}; + + +/** * Information about a KYC provider. */ struct TALER_KYCLOGIC_KycProvider; @@ -478,6 +510,9 @@ TALER_KYCLOGIC_rule_to_measures ( * have references into the legitimization rule set provided to * #TALER_KYCLOGIC_requirements_to_check() and thus has a lifetime that * matches the legitimization rule set. + * + * FIXME(fdold, 2024-11-07): Consider not making this public, + * instead use struct TALER_KYCLOGIC_Measure. */ struct TALER_KYCLOGIC_KycCheckContext { @@ -509,7 +544,7 @@ struct TALER_KYCLOGIC_KycCheckContext * ``LegitimizationMeasures`` */ json_t * -TALER_KYCLOGIC_check_to_measures ( +TALER_KYCLOGIC_check_to_jmeasures ( const struct TALER_KYCLOGIC_KycCheckContext *kcc); @@ -570,6 +605,7 @@ TALER_KYCLOGIC_check_form ( * * @param check_name the prescribed check * @param prog_name the program to run + * @param context context to return, can be NULL * @param access_token access token for the measure * @param offset offset of the measure * @param legitimization_measure_row_id row in the legitimization_measures table @@ -579,6 +615,7 @@ json_t * TALER_KYCLOGIC_measure_to_requirement ( const char *check_name, const char *prog_name, + const json_t *context, const struct TALER_AccountAccessTokenP *access_token, size_t offset, uint64_t legitimization_measure_row_id); @@ -593,7 +630,7 @@ TALER_KYCLOGIC_measure_to_requirement ( * @return JSON object of type LegitimizationMeasures */ json_t * -TALER_KYCLOGIC_get_measures ( +TALER_KYCLOGIC_get_jmeasures ( const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs, const char *measures_spec); @@ -696,11 +733,11 @@ TALER_KYCLOGIC_rules_get_expiration ( * Return successor measure for the given @a lrs * * @param lrs legitimization rules to inspect - * @return name of the successor measure; + * @return successor measure; * NULL to fall back to default rules; * pointer will be valid as long as @a lrs is valid */ -const char * +const struct TALER_KYCLOGIC_Measure * TALER_KYCLOGIC_rules_get_successor ( const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs); @@ -770,6 +807,47 @@ TALER_KYCLOGIC_rule_get_instant_measure ( /** + * Check if there is a measure in @a lrs + * that is included in @a measure_spec + * and a SKIP measure, and thus should be immediately + * executed. + * + * @param rls legitimization rule set + * @param measures_spec measures spec + * @returns NULL if there is no instant measure + */ +const struct TALER_KYCLOGIC_Measure * +TALER_KYCLOGIC_get_instant_measure ( + const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs, + const char *measures_spec); + + +/** + * Check if there is a measure in @a lrs + * that is named @a measure. + * + * @param rls legitimization rule set + * @param measure_name measures spec + * @returns NULL if not found + */ +const struct TALER_KYCLOGIC_Measure * +TALER_KYCLOGIC_get_measure ( + const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs, + const char *measure_name); + + +/** + * Convert a measure to JSON. + * + * @param m measure to convert to JSON + * @returns JSON representation of the measure + */ +json_t * +TALER_KYCLOGIC_measure_to_jmeasures ( + const struct TALER_KYCLOGIC_Measure *m); + + +/** * Handle to manage a running AML program. */ struct TALER_KYCLOGIC_AmlProgramRunnerHandle; diff --git a/src/include/taler_kyclogic_plugin.h b/src/include/taler_kyclogic_plugin.h index 0018086b6..00f35fd60 100644 --- a/src/include/taler_kyclogic_plugin.h +++ b/src/include/taler_kyclogic_plugin.h @@ -201,7 +201,7 @@ typedef void (*TALER_KYCLOGIC_WebhookCallback)( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, const char *provider_name, const char *provider_user_id, const char *provider_legitimization_id, @@ -229,7 +229,7 @@ typedef enum GNUNET_DB_QueryStatus void *cls, const char *provider_name, const char *provider_legitimization_id, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, uint64_t *process_row); @@ -291,7 +291,7 @@ struct TALER_KYCLOGIC_Plugin struct TALER_KYCLOGIC_InitiateHandle * (*initiate)(void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t process_row, TALER_KYCLOGIC_InitiateCallback cb, void *cb_cls); @@ -324,7 +324,7 @@ struct TALER_KYCLOGIC_Plugin (*proof)(void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, struct MHD_Connection *connection, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t process_row, const char *provider_user_id, const char *provider_legitimization_id, diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 98a74f39f..8bd793120 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -153,17 +153,22 @@ struct TALER_TESTING_Credentials /** * RFC 8905 URI of the exchange. */ - char *exchange_payto; + struct TALER_FullPayto exchange_payto; /** * RFC 8905 URI of a user. */ - char *user42_payto; + struct TALER_FullPayto user42_payto; /** * RFC 8905 URI of a user. */ - char *user43_payto; + struct TALER_FullPayto user43_payto; + + /** + * RFC 8905 URI of a user. + */ + struct TALER_FullPayto user44_payto; }; @@ -200,12 +205,12 @@ TALER_TESTING_get_credentials ( * Allocate and return a piece of wire-details. Combines * a @a payto -URL and adds some salt to create the JSON. * - * @param payto payto://-URL to encapsulate + * @param fpayto payto://-URL to encapsulate * @return JSON describing the account, including the * payto://-URL of the account, must be manually decref'd */ json_t * -TALER_TESTING_make_wire_details (const char *payto); +TALER_TESTING_make_wire_details (const struct TALER_FullPayto fpayto); /** @@ -354,8 +359,9 @@ struct TALER_TESTING_Command * @return the command, if it is found, or NULL. */ const struct TALER_TESTING_Command * -TALER_TESTING_interpreter_lookup_command (struct TALER_TESTING_Interpreter *is, - const char *label); +TALER_TESTING_interpreter_lookup_command ( + struct TALER_TESTING_Interpreter *is, + const char *label); /** @@ -366,8 +372,9 @@ TALER_TESTING_interpreter_lookup_command (struct TALER_TESTING_Interpreter *is, * @return the command, if it is found, or NULL. */ const struct TALER_TESTING_Command * -TALER_TESTING_interpreter_get_command (struct TALER_TESTING_Interpreter *is, - const char *name); +TALER_TESTING_interpreter_get_command ( + struct TALER_TESTING_Interpreter *is, + const char *name); /** @@ -627,6 +634,19 @@ TALER_TESTING_cmd_set_var (const char *name, /** + * Update interpeter @a is variable state due to execution of @a cmd. + * + * @param[in,out] is interpreter to update + * @param[in,out] cmd command that we are exeucting and that + * needs to be checked for side-effects on the variable state + */ +void +TALER_TESTING_update_variables_ ( + struct TALER_TESTING_Interpreter *is, + struct TALER_TESTING_Command *cmd); + + +/** * Launch GNU Taler setup. * * @param label command label. @@ -761,8 +781,8 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_transfer (const char *label, const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account, - const char *payto_credit_account, + const struct TALER_FullPayto payto_debit_account, + const struct TALER_FullPayto payto_credit_account, const struct TALER_WireTransferIdentifierRawP *wtid, const char *exchange_base_url); @@ -849,7 +869,7 @@ TALER_TESTING_cmd_admin_add_incoming ( const char *label, const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account); + const struct TALER_FullPayto payto_debit_account); /** @@ -869,7 +889,7 @@ TALER_TESTING_cmd_admin_add_kycauth ( const char *label, const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account, + const struct TALER_FullPayto payto_debit_account, const char *account_ref); @@ -893,7 +913,7 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref ( const char *label, const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account, + const struct TALER_FullPayto payto_debit_account, const char *ref, unsigned int http_status); @@ -1283,10 +1303,11 @@ TALER_TESTING_cmd_reserve_poll_finish (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_reserve_history (const char *label, - const char *reserve_reference, - const char *expected_balance, - unsigned int expected_response_code); +TALER_TESTING_cmd_reserve_history ( + const char *label, + const char *reserve_reference, + const char *expected_balance, + unsigned int expected_response_code); /** @@ -1299,10 +1320,11 @@ TALER_TESTING_cmd_reserve_history (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_coin_history (const char *label, - const char *coin_reference, - const char *expected_balance, - unsigned int expected_response_code); +TALER_TESTING_cmd_coin_history ( + const char *label, + const char *coin_reference, + const char *expected_balance, + unsigned int expected_response_code); /** @@ -1318,13 +1340,14 @@ TALER_TESTING_cmd_coin_history (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_reserve_open (const char *label, - const char *reserve_reference, - const char *reserve_pay, - struct GNUNET_TIME_Relative expiration_time, - uint32_t min_purses, - unsigned int expected_response_code, - ...); +TALER_TESTING_cmd_reserve_open ( + const char *label, + const char *reserve_reference, + const char *reserve_pay, + struct GNUNET_TIME_Relative expiration_time, + uint32_t min_purses, + unsigned int expected_response_code, + ...); /** @@ -1337,10 +1360,11 @@ TALER_TESTING_cmd_reserve_open (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_reserve_get_attestable (const char *label, - const char *reserve_reference, - unsigned int expected_response_code, - ...); +TALER_TESTING_cmd_reserve_get_attestable ( + const char *label, + const char *reserve_reference, + unsigned int expected_response_code, + ...); /** @@ -1353,10 +1377,11 @@ TALER_TESTING_cmd_reserve_get_attestable (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_reserve_attest (const char *label, - const char *reserve_reference, - unsigned int expected_response_code, - ...); +TALER_TESTING_cmd_reserve_attest ( + const char *label, + const char *reserve_reference, + unsigned int expected_response_code, + ...); /** @@ -1369,10 +1394,11 @@ TALER_TESTING_cmd_reserve_attest (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_reserve_close (const char *label, - const char *reserve_reference, - const char *target_account, - unsigned int expected_response_code); +TALER_TESTING_cmd_reserve_close ( + const char *label, + const char *reserve_reference, + struct TALER_FullPayto target_account, + unsigned int expected_response_code); /** @@ -1395,14 +1421,15 @@ TALER_TESTING_cmd_reserve_close (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit (const char *label, - const char *coin_reference, - unsigned int coin_index, - const char *target_account_payto, - const char *contract_terms, - struct GNUNET_TIME_Relative refund_deadline, - const char *amount, - unsigned int expected_response_code); +TALER_TESTING_cmd_deposit ( + const char *label, + const char *coin_reference, + unsigned int coin_index, + const struct TALER_FullPayto target_account_payto, + const char *contract_terms, + struct GNUNET_TIME_Relative refund_deadline, + const char *amount, + unsigned int expected_response_code); /** * Create a "deposit" command that references an existing merchant key. @@ -1429,15 +1456,16 @@ TALER_TESTING_cmd_deposit (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit_with_ref (const char *label, - const char *coin_reference, - unsigned int coin_index, - const char *target_account_payto, - const char *contract_terms, - struct GNUNET_TIME_Relative refund_deadline, - const char *amount, - unsigned int expected_response_code, - const char *merchant_priv_reference); +TALER_TESTING_cmd_deposit_with_ref ( + const char *label, + const char *coin_reference, + unsigned int coin_index, + const struct TALER_FullPayto target_account_payto, + const char *contract_terms, + struct GNUNET_TIME_Relative refund_deadline, + const char *amount, + unsigned int expected_response_code, + const char *merchant_priv_reference); /** * Modify a deposit command to enable retries when we get transient @@ -1482,12 +1510,13 @@ TALER_TESTING_cmd_deposit_replay (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_batch_deposit (const char *label, - const char *target_account_payto, - const char *contract_terms, - struct GNUNET_TIME_Relative refund_deadline, - unsigned int expected_response_code, - ...); +TALER_TESTING_cmd_batch_deposit ( + const char *label, + const struct TALER_FullPayto target_account_payto, + const char *contract_terms, + struct GNUNET_TIME_Relative refund_deadline, + unsigned int expected_response_code, + ...); /** @@ -1662,8 +1691,8 @@ TALER_TESTING_cmd_check_bank_transfer ( const char *label, const char *exchange_base_url, const char *amount, - const char *debit_payto, - const char *credit_payto); + const struct TALER_FullPayto debit_payto, + const struct TALER_FullPayto credit_payto); /** @@ -1681,8 +1710,8 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_check_bank_admin_transfer ( const char *label, const char *amount, - const char *debit_payto, - const char *credit_payto, + const struct TALER_FullPayto debit_payto, + const struct TALER_FullPayto credit_payto, const char *reserve_pub_ref); @@ -2060,7 +2089,7 @@ TALER_TESTING_cmd_set_wire_fee (const char *label, */ struct TALER_TESTING_Command TALER_TESTING_cmd_wire_add (const char *label, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, unsigned int expected_http_status, bool bad_sig); @@ -2077,7 +2106,7 @@ TALER_TESTING_cmd_wire_add (const char *label, */ struct TALER_TESTING_Command TALER_TESTING_cmd_wire_del (const char *label, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, unsigned int expected_http_status, bool bad_sig); @@ -2742,7 +2771,8 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, op (contract_priv, const struct TALER_ContractDiffiePrivateP) \ op (reserve_priv, const struct TALER_ReservePrivateKeyP) \ op (reserve_sig, const struct TALER_ReserveSignatureP) \ - op (h_payto, const struct TALER_PaytoHashP) \ + op (h_full_payto, const struct TALER_FullPaytoHashP) \ + op (h_normalized_payto, const struct TALER_NormalizedPaytoHashP) \ op (account_access_token, const struct TALER_AccountAccessTokenP) \ op (account_priv, const union TALER_AccountPrivateKeyP) \ op (account_pub, const union TALER_AccountPublicKeyP) \ @@ -2760,14 +2790,15 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, op (auditor_url, const char) \ op (exchange_bank_account_url, const char) \ op (taler_uri, const char) \ - op (payto_uri, const char) \ + op (full_payto_uri, const struct TALER_FullPayto) \ + op (normalized_payto_uri, const struct TALER_NormalizedPayto) \ op (kyc_url, const char) \ op (web_url, const char) \ op (row, const uint64_t) \ op (legi_requirement_row, const uint64_t) \ op (array_length, const unsigned int) \ - op (credit_payto_uri, const char) \ - op (debit_payto_uri, const char) \ + op (credit_payto_uri, const struct TALER_FullPayto) \ + op (debit_payto_uri, const struct TALER_FullPayto) \ op (order_id, const char) \ op (amount, const struct TALER_Amount) \ op (amount_with_fee, const struct TALER_Amount) \ diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 3bb0b1c05..994e09544 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -382,6 +382,41 @@ TALER_url_valid_charset (const char *url); /** + * Compare two full payto URIs for equality. + * + * @param a a full payto URI, NULL is permitted + * @param b a full payto URI, NULL is permitted + * @return 0 if both are equal, otherwise -1 or 1 + */ +int +TALER_full_payto_cmp (const struct TALER_FullPayto a, + const struct TALER_FullPayto b); + +/** + * Compare two full payto URIs for equality in their normalized form. + * + * @param a a full payto URI, NULL is permitted + * @param b a full payto URI, NULL is permitted + * @return 0 if both are equal, otherwise -1 or 1 + */ +int +TALER_full_payto_normalize_and_cmp (const struct TALER_FullPayto a, + const struct TALER_FullPayto b); + + +/** + * Compare two normalized payto URIs for equality. + * + * @param a a full payto URI, NULL is permitted + * @param b a full payto URI, NULL is permitted + * @return 0 if both are equal, otherwise -1 or 1 + */ +int +TALER_normalized_payto_cmp (const struct TALER_NormalizedPayto a, + const struct TALER_NormalizedPayto b); + + +/** * Test if the URL is a valid "http" (or "https") * URL (includes test for #TALER_url_valid_charset()). * @@ -522,8 +557,20 @@ TALER_payto_get_method (const char *payto_uri); * @param input a payto://-URI * @return normalized URI, or NULL if @a input was not well-formed */ -char * -TALER_payto_normalize (const char *input); +struct TALER_NormalizedPayto +TALER_payto_normalize (const struct TALER_FullPayto input); + + +/** + * Normalize the given full payto URI and hash it. + * + * @param in full payto URI + * @param[out] out hash of the normalized payto URI + */ +void +TALER_full_payto_normalize_and_hash ( + const struct TALER_FullPayto in, + struct TALER_NormalizedPaytoHashP *out); /** @@ -534,39 +581,39 @@ TALER_payto_normalize (const char *input); * payto URL */ char * -TALER_xtalerbank_account_from_payto (const char *payto); +TALER_xtalerbank_account_from_payto (const struct TALER_FullPayto payto); /** * Obtain the receiver name from a payto URL. * - * @param payto an x-taler-bank payto URL - * @return only the receiver name from the @a payto URL, NULL if not an x-taler-bank payto URL + * @param fpayto a full payto URL + * @return only the receiver name from the @a payto URL, NULL if not a full payto URL */ char * -TALER_payto_get_receiver_name (const char *payto); +TALER_payto_get_receiver_name (const struct TALER_FullPayto fpayto); /** * Extract the subject value from the URI parameters. * - * @param payto_uri the URL to parse + * @param payto_uri the full URL to parse * @return NULL if the subject parameter is not found. * The caller should free the returned value. */ char * -TALER_payto_get_subject (const char *payto_uri); +TALER_payto_get_subject (const struct TALER_FullPayto payto_uri); /** - * Check that a payto:// URI is well-formed. + * Check that a full payto:// URI is well-formed. * - * @param payto_uri the URL to check + * @param fpayto_uri the full URL to check * @return NULL on success, otherwise an error * message to be freed by the caller! */ char * -TALER_payto_validate (const char *payto_uri); +TALER_payto_validate (const struct TALER_FullPayto fpayto_uri); /** @@ -577,7 +624,7 @@ TALER_payto_validate (const char *payto_uri); * @param reserve_pub the public key of the reserve * @return payto://-URI for the reserve (without receiver-name!) */ -char * +struct TALER_NormalizedPayto TALER_reserve_make_payto (const char *exchange_url, const struct TALER_ReservePublicKeyP *reserve_pub); diff --git a/src/json/conversion.c b/src/json/conversion.c index 42b6f8ed2..b319eae0b 100644 --- a/src/json/conversion.c +++ b/src/json/conversion.c @@ -298,12 +298,11 @@ TALER_JSON_external_conversion_start (const json_t *input, TALER_JSON_JsonCallback cb, void *cb_cls, const char *binary, - ...) + const char **argv) { struct TALER_JSON_ExternalConversion *ec; struct GNUNET_DISK_PipeHandle *pipe_stdin; struct GNUNET_DISK_PipeHandle *pipe_stdout; - va_list ap; ec = GNUNET_new (struct TALER_JSON_ExternalConversion); ec->cb = cb; @@ -312,15 +311,12 @@ TALER_JSON_external_conversion_start (const json_t *input, GNUNET_assert (NULL != pipe_stdin); pipe_stdout = GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_WRITE); GNUNET_assert (NULL != pipe_stdout); - va_start (ap, - binary); - ec->helper = GNUNET_OS_start_process_va (GNUNET_OS_INHERIT_STD_ERR, - pipe_stdin, - pipe_stdout, - NULL, - binary, - ap); - va_end (ap); + ec->helper = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, + pipe_stdin, + pipe_stdout, + NULL, + binary, + (char *const *) argv); if (NULL == ec->helper) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -345,6 +341,9 @@ TALER_JSON_external_conversion_start (const json_t *input, GNUNET_DISK_pipe_close (pipe_stdout)); ec->write_buf = json_dumps (input, JSON_COMPACT); ec->write_size = strlen (ec->write_buf); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Passing %llu bytes to JSON conversion tool\n", + (unsigned long long) ec->write_size); ec->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, ec->chld_stdout, diff --git a/src/json/json_helper.c b/src/json/json_helper.c index 2d1037ef6..5ed4571a2 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c @@ -1200,10 +1200,11 @@ TALER_JSON_spec_web_url (const char *field, * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ static enum GNUNET_GenericReturnValue -parse_payto_uri (void *cls, - json_t *root, - struct GNUNET_JSON_Specification *spec) +parse_full_payto_uri (void *cls, + json_t *root, + struct GNUNET_JSON_Specification *spec) { + struct TALER_FullPayto *payto_uri = spec->ptr; const char *str; char *err; @@ -1214,29 +1215,89 @@ parse_payto_uri (void *cls, GNUNET_break_op (0); return GNUNET_SYSERR; } - err = TALER_payto_validate (str); + payto_uri->full_payto = (char *) str; + err = TALER_payto_validate (*payto_uri); if (NULL != err) { GNUNET_break_op (0); GNUNET_free (err); + payto_uri->full_payto = NULL; return GNUNET_SYSERR; } - *(const char **) spec->ptr = str; return GNUNET_OK; } struct GNUNET_JSON_Specification -TALER_JSON_spec_payto_uri (const char *field, - const char **payto_uri) +TALER_JSON_spec_full_payto_uri ( + const char *field, + struct TALER_FullPayto *payto_uri) +{ + struct GNUNET_JSON_Specification ret = { + .parser = &parse_full_payto_uri, + .field = field, + .ptr = payto_uri + }; + + payto_uri->full_payto = NULL; + return ret; +} + + +/** + * Parse given JSON object to payto:// URI. + * + * @param cls closure, NULL + * @param root the json object representing data + * @param[out] spec where to write the data + * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error + */ +static enum GNUNET_GenericReturnValue +parse_normalized_payto_uri (void *cls, + json_t *root, + struct GNUNET_JSON_Specification *spec) +{ + struct TALER_NormalizedPayto *payto_uri = spec->ptr; + const char *str; + + (void) cls; + str = json_string_value (root); + if (NULL == str) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + payto_uri->normalized_payto = (char *) str; +#if FIXME /* need reduced validation for normalized paytos! */ + { + char *err; + + err = TALER_payto_validate (*payto_uri); + if (NULL != err) + { + GNUNET_break_op (0); + GNUNET_free (err); + payto_uri->normalized_payto = NULL; + return GNUNET_SYSERR; + } + } +#endif + return GNUNET_OK; +} + + +struct GNUNET_JSON_Specification +TALER_JSON_spec_normalized_payto_uri ( + const char *field, + struct TALER_NormalizedPayto *payto_uri) { struct GNUNET_JSON_Specification ret = { - .parser = &parse_payto_uri, + .parser = &parse_normalized_payto_uri, .field = field, .ptr = payto_uri }; - *payto_uri = NULL; + payto_uri->normalized_payto = NULL; return ret; } diff --git a/src/json/json_pack.c b/src/json/json_pack.c index 859976acb..409d7f43f 100644 --- a/src/json/json_pack.c +++ b/src/json/json_pack.c @@ -339,4 +339,24 @@ TALER_JSON_pack_amount (const char *name, } +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_full_payto ( + const char *name, + const struct TALER_FullPayto payto) +{ + return GNUNET_JSON_pack_string (name, + payto.full_payto); +} + + +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_normalized_payto ( + const char *name, + const struct TALER_NormalizedPayto payto) +{ + return GNUNET_JSON_pack_string (name, + payto.normalized_payto); +} + + /* End of json/json_pack.c */ diff --git a/src/json/json_wire.c b/src/json/json_wire.c index 9d22d28ea..f0ca00203 100644 --- a/src/json/json_wire.c +++ b/src/json/json_wire.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018, 2021 Taler Systems SA + Copyright (C) 2018, 2021, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -28,11 +28,11 @@ enum GNUNET_GenericReturnValue TALER_JSON_merchant_wire_signature_hash (const json_t *wire_s, struct TALER_MerchantWireHashP *hc) { - const char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_WireSaltP salt; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), GNUNET_JSON_spec_fixed_auto ("salt", &salt), GNUNET_JSON_spec_end () @@ -48,7 +48,7 @@ TALER_JSON_merchant_wire_signature_hash (const json_t *wire_s, } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Validating `%s'\n", - payto_uri); + payto_uri.full_payto); { char *err; @@ -57,7 +57,7 @@ TALER_JSON_merchant_wire_signature_hash (const json_t *wire_s, { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "URI `%s' ill-formed: %s\n", - payto_uri, + payto_uri.full_payto, err); GNUNET_free (err); return GNUNET_SYSERR; @@ -70,11 +70,14 @@ TALER_JSON_merchant_wire_signature_hash (const json_t *wire_s, } -char * +struct TALER_FullPayto TALER_JSON_wire_to_payto (const json_t *wire_s) { json_t *payto_o; const char *payto_str; + struct TALER_FullPayto payto = { + NULL + }; char *err; payto_o = json_object_get (wire_s, @@ -84,19 +87,21 @@ TALER_JSON_wire_to_payto (const json_t *wire_s) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed wire record encountered: lacks payto://-url\n"); - return NULL; + return payto; } + payto.full_payto = GNUNET_strdup (payto_str); if (NULL != - (err = TALER_payto_validate (payto_str))) + (err = TALER_payto_validate (payto))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed wire record encountered: payto URI `%s' invalid: %s\n", payto_str, err); + GNUNET_free (payto.full_payto); GNUNET_free (err); - return NULL; + return payto; } - return GNUNET_strdup (payto_str); + return payto; } diff --git a/src/json/test_conversion.c b/src/json/test_conversion.c index 449b02d59..e148927f5 100644 --- a/src/json/test_conversion.c +++ b/src/json/test_conversion.c @@ -65,6 +65,7 @@ conv_cb (void *cls, GNUNET_JSON_pack_string ("foo", "arg") ); + GNUNET_assert (NULL != expect); if (1 == json_equal (expect, result)) { @@ -111,6 +112,11 @@ static void run (void *cls) { json_t *input; + const char *argv[] = { + "test_conversion.sh", + "arg", + NULL + }; (void) cls; GNUNET_SCHEDULER_add_shutdown (&do_shutdown, @@ -119,13 +125,12 @@ run (void *cls) GNUNET_JSON_pack_string ("key", "foo") ); + GNUNET_assert (NULL != input); ec = TALER_JSON_external_conversion_start (input, &conv_cb, NULL, "./test_conversion.sh", - "test_conversion.sh", - "arg", - NULL); + argv); json_decref (input); GNUNET_assert (NULL != ec); } @@ -140,7 +145,7 @@ main (int argc, unsetenv ("XDG_DATA_HOME"); unsetenv ("XDG_CONFIG_HOME"); GNUNET_log_setup ("test-conversion", - "WARNING", + "INFO", NULL); GNUNET_OS_init (TALER_project_data_default ()); global_ret = 1; diff --git a/src/kyclogic/Makefile.am b/src/kyclogic/Makefile.am index 35e68e1a2..1b7d61dc4 100644 --- a/src/kyclogic/Makefile.am +++ b/src/kyclogic/Makefile.am @@ -18,6 +18,8 @@ bin_SCRIPTS = \ taler-exchange-helper-converter-oauth2-test-full_name \ taler-exchange-helper-measure-test-form \ taler-exchange-helper-measure-test-oauth \ + taler-exchange-helper-measure-none \ + taler-exchange-helper-measure-freeze \ taler-exchange-kyc-kycaid-converter.sh \ taler-exchange-kyc-persona-converter.sh \ taler-exchange-kyc-oauth2-test-converter.sh \ diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c index 9a563df08..825282021 100644 --- a/src/kyclogic/kyclogic_api.c +++ b/src/kyclogic/kyclogic_api.c @@ -125,38 +125,6 @@ struct TALER_KYCLOGIC_KycRule /** - * KYC measure that can be taken. - */ -struct TALER_KYCLOGIC_Measure -{ - /** - * Name of the KYC measure. - */ - char *measure_name; - - /** - * Name of the KYC check. - */ - char *check_name; - - /** - * Name of the AML program. - */ - char *prog_name; - - /** - * Context for the check. Can be NULL. - */ - json_t *context; - - /** - * Can this measure be triggered voluntarily? - */ - bool voluntary; -}; - - -/** * Set of rules that applies to an account. */ struct TALER_KYCLOGIC_LegitimizationRuleSet @@ -309,11 +277,19 @@ TALER_KYCLOGIC_rules_get_expiration ( } -const char * +const struct TALER_KYCLOGIC_Measure * TALER_KYCLOGIC_rules_get_successor ( const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs) { - return lrs->successor_measure; + const char *successor_measure_name = lrs->successor_measure; + + if (NULL == successor_measure_name) + { + return NULL; + } + return TALER_KYCLOGIC_get_measure ( + lrs, + successor_measure_name); } @@ -599,6 +575,11 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs) GNUNET_break_op (0); goto cleanup; } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Parsed KYC rule %u for %d with threshold %s\n", + (unsigned int) off, + (int) rule->trigger, + TALER_amount2s (&rule->threshold)); rule->lrs = lrs; rule->num_measures = json_array_size (jmeasures); rule->next_measures @@ -626,6 +607,10 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs) GNUNET_break (0); goto cleanup; } + if (0 == strcasecmp (str, KYC_MEASURE_IMPOSSIBLE)) + { + rule->verboten = true; + } rule->next_measures[j] = GNUNET_strdup (str); } @@ -658,8 +643,8 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs) GNUNET_JSON_spec_string ("prog_name", &prog_name), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_array_const ("context", - &context), + GNUNET_JSON_spec_object_const ("context", + &context), NULL), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_bool ("voluntary", @@ -957,6 +942,13 @@ TALER_KYCLOGIC_rule_get_instant_measure ( const char *measure_name = r->next_measures[i]; const struct TALER_KYCLOGIC_Measure *ms; + if (0 == strcasecmp (measure_name, KYC_MEASURE_IMPOSSIBLE)) + { + /* If any of the measures if verboten, we do not even + consider execution of the instant measure. */ + return NULL; + } + ms = find_measure (lrs, measure_name); if (NULL == ms) @@ -1059,7 +1051,7 @@ TALER_KYCLOGIC_zero_measures ( json_decref (zero_measures); return NULL; } - if (0 == strcasecmp ("verboten", + if (0 == strcasecmp (KYC_MEASURE_IMPOSSIBLE, ms->check_name)) continue; /* not a measure to be selected */ mi = GNUNET_JSON_PACK ( @@ -1107,7 +1099,7 @@ append_voluntary_measure ( if (! ms->voluntary) return; - if (0 == strcasecmp ("verboten", + if (0 == strcasecmp (KYC_MEASURE_IMPOSSIBLE, ms->check_name)) return; /* very strange configuration */ #if 0 @@ -1167,8 +1159,70 @@ TALER_KYCLOGIC_voluntary_measures ( } +const struct TALER_KYCLOGIC_Measure * +TALER_KYCLOGIC_get_instant_measure ( + const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs, + const char *measures_spec) +{ + char *nm; + const struct TALER_KYCLOGIC_Measure *ret = NULL; + + GNUNET_assert (NULL != measures_spec); + + if ('+' == measures_spec[0]) + { + nm = GNUNET_strdup (&measures_spec[1]); + } + else + { + nm = GNUNET_strdup (measures_spec); + } + for (const char *tok = strtok (nm, " "); + NULL != tok; + tok = strtok (NULL, " ")) + { + const struct TALER_KYCLOGIC_Measure *ms; + + if (0 == strcasecmp (KYC_MEASURE_IMPOSSIBLE, + tok)) + { + continue; + } + ms = find_measure (lrs, + tok); + if (NULL == ms) + { + GNUNET_break (0); + continue; + } + if (0 == strcasecmp (KYC_MEASURE_IMPOSSIBLE, + ms->check_name)) + { + continue; + } + if (0 == strcasecmp ("SKIP", ms->check_name)) + { + ret = ms; + goto done; + } + } +done: + GNUNET_free (nm); + return ret; +} + + +const struct TALER_KYCLOGIC_Measure * +TALER_KYCLOGIC_get_measure ( + const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs, + const char *measure_name) +{ + return find_measure (lrs, measure_name); +} + + json_t * -TALER_KYCLOGIC_get_measures ( +TALER_KYCLOGIC_get_jmeasures ( const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs, const char *measures_spec) { @@ -1195,7 +1249,7 @@ TALER_KYCLOGIC_get_measures ( const struct TALER_KYCLOGIC_Measure *ms; json_t *mi; - if (0 == strcasecmp ("verboten", + if (0 == strcasecmp (KYC_MEASURE_IMPOSSIBLE, tok)) { verboten = true; @@ -1210,12 +1264,6 @@ TALER_KYCLOGIC_get_measures ( json_decref (jmeasures); return NULL; } - if (0 == strcasecmp ("verboten", - ms->check_name)) - { - verboten = true; - continue; - } mi = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("check_name", ms->check_name), @@ -1240,7 +1288,7 @@ TALER_KYCLOGIC_get_measures ( json_t * -TALER_KYCLOGIC_check_to_measures ( +TALER_KYCLOGIC_check_to_jmeasures ( const struct TALER_KYCLOGIC_KycCheckContext *kcc) { const struct TALER_KYCLOGIC_KycCheck *check @@ -1273,6 +1321,36 @@ TALER_KYCLOGIC_check_to_measures ( } +json_t * +TALER_KYCLOGIC_measure_to_jmeasures ( + const struct TALER_KYCLOGIC_Measure *m) +{ + json_t *jmeasures; + json_t *mi; + + mi = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("check_name", + m->check_name), + GNUNET_JSON_pack_string ("prog_name", + m->prog_name), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_object_incref ("context", + (json_t *) m->context))); + jmeasures = json_array (); + GNUNET_assert (NULL != jmeasures); + GNUNET_assert (0 == + json_array_append_new (jmeasures, + mi)); + return GNUNET_JSON_PACK ( + GNUNET_JSON_pack_array_steal ("measures", + jmeasures), + GNUNET_JSON_pack_bool ("is_and_combinator", + false), + GNUNET_JSON_pack_bool ("verboten", + false)); +} + + uint32_t TALER_KYCLOGIC_rule2priority ( const struct TALER_KYCLOGIC_KycRule *r) @@ -1282,6 +1360,88 @@ TALER_KYCLOGIC_rule2priority ( /** + * Perform very primitive word splitting of a command. + * + * @args command command to split + * @args extra_args extra arguments to append after the word + * @returns NULL-terminated array of words + */ +static char ** +split_words (const char *command, const char **extra_args) +{ + unsigned int i = 0; + unsigned int j = 0; + unsigned int n = 0; + char **res = NULL; + + /* Result is always NULL-terminated */ + GNUNET_array_append (res, n, NULL); + + /* Split command into words */ + while (1) + { + char *c; + + /* Skip initial whitespace before word */ + while (' ' == command[i]) + i++; + + /* Start of new word */ + j = i; + + /* Scan to end of word */ + while ( (0 != command[j]) && (' ' != command[j]) ) + j++; + + /* No new word found */ + if (i == j) + break; + + /* Append word to result */ + c = GNUNET_malloc (j - i + 1); + memcpy (c, &command[i], j - i); + c[j - i] = 0; + res[n - 1] = c; + GNUNET_array_append (res, n, NULL); + + /* Continue at end of word */ + i = j; + } + + /* Append extra args */ + if (NULL != extra_args) + { + for (const char **m = extra_args; *m; m++) + { + res[n - 1] = GNUNET_strdup (*m); + GNUNET_array_append (res, n, NULL); + } + } + + return res; +} + + +/** + * Free arguments allocated with split_words. + * + * @param args NULL-terminated array of strings to free. + */ +static void +destroy_words (char **args) +{ + if (NULL == args) + return; + for (char **m = args; *m; m++) + { + GNUNET_free (*m); + *m = NULL; + } + GNUNET_free (args); +} + + +/** * Run @a command with @a argument and return the * respective output from stdout. * @@ -1299,6 +1459,12 @@ command_output (const char *command, ssize_t ret; int sout[2]; pid_t chld; + const char *extra_args[] = { + argument, + "-c", + cfg_filename, + NULL, + }; if (0 != pipe (sout)) { @@ -1315,6 +1481,11 @@ command_output (const char *command, } if (0 == chld) { + char **argv; + + argv = split_words (command, + extra_args); + GNUNET_break (0 == close (sout[0])); GNUNET_break (0 == @@ -1324,12 +1495,9 @@ command_output (const char *command, STDOUT_FILENO)); GNUNET_break (0 == close (sout[1])); - execlp (command, - command, - argument, - "-c", - cfg_filename, - NULL); + execvp (argv[0], + argv); + destroy_words (argv); GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "exec", command); @@ -2042,8 +2210,10 @@ add_rule (const struct GNUNET_CONFIGURATION_Handle *cfg, } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Adding KYC rule %s\n", - section); + "Adding KYC rule %s for trigger %d with threshold %s\n", + section, + (int) ot, + TALER_amount2s (&threshold)); { struct TALER_KYCLOGIC_KycRule kt = { .lrs = &default_rules, @@ -2430,7 +2600,7 @@ TALER_KYCLOGIC_kyc_init ( const char *measure_name = rule->next_measures[j]; const struct TALER_KYCLOGIC_Measure *m; - if (0 == strcmp ("verboten", + if (0 == strcmp (KYC_MEASURE_IMPOSSIBLE, measure_name)) continue; m = find_measure (&default_rules, @@ -2947,7 +3117,14 @@ TALER_KYCLOGIC_kyc_test_required ( = &lrs->kyc_rules[i]; if (event != rule->trigger) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Rule %u is for a different trigger (%d/%d)\n", + i, + (int) event, + (int) rule->trigger); continue; + } if (have_threshold) { GNUNET_assert (GNUNET_OK == @@ -2961,16 +3138,19 @@ TALER_KYCLOGIC_kyc_test_required ( have_threshold = true; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Matched rule %u with timeframe %s\n", + "Matched rule %u with timeframe %s and threshold %s\n", i, GNUNET_TIME_relative2s (rule->timeframe, - true)); + true), + TALER_amount2s (&rule->threshold)); range = GNUNET_TIME_relative_max (range, rule->timeframe); } if (! have_threshold) { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "No rules apply\n"); *triggered_rule = NULL; return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; } @@ -3003,6 +3183,7 @@ json_t * TALER_KYCLOGIC_measure_to_requirement ( const char *check_name, const char *prog_name, + const json_t *context, const struct TALER_AccountAccessTokenP *access_token, size_t offset, uint64_t legitimization_measure_row_id) @@ -3050,6 +3231,9 @@ TALER_KYCLOGIC_measure_to_requirement ( kc->details.form.name), GNUNET_JSON_pack_string ("id", xids), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_object_incref ("context", + (json_t *) context)), GNUNET_JSON_pack_string ("description", kc->description), GNUNET_JSON_pack_allow_null ( @@ -3676,6 +3860,13 @@ TALER_KYCLOGIC_run_aml_program2 ( { json_t *input; + const char *extra_args[] = { + "-c", + cfg_filename, + NULL, + }; + + char **args; input = GNUNET_JSON_PACK ( GNUNET_JSON_pack_allow_null ( @@ -3688,15 +3879,22 @@ TALER_KYCLOGIC_run_aml_program2 ( GNUNET_JSON_pack_array_incref ("kyc_history", (json_t *) kyc_history) ); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Running AML program %s\n", + prog->command); + args = split_words (prog->command, extra_args); + GNUNET_assert (NULL != args); + GNUNET_assert (NULL != args[0]); + json_dumpf (input, + stderr, + JSON_INDENT (2)); aprh->proc = TALER_JSON_external_conversion_start ( input, &handle_aml_output, aprh, - prog->command, - prog->command, - "-c", - cfg_filename, - NULL); + args[0], + (const char **) args); + destroy_words (args); json_decref (input); } return aprh; diff --git a/src/kyclogic/plugin_kyclogic_kycaid.c b/src/kyclogic/plugin_kyclogic_kycaid.c index a22696a4a..a5df10b4b 100644 --- a/src/kyclogic/plugin_kyclogic_kycaid.c +++ b/src/kyclogic/plugin_kyclogic_kycaid.c @@ -117,7 +117,7 @@ struct TALER_KYCLOGIC_InitiateHandle * Hash of the payto:// URI we are initiating * the KYC for. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * UUID being checked. @@ -271,7 +271,7 @@ struct TALER_KYCLOGIC_WebhookHandle /** * Our account ID. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Row in legitimizations for the given @@ -578,7 +578,7 @@ handle_initiate_finished (void *cls, static struct TALER_KYCLOGIC_InitiateHandle * kycaid_initiate (void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t legitimization_uuid, TALER_KYCLOGIC_InitiateCallback cb, void *cb_cls) @@ -717,7 +717,7 @@ static struct TALER_KYCLOGIC_ProofHandle * kycaid_proof (void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, struct MHD_Connection *connection, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t process_row, const char *provider_user_id, const char *provider_legitimization_id, @@ -967,16 +967,22 @@ handle_webhook_finished (void *cls, resp); break; } - wh->econ - = TALER_JSON_external_conversion_start ( - j, - &webhook_conversion_cb, - wh, - wh->pd->conversion_helper, - wh->pd->conversion_helper, - "-a", - wh->pd->auth_token, - NULL); + { + const char *argv[] = { + wh->pd->conversion_helper, + "-a", + wh->pd->auth_token, + NULL, + }; + + wh->econ + = TALER_JSON_external_conversion_start ( + j, + &webhook_conversion_cb, + wh, + wh->pd->conversion_helper, + argv); + } if (NULL == wh->econ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/kyclogic/plugin_kyclogic_oauth2.c b/src/kyclogic/plugin_kyclogic_oauth2.c index e5d7a0a72..bb3b9dad2 100644 --- a/src/kyclogic/plugin_kyclogic_oauth2.c +++ b/src/kyclogic/plugin_kyclogic_oauth2.c @@ -142,7 +142,7 @@ struct TALER_KYCLOGIC_InitiateHandle * Hash of the payto:// URI we are initiating * the KYC for. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * UUID being checked. @@ -202,7 +202,7 @@ struct TALER_KYCLOGIC_ProofHandle /** * Hash of the payto URI that this is about. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Continuation to call. @@ -767,7 +767,7 @@ initiate_task (void *cls) static struct TALER_KYCLOGIC_InitiateHandle * oauth2_initiate (void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t legitimization_uuid, TALER_KYCLOGIC_InitiateCallback cb, void *cb_cls) @@ -1084,6 +1084,10 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph, const json_t *j) { const struct TALER_KYCLOGIC_ProviderDetails *pd = ph->pd; + const char *argv[] = { + pd->conversion_binary, + NULL, + }; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Calling converter `%s' with JSON\n", @@ -1096,8 +1100,7 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph, &converted_proof_cb, ph, pd->conversion_binary, - pd->conversion_binary, - NULL); + argv); if (NULL != ph->ec) return; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1398,7 +1401,7 @@ static struct TALER_KYCLOGIC_ProofHandle * oauth2_proof (void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, struct MHD_Connection *connection, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t process_row, const char *provider_user_id, const char *provider_legitimization_id, diff --git a/src/kyclogic/plugin_kyclogic_persona.c b/src/kyclogic/plugin_kyclogic_persona.c index 67bd546dd..22abe7ca2 100644 --- a/src/kyclogic/plugin_kyclogic_persona.c +++ b/src/kyclogic/plugin_kyclogic_persona.c @@ -144,7 +144,7 @@ struct TALER_KYCLOGIC_InitiateHandle /** * Hash of the payto:// URI we are initiating the KYC for. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * UUID being checked. @@ -245,7 +245,7 @@ struct TALER_KYCLOGIC_ProofHandle /** * Hash of the payto:// URI we are checking the KYC for. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Row in the legitimization processes of the @@ -346,7 +346,7 @@ struct TALER_KYCLOGIC_WebhookHandle /** * Our account ID. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * UUID being checked. @@ -755,7 +755,7 @@ handle_initiate_finished (void *cls, static struct TALER_KYCLOGIC_InitiateHandle * persona_initiate (void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t legitimization_uuid, TALER_KYCLOGIC_InitiateCallback cb, void *cb_cls) @@ -1022,6 +1022,13 @@ start_conversion (const struct TALER_KYCLOGIC_ProviderDetails *pd, TALER_JSON_JsonCallback cb, void *cb_cls) { + const char *argv[] = { + pd->conversion_binary, + "-a", + pd->auth_token, + NULL, + }; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Calling converter `%s' with JSON\n", pd->conversion_binary); @@ -1033,11 +1040,7 @@ start_conversion (const struct TALER_KYCLOGIC_ProviderDetails *pd, cb, cb_cls, pd->conversion_binary, - pd->conversion_binary, - "-a", - pd->auth_token, - NULL - ); + argv); } @@ -1455,7 +1458,7 @@ static struct TALER_KYCLOGIC_ProofHandle * persona_proof (void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, struct MHD_Connection *connection, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t process_row, const char *provider_user_id, const char *inquiry_id, diff --git a/src/kyclogic/plugin_kyclogic_template.c b/src/kyclogic/plugin_kyclogic_template.c index b7fce18a7..d91988941 100644 --- a/src/kyclogic/plugin_kyclogic_template.c +++ b/src/kyclogic/plugin_kyclogic_template.c @@ -86,7 +86,7 @@ struct TALER_KYCLOGIC_InitiateHandle * Hash of the payto:// URI we are initiating * the KYC for. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * UUID being checked. @@ -242,7 +242,7 @@ template_initiate_cancel (struct TALER_KYCLOGIC_InitiateHandle *ih) static struct TALER_KYCLOGIC_InitiateHandle * template_initiate (void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t legitimization_uuid, TALER_KYCLOGIC_InitiateCallback cb, void *cb_cls) @@ -292,7 +292,7 @@ static struct TALER_KYCLOGIC_ProofHandle * template_proof (void *cls, const struct TALER_KYCLOGIC_ProviderDetails *pd, struct MHD_Connection *connection, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, uint64_t process_row, const char *provider_user_id, const char *provider_legitimization_id, diff --git a/src/kyclogic/taler-exchange-helper-measure-freeze b/src/kyclogic/taler-exchange-helper-measure-freeze index 9be652372..1e2e83070 100755 --- a/src/kyclogic/taler-exchange-helper-measure-freeze +++ b/src/kyclogic/taler-exchange-helper-measure-freeze @@ -85,12 +85,11 @@ EXPIRATION=$((3600 * 30 + $(date +%s))) # See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlOutcome # for the required output format. -# NOTE: new_check is not yet supported! #9124 jq -n \ --arg expiration "$EXPIRATION" \ '{ "to_investigate": true, "new_rules" : { - "new_check" : "info-frozen", + "new_measures" : "info-frozen", "custom_measures" : {}, "expiration_time" : { "t_s": $expiration }, "rules" : [ diff --git a/src/kyclogic/taler-exchange-helper-measure-none b/src/kyclogic/taler-exchange-helper-measure-none new file mode 100755 index 000000000..182fa1f33 --- /dev/null +++ b/src/kyclogic/taler-exchange-helper-measure-none @@ -0,0 +1,79 @@ +#!/bin/bash +# +# This file is part of TALER +# Copyright (C) 2014-2024 Taler Systems SA +# +# TALER is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# +# TALER is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/license> + +# This AMP is used as a dummy program for measures that just use an INFO check. +# +# It program fails when running it, but correctly responds to commands that try +# to inspect it. + +# Hard error reporting on. +set -eu + +# Exit, with error message (hard failure) +function exit_fail() { + echo " FAIL: " "$@" >&2 + EXIT_STATUS=1 + exit "$EXIT_STATUS" +} + +CONF="$HOME/.config/taler.conf" +VERBOSE=0 + +while getopts 'ac:hrvV' OPTION; do + case "$OPTION" in + a) + # No attributes are required. + exit 0 + ;; + c) + # shellcheck disable=SC2034 + CONF="$OPTARG" + ;; + h) + echo "This is a KYC measure program that freezes the account and flags it for manual investigation. This is the ultimate fallback measure." + echo 'Supported options:' + echo ' -a -- show required attributes' + # shellcheck disable=SC2016 + echo ' -c $CONF -- set configuration' + echo ' -h -- print this help' + echo ' -r -- show required context' + echo ' -v -- show version' + echo ' -V -- be verbose' + ;; + r) + # No context is required. + exit 0 + ;; + v) + echo "$0 v0.0.0" + exit 0 + ;; + V) + VERBOSE=1 + ;; + ?) + exit_fail "Unrecognized command line option" + ;; + esac +done + +if [ 1 = "$VERBOSE" ]; then + echo "Running $0" 1>&2 +fi + +echo "FATAL: This measure program is a dummy and should never run. Only use it for INFO checks." >&2 + +exit 1 diff --git a/src/kyclogic/taler-exchange-helper-measure-test-form b/src/kyclogic/taler-exchange-helper-measure-test-form index f5bd3767a..c9835dcbf 100755 --- a/src/kyclogic/taler-exchange-helper-measure-test-form +++ b/src/kyclogic/taler-exchange-helper-measure-test-form @@ -102,13 +102,12 @@ CURRENCY=$(taler-config -c $CONF -s taler -o currency) # See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlOutcome # for the required output format. -# NOTE: new_check is not yet supported! #9124 jq -n \ --argjson expiration "$EXPIRATION" \ --arg currency "$CURRENCY" \ '{ "to_investigate": false, "new_rules" : { - "new_check" : "info-oauth-test-passed", + "new_measures" : "info-oauth-test-passed", "custom_measures" : {}, "expiration_time" : { "t_s": $expiration }, "rules" : [ diff --git a/src/kyclogic/taler-exchange-helper-measure-test-oauth b/src/kyclogic/taler-exchange-helper-measure-test-oauth index fcdaa255d..2b7bf69c9 100755 --- a/src/kyclogic/taler-exchange-helper-measure-test-oauth +++ b/src/kyclogic/taler-exchange-helper-measure-test-oauth @@ -98,13 +98,11 @@ EXPIRATION=$((3600 * 30 + $(date +%s))) # See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlOutcome # for the required output format. -# NOTE: new_check is not yet supported! #9124 - jq -n \ --argjson expiration "$EXPIRATION" \ '{ "to_investigate": false, "new_rules" : { - "new_check" : "info-oauth-test-passed", + "new_measures" : "info-oauth-test-passed", "custom_measures" : {}, "expiration_time" : { "t_s": $expiration }, "rules" : [ diff --git a/src/kyclogic/taler-exchange-kyc-tester.c b/src/kyclogic/taler-exchange-kyc-tester.c index 14af603ab..33bc0eb0d 100644 --- a/src/kyclogic/taler-exchange-kyc-tester.c +++ b/src/kyclogic/taler-exchange-kyc-tester.c @@ -239,7 +239,7 @@ static char *TEKT_base_url; /** * Payto set via command-line (or otherwise random). */ -static struct TALER_PaytoHashP cmd_line_h_payto; +static struct TALER_NormalizedPaytoHashP cmd_line_h_payto; /** * Provider user ID to use. @@ -454,7 +454,7 @@ static void webhook_finished_cb ( void *cls, uint64_t process_row, - const struct TALER_PaytoHashP *account_id, + const struct TALER_NormalizedPaytoHashP *account_id, const char *provider_section, const char *provider_user_id, const char *provider_legitimization_id, @@ -565,7 +565,7 @@ kyc_provider_account_lookup ( void *cls, const char *provider_section, const char *provider_legitimization_id, - struct TALER_PaytoHashP *h_payto, + struct TALER_NormalizedPaytoHashP *h_payto, uint64_t *legi_row) { (void) cls; @@ -783,7 +783,7 @@ handler_kyc_proof_get ( struct TEKT_RequestContext *rc, const char *const args[1]) { - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; struct TALER_KYCLOGIC_ProviderDetails *pd; struct TALER_KYCLOGIC_Plugin *logic; struct ProofRequestState *rs; @@ -1748,11 +1748,12 @@ run (void *cls, /** - * The main function of the taler-exchange-httpd server ("the exchange"). + * The main function of the taler-exchange-kyc-tester, a tool for + * testing KYC processes. * * @param argc number of arguments from the command line * @param argv command line arguments - * @return 0 ok, 1 on error + * @return 0 ok, non-zero on error */ int main (int argc, @@ -1781,7 +1782,7 @@ main (int argc, GNUNET_GETOPT_option_flag ( 'P', "print-payto-hash", - "output the hash of the payto://-URI", + "output the hash of the (normalized) payto://-URI", &print_h_payto), GNUNET_GETOPT_option_base32_fixed_size ( 'p', diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 88d00765f..cd7e5aed5 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -18,7 +18,7 @@ lib_LTLIBRARIES = \ libtalerexchange.la libtalerexchange_la_LDFLAGS = \ - -version-info 12:0:0 \ + -version-info 13:0:0 \ -no-undefined libtalerexchange_la_SOURCES = \ exchange_api_add_aml_decision.c \ diff --git a/src/lib/exchange_api_add_aml_decision.c b/src/lib/exchange_api_add_aml_decision.c index e60b88c6c..69ba03f08 100644 --- a/src/lib/exchange_api_add_aml_decision.c +++ b/src/lib/exchange_api_add_aml_decision.c @@ -127,8 +127,8 @@ struct TALER_EXCHANGE_AddAmlDecision * TALER_EXCHANGE_post_aml_decision ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, - const char *payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp decision_time, const char *successor_measure, const char *new_measures, @@ -271,8 +271,8 @@ TALER_EXCHANGE_post_aml_decision ( GNUNET_JSON_pack_data_auto ("h_payto", h_payto), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("payto_uri", - payto_uri)), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri)), GNUNET_JSON_pack_object_steal ("new_rules", new_rules), GNUNET_JSON_pack_object_incref ("properties", diff --git a/src/lib/exchange_api_batch_deposit.c b/src/lib/exchange_api_batch_deposit.c index dd0f09380..23bef742f 100644 --- a/src/lib/exchange_api_batch_deposit.c +++ b/src/lib/exchange_api_batch_deposit.c @@ -436,24 +436,82 @@ handle_deposit_finished (void *cls, break; case MHD_HTTP_CONFLICT: { - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("coin_pub", - &dr->details.conflict.coin_pub), - GNUNET_JSON_spec_end () - }; - - if (GNUNET_OK != - GNUNET_JSON_parse (j, - spec, - NULL, NULL)) + dr->hr.ec = TALER_JSON_get_error_code (j); + dr->hr.hint = TALER_JSON_get_error_hint (j); + switch (dr->hr.ec) { + case TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS: + { + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_fixed_auto ( + "coin_pub", + &dr->details.conflict.details + .insufficient_funds.coin_pub), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (j, + spec, + NULL, NULL)) + { + GNUNET_break_op (0); + dr->hr.http_status = 0; + dr->hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; + break; + } + } + break; + case TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_AGE_HASH: + { + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_fixed_auto ( + "coin_pub", + &dr->details.conflict.details + .coin_conflicting_age_hash.coin_pub), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (j, + spec, + NULL, NULL)) + { + GNUNET_break_op (0); + dr->hr.http_status = 0; + dr->hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; + break; + } + } + break; + case TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_DENOMINATION_KEY: + { + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_fixed_auto ( + "coin_pub", + &dr->details.conflict.details + .coin_conflicting_denomination_key.coin_pub), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (j, + spec, + NULL, NULL)) + { + GNUNET_break_op (0); + dr->hr.http_status = 0; + dr->hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; + break; + } + } + break; + case TALER_EC_EXCHANGE_DEPOSIT_CONFLICTING_CONTRACT: + break; + default: GNUNET_break_op (0); - dr->hr.http_status = 0; - dr->hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; break; } - dr->hr.ec = TALER_JSON_get_error_code (j); - dr->hr.hint = TALER_JSON_get_error_hint (j); } break; case MHD_HTTP_GONE: @@ -610,6 +668,10 @@ TALER_EXCHANGE_batch_deposit ( json_decref (deposits); return NULL; } + if (! GNUNET_is_zero (&dcd->merchant_sig)) + { + /* FIXME #9185: check merchant_sig!? */ + } if (GNUNET_is_zero (&cdd->h_age_commitment)) h_age_commitmentp = NULL; else @@ -654,8 +716,8 @@ TALER_EXCHANGE_batch_deposit ( wallet_data_hashp = &dcd->wallet_data_hash; deposit_obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("merchant_payto_uri", - dcd->merchant_payto_uri), + TALER_JSON_pack_full_payto ("merchant_payto_uri", + dcd->merchant_payto_uri), GNUNET_JSON_pack_data_auto ("wire_salt", &dcd->wire_salt), GNUNET_JSON_pack_data_auto ("h_contract_terms", @@ -672,6 +734,8 @@ TALER_EXCHANGE_batch_deposit ( dcd->wallet_timestamp), GNUNET_JSON_pack_data_auto ("merchant_pub", &dcd->merchant_pub), + GNUNET_JSON_pack_data_auto ("merchant_sig", + &dcd->merchant_sig), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_timestamp ("refund_deadline", dcd->refund_deadline)), diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index bd731ad37..42dd9c2ba 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -130,7 +130,7 @@ TALER_EXCHANGE_check_purse_merge_conflict_ ( &reserve_pub), GNUNET_JSON_spec_end () }; - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; if (GNUNET_OK != GNUNET_JSON_parse (proof, @@ -153,10 +153,10 @@ TALER_EXCHANGE_check_purse_merge_conflict_ ( &merge_sig)) { GNUNET_break_op (0); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.normalized_payto); return GNUNET_SYSERR; } - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.normalized_payto); if (0 == GNUNET_memcmp (&merge_sig, cmerge_sig)) @@ -514,15 +514,15 @@ TALER_EXCHANGE_parse_accounts ( i++) { struct TALER_EXCHANGE_WireAccount *wa = &was[i]; - const char *payto_uri; + struct TALER_FullPayto payto_uri; const char *conversion_url = NULL; const char *bank_label = NULL; int64_t priority = 0; const json_t *credit_restrictions; const json_t *debit_restrictions; struct GNUNET_JSON_Specification spec_account[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_web_url ("conversion_url", &conversion_url), @@ -583,7 +583,8 @@ TALER_EXCHANGE_parse_accounts ( GNUNET_break_op (0); return GNUNET_SYSERR; } - wa->payto_uri = GNUNET_strdup (payto_uri); + wa->fpayto_uri.full_payto + = GNUNET_strdup (payto_uri.full_payto); wa->priority = priority; if (NULL != conversion_url) wa->conversion_url = GNUNET_strdup (conversion_url); @@ -633,7 +634,7 @@ TALER_EXCHANGE_free_accounts ( { struct TALER_EXCHANGE_WireAccount *wa = &was[i]; - GNUNET_free (wa->payto_uri); + GNUNET_free (wa->fpayto_uri.full_payto); GNUNET_free (wa->conversion_url); GNUNET_free (wa->bank_label); free_restrictions (wa->credit_restrictions_length, diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index c39440857..acb40151e 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -40,12 +40,12 @@ * Which version of the Taler protocol is implemented * by this library? Used to determine compatibility. */ -#define EXCHANGE_PROTOCOL_CURRENT 21 +#define EXCHANGE_PROTOCOL_CURRENT 22 /** * How many versions are we backwards compatible with? */ -#define EXCHANGE_PROTOCOL_AGE 4 +#define EXCHANGE_PROTOCOL_AGE 5 /** * Set to 1 for extra debug logging. @@ -1830,7 +1830,7 @@ TALER_EXCHANGE_get_keys ( ? last_date : NULL, NULL); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting keys with URL `%s'.\n", gkh->url); eh = TALER_EXCHANGE_curl_easy_get_ (gkh->url); @@ -2248,6 +2248,8 @@ TALER_EXCHANGE_keys_to_json (const struct TALER_EXCHANGE_Keys *kd) json_t *accounts; json_t *global_fees; json_t *wblwk = NULL; + json_t *hard_limits; + json_t *zero_limits; now = GNUNET_TIME_timestamp_get (); signkeys = json_array (); @@ -2459,8 +2461,8 @@ TALER_EXCHANGE_keys_to_json (const struct TALER_EXCHANGE_Keys *kd) json_array_append_new ( accounts, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - acc->payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + acc->fpayto_uri), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("conversion_url", acc->conversion_url)), @@ -2545,6 +2547,44 @@ TALER_EXCHANGE_keys_to_json (const struct TALER_EXCHANGE_Keys *kd) TALER_JSON_from_amount (a))); } + hard_limits = json_array (); + for (unsigned int i = 0; i < kd->hard_limits_length; i++) + { + const struct TALER_EXCHANGE_AccountLimit *al + = &kd->hard_limits[i]; + json_t *j; + + j = GNUNET_JSON_PACK ( + TALER_JSON_pack_amount ("threshold", + &al->threshold), + GNUNET_JSON_pack_time_rel ("timeframe", + al->timeframe), + TALER_JSON_pack_kycte ("operation_type", + al->operation_type) + ); + GNUNET_assert (0 == + json_array_append_new ( + hard_limits, + j)); + } + + zero_limits = json_array (); + for (unsigned int i = 0; i < kd->zero_limits_length; i++) + { + const struct TALER_EXCHANGE_ZeroLimitedOperation *zol + = &kd->zero_limits[i]; + json_t *j; + + j = GNUNET_JSON_PACK ( + TALER_JSON_pack_kycte ("operation_type", + zol->operation_type) + ); + GNUNET_assert (0 == + json_array_append_new ( + zero_limits, + j)); + } + keys = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("version", kd->version), @@ -2577,6 +2617,10 @@ TALER_EXCHANGE_keys_to_json (const struct TALER_EXCHANGE_Keys *kd) accounts), GNUNET_JSON_pack_array_steal ("wads", json_array ()), + GNUNET_JSON_pack_array_steal ("hard_limits", + hard_limits), + GNUNET_JSON_pack_array_steal ("zero_limits", + zero_limits), GNUNET_JSON_pack_array_steal ("denominations", denominations_by_group), GNUNET_JSON_pack_allow_null ( diff --git a/src/lib/exchange_api_kyc_check.c b/src/lib/exchange_api_kyc_check.c index 1231c7cc1..283fcc009 100644 --- a/src/lib/exchange_api_kyc_check.c +++ b/src/lib/exchange_api_kyc_check.c @@ -256,7 +256,7 @@ struct TALER_EXCHANGE_KycCheckHandle * TALER_EXCHANGE_kyc_check ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPrivateKeyP *account_priv, enum TALER_EXCHANGE_KycLongPollTarget lpt, struct GNUNET_TIME_Relative timeout, diff --git a/src/lib/exchange_api_kyc_proof.c b/src/lib/exchange_api_kyc_proof.c index 8be30dbcf..a942b5cee 100644 --- a/src/lib/exchange_api_kyc_proof.c +++ b/src/lib/exchange_api_kyc_proof.c @@ -138,7 +138,7 @@ struct TALER_EXCHANGE_KycProofHandle * TALER_EXCHANGE_kyc_proof ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *logic, const char *args, TALER_EXCHANGE_KycProofCallback cb, @@ -152,7 +152,7 @@ TALER_EXCHANGE_kyc_proof ( else GNUNET_assert (args[0] == '&'); { - char hstr[sizeof (struct TALER_PaytoHashP) * 2]; + char hstr[sizeof (*h_payto) * 2]; char *end; end = GNUNET_STRINGS_data_to_string (h_payto, diff --git a/src/lib/exchange_api_lookup_aml_decisions.c b/src/lib/exchange_api_lookup_aml_decisions.c index 8f9b2c237..39fb24d28 100644 --- a/src/lib/exchange_api_lookup_aml_decisions.c +++ b/src/lib/exchange_api_lookup_aml_decisions.c @@ -477,7 +477,7 @@ struct TALER_EXCHANGE_LookupAmlDecisions * TALER_EXCHANGE_lookup_aml_decisions ( struct GNUNET_CURL_Context *ctx, const char *exchange_url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, enum TALER_EXCHANGE_YesNoAll investigation_only, enum TALER_EXCHANGE_YesNoAll active_only, uint64_t offset, diff --git a/src/lib/exchange_api_lookup_kyc_attributes.c b/src/lib/exchange_api_lookup_kyc_attributes.c index 6be04f4e4..e23d50804 100644 --- a/src/lib/exchange_api_lookup_kyc_attributes.c +++ b/src/lib/exchange_api_lookup_kyc_attributes.c @@ -256,7 +256,7 @@ struct TALER_EXCHANGE_LookupKycAttributes * TALER_EXCHANGE_lookup_kyc_attributes ( struct GNUNET_CURL_Context *ctx, const char *exchange_url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t offset, int64_t limit, const struct TALER_AmlOfficerPrivateKeyP *officer_priv, @@ -267,8 +267,8 @@ TALER_EXCHANGE_lookup_kyc_attributes ( CURL *eh; struct TALER_AmlOfficerPublicKeyP officer_pub; struct TALER_AmlOfficerSignatureP officer_sig; - char arg_str[sizeof (struct TALER_AmlOfficerPublicKeyP) * 2 - + sizeof (struct TALER_PaytoHashP) * 2 + char arg_str[sizeof (officer_pub) * 2 + + sizeof (*h_payto) * 2 + 32]; GNUNET_CRYPTO_eddsa_key_get_public (&officer_priv->eddsa_priv, diff --git a/src/lib/exchange_api_management_drain_profits.c b/src/lib/exchange_api_management_drain_profits.c index bc7232b87..ea646aee5 100644 --- a/src/lib/exchange_api_management_drain_profits.c +++ b/src/lib/exchange_api_management_drain_profits.c @@ -130,7 +130,7 @@ TALER_EXCHANGE_management_drain_profits ( const struct TALER_Amount *amount, struct GNUNET_TIME_Timestamp date, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_MasterSignatureP *master_sig, TALER_EXCHANGE_ManagementDrainProfitsCallback cb, void *cb_cls) @@ -156,8 +156,8 @@ TALER_EXCHANGE_management_drain_profits ( body = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("debit_account_section", account_section), - GNUNET_JSON_pack_string ("credit_payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("credit_payto_uri", + payto_uri), GNUNET_JSON_pack_data_auto ("wtid", wtid), GNUNET_JSON_pack_data_auto ("master_sig", diff --git a/src/lib/exchange_api_management_wire_disable.c b/src/lib/exchange_api_management_wire_disable.c index 23b10c58c..73dff6087 100644 --- a/src/lib/exchange_api_management_wire_disable.c +++ b/src/lib/exchange_api_management_wire_disable.c @@ -142,7 +142,7 @@ struct TALER_EXCHANGE_ManagementWireDisableHandle * TALER_EXCHANGE_management_disable_wire ( struct GNUNET_CURL_Context *ctx, const char *url, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp validity_end, const struct TALER_MasterSignatureP *master_sig, TALER_EXCHANGE_ManagementWireDisableCallback cb, @@ -167,8 +167,8 @@ TALER_EXCHANGE_management_disable_wire ( return NULL; } body = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_data_auto ("master_sig_del", master_sig), GNUNET_JSON_pack_timestamp ("validity_end", diff --git a/src/lib/exchange_api_management_wire_enable.c b/src/lib/exchange_api_management_wire_enable.c index 9a163b558..d47a3ee81 100644 --- a/src/lib/exchange_api_management_wire_enable.c +++ b/src/lib/exchange_api_management_wire_enable.c @@ -142,7 +142,7 @@ struct TALER_EXCHANGE_ManagementWireEnableHandle * TALER_EXCHANGE_management_enable_wire ( struct GNUNET_CURL_Context *ctx, const char *url, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -185,8 +185,8 @@ TALER_EXCHANGE_management_enable_wire ( return NULL; } body = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_array_incref ("debit_restrictions", (json_t *) debit_restrictions), GNUNET_JSON_pack_array_incref ("credit_restrictions", diff --git a/src/lib/exchange_api_purse_create_with_merge.c b/src/lib/exchange_api_purse_create_with_merge.c index 0c8878342..3794fc1ea 100644 --- a/src/lib/exchange_api_purse_create_with_merge.c +++ b/src/lib/exchange_api_purse_create_with_merge.c @@ -457,7 +457,7 @@ TALER_EXCHANGE_purse_create_with_merge ( purse_priv, &pcm->purse_sig); { - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; payto_uri = TALER_reserve_make_payto (url, &pcm->reserve_pub); @@ -466,7 +466,7 @@ TALER_EXCHANGE_purse_create_with_merge ( &pcm->purse_pub, merge_priv, &pcm->merge_sig); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.normalized_payto); } TALER_wallet_account_merge_sign (merge_timestamp, &pcm->purse_pub, diff --git a/src/lib/exchange_api_purse_merge.c b/src/lib/exchange_api_purse_merge.c index c013b29d2..57f2af798 100644 --- a/src/lib/exchange_api_purse_merge.c +++ b/src/lib/exchange_api_purse_merge.c @@ -319,7 +319,7 @@ TALER_EXCHANGE_account_merge ( json_t *merge_obj; CURL *eh; char arg_str[sizeof (pch->purse_pub) * 2 + 32]; - char *reserve_url; + struct TALER_NormalizedPayto reserve_url; pch = GNUNET_new (struct TALER_EXCHANGE_AccountMergeHandle); pch->merge_priv = *merge_priv; @@ -353,7 +353,7 @@ TALER_EXCHANGE_account_merge ( } reserve_url = TALER_reserve_make_payto (pch->provider_url, &pch->reserve_pub); - if (NULL == reserve_url) + if (NULL == reserve_url.normalized_payto) { GNUNET_break (0); GNUNET_free (pch->provider_url); @@ -366,7 +366,7 @@ TALER_EXCHANGE_account_merge ( if (NULL == pch->url) { GNUNET_break (0); - GNUNET_free (reserve_url); + GNUNET_free (reserve_url.normalized_payto); GNUNET_free (pch->provider_url); GNUNET_free (pch); return NULL; @@ -394,8 +394,8 @@ TALER_EXCHANGE_account_merge ( &pch->reserve_sig); } merge_obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - reserve_url), + TALER_JSON_pack_normalized_payto ("payto_uri", + reserve_url), GNUNET_JSON_pack_data_auto ("merge_sig", &pch->merge_sig), GNUNET_JSON_pack_data_auto ("reserve_sig", @@ -403,7 +403,7 @@ TALER_EXCHANGE_account_merge ( GNUNET_JSON_pack_timestamp ("merge_timestamp", merge_timestamp)); GNUNET_assert (NULL != merge_obj); - GNUNET_free (reserve_url); + GNUNET_free (reserve_url.normalized_payto); eh = TALER_EXCHANGE_curl_easy_get_ (pch->url); if ( (NULL == eh) || (GNUNET_OK != diff --git a/src/lib/exchange_api_reserves_close.c b/src/lib/exchange_api_reserves_close.c index a3769a22f..365246535 100644 --- a/src/lib/exchange_api_reserves_close.c +++ b/src/lib/exchange_api_reserves_close.c @@ -267,14 +267,14 @@ TALER_EXCHANGE_reserves_close ( struct GNUNET_CURL_Context *ctx, const char *url, const struct TALER_ReservePrivateKeyP *reserve_priv, - const char *target_payto_uri, + const struct TALER_FullPayto target_payto_uri, TALER_EXCHANGE_ReservesCloseCallback cb, void *cb_cls) { struct TALER_EXCHANGE_ReservesCloseHandle *rch; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; rch = GNUNET_new (struct TALER_EXCHANGE_ReservesCloseHandle); rch->cb = cb; @@ -313,11 +313,11 @@ TALER_EXCHANGE_reserves_close ( GNUNET_free (rch); return NULL; } - if (NULL != target_payto_uri) - TALER_payto_hash (target_payto_uri, - &h_payto); + if (NULL != target_payto_uri.full_payto) + TALER_full_payto_hash (target_payto_uri, + &h_payto); TALER_wallet_reserve_close_sign (rch->ts, - (NULL != target_payto_uri) + (NULL != target_payto_uri.full_payto) ? &h_payto : NULL, reserve_priv, @@ -325,8 +325,8 @@ TALER_EXCHANGE_reserves_close ( { json_t *close_obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("payto_uri", - target_payto_uri)), + TALER_JSON_pack_full_payto ("payto_uri", + target_payto_uri)), GNUNET_JSON_pack_timestamp ("request_timestamp", rch->ts), GNUNET_JSON_pack_data_auto ("reserve_sig", diff --git a/src/lib/exchange_api_reserves_history.c b/src/lib/exchange_api_reserves_history.c index 0654ad837..ecf1047c3 100644 --- a/src/lib/exchange_api_reserves_history.c +++ b/src/lib/exchange_api_reserves_history.c @@ -148,7 +148,7 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { - const char *wire_uri; + struct TALER_FullPayto wire_uri; uint64_t wire_reference; struct GNUNET_TIME_Timestamp timestamp; struct GNUNET_JSON_Specification withdraw_spec[] = { @@ -156,8 +156,8 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, &wire_reference), GNUNET_JSON_spec_timestamp ("timestamp", ×tamp), - TALER_JSON_spec_payto_uri ("sender_account_url", - &wire_uri), + TALER_JSON_spec_full_payto_uri ("sender_account_url", + &wire_uri), GNUNET_JSON_spec_end () }; @@ -179,7 +179,8 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, GNUNET_break_op (0); return GNUNET_SYSERR; } - rh->details.in_details.sender_url = GNUNET_strdup (wire_uri); + rh->details.in_details.sender_url.full_payto + = GNUNET_strdup (wire_uri.full_payto); rh->details.in_details.wire_reference = wire_reference; rh->details.in_details.timestamp = timestamp; return GNUNET_OK; @@ -378,10 +379,11 @@ parse_closing (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, const json_t *transaction) { const struct TALER_EXCHANGE_Keys *key_state; + struct TALER_FullPayto receiver_uri; struct GNUNET_JSON_Specification closing_spec[] = { - TALER_JSON_spec_payto_uri ( + TALER_JSON_spec_full_payto_uri ( "receiver_account_details", - &rh->details.close_details.receiver_account_details), + &receiver_uri), GNUNET_JSON_spec_fixed_auto ("wtid", &rh->details.close_details.wtid), GNUNET_JSON_spec_fixed_auto ("exchange_sig", @@ -418,7 +420,7 @@ parse_closing (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, rh->details.close_details.timestamp, &rh->amount, &rh->details.close_details.fee, - rh->details.close_details.receiver_account_details, + receiver_uri, &rh->details.close_details.wtid, uc->reserve_pub, &rh->details.close_details.exchange_pub, @@ -436,6 +438,8 @@ parse_closing (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, GNUNET_break_op (0); return GNUNET_SYSERR; } + rh->details.close_details.receiver_account_details.full_payto + = GNUNET_strdup (receiver_uri.full_payto); return GNUNET_OK; } @@ -654,10 +658,12 @@ free_reserve_history ( { for (unsigned int i = 0; i<len; i++) { - switch (rhistory[i].type) + struct TALER_EXCHANGE_ReserveHistoryEntry *rhi = &rhistory[i]; + + switch (rhi->type) { case TALER_EXCHANGE_RTT_CREDIT: - GNUNET_free (rhistory[i].details.in_details.sender_url); + GNUNET_free (rhi->details.in_details.sender_url.full_payto); break; case TALER_EXCHANGE_RTT_WITHDRAWAL: break; @@ -672,6 +678,8 @@ free_reserve_history ( case TALER_EXCHANGE_RTT_OPEN: break; case TALER_EXCHANGE_RTT_CLOSE: + GNUNET_free (rhi->details.close_details + .receiver_account_details.full_payto); break; } } diff --git a/src/lib/exchange_api_restrictions.c b/src/lib/exchange_api_restrictions.c index 1b5bd0214..1876d277c 100644 --- a/src/lib/exchange_api_restrictions.c +++ b/src/lib/exchange_api_restrictions.c @@ -28,7 +28,7 @@ enum GNUNET_GenericReturnValue TALER_EXCHANGE_test_account_allowed ( const struct TALER_EXCHANGE_WireAccount *account, bool check_credit, - const char *payto_uri) + const struct TALER_NormalizedPayto payto_uri) { unsigned int limit = check_credit @@ -41,8 +41,8 @@ TALER_EXCHANGE_test_account_allowed ( char *wm2; bool ok; - wm1 = TALER_payto_get_method (payto_uri); - wm2 = TALER_payto_get_method (account->payto_uri); + wm1 = TALER_payto_get_method (payto_uri.normalized_payto); + wm2 = TALER_payto_get_method (account->fpayto_uri.full_payto); ok = (0 == strcmp (wm1, wm2)); GNUNET_free (wm1); @@ -78,13 +78,13 @@ TALER_EXCHANGE_test_account_allowed ( return GNUNET_SYSERR; } if (regexec (&ex, - payto_uri, + payto_uri.normalized_payto, 0, NULL, REG_STARTEND)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Account `%s' allowed by regex\n", - payto_uri); + payto_uri.normalized_payto); allowed = true; } regfree (&ex); diff --git a/src/lib/exchange_api_stefan.c b/src/lib/exchange_api_stefan.c index 437e78c8b..92d419c03 100644 --- a/src/lib/exchange_api_stefan.c +++ b/src/lib/exchange_api_stefan.c @@ -125,7 +125,7 @@ TALER_EXCHANGE_keys_stefan_b2n ( min = get_unit (keys); if (NULL == min) return GNUNET_SYSERR; - if (1.0d <= keys->stefan_lin) + if (1.0 <= keys->stefan_lin) { /* This cannot work, linear STEFAN fee estimate always exceed any gross amount. */ @@ -273,7 +273,7 @@ TALER_EXCHANGE_keys_stefan_n2b ( min = get_unit (keys); if (NULL == min) return GNUNET_SYSERR; - if (1.0d <= keys->stefan_lin) + if (1.0 <= keys->stefan_lin) { /* This cannot work, linear STEFAN fee estimate always exceed any gross amount. */ diff --git a/src/testing/taler-unified-setup.sh b/src/testing/taler-unified-setup.sh index dd8c9f81e..86ec65b61 100755 --- a/src/testing/taler-unified-setup.sh +++ b/src/testing/taler-unified-setup.sh @@ -385,7 +385,7 @@ then echo "OK" echo -n "Set admin password..." AUSER="admin" - APASS="secret" + APASS="secret-password" libeufin-bank \ passwd \ -c "$CONF" \ @@ -450,13 +450,13 @@ STAGE="accounts" if [ "1" = "$START_FAKEBANK" ] then echo -n "Register Fakebank users ..." - register_fakebank_account fortytwo x - register_fakebank_account fortythree x - register_fakebank_account exchange x - register_fakebank_account tor x - register_fakebank_account gnunet x - register_fakebank_account tutorial x - register_fakebank_account survey x + register_fakebank_account fortytwo password + register_fakebank_account fortythree password + register_fakebank_account exchange password + register_fakebank_account tor password + register_fakebank_account gnunet password + register_fakebank_account tutorial password + register_fakebank_account survey password echo " DONE" fi @@ -467,13 +467,13 @@ then # the C helper for the add-incoming call. Without this value, # libeufin-bank won't find the target account to debit along a /add-incoming # call. - register_bank_account fortytwo x "User42" FR7630006000011234567890189 - register_bank_account fortythree x "Forty Three" - register_bank_account exchange x "Exchange Company" DE989651 - register_bank_account tor x "Tor Project" - register_bank_account gnunet x "GNUnet" - register_bank_account tutorial x "Tutorial" - register_bank_account survey x "Survey" + register_bank_account fortytwo password "User42" FR7630006000011234567890189 + register_bank_account fortythree password "Forty Three" + register_bank_account exchange password "Exchange Company" DE989651 + register_bank_account tor password "Tor Project" + register_bank_account gnunet password "GNUnet" + register_bank_account tutorial password "Tutorial" + register_bank_account survey password "Survey" echo " DONE" fi diff --git a/src/testing/test-taler-exchange-aggregator-postgres.conf b/src/testing/test-taler-exchange-aggregator-postgres.conf index 8c3ee4ba5..45789bd1c 100644 --- a/src/testing/test-taler-exchange-aggregator-postgres.conf +++ b/src/testing/test-taler-exchange-aggregator-postgres.conf @@ -47,13 +47,13 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [admin-accountcredentials-1] WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [bank] HTTP_PORT = 8082 diff --git a/src/testing/test-taler-exchange-wirewatch-postgres.conf b/src/testing/test-taler-exchange-wirewatch-postgres.conf index 4f13077ac..fc13371d8 100644 --- a/src/testing/test-taler-exchange-wirewatch-postgres.conf +++ b/src/testing/test-taler-exchange-wirewatch-postgres.conf @@ -46,13 +46,13 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [admin-accountcredentials-1] WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [bank] HTTP_PORT = 8082 @@ -66,6 +66,8 @@ REGISTRATION_BONUS = EUR:100 SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/ SERVE = tcp PORT = 8082 +PWD_HASH_CONFIG = { "cost": 4 } +PWD_AUTH_COMPAT = yes # Need at least one coin, otherwise Exchange # refuses to start. diff --git a/src/testing/test_auditor_api_version.c b/src/testing/test_auditor_api_version.c index dcd542ad8..83ef969a0 100644 --- a/src/testing/test_auditor_api_version.c +++ b/src/testing/test_auditor_api_version.c @@ -146,6 +146,38 @@ main (int argc, NULL); proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, + "taler-auditor-dbinit", + "taler-auditor-dbinit", + "-c", CONFIG_FILE, + "-L", "INFO", + NULL); + if (NULL == proc) + { + GNUNET_log ( + GNUNET_ERROR_TYPE_ERROR, + "Failed to run `taler-auditor-dbinit`, is your PATH correct?\n"); + return 77; + } + GNUNET_OS_process_wait (proc); + GNUNET_OS_process_destroy (proc); + proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-dbinit", + "taler-exchange-dbinit", + "-c", CONFIG_FILE, + "-L", "INFO", + NULL); + if (NULL == proc) + { + GNUNET_log ( + GNUNET_ERROR_TYPE_ERROR, + "Failed to run `taler-auditor-dbinit`, is your PATH correct?\n"); + return 77; + } + GNUNET_OS_process_wait (proc); + GNUNET_OS_process_destroy (proc); + proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, "taler-auditor-httpd", "taler-auditor-httpd", "-c", CONFIG_FILE, @@ -153,8 +185,9 @@ main (int argc, NULL); if (NULL == proc) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-auditor-httpd`, is your PATH correct?\n"); + GNUNET_log ( + GNUNET_ERROR_TYPE_ERROR, + "Failed to run `taler-auditor-httpd`, is your PATH correct?\n"); return 77; } global_ret = TALER_TESTING_wait_httpd_ready ("http://localhost:8083/"); diff --git a/src/testing/test_bank_api.conf b/src/testing/test_bank_api.conf index c262ae197..42c8bfe2d 100644 --- a/src/testing/test_bank_api.conf +++ b/src/testing/test_bank_api.conf @@ -21,3 +21,5 @@ REGISTRATION_BONUS = EUR:100 SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/ SERVE = tcp PORT = 8082 +PWD_HASH_CONFIG = { "cost": 4 } +PWD_AUTH_COMPAT = yes diff --git a/src/testing/test_bank_api_fakebank.conf b/src/testing/test_bank_api_fakebank.conf index 62fa4cd4c..c387a0a09 100644 --- a/src/testing/test_bank_api_fakebank.conf +++ b/src/testing/test_bank_api_fakebank.conf @@ -11,11 +11,11 @@ PAYTO_URI = "payto://x-taler-bank/localhost:8082/2?receiver-name=2" WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [admin-accountcredentials-2] WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic # For now, fakebank still checks against the Exchange account... USERNAME = Exchange -PASSWORD = x +PASSWORD = password diff --git a/src/testing/test_bank_api_nexus.conf b/src/testing/test_bank_api_nexus.conf index 605c7b00e..b2ce98d08 100644 --- a/src/testing/test_bank_api_nexus.conf +++ b/src/testing/test_bank_api_nexus.conf @@ -8,14 +8,14 @@ PAYTO_URI = payto://iban/BIC/ES9121000418450200051332?receiver-name=Exchange WIRE_GATEWAY_URL = http://localhost:8082/accounts/exchange/taler-wire-gateway/ WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = exchange -PASSWORD = x +PASSWORD = password [admin-accountcredentials-2] WIRE_GATEWAY_URL = http://localhost:8082/accounts/exchange/taler-wire-gateway/ WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = admin # 'secret' is from taler-unified-setup.sh -PASSWORD = secret +PASSWORD = secret-password [libeufin-bankdb-postgres] CONFIG="postgresql:///talercheck" diff --git a/src/testing/test_bank_api_twisted.c b/src/testing/test_bank_api_twisted.c index 038ec8a1f..80b8b54de 100644 --- a/src/testing/test_bank_api_twisted.c +++ b/src/testing/test_bank_api_twisted.c @@ -94,12 +94,12 @@ run (void *cls, { case TALER_TESTING_BS_FAKEBANK: exchange_auth_twisted.wire_gateway_url - = "http://localhost:8888/accounts/2/taler-wire-gateway/"; + = (char *) "http://localhost:8888/accounts/2/taler-wire-gateway/"; systype = "-f"; break; case TALER_TESTING_BS_IBAN: exchange_auth_twisted.wire_gateway_url - = "http://localhost:8888/accounts/Exchange/taler-wire-gateway/"; + = (char *) "http://localhost:8888/accounts/Exchange/taler-wire-gateway/"; systype = "-b"; break; } diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 533995b37..964e7e8ef 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -179,22 +179,40 @@ run (void *cls, /** * Spend the coin. */ - TALER_TESTING_cmd_deposit ("deposit-simple", - "withdraw-coin-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-1", - "deposit-simple", - MHD_HTTP_OK), - TALER_TESTING_cmd_sleep ("sleep-before-deposit-replay", - 1), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-2", - "deposit-simple", - MHD_HTTP_OK), + TALER_TESTING_cmd_set_var ( + "account-priv", + TALER_TESTING_cmd_deposit ( + "deposit-simple-fail-kyc", + "withdraw-coin-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS)), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user42_payto, + "deposit-simple-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account-withdraw"), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple", + "deposit-simple-fail-kyc", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-1", + "deposit-simple", + MHD_HTTP_OK), + TALER_TESTING_cmd_sleep ( + "sleep-before-deposit-replay", + 1), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-2", + "deposit-simple", + MHD_HTTP_OK), /* This creates a conflict, as we have the same coin public key (reuse!), but different denomination public keys (which is not allowed). However, note that this does NOT work with 'CS', as for a different @@ -202,52 +220,64 @@ run (void *cls, thus will generate a different coin private key as R0/R1 are hashed into the coin priv. So here, we fail to 'reuse' the key due to the cryptographic construction! */ - TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure", - "withdraw-coin-1x", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - uses_cs - ? MHD_HTTP_OK - : MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_deposit ( + "deposit-reused-coin-key-failure", + "withdraw-coin-1x", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"conflicting ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + uses_cs + ? MHD_HTTP_OK + : MHD_HTTP_CONFLICT), /** * Try to double spend using different wire details. */ - TALER_TESTING_cmd_deposit ("deposit-double-1", - "withdraw-coin-1", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer-2", + "EUR:0.01", + &cred.ba, + cred.user43_payto, + "deposit-simple-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account-1"), + TALER_TESTING_cmd_deposit ( + "deposit-double-1", + "withdraw-coin-1", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_CONFLICT), /* Try to double spend using a different transaction id. * The test needs the contract terms to differ. This * is currently the case because of the "timestamp" field, * which is set automatically by #TALER_TESTING_cmd_deposit(). * This could theoretically fail if at some point a deposit - * command executes in less than 1 ms. */// - TALER_TESTING_cmd_deposit ("deposit-double-1", - "withdraw-coin-1", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_CONFLICT), + * command executes in less than 1 ms. */ + TALER_TESTING_cmd_deposit ( + "deposit-double-1", + "withdraw-coin-1", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_CONFLICT), /** * Try to double spend with different proposal. */ - TALER_TESTING_cmd_deposit ("deposit-double-2", - "withdraw-coin-1", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_deposit ( + "deposit-double-2", + "withdraw-coin-1", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_CONFLICT), TALER_TESTING_cmd_end () }; @@ -258,19 +288,22 @@ run (void *cls, * with MHD_HTTP_CONFLICT, but for a different reason: here it * is not a denomination conflict, but a double-spending conflict. */ - TALER_TESTING_cmd_melt ("refresh-melt-reused-coin-key-failure", - "withdraw-coin-1x", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-reused-coin-key-failure", + "withdraw-coin-1x", + MHD_HTTP_CONFLICT, + NULL), /* Fill reserve with EUR:5, 1ct is for fees. */ - CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-1", - "EUR:5.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1", - "EUR:5.01", - cred.user42_payto, - cred.exchange_payto, - "refresh-create-reserve-1"), + CMD_TRANSFER_TO_EXCHANGE ( + "refresh-create-reserve-1", + "EUR:5.01"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "ck-refresh-create-reserve-1", + "EUR:5.01", + cred.user42_payto, + cred.exchange_payto, + "refresh-create-reserve-1"), /** * Make previous command effective. */ @@ -278,83 +311,93 @@ run (void *cls, /** * Withdraw EUR:5. */ - TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-1", - "refresh-create-reserve-1", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "refresh-withdraw-coin-1", + "refresh-create-reserve-1", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), /* Try to partially spend (deposit) 1 EUR of the 5 EUR coin * (in full) (merchant would receive EUR:0.99 due to 1 ct * deposit fee) */ - TALER_TESTING_cmd_deposit ("refresh-deposit-partial", - "refresh-withdraw-coin-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-partial", + "refresh-withdraw-coin-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Melt the rest of the coin's value * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ - TALER_TESTING_cmd_melt_double ("refresh-melt-1", - "refresh-withdraw-coin-1", - MHD_HTTP_OK, - NULL), + TALER_TESTING_cmd_melt_double ( + "refresh-melt-1", + "refresh-withdraw-coin-1", + MHD_HTTP_OK, + NULL), /** * Complete (successful) melt operation, and * withdraw the coins */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1", - "refresh-melt-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_reveal ( + "refresh-reveal-1", + "refresh-melt-1", + MHD_HTTP_OK), /** * Do it again to check idempotency */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1-idempotency", - "refresh-melt-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_reveal ( + "refresh-reveal-1-idempotency", + "refresh-melt-1", + MHD_HTTP_OK), /** * Test that /refresh/link works */ - TALER_TESTING_cmd_refresh_link ("refresh-link-1", - "refresh-reveal-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_link ( + "refresh-link-1", + "refresh-reveal-1", + MHD_HTTP_OK), /** * Try to spend a refreshed EUR:1 coin */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a", - "refresh-reveal-1-idempotency", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-refreshed-1a", + "refresh-reveal-1-idempotency", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Try to spend a refreshed EUR:0.1 coin */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b", - "refresh-reveal-1", - 3, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-refreshed-1b", + "refresh-reveal-1", + 3, + cred.user43_payto, + "{\"items\":[{\"name\":\"cheap ice cream\",\"value\":3}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.1", + MHD_HTTP_OK), /* Test running a failing melt operation (same operation * again must fail) */ - TALER_TESTING_cmd_melt ("refresh-melt-failing", - "refresh-withdraw-coin-1", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-failing", + "refresh-withdraw-coin-1", + MHD_HTTP_CONFLICT, + NULL), /* Test running a failing melt operation (on a coin that was itself revealed and subsequently deposited) */ - TALER_TESTING_cmd_melt ("refresh-melt-failing-2", - "refresh-reveal-1", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-failing-2", + "refresh-reveal-1", + MHD_HTTP_CONFLICT, + NULL), TALER_TESTING_cmd_end () }; @@ -372,13 +415,15 @@ run (void *cls, /** * Move money to the exchange's bank account. */ - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-age", - "EUR:6.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age", - "EUR:6.01", - cred.user42_payto, - cred.exchange_payto, - "create-reserve-age"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-reserve-age", + "EUR:6.01"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-create-reserve-age", + "EUR:6.01", + cred.user42_payto, + cred.exchange_payto, + "create-reserve-age"), /** * Make a reserve exist, according to the previous * transfer. @@ -387,11 +432,12 @@ run (void *cls, /** * Withdraw EUR:5. */ - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-age-1", - "create-reserve-age", - "EUR:5", - 13, - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-age-1", + "create-reserve-age", + "EUR:5", + 13, + MHD_HTTP_OK), TALER_TESTING_cmd_end () }; @@ -400,25 +446,30 @@ run (void *cls, /** * Spend the coin. */ - TALER_TESTING_cmd_deposit ("deposit-simple-age", - "withdraw-coin-age-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:4.99", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age", - "deposit-simple-age", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age-1", - "deposit-simple-age", - MHD_HTTP_OK), - TALER_TESTING_cmd_sleep ("sleep-before-age-deposit-replay", - 1), - TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age-2", - "deposit-simple-age", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-simple-age", + "withdraw-coin-age-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"unique ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:4.99", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-age", + "deposit-simple-age", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-age-1", + "deposit-simple-age", + MHD_HTTP_OK), + TALER_TESTING_cmd_sleep ( + "sleep-before-age-deposit-replay", + 1), + TALER_TESTING_cmd_deposit_replay ( + "deposit-simple-replay-age-2", + "deposit-simple-age", + MHD_HTTP_OK), TALER_TESTING_cmd_end () }; @@ -427,102 +478,68 @@ run (void *cls, * execution of transactions, the answer should be that * the exchange knows about the deposit, but has no WTID yet. */ - TALER_TESTING_cmd_deposits_get ("deposit-wtid-found", - "deposit-simple", - 0, - MHD_HTTP_ACCEPTED, - NULL), + TALER_TESTING_cmd_deposits_get ( + "deposit-wtid-found", + "deposit-simple", + 0, + MHD_HTTP_ACCEPTED, + NULL), /* Try resolving a deposit's WTID for a failed deposit. * As the deposit failed, the answer should be that the * exchange does NOT know about the deposit. */ - TALER_TESTING_cmd_deposits_get ("deposit-wtid-failing", - "deposit-double-2", - 0, - MHD_HTTP_NOT_FOUND, - NULL), + TALER_TESTING_cmd_deposits_get ( + "deposit-wtid-failing", + "deposit-double-2", + 0, + MHD_HTTP_NOT_FOUND, + NULL), /* Try resolving an undefined (all zeros) WTID; this * should fail as obviously the exchange didn't use that * WTID value for any transaction. */ - TALER_TESTING_cmd_track_transfer_empty ("wire-deposit-failing", - NULL, - MHD_HTTP_NOT_FOUND), - /* Run transfers. Note that _actual_ aggregation will NOT - * happen here, as each deposit operation is run with a - * fresh merchant public key, so the aggregator will treat - * them as "different" merchants and do the wire transfers - * individually. */ + TALER_TESTING_cmd_track_transfer_empty ( + "wire-deposit-failing", + NULL, + MHD_HTTP_NOT_FOUND), + /* Run transfers. */ CMD_EXEC_AGGREGATOR ("run-aggregator"), /** * Check all the transfers took place. */ - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c", - cred.exchange_url, - "EUR:4.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c2", - cred.exchange_url, - "EUR:4.97", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c3", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c4", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c", - cred.exchange_url, - "EUR:0.08", - cred.exchange_payto, - cred.user43_payto), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c2", - cred.exchange_url, - "EUR:0.08", - cred.exchange_payto, - cred.user43_payto), - /* In case of CS, one transaction above succeeded that - failed for RSA, hence we need to check for an extra transfer here */ - uses_cs - ? TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-98c", - cred.exchange_url, - "EUR:0.98", - cred.exchange_payto, - cred.user42_payto) - : TALER_TESTING_cmd_sleep ("dummy", - 0), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-42-aggregate", + cred.exchange_url, + /* In case of CS, one transaction above succeeded that + failed for RSA, hence we get a larger amount here */ + uses_cs ? "EUR:14.91" : "EUR:13.92", + cred.exchange_payto, + cred.user42_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-43-aggregate", + cred.exchange_url, + "EUR:0.17", + cred.exchange_payto, + cred.user43_payto), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), - TALER_TESTING_cmd_deposits_get ("deposit-wtid-ok", - "deposit-simple", - 0, - MHD_HTTP_OK, - "check_bank_transfer-499c"), - TALER_TESTING_cmd_track_transfer ("wire-deposit-success-bank", - "check_bank_transfer-99c1", - MHD_HTTP_OK, - "EUR:0.98", - "EUR:0.01"), - TALER_TESTING_cmd_track_transfer ("wire-deposits-success-wtid", - "deposit-wtid-ok", - MHD_HTTP_OK, - "EUR:4.98", - "EUR:0.01"), + TALER_TESTING_cmd_deposits_get ( + "deposit-wtid-ok", + "deposit-simple", + 0, + MHD_HTTP_OK, + "check_bank_transfer-42-aggregate"), + TALER_TESTING_cmd_track_transfer ( + "wire-deposit-success-bank", + "check_bank_transfer-42-aggregate", + MHD_HTTP_OK, + uses_cs ? "EUR:14.91" : "EUR:13.92", + "EUR:0.01"), + TALER_TESTING_cmd_track_transfer ( + "wire-deposits-success-wtid", + "check_bank_transfer-43-aggregate", + MHD_HTTP_OK, + "EUR:0.17", + "EUR:0.01"), TALER_TESTING_cmd_end () }; @@ -532,8 +549,9 @@ run (void *cls, */ struct TALER_TESTING_Command unaggregation[] = { TALER_TESTING_cmd_check_bank_empty ("far-future-aggregation-a"), - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-unaggregated", - "EUR:5.01"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-reserve-unaggregated", + "EUR:5.01"), /* "consume" reserve creation transfer. */ TALER_TESTING_cmd_check_bank_admin_transfer ( "check-create-reserve-unaggregated", @@ -542,21 +560,23 @@ run (void *cls, cred.exchange_payto, "create-reserve-unaggregated"), CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated", - "create-reserve-unaggregated", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("deposit-unaggregated", - "withdraw-coin-unaggregated", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_relative_multiply ( - GNUNET_TIME_UNIT_YEARS, - 3000), - "EUR:5", - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-unaggregated", + "create-reserve-unaggregated", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-unaggregated", + "withdraw-coin-unaggregated", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"different ice cream\",\"value\":1}]}", + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_YEARS, + 3000), + "EUR:5", + MHD_HTTP_OK), CMD_EXEC_AGGREGATOR ("aggregation-attempt"), TALER_TESTING_cmd_check_bank_empty ( @@ -567,8 +587,9 @@ run (void *cls, struct TALER_TESTING_Command refresh_age[] = { /* Fill reserve with EUR:5, 1ct is for fees. */ - CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-age-1", - "EUR:6.01"), + CMD_TRANSFER_TO_EXCHANGE ( + "refresh-create-reserve-age-1", + "EUR:6.01"), TALER_TESTING_cmd_check_bank_admin_transfer ( "ck-refresh-create-reserve-age-1", "EUR:6.01", @@ -582,83 +603,93 @@ run (void *cls, /** * Withdraw EUR:7 with age restriction for age 13. */ - TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-age-1", - "refresh-create-reserve-age-1", - "EUR:5", - 13, - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "refresh-withdraw-coin-age-1", + "refresh-create-reserve-age-1", + "EUR:5", + 13, + MHD_HTTP_OK), /* Try to partially spend (deposit) 1 EUR of the 5 EUR coin * (in full) (merchant would receive EUR:0.99 due to 1 ct * deposit fee) */ - TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age", - "refresh-withdraw-coin-age-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-partial-age", + "refresh-withdraw-coin-age-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"special ice cream\",\"value\":\"EUR:1\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Melt the rest of the coin's value * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ - TALER_TESTING_cmd_melt_double ("refresh-melt-age-1", - "refresh-withdraw-coin-age-1", - MHD_HTTP_OK, - NULL), + TALER_TESTING_cmd_melt_double ( + "refresh-melt-age-1", + "refresh-withdraw-coin-age-1", + MHD_HTTP_OK, + NULL), /** * Complete (successful) melt operation, and * withdraw the coins */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-age-1", - "refresh-melt-age-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_reveal ( + "refresh-reveal-age-1", + "refresh-melt-age-1", + MHD_HTTP_OK), /** * Do it again to check idempotency */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-age-1-idempotency", - "refresh-melt-age-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_reveal ( + "refresh-reveal-age-1-idempotency", + "refresh-melt-age-1", + MHD_HTTP_OK), /** * Test that /refresh/link works */ - TALER_TESTING_cmd_refresh_link ("refresh-link-age-1", - "refresh-reveal-age-1", - MHD_HTTP_OK), + TALER_TESTING_cmd_refresh_link ( + "refresh-link-age-1", + "refresh-reveal-age-1", + MHD_HTTP_OK), /** * Try to spend a refreshed EUR:1 coin */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a", - "refresh-reveal-age-1-idempotency", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-refreshed-age-1a", + "refresh-reveal-age-1-idempotency", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"garlic ice cream\",\"value\":3}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /** * Try to spend a refreshed EUR:0.1 coin */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b", - "refresh-reveal-age-1", - 3, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.1", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "refresh-deposit-refreshed-age-1b", + "refresh-reveal-age-1", + 3, + cred.user43_payto, + "{\"items\":[{\"name\":\"spicy ice cream\",\"value\":3}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.1", + MHD_HTTP_OK), /* Test running a failing melt operation (same operation * again must fail) */ - TALER_TESTING_cmd_melt ("refresh-melt-failing-age", - "refresh-withdraw-coin-age-1", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-failing-age", + "refresh-withdraw-coin-age-1", + MHD_HTTP_CONFLICT, + NULL), /* Test running a failing melt operation (on a coin that was itself revealed and subsequently deposited) */ - TALER_TESTING_cmd_melt ("refresh-melt-failing-age-2", - "refresh-reveal-age-1", - MHD_HTTP_CONFLICT, - NULL), + TALER_TESTING_cmd_melt ( + "refresh-melt-failing-age-2", + "refresh-reveal-age-1", + MHD_HTTP_CONFLICT, + NULL), TALER_TESTING_cmd_end () }; @@ -677,34 +708,38 @@ run (void *cls, cred.exchange_payto, "create-reserve-aggtest"), CMD_EXEC_WIREWATCH ("wirewatch-aggtest"), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aggtest", - "create-reserve-aggtest", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("deposit-aggtest-1", - "withdraw-coin-aggtest", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:2", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit_with_ref ("deposit-aggtest-2", - "withdraw-coin-aggtest", - 0, - cred.user43_payto, - "{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:2", - MHD_HTTP_OK, - "deposit-aggtest-1"), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-aggtest", + "create-reserve-aggtest", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-aggtest-1", + "withdraw-coin-aggtest", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"cinamon ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:2", + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit_with_ref ( + "deposit-aggtest-2", + "withdraw-coin-aggtest", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:2", + MHD_HTTP_OK, + "deposit-aggtest-1"), CMD_EXEC_AGGREGATOR ("aggregation-aggtest"), - TALER_TESTING_cmd_check_bank_transfer ("check-bank-transfer-aggtest", - cred.exchange_url, - "EUR:3.97", - cred.exchange_payto, - cred.user43_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check-bank-transfer-aggtest", + cred.exchange_url, + "EUR:3.97", + cred.exchange_payto, + cred.user43_payto), TALER_TESTING_cmd_check_bank_empty ("check-bank-empty-aggtest"), TALER_TESTING_cmd_end () }; @@ -714,35 +749,39 @@ run (void *cls, * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per * config. */ - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-r1", - "EUR:5.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1", - "EUR:5.01", - cred.user42_payto, - cred.exchange_payto, - "create-reserve-r1"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-reserve-r1", + "EUR:5.01"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-create-reserve-r1", + "EUR:5.01", + cred.user42_payto, + cred.exchange_payto, + "create-reserve-r1"), /** * Run wire-watch to trigger the reserve creation. */ CMD_EXEC_WIREWATCH ("wirewatch-3"), /* Withdraw a 5 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1", - "create-reserve-r1", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-r1", + "create-reserve-r1", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), /** * Spend 5 EUR of the 5 EUR coin (in full) (merchant would * receive EUR:4.99 due to 1 ct deposit fee) */ - TALER_TESTING_cmd_deposit ("deposit-refund-1", - "withdraw-coin-r1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_MINUTES, - "EUR:5", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-refund-1", + "withdraw-coin-r1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"blue ice cream\",\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_MINUTES, + "EUR:5", + MHD_HTTP_OK), /** * Run transfers. Should do nothing as refund deadline blocks it */ @@ -753,47 +792,53 @@ run (void *cls, * fakebank and the second to actually check there are not * other transfers around. */ TALER_TESTING_cmd_check_bank_empty ("check_bank_transfer-pre-refund"), - TALER_TESTING_cmd_refund_with_id ("refund-ok", - MHD_HTTP_OK, - "EUR:3", - "deposit-refund-1", - 3), - TALER_TESTING_cmd_refund_with_id ("refund-ok-double", - MHD_HTTP_OK, - "EUR:3", - "deposit-refund-1", - 3), + TALER_TESTING_cmd_refund_with_id ( + "refund-ok", + MHD_HTTP_OK, + "EUR:3", + "deposit-refund-1", + 3), + TALER_TESTING_cmd_refund_with_id ( + "refund-ok-double", + MHD_HTTP_OK, + "EUR:3", + "deposit-refund-1", + 3), /* Previous /refund(s) had id == 0. */ - TALER_TESTING_cmd_refund_with_id ("refund-conflicting", - MHD_HTTP_CONFLICT, - "EUR:5", - "deposit-refund-1", - 1), - TALER_TESTING_cmd_deposit ("deposit-refund-insufficient-refund", - "withdraw-coin-r1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:4\"}]}", - GNUNET_TIME_UNIT_MINUTES, - "EUR:4", - MHD_HTTP_CONFLICT), - TALER_TESTING_cmd_refund_with_id ("refund-ok-increase", - MHD_HTTP_OK, - "EUR:2", - "deposit-refund-1", - 2), + TALER_TESTING_cmd_refund_with_id ( + "refund-conflicting", + MHD_HTTP_CONFLICT, + "EUR:5", + "deposit-refund-1", + 1), + TALER_TESTING_cmd_deposit ( + "deposit-refund-insufficient-refund", + "withdraw-coin-r1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"fruit ice cream\",\"value\":\"EUR:4\"}]}", + GNUNET_TIME_UNIT_MINUTES, + "EUR:4", + MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_refund_with_id ( + "refund-ok-increase", + MHD_HTTP_OK, + "EUR:2", + "deposit-refund-1", + 2), /** * Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone * due to refund) (merchant would receive EUR:4.98 due to * 1 ct deposit fee) */ - TALER_TESTING_cmd_deposit ("deposit-refund-2", - "withdraw-coin-r1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:4.99", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-refund-2", + "withdraw-coin-r1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:4.99", + MHD_HTTP_OK), /** * Run transfers. This will do the transfer as refund deadline * was 0 @@ -802,52 +847,59 @@ run (void *cls, /** * Check that deposit did run. */ - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund", - cred.exchange_url, - "EUR:4.97", - cred.exchange_payto, - cred.user42_payto), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-pre-refund", + cred.exchange_url, + "EUR:4.97", + cred.exchange_payto, + cred.user42_payto), /** * Run failing refund, as past deadline & aggregation. */ - TALER_TESTING_cmd_refund ("refund-fail", - MHD_HTTP_GONE, - "EUR:4.99", - "deposit-refund-2"), + TALER_TESTING_cmd_refund ( + "refund-fail", + MHD_HTTP_GONE, + "EUR:4.99", + "deposit-refund-2"), TALER_TESTING_cmd_check_bank_empty ("check-empty-after-refund"), /** * Test refunded coins are never executed, even past * refund deadline */ - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-rb", - "EUR:5.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb", - "EUR:5.01", - cred.user42_payto, - cred.exchange_payto, - "create-reserve-rb"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-reserve-rb", + "EUR:5.01"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-create-reserve-rb", + "EUR:5.01", + cred.user42_payto, + cred.exchange_payto, + "create-reserve-rb"), CMD_EXEC_WIREWATCH ("wirewatch-rb"), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb", - "create-reserve-rb", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("deposit-refund-1b", - "withdraw-coin-rb", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-rb", + "create-reserve-rb", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-refund-1b", + "withdraw-coin-rb", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"purple ice cream\",\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_OK), /** * Trigger refund (before aggregator had a chance to execute * deposit, even though refund deadline was zero). */ - TALER_TESTING_cmd_refund ("refund-ok-fast", - MHD_HTTP_OK, - "EUR:5", - "deposit-refund-1b"), + TALER_TESTING_cmd_refund ( + "refund-ok-fast", + MHD_HTTP_OK, + "EUR:5", + "deposit-refund-1b"), /** * Run transfers. This will do the transfer as refund deadline * was 0, except of course because the refund succeeded, the @@ -864,8 +916,9 @@ run (void *cls, * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per * config. */ - CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-1", - "EUR:15.02"), + CMD_TRANSFER_TO_EXCHANGE ( + "recoup-create-reserve-1", + "EUR:15.02"), TALER_TESTING_cmd_check_bank_admin_transfer ( "recoup-create-reserve-1-check", "EUR:15.02", @@ -877,156 +930,185 @@ run (void *cls, */ CMD_EXEC_WIREWATCH ("wirewatch-4"), /* Withdraw a 5 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-1", - "recoup-create-reserve-1", - "EUR:5", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-1", + "recoup-create-reserve-1", + "EUR:5", + 0, /* age restriction off */ + MHD_HTTP_OK), /* Withdraw a 10 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-1b", - "recoup-create-reserve-1", - "EUR:10", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-1b", + "recoup-create-reserve-1", + "EUR:10", + 0, /* age restriction off */ + MHD_HTTP_OK), /* melt 10 EUR coin to get 5 EUR refreshed coin */ - TALER_TESTING_cmd_melt ("recoup-melt-coin-1b", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:5", - NULL), - TALER_TESTING_cmd_refresh_reveal ("recoup-reveal-coin-1b", - "recoup-melt-coin-1b", - MHD_HTTP_OK), + TALER_TESTING_cmd_melt ( + "recoup-melt-coin-1b", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:5", + NULL), + TALER_TESTING_cmd_refresh_reveal ( + "recoup-reveal-coin-1b", + "recoup-melt-coin-1b", + MHD_HTTP_OK), /* Revoke both 5 EUR coins */ - TALER_TESTING_cmd_revoke ("revoke-0-EUR:5", - MHD_HTTP_OK, - "recoup-withdraw-coin-1", - config_file), + TALER_TESTING_cmd_revoke ( + "revoke-0-EUR:5", + MHD_HTTP_OK, + "recoup-withdraw-coin-1", + config_file), /* Recoup coin to reserve */ - TALER_TESTING_cmd_recoup ("recoup-1", - MHD_HTTP_OK, - "recoup-withdraw-coin-1", - "EUR:5"), + TALER_TESTING_cmd_recoup ( + "recoup-1", + MHD_HTTP_OK, + "recoup-withdraw-coin-1", + "EUR:5"), /* Check the money is back with the reserve */ - TALER_TESTING_cmd_status ("recoup-reserve-status-1", - "recoup-create-reserve-1", - "EUR:5.0", - MHD_HTTP_OK), + TALER_TESTING_cmd_status ( + "recoup-reserve-status-1", + "recoup-create-reserve-1", + "EUR:5.0", + MHD_HTTP_OK), /* Recoup-refresh coin to 10 EUR coin */ - TALER_TESTING_cmd_recoup_refresh ("recoup-1b", - MHD_HTTP_OK, - "recoup-reveal-coin-1b", - "recoup-melt-coin-1b", - "EUR:5"), + TALER_TESTING_cmd_recoup_refresh ( + "recoup-1b", + MHD_HTTP_OK, + "recoup-reveal-coin-1b", + "recoup-melt-coin-1b", + "EUR:5"), /* melt 10 EUR coin *again* to get 1 EUR refreshed coin */ - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1a", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_refresh_reveal ("recoup-reveal-coin-1a", - "recoup-remelt-coin-1a", - MHD_HTTP_OK), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1a", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_refresh_reveal ( + "recoup-reveal-coin-1a", + "recoup-remelt-coin-1a", + MHD_HTTP_OK), /* Try melting for more than the residual value to provoke an error */ - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1b", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1c", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1d", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1e", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1f", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1g", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1h", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1i", - "recoup-withdraw-coin-1b", - MHD_HTTP_OK, - "EUR:1", - NULL), - TALER_TESTING_cmd_melt ("recoup-remelt-coin-1b-failing", - "recoup-withdraw-coin-1b", - MHD_HTTP_CONFLICT, - "EUR:1", - NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1b", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1c", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1d", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1e", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1f", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1g", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1h", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1i", + "recoup-withdraw-coin-1b", + MHD_HTTP_OK, + "EUR:1", + NULL), + TALER_TESTING_cmd_melt ( + "recoup-remelt-coin-1b-failing", + "recoup-withdraw-coin-1b", + MHD_HTTP_CONFLICT, + "EUR:1", + NULL), /* Re-withdraw from this reserve */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2", - "recoup-create-reserve-1", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-2", + "recoup-create-reserve-1", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_OK), /** * This withdrawal will test the logic to create a "recoup" * element to insert into the reserve's history. */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2-over", - "recoup-create-reserve-1", - "EUR:10", - 0, /* age restriction off */ - MHD_HTTP_CONFLICT), - TALER_TESTING_cmd_status ("recoup-reserve-status-2", - "recoup-create-reserve-1", - "EUR:3.99", - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-2-over", + "recoup-create-reserve-1", + "EUR:10", + 0, /* age restriction off */ + MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_status ( + "recoup-reserve-status-2", + "recoup-create-reserve-1", + "EUR:3.99", + MHD_HTTP_OK), /* These commands should close the reserve because * the aggregator is given a config file that overrides * the reserve expiration time (making it now-ish) */ CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve", "EUR:5.01"), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve", - "EUR:5.01", - cred.user42_payto, - cred.exchange_payto, - "short-lived-reserve"), - TALER_TESTING_cmd_exec_wirewatch2 ("short-lived-aggregation", - config_file_expire_reserve_now, - "exchange-account-2"), - TALER_TESTING_cmd_exec_closer ("close-reserves", - config_file_expire_reserve_now, - "EUR:5", - "EUR:0.01", - "short-lived-reserve"), - TALER_TESTING_cmd_exec_transfer ("close-reserves-transfer", - config_file_expire_reserve_now), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-short-lived-reserve", + "EUR:5.01", + cred.user42_payto, + cred.exchange_payto, + "short-lived-reserve"), + TALER_TESTING_cmd_exec_wirewatch2 ( + "short-lived-aggregation", + config_file_expire_reserve_now, + "exchange-account-2"), + TALER_TESTING_cmd_exec_closer ( + "close-reserves", + config_file_expire_reserve_now, + "EUR:5", + "EUR:0.01", + "short-lived-reserve"), + TALER_TESTING_cmd_exec_transfer ( + "close-reserves-transfer", + config_file_expire_reserve_now), - TALER_TESTING_cmd_status ("short-lived-status", - "short-lived-reserve", - "EUR:0", - MHD_HTTP_OK), - TALER_TESTING_cmd_withdraw_amount ("expired-withdraw", - "short-lived-reserve", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_CONFLICT), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse", - cred.exchange_url, - "EUR:5", - cred.exchange_payto, - cred.user42_payto), + TALER_TESTING_cmd_status ( + "short-lived-status", + "short-lived-reserve", + "EUR:0", + MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "expired-withdraw", + "short-lived-reserve", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_short-lived_reimburse", + cred.exchange_url, + "EUR:5", + cred.exchange_payto, + cred.user42_payto), /* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per * config, then withdraw two coin, partially spend one, and * then have the rest paid back. Check deposit of other coin @@ -1034,76 +1116,87 @@ run (void *cls, * revoked and we did not bother to create a new one... */ CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-2", "EUR:2.02"), - TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2", - "EUR:2.02", - cred.user42_payto, - cred.exchange_payto, - "recoup-create-reserve-2"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "ck-recoup-create-reserve-2", + "EUR:2.02", + cred.user42_payto, + cred.exchange_payto, + "recoup-create-reserve-2"), /* Make previous command effective. */ CMD_EXEC_WIREWATCH ("wirewatch-5"), /* Withdraw a 1 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2a", - "recoup-create-reserve-2", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-2a", + "recoup-create-reserve-2", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_OK), /* Withdraw a 1 EUR coin, at fee of 1 ct */ - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2b", - "recoup-create-reserve-2", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("recoup-deposit-partial", - "recoup-withdraw-coin-2a", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.5", - MHD_HTTP_OK), - TALER_TESTING_cmd_revoke ("revoke-1-EUR:1", - MHD_HTTP_OK, - "recoup-withdraw-coin-2a", - config_file), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-2b", + "recoup-create-reserve-2", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "recoup-deposit-partial", + "recoup-withdraw-coin-2a", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.5", + MHD_HTTP_OK), + TALER_TESTING_cmd_revoke ( + "revoke-1-EUR:1", + MHD_HTTP_OK, + "recoup-withdraw-coin-2a", + config_file), /* Check recoup is failing for the coin with the reused coin key (fails either because of denomination conflict (RSA) or double-spending (CS))*/ - TALER_TESTING_cmd_recoup ("recoup-2x", - MHD_HTTP_CONFLICT, - "withdraw-coin-1x", - "EUR:1"), - TALER_TESTING_cmd_recoup ("recoup-2", - MHD_HTTP_OK, - "recoup-withdraw-coin-2a", - "EUR:0.5"), + TALER_TESTING_cmd_recoup ( + "recoup-2x", + MHD_HTTP_CONFLICT, + "withdraw-coin-1x", + "EUR:1"), + TALER_TESTING_cmd_recoup ( + "recoup-2", + MHD_HTTP_OK, + "recoup-withdraw-coin-2a", + "EUR:0.5"), /* Idempotency of recoup (withdrawal variant) */ - TALER_TESTING_cmd_recoup ("recoup-2b", - MHD_HTTP_OK, - "recoup-withdraw-coin-2a", - "EUR:0.5"), - TALER_TESTING_cmd_deposit ("recoup-deposit-revoked", - "recoup-withdraw-coin-2b", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_GONE), + TALER_TESTING_cmd_recoup ( + "recoup-2b", + MHD_HTTP_OK, + "recoup-withdraw-coin-2a", + "EUR:0.5"), + TALER_TESTING_cmd_deposit ( + "recoup-deposit-revoked", + "recoup-withdraw-coin-2b", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"gnu ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_GONE), /* Test deposit fails after recoup, with proof in recoup */ /* Note that, the exchange will never return the coin's transaction * history with recoup data, as we get a 410 on the DK! */ - TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup", - "recoup-withdraw-coin-2a", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.5", - MHD_HTTP_GONE), + TALER_TESTING_cmd_deposit ( + "recoup-deposit-partial-after-recoup", + "recoup-withdraw-coin-2a", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:0.5", + MHD_HTTP_GONE), /* Test that revoked coins cannot be withdrawn */ - CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-3", - "EUR:1.01"), + CMD_TRANSFER_TO_EXCHANGE ( + "recoup-create-reserve-3", + "EUR:1.01"), TALER_TESTING_cmd_check_bank_admin_transfer ( "check-recoup-create-reserve-3", "EUR:1.01", @@ -1111,11 +1204,12 @@ run (void *cls, cred.exchange_payto, "recoup-create-reserve-3"), CMD_EXEC_WIREWATCH ("wirewatch-6"), - TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked", - "recoup-create-reserve-3", - "EUR:1", - 0, /* age restriction off */ - MHD_HTTP_GONE), + TALER_TESTING_cmd_withdraw_amount ( + "recoup-withdraw-coin-3-revoked", + "recoup-create-reserve-3", + "EUR:1", + 0, /* age restriction off */ + MHD_HTTP_GONE), /* check that we are empty before the rejection test */ TALER_TESTING_cmd_check_bank_empty ("check-empty-again"), @@ -1129,64 +1223,73 @@ run (void *cls, /** * Move money to the exchange's bank account. */ - CMD_TRANSFER_TO_EXCHANGE ("create-batch-reserve-1", - "EUR:6.03"), - TALER_TESTING_cmd_reserve_poll ("poll-batch-reserve-1", - "create-batch-reserve-1", - "EUR:6.03", - GNUNET_TIME_UNIT_MINUTES, - MHD_HTTP_OK), - TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1", - "EUR:6.03", - cred.user42_payto, - cred.exchange_payto, - "create-batch-reserve-1"), + CMD_TRANSFER_TO_EXCHANGE ( + "create-batch-reserve-1", + "EUR:6.03"), + TALER_TESTING_cmd_reserve_poll ( + "poll-batch-reserve-1", + "create-batch-reserve-1", + "EUR:6.03", + GNUNET_TIME_UNIT_MINUTES, + MHD_HTTP_OK), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check-create-batch-reserve-1", + "EUR:6.03", + cred.user42_payto, + cred.exchange_payto, + "create-batch-reserve-1"), /* * Make a reserve exist, according to the previous * transfer. */ CMD_EXEC_WIREWATCH ("wirewatch-batch-1"), - TALER_TESTING_cmd_reserve_poll_finish ("finish-poll-batch-reserve-1", - GNUNET_TIME_UNIT_SECONDS, - "poll-batch-reserve-1"), + TALER_TESTING_cmd_reserve_poll_finish ( + "finish-poll-batch-reserve-1", + GNUNET_TIME_UNIT_SECONDS, + "poll-batch-reserve-1"), /** * Withdraw EUR:5 AND EUR:1. */ - TALER_TESTING_cmd_batch_withdraw ("batch-withdraw-coin-1", - "create-batch-reserve-1", - 0, /* age restriction off */ - MHD_HTTP_OK, - "EUR:5", - "EUR:1", - NULL), + TALER_TESTING_cmd_batch_withdraw ( + "batch-withdraw-coin-1", + "create-batch-reserve-1", + 0, /* age restriction off */ + MHD_HTTP_OK, + "EUR:5", + "EUR:1", + NULL), /** * Check the reserve is (almost) depleted. */ - TALER_TESTING_cmd_status ("status-batch-1", - "create-batch-reserve-1", - "EUR:0.01", - MHD_HTTP_OK), - TALER_TESTING_cmd_reserve_history ("history-batch-1", - "create-batch-reserve-1", - "EUR:0.01", - MHD_HTTP_OK), + TALER_TESTING_cmd_status ( + "status-batch-1", + "create-batch-reserve-1", + "EUR:0.01", + MHD_HTTP_OK), + TALER_TESTING_cmd_reserve_history ( + "history-batch-1", + "create-batch-reserve-1", + "EUR:0.01", + MHD_HTTP_OK), /** * Spend the coins. */ - TALER_TESTING_cmd_batch_deposit ("batch-deposit-1", - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}", - GNUNET_TIME_UNIT_ZERO, - MHD_HTTP_OK, - "batch-withdraw-coin-1#0", - "EUR:5", - "batch-withdraw-coin-1#1", - "EUR:1", - NULL), - TALER_TESTING_cmd_coin_history ("coin-history-batch-1", - "batch-withdraw-coin-1#0", - "EUR:0.0", - MHD_HTTP_OK), + TALER_TESTING_cmd_batch_deposit ( + "batch-deposit-1", + cred.user42_payto, + "{\"items\":[{\"name\":\"final ice cream\",\"value\":5}]}", + GNUNET_TIME_UNIT_ZERO, + MHD_HTTP_OK, + "batch-withdraw-coin-1#0", + "EUR:5", + "batch-withdraw-coin-1#1", + "EUR:1", + NULL), + TALER_TESTING_cmd_coin_history ( + "coin-history-batch-1", + "batch-withdraw-coin-1#0", + "EUR:0.0", + MHD_HTTP_OK), TALER_TESTING_cmd_end () }; diff --git a/src/testing/test_exchange_api.conf b/src/testing/test_exchange_api.conf index daf24022c..a0d9f75f9 100644 --- a/src/testing/test_exchange_api.conf +++ b/src/testing/test_exchange_api.conf @@ -15,6 +15,8 @@ WIRE_TYPE = iban IBAN_PAYTO_BIC = SANDBOXX SERVE = tcp PORT = 8082 +PWD_HASH_CONFIG = { "cost": 4 } +PWD_AUTH_COMPAT = yes [libeufin-bankdb-postgres] CONFIG = postgresql:///talercheck @@ -85,14 +87,14 @@ ENABLE_CREDIT = YES [exchange-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" [admin-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic # For now, fakebank still checks against the Exchange account... USERNAME = Exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" @@ -122,6 +124,7 @@ PROVIDER_ID = test-oauth2 # Outputs from this check OUTPUTS = full_name birthdate + [kyc-check-test-form] VOLUNTARY = NO # We use an external provider @@ -167,6 +170,13 @@ REQUIRES = # where we are: frozen. FALLBACK = manual-freeze +[kyc-measure-info-frozen] +CHECK_NAME = info-frozen +# No context +CONTEXT = {} +# Command if INFO check will never be run. +PROGRAM = none + # If this "check" is triggered, we merely inform # the user that we got their oauth-test data on file. [kyc-check-info-oauth-test-passed] @@ -181,6 +191,19 @@ REQUIRES = # where we are: frozen. FALLBACK = manual-freeze + +[kyc-measure-info-oauth-test-passed] +CHECK_NAME = info-oauth-test-passed +# No context +CONTEXT = {} +# Command if INFO check will never be run. +PROGRAM = none + +[aml-program-none] +DESCRIPTION = "Dummy AML program used for INFO checks, always fails" +COMMAND = taler-exchange-helper-measure-none +FALLBACK = manual-freeze + [aml-program-oauth-output-check] DESCRIPTION = "Validates the output from OAauth2 and then increases all limits to EUR:1000" # Command that runs on the output of the OAuth provider @@ -189,6 +212,7 @@ COMMAND = taler-exchange-helper-measure-test-oauth # What measure to take if the COMMAND failed. FALLBACK = manual-freeze + [aml-program-test-form-check] DESCRIPTION = "Validates the output from the test-form and then increases all limits to EUR:1000" # Command that runs on the output of the form diff --git a/src/testing/test_exchange_api_age_restriction.c b/src/testing/test_exchange_api_age_restriction.c index 38e536d52..75c3a41f8 100644 --- a/src/testing/test_exchange_api_age_restriction.c +++ b/src/testing/test_exchange_api_age_restriction.c @@ -144,12 +144,37 @@ run (void *cls, /** * Spend the coin. */ + TALER_TESTING_cmd_set_var ( + "account-priv", + TALER_TESTING_cmd_deposit ( + "deposit-simple-age-fail-kyc", + "withdraw-coin-age-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:4.99", + MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS)), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user42_payto, + "deposit-simple-age-fail-kyc"), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user43_payto, + "deposit-simple-age-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account-withdraw"), TALER_TESTING_cmd_deposit ( "deposit-simple-age", "withdraw-coin-age-1", 0, cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", GNUNET_TIME_UNIT_ZERO, "EUR:4.99", MHD_HTTP_OK), @@ -194,7 +219,7 @@ run (void *cls, "refresh-withdraw-coin-age-1", 0, cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", + "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:3\"}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), @@ -236,7 +261,7 @@ run (void *cls, "refresh-reveal-age-1-idempotency", 0, cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", + "{\"items\":[{\"name\":\"ice cream\",\"value\":4}]}", GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK), @@ -248,7 +273,7 @@ run (void *cls, "refresh-reveal-age-1", 3, cred.user43_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", + "{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}", GNUNET_TIME_UNIT_ZERO, "EUR:0.1", MHD_HTTP_OK), diff --git a/src/testing/test_exchange_api_age_restriction.conf b/src/testing/test_exchange_api_age_restriction.conf index 646cafbb2..b47be9fcc 100644 --- a/src/testing/test_exchange_api_age_restriction.conf +++ b/src/testing/test_exchange_api_age_restriction.conf @@ -66,13 +66,13 @@ ENABLE_CREDIT = YES [exchange-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" [admin-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" [exchange-extension-age_restriction] diff --git a/src/testing/test_exchange_api_conflicts.conf b/src/testing/test_exchange_api_conflicts.conf index d04379f05..d8eb6798e 100644 --- a/src/testing/test_exchange_api_conflicts.conf +++ b/src/testing/test_exchange_api_conflicts.conf @@ -66,13 +66,13 @@ ENABLE_CREDIT = YES [exchange-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" [admin-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" diff --git a/src/testing/test_exchange_api_keys_cherry_picking.conf b/src/testing/test_exchange_api_keys_cherry_picking.conf index 142242424..105b468d0 100644 --- a/src/testing/test_exchange_api_keys_cherry_picking.conf +++ b/src/testing/test_exchange_api_keys_cherry_picking.conf @@ -46,13 +46,13 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = "http://localhost:9082/accounts/2/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [admin-accountcredentials-2] WIRE_GATEWAY_URL = "http://localhost:9082/accounts/2/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [bank] HTTP_PORT=8082 diff --git a/src/testing/test_exchange_api_revocation.c b/src/testing/test_exchange_api_revocation.c index 92e36a30a..2b707c968 100644 --- a/src/testing/test_exchange_api_revocation.c +++ b/src/testing/test_exchange_api_revocation.c @@ -48,6 +48,21 @@ static struct TALER_TESTING_Credentials cred; /** + * Execute the taler-exchange-wirewatch command with + * our configuration file. + * + * @param label label to use for the command. + */ +static struct TALER_TESTING_Command +CMD_EXEC_WIREWATCH (const char *label) +{ + return TALER_TESTING_cmd_exec_wirewatch2 (label, + config_file, + "exchange-account-2"); +} + + +/** * Main function that will tell the interpreter what commands to * run. * @@ -86,9 +101,7 @@ run (void *cls, /** * Run wire-watch to trigger the reserve creation. */ - TALER_TESTING_cmd_exec_wirewatch2 ("wirewatch-4", - config_file, - "exchange-account-2"), + CMD_EXEC_WIREWATCH ("wirewatch-4"), /* Withdraw a 5 EUR coin, at fee of 1 ct */ TALER_TESTING_cmd_withdraw_amount ("withdraw-revocation-coin-1", "create-reserve-1", @@ -103,23 +116,44 @@ run (void *cls, MHD_HTTP_OK), /* Try to partially spend (deposit) 1 EUR of the 5 EUR coin (in full) * (merchant would receive EUR:0.99 due to 1 ct deposit fee) */// - TALER_TESTING_cmd_deposit ("deposit-partial", - "withdraw-revocation-coin-1", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), + TALER_TESTING_cmd_set_var ( + "account-priv", + TALER_TESTING_cmd_deposit ( + "deposit-partial-fail-kyc", + "withdraw-revocation-coin-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS)), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user42_payto, + "deposit-partial-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account-withdraw"), + TALER_TESTING_cmd_deposit ( + "deposit-partial", + "withdraw-revocation-coin-1", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:2\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_OK), /* Deposit another coin in full */ - TALER_TESTING_cmd_deposit ("deposit-full", - "withdraw-revocation-coin-2", - 0, - cred.user42_payto, - "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_OK), + TALER_TESTING_cmd_deposit ( + "deposit-full", + "withdraw-revocation-coin-2", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_OK), /** * Melt SOME of the rest of the coin's value * (EUR:3.17 = 3x EUR:1.03 + 7x EUR:0.13) diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 75ffe1f15..a31e7a4c3 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -124,6 +124,25 @@ run (void *cls, "EUR:5", 0, /* age restriction off */ MHD_HTTP_OK), + TALER_TESTING_cmd_set_var ( + "account-priv", + TALER_TESTING_cmd_deposit ( + "refresh-deposit-partial-fail-kyc", + "refresh-withdraw-coin", + 0, + cred.user42_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:1", + MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS)), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user42_payto, + "refresh-deposit-partial-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account-withdraw"), TALER_TESTING_cmd_deposit ( "refresh-deposit-partial", "refresh-withdraw-coin", diff --git a/src/testing/test_exchange_management_api.c b/src/testing/test_exchange_management_api.c index 7cce61b55..98a375ca0 100644 --- a/src/testing/test_exchange_management_api.c +++ b/src/testing/test_exchange_management_api.c @@ -117,31 +117,31 @@ run (void *cls, MHD_HTTP_NO_CONTENT, false), TALER_TESTING_cmd_wire_add ("add-wire-account", - "payto://x-taler-bank/localhost/42?receiver-name=42", + cred.user42_payto, MHD_HTTP_NO_CONTENT, false), TALER_TESTING_cmd_wire_add ("add-wire-account-idempotent", - "payto://x-taler-bank/localhost/42?receiver-name=42", + cred.user42_payto, MHD_HTTP_NO_CONTENT, false), TALER_TESTING_cmd_wire_add ("add-wire-account-another", - "payto://x-taler-bank/localhost/43?receiver-name=43", + cred.user43_payto, MHD_HTTP_NO_CONTENT, false), TALER_TESTING_cmd_wire_add ("add-wire-account-bad-signature", - "payto://x-taler-bank/localhost/44?receiver-name=44", + cred.user44_payto, MHD_HTTP_FORBIDDEN, true), TALER_TESTING_cmd_wire_del ("del-wire-account-not-found", - "payto://x-taler-bank/localhost/44?receiver-name=44", + cred.user44_payto, MHD_HTTP_NOT_FOUND, false), TALER_TESTING_cmd_wire_del ("del-wire-account-bad-signature", - "payto://x-taler-bank/localhost/43?receiver-name=43", + cred.user43_payto, MHD_HTTP_FORBIDDEN, true), TALER_TESTING_cmd_wire_del ("del-wire-account-ok", - "payto://x-taler-bank/localhost/43?receiver-name=43", + cred.user43_payto, MHD_HTTP_NO_CONTENT, false), TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys", diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c index 2a21bb723..b2d06b3ef 100644 --- a/src/testing/test_exchange_p2p.c +++ b/src/testing/test_exchange_p2p.c @@ -325,14 +325,14 @@ run (void *cls, GNUNET_TIME_UNIT_SECONDS, 1), /* expiration */ "withdraw-coin-1", - "EUR:1.01", + "EUR:1.02", NULL), TALER_TESTING_cmd_purse_poll ( "push-poll-purse-before-expire", MHD_HTTP_GONE, "purse-with-deposit-expire", "EUR:1", - true, + true, /* wait for merge */ GNUNET_TIME_UNIT_MINUTES), /* This should fail, as too much of the coin is already spend / in a purse */ @@ -484,14 +484,14 @@ run (void *cls, TALER_TESTING_cmd_reserve_close ( "reserve-101-close-kyc", "create-reserve-101", - /* 42b => not to origin */ - "payto://x-taler-bank/localhost/42b?receiver-name=42b", + /* 44 => not to origin */ + cred.user44_payto, MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), TALER_TESTING_cmd_admin_add_kycauth ( "setup-account-key", "EUR:0.01", &cred.ba, - "payto://x-taler-bank/localhost/42b?receiver-name=42b", + cred.user44_payto, NULL /* create new key */), CMD_EXEC_WIREWATCH ( "import-kyc-account"), @@ -526,8 +526,8 @@ run (void *cls, TALER_TESTING_cmd_reserve_close ( "reserve-101-close", "create-reserve-101", - /* 42b => not to origin */ - "payto://x-taler-bank/localhost/42b?receiver-name=42b", + /* 44 => not to origin */ + cred.user44_payto, MHD_HTTP_OK), TALER_TESTING_cmd_exec_closer ( "close-reserves-101", diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c index 617f2ed2d..f79da7f0e 100644 --- a/src/testing/test_kyc_api.c +++ b/src/testing/test_kyc_api.c @@ -187,6 +187,31 @@ run (void *cls, TALER_TESTING_cmd_end () }; struct TALER_TESTING_Command spend[] = { + TALER_TESTING_cmd_set_var ( + "account-priv", + TALER_TESTING_cmd_deposit ( + "deposit-simple-fail-kyc", + "withdraw-coin-1", + 0, + cred.user43_payto, + "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", + GNUNET_TIME_UNIT_ZERO, + "EUR:5", + MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS)), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user42_payto, + "deposit-simple-fail-kyc"), + TALER_TESTING_cmd_admin_add_kycauth ( + "kyc-auth-transfer", + "EUR:0.01", + &cred.ba, + cred.user43_payto, + "deposit-simple-fail-kyc"), + CMD_EXEC_WIREWATCH ( + "import-kyc-account"), TALER_TESTING_cmd_deposit ( "deposit-simple", "withdraw-coin-1", diff --git a/src/testing/test_taler_exchange_aggregator.c b/src/testing/test_taler_exchange_aggregator.c index 2d7acc6dc..b9b1fe2ec 100644 --- a/src/testing/test_taler_exchange_aggregator.c +++ b/src/testing/test_taler_exchange_aggregator.c @@ -41,6 +41,8 @@ struct TALER_TESTING_Credentials cred; static char *config_filename; #define USER42_ACCOUNT "42" +#define USER43_ACCOUNT "43" +#define USER44_ACCOUNT "44" /** @@ -51,8 +53,8 @@ static char *config_filename; * @param cfg_fn configuration file to use */ #define CMD_EXEC_AGGREGATOR(label, cfg_fn) \ - TALER_TESTING_cmd_exec_aggregator (label "-aggregator", cfg_fn), \ - TALER_TESTING_cmd_exec_transfer (label "-transfer", cfg_fn) + TALER_TESTING_cmd_exec_aggregator (label "-aggregator", cfg_fn), \ + TALER_TESTING_cmd_exec_transfer (label "-transfer", cfg_fn) /** @@ -127,7 +129,7 @@ run (void *cls, TALER_TESTING_cmd_insert_deposit ("do-deposit-3a", cred.cfg, "bob", - "4", + USER43_ACCOUNT, GNUNET_TIME_timestamp_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -135,7 +137,7 @@ run (void *cls, TALER_TESTING_cmd_insert_deposit ("do-deposit-3b", cred.cfg, "bob", - "5", + USER44_ACCOUNT, GNUNET_TIME_timestamp_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -143,7 +145,7 @@ run (void *cls, TALER_TESTING_cmd_insert_deposit ("do-deposit-3c", cred.cfg, "alice", - "4", + USER43_ACCOUNT, GNUNET_TIME_timestamp_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", @@ -155,17 +157,17 @@ run (void *cls, cred.exchange_url, "EUR:0.89", cred.exchange_payto, - "payto://x-taler-bank/localhost/4?receiver-name=4"), + cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b", cred.exchange_url, "EUR:0.89", cred.exchange_payto, - "payto://x-taler-bank/localhost/4?receiver-name=4"), + cred.user43_payto), TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c", cred.exchange_url, "EUR:0.89", cred.exchange_payto, - "payto://x-taler-bank/localhost/5?receiver-name=5"), + cred.user44_payto), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"), /* checking that aggregator waits for the deadline. */ diff --git a/src/testing/testing_api_cmd_age_withdraw.c b/src/testing/testing_api_cmd_age_withdraw.c index 3192fc9b1..1a424fb4a 100644 --- a/src/testing/testing_api_cmd_age_withdraw.c +++ b/src/testing/testing_api_cmd_age_withdraw.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2023 Taler Systems SA + Copyright (C) 2023, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -80,7 +80,7 @@ struct AgeWithdrawState /** * URI of the reserve we are withdrawing from. */ - char *reserve_payto_uri; + struct TALER_NormalizedPayto reserve_payto_uri; /** * Private key of the reserve we are withdrawing from. @@ -151,7 +151,7 @@ struct AgeWithdrawState * Set to the KYC requirement payto hash *if* the exchange replied with a * request for KYC. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -374,7 +374,7 @@ age_withdraw_cleanup ( } GNUNET_free (aws->coin_outputs); GNUNET_free (aws->exchange_url); - GNUNET_free (aws->reserve_payto_uri); + GNUNET_free (aws->reserve_payto_uri.normalized_payto); GNUNET_free (aws); } @@ -417,7 +417,7 @@ age_withdraw_traits ( */ TALER_TESTING_make_trait_h_blinded_coin (idx, &aws->blinded_coin_hs[idx]), - TALER_TESTING_make_trait_payto_uri (aws->reserve_payto_uri), + TALER_TESTING_make_trait_normalized_payto_uri (&aws->reserve_payto_uri), TALER_TESTING_make_trait_exchange_url (aws->exchange_url), TALER_TESTING_make_trait_coin_priv (idx, &details->coin_priv), diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c b/src/testing/testing_api_cmd_bank_admin_add_incoming.c index 39c82429c..005fd9c62 100644 --- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c +++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c @@ -67,7 +67,7 @@ struct AdminAddIncomingState /** * Money sender payto URL. */ - const char *payto_debit_account; + struct TALER_FullPayto payto_debit_account; /** * Username to use for authentication. @@ -242,6 +242,11 @@ confirmation_cb (void *cls, "Basic authentication (%s) failed.\n", fts->auth.details.basic.username); break; + case TALER_BANK_AUTH_BEARER: + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Bearer authentication (%s) failed.\n", + fts->auth.details.bearer.token); + break; } break; case MHD_HTTP_CONFLICT: @@ -351,7 +356,7 @@ admin_add_incoming_run ( fts->reserve_history.type = TALER_EXCHANGE_RTT_CREDIT; fts->reserve_history.amount = fts->amount; fts->reserve_history.details.in_details.sender_url - = (char *) fts->payto_debit_account; /* remember to NOT free this one... */ + = fts->payto_debit_account; /* remember to NOT free this one... */ fts->aih = TALER_BANK_admin_add_incoming ( TALER_TESTING_interpreter_get_context (is), @@ -417,7 +422,9 @@ admin_add_incoming_traits (void *cls, unsigned int index) { struct AdminAddIncomingState *fts = cls; - static const char *void_uri = "payto://void/the-exchange"; + static struct TALER_FullPayto void_uri = { + .full_payto = (char *) "payto://void/the-exchange?receiver=name=exchange" + }; if (MHD_HTTP_OK != fts->expected_http_status) @@ -426,10 +433,10 @@ admin_add_incoming_traits (void *cls, { struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_bank_row (&fts->serial_id), - TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account), - TALER_TESTING_make_trait_payto_uri (fts->payto_debit_account), + TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account), + TALER_TESTING_make_trait_full_payto_uri (&fts->payto_debit_account), /* Used as a marker, content does not matter */ - TALER_TESTING_make_trait_credit_payto_uri (void_uri), + TALER_TESTING_make_trait_credit_payto_uri (&void_uri), TALER_TESTING_make_trait_exchange_bank_account_url ( fts->exchange_credit_url), TALER_TESTING_make_trait_amount (&fts->amount), @@ -457,9 +464,9 @@ admin_add_incoming_traits (void *cls, { struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_bank_row (&fts->serial_id), - TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account), + TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account), /* Used as a marker, content does not matter */ - TALER_TESTING_make_trait_credit_payto_uri (void_uri), + TALER_TESTING_make_trait_credit_payto_uri (&void_uri), TALER_TESTING_make_trait_exchange_bank_account_url ( fts->exchange_credit_url), TALER_TESTING_make_trait_amount (&fts->amount), @@ -494,7 +501,7 @@ admin_add_incoming_traits (void *cls, static struct AdminAddIncomingState * make_fts (const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account) + const struct TALER_FullPayto payto_debit_account) { struct AdminAddIncomingState *fts; @@ -544,7 +551,7 @@ TALER_TESTING_cmd_admin_add_incoming ( const char *label, const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account) + const struct TALER_FullPayto payto_debit_account) { return make_command (label, make_fts (amount, @@ -558,7 +565,7 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref ( const char *label, const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account, + const struct TALER_FullPayto payto_debit_account, const char *ref, unsigned int http_status) { diff --git a/src/testing/testing_api_cmd_bank_admin_add_kycauth.c b/src/testing/testing_api_cmd_bank_admin_add_kycauth.c index d804d3813..edacb4d90 100644 --- a/src/testing/testing_api_cmd_bank_admin_add_kycauth.c +++ b/src/testing/testing_api_cmd_bank_admin_add_kycauth.c @@ -55,7 +55,7 @@ struct AdminAddKycauthState /** * Money sender payto URL. */ - const char *payto_debit_account; + struct TALER_FullPayto payto_debit_account; /** * Username to use for authentication. @@ -149,6 +149,11 @@ confirmation_cb (void *cls, "Basic authentication (%s) failed.\n", fts->auth.details.basic.username); break; + case TALER_BANK_AUTH_BEARER: + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Bearer authentication (%s) failed.\n", + fts->auth.details.bearer.token); + break; } break; case MHD_HTTP_CONFLICT: @@ -293,15 +298,17 @@ admin_add_kycauth_traits (void *cls, unsigned int index) { struct AdminAddKycauthState *fts = cls; - static const char *void_uri = "payto://void/the-exchange"; + static struct TALER_FullPayto void_uri = { + .full_payto = (char *) "payto://void/the-exchange?receiver=name=exchange" + }; struct TALER_TESTING_Trait traits[] = { /* must be first! */ TALER_TESTING_make_trait_account_priv (&fts->account_priv), TALER_TESTING_make_trait_bank_row (&fts->serial_id), - TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account), - TALER_TESTING_make_trait_payto_uri (fts->payto_debit_account), + TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account), + TALER_TESTING_make_trait_full_payto_uri (&fts->payto_debit_account), /* Used as a marker, content does not matter */ - TALER_TESTING_make_trait_credit_payto_uri (void_uri), + TALER_TESTING_make_trait_credit_payto_uri (&void_uri), TALER_TESTING_make_trait_exchange_bank_account_url ( fts->exchange_credit_url), TALER_TESTING_make_trait_amount (&fts->amount), @@ -335,7 +342,7 @@ admin_add_kycauth_traits (void *cls, static struct AdminAddKycauthState * make_fts (const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account, + const struct TALER_FullPayto payto_debit_account, const char *account_ref) { struct AdminAddKycauthState *fts; @@ -364,7 +371,7 @@ TALER_TESTING_cmd_admin_add_kycauth ( const char *label, const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account, + const struct TALER_FullPayto payto_debit_account, const char *account_ref) { struct TALER_TESTING_Command cmd = { diff --git a/src/testing/testing_api_cmd_bank_admin_check.c b/src/testing/testing_api_cmd_bank_admin_check.c index 6406fe2c2..096ab0f62 100644 --- a/src/testing/testing_api_cmd_bank_admin_check.c +++ b/src/testing/testing_api_cmd_bank_admin_check.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2020 Taler Systems SA + Copyright (C) 2018-2020, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -43,12 +43,12 @@ struct BankAdminCheckState /** * Expected debit bank account. */ - const char *debit_payto; + struct TALER_FullPayto debit_payto; /** * Expected credit bank account. */ - const char *credit_payto; + struct TALER_FullPayto credit_payto; /** * Command providing the reserve public key trait to use. @@ -78,8 +78,8 @@ check_bank_admin_transfer_run (void *cls, struct TALER_Amount amount; char *debit_account; char *credit_account; - const char *debit_payto; - const char *credit_payto; + struct TALER_FullPayto debit_payto; + struct TALER_FullPayto credit_payto; const struct TALER_ReservePublicKeyP *reserve_pub; const struct TALER_TESTING_Command *cmd_ref; struct TALER_FAKEBANK_Handle *fakebank; @@ -141,7 +141,7 @@ check_bank_admin_transfer_run (void *cls, credit_account = TALER_xtalerbank_account_from_payto (credit_payto); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "converted debit_payto (%s) to debit_account (%s)\n", - debit_payto, + debit_payto.full_payto, debit_account); if (GNUNET_OK != TALER_FAKEBANK_check_credit (fakebank, @@ -191,11 +191,11 @@ check_bank_admin_transfer_cleanup (void *cls, * @return the command */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_bank_admin_transfer - (const char *label, +TALER_TESTING_cmd_check_bank_admin_transfer ( + const char *label, const char *amount, - const char *debit_payto, - const char *credit_payto, + struct TALER_FullPayto debit_payto, + struct TALER_FullPayto credit_payto, const char *reserve_pub_ref) { struct BankAdminCheckState *bcs; diff --git a/src/testing/testing_api_cmd_bank_check.c b/src/testing/testing_api_cmd_bank_check.c index 77d120e09..7b61ea6e7 100644 --- a/src/testing/testing_api_cmd_bank_check.c +++ b/src/testing/testing_api_cmd_bank_check.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2022 Taler Systems SA + Copyright (C) 2018-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -49,12 +49,12 @@ struct BankCheckState /** * Expected debit bank account. */ - const char *debit_payto; + struct TALER_FullPayto debit_payto; /** * Expected credit bank account. */ - const char *credit_payto; + struct TALER_FullPayto credit_payto; /** * Binary form of the wire transfer subject. @@ -92,8 +92,8 @@ check_bank_transfer_run (void *cls, char *debit_account; char *credit_account; const char *exchange_base_url; - const char *debit_payto; - const char *credit_payto; + const struct TALER_FullPayto *debit_payto; + const struct TALER_FullPayto *credit_payto; struct TALER_FAKEBANK_Handle *fakebank; (void) cmd; @@ -121,8 +121,8 @@ check_bank_transfer_run (void *cls, if (NULL == bcs->deposit_reference) { TALER_LOG_INFO ("Deposit reference NOT given\n"); - debit_payto = bcs->debit_payto; - credit_payto = bcs->credit_payto; + debit_payto = &bcs->debit_payto; + credit_payto = &bcs->credit_payto; exchange_base_url = bcs->exchange_base_url; if (GNUNET_OK != @@ -167,15 +167,15 @@ check_bank_transfer_run (void *cls, TALER_TESTING_FAIL (is); amount = *amount_ptr; } - debit_account = TALER_xtalerbank_account_from_payto (debit_payto); - credit_account = TALER_xtalerbank_account_from_payto (credit_payto); + debit_account = TALER_xtalerbank_account_from_payto (*debit_payto); + credit_account = TALER_xtalerbank_account_from_payto (*credit_payto); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "converted debit_payto (%s) to debit_account (%s)\n", - debit_payto, + debit_payto->full_payto, debit_account); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "converted credit_payto (%s) to credit_account (%s)\n", - credit_payto, + credit_payto->full_payto, credit_account); if (GNUNET_OK != TALER_FAKEBANK_check_debit (fakebank, @@ -246,11 +246,12 @@ check_bank_transfer_traits (void *cls, struct TALER_TESTING_Command -TALER_TESTING_cmd_check_bank_transfer (const char *label, - const char *exchange_base_url, - const char *amount, - const char *debit_payto, - const char *credit_payto) +TALER_TESTING_cmd_check_bank_transfer ( + const char *label, + const char *exchange_base_url, + const char *amount, + const struct TALER_FullPayto debit_payto, + const struct TALER_FullPayto credit_payto) { struct BankCheckState *bcs; diff --git a/src/testing/testing_api_cmd_bank_history_credit.c b/src/testing/testing_api_cmd_bank_history_credit.c index e54f8fb07..6dbb2b993 100644 --- a/src/testing/testing_api_cmd_bank_history_credit.c +++ b/src/testing/testing_api_cmd_bank_history_credit.c @@ -149,7 +149,7 @@ print_expected (struct History *h, TALER_amount2s (&cd->amount), (unsigned long long) h[i].row_id, TALER_B2S (&cd->details.reserve.reserve_pub), - cd->debit_account_uri); + cd->debit_account_uri.full_payto); break; case TALER_BANK_CT_KYCAUTH: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -159,7 +159,7 @@ print_expected (struct History *h, TALER_amount2s (&cd->amount), (unsigned long long) h[i].row_id, TALER_B2S (&cd->details.kycauth.account_pub), - cd->debit_account_uri); + cd->debit_account_uri.full_payto); break; case TALER_BANK_CT_WAD: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -170,7 +170,7 @@ print_expected (struct History *h, (unsigned long long) h[i].row_id, TALER_B2S (&cd->details.wad.wad_id), cd->details.wad.origin_exchange_url, - cd->debit_account_uri); + cd->debit_account_uri.full_payto); break; } } @@ -231,8 +231,8 @@ command_cb (void *cls, struct IteratorContext *ic = cls; struct HistoryState *hs = ic->hs; const uint64_t *row_id; - const char *credit_account; - const char *debit_account; + const struct TALER_FullPayto *credit_account; + const struct TALER_FullPayto *debit_account; const struct TALER_Amount *amount; const struct TALER_ReservePublicKeyP *reserve_pub; const char *exchange_credit_url; @@ -294,8 +294,8 @@ command_cb (void *cls, return; } TALER_LOG_INFO ("Found history: %s->%s for account %s\n", - debit_account, - credit_account, + debit_account->full_payto, + credit_account->full_payto, hs->account_url); /* found matching record, make sure we have room */ if (ic->pos == ic->total) @@ -303,12 +303,12 @@ command_cb (void *cls, ic->total, ic->pos * 2); ic->h[ic->pos].url - = GNUNET_strdup (debit_account); + = GNUNET_strdup (debit_account->full_payto); ic->h[ic->pos].row_id = *row_id; ic->h[ic->pos].credit_details.type = TALER_BANK_CT_RESERVE; - ic->h[ic->pos].credit_details.debit_account_uri + ic->h[ic->pos].credit_details.debit_account_uri.full_payto = ic->h[ic->pos].url; ic->h[ic->pos].credit_details.amount = *amount; @@ -377,69 +377,6 @@ build_history (struct HistoryState *hs, /** - * Normalize IBAN-based payto URI in @a in. - * - * @param in input payto://-URI to normalize - * @return normalized IBAN for the test - */ -static char * -normalize (const char *in) -{ - char *npt; - const char *q = strchr (in, - '?'); - const char *mptr; - const char *bic; - const char *iban; - - if (NULL == q) - npt = GNUNET_strdup (in); - else - npt = GNUNET_strndup (in, - q - in); - if (0 != strncasecmp (npt, - "payto://", - strlen ("payto://"))) - { - GNUNET_break (0); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Invalid payto: %s\n", - npt); - GNUNET_free (npt); - return NULL; - } - mptr = npt + strlen ("payto://"); - bic = strchr (mptr, '/'); - if (NULL == bic) - { - GNUNET_break (0); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Invalid payto: %s\n", - npt); - GNUNET_free (npt); - return NULL; - } - bic++; - iban = strchr (bic, '/'); - if (NULL != iban) - { - /* need to remove bic */ - char *n; - - iban++; - GNUNET_asprintf (&n, - "payto://%.*s/%s", - (int) ((bic - mptr) - 1), - mptr, - iban); - GNUNET_free (npt); - npt = n; - } - return npt; -} - - -/** * Check that the "/history/incoming" response matches the * CMD whose offset in the list of CMDs is @a off. * @@ -456,9 +393,6 @@ check_result (struct History *h, unsigned int off, const struct TALER_BANK_CreditDetails *credit_details) { - char *u1; - char *u2; - if (off >= total) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -471,61 +405,50 @@ check_result (struct History *h, off); return GNUNET_SYSERR; } - u1 = normalize (h[off].credit_details.debit_account_uri); - if (NULL == u1) - return GNUNET_SYSERR; - u2 = normalize (credit_details->debit_account_uri); - if (NULL == u2) - { - GNUNET_free (u1); - return GNUNET_SYSERR; - } if ( (h[off].credit_details.type != credit_details->type) || (0 != TALER_amount_cmp (&h[off].credit_details.amount, &credit_details->amount)) || - (0 != strcasecmp (u1, - u2)) ) + (0 != TALER_full_payto_normalize_and_cmp ( + h[off].credit_details.debit_account_uri, + credit_details->debit_account_uri)) ) { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected debit_account_uri: %s with %s\n", - u1, + h[off].credit_details.debit_account_uri.full_payto, TALER_amount2s (&h[off].credit_details.amount)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "actual debit_account_uri: %s with %s\n", - u2, + credit_details->debit_account_uri.full_payto, TALER_amount2s (&credit_details->amount)); print_expected (h, total, off); - GNUNET_free (u1); - GNUNET_free (u2); return GNUNET_SYSERR; } switch (credit_details->type) { case TALER_BANK_CT_RESERVE: - if (0 != GNUNET_memcmp (&h[off].credit_details.details.reserve.reserve_pub, - &credit_details->details.reserve.reserve_pub)) + if (0 != + GNUNET_memcmp (&h[off].credit_details.details.reserve.reserve_pub, + &credit_details->details.reserve.reserve_pub)) { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected debit_account_uri: %s with %s for %s\n", - u1, + h[off].credit_details.debit_account_uri.full_payto, TALER_amount2s (&h[off].credit_details.amount), TALER_B2S (&h[off].credit_details.details.reserve.reserve_pub) ); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "actual debit_account_uri: %s with %s for %s\n", - u2, + credit_details->debit_account_uri.full_payto, TALER_amount2s (&credit_details->amount), TALER_B2S (&credit_details->details.reserve.reserve_pub)); print_expected (h, total, off); - GNUNET_free (u1); - GNUNET_free (u2); return GNUNET_SYSERR; } break; @@ -536,20 +459,18 @@ check_result (struct History *h, GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected debit_account_uri: %s with %s for %s\n", - u1, + h[off].credit_details.debit_account_uri.full_payto, TALER_amount2s (&h[off].credit_details.amount), TALER_B2S (&h[off].credit_details.details.kycauth.account_pub) ); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "actual debit_account_uri: %s with %s for %s\n", - u2, + credit_details->debit_account_uri.full_payto, TALER_amount2s (&credit_details->amount), TALER_B2S (&credit_details->details.kycauth.account_pub)); print_expected (h, total, off); - GNUNET_free (u1); - GNUNET_free (u2); return GNUNET_SYSERR; } break; @@ -562,28 +483,23 @@ check_result (struct History *h, GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected debit_account_uri: %s with %s for %s-%s\n", - u1, + h[off].credit_details.debit_account_uri.full_payto, TALER_amount2s (&h[off].credit_details.amount), h[off].credit_details.details.wad.origin_exchange_url, TALER_B2S (&h[off].credit_details.details.wad.wad_id)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "actual debit_account_uri: %s with %s for %s-%s\n", - u2, + credit_details->debit_account_uri.full_payto, TALER_amount2s (&credit_details->amount), credit_details->details.wad.origin_exchange_url, TALER_B2S (&credit_details->details.wad.wad_id)); print_expected (h, total, off); - GNUNET_free (u1); - GNUNET_free (u2); return GNUNET_SYSERR; } break; } - - GNUNET_free (u1); - GNUNET_free (u2); return GNUNET_OK; } diff --git a/src/testing/testing_api_cmd_bank_history_debit.c b/src/testing/testing_api_cmd_bank_history_debit.c index 1cb7320fa..b6e6ea40c 100644 --- a/src/testing/testing_api_cmd_bank_history_debit.c +++ b/src/testing/testing_api_cmd_bank_history_debit.c @@ -52,10 +52,6 @@ struct History */ char *c_url; - /** - * URL to free. - */ - char *d_url; }; @@ -146,7 +142,7 @@ print_expected (struct History *h, TALER_amount2s (&h[i].details.amount), (unsigned long long) h[i].row_id, TALER_B2S (&h[i].details.wtid), - h[i].details.credit_account_uri); + h[i].details.credit_account_uri.full_payto); } } @@ -204,10 +200,9 @@ command_cb (void *cls, { struct IteratorContext *ic = cls; struct HistoryState *hs = ic->hs; - const uint64_t *row_id; - const char *debit_account; - const char *credit_account; + const struct TALER_FullPayto *debit_account; + const struct TALER_FullPayto *credit_account; const struct TALER_Amount *amount; const struct TALER_WireTransferIdentifierRawP *wtid; const char *exchange_base_url; @@ -256,17 +251,17 @@ command_cb (void *cls, return; } TALER_LOG_INFO ("Found history: %s->%s for account %s\n", - debit_account, - credit_account, + debit_account->full_payto, + credit_account->full_payto, hs->account_url); /* found matching record, make sure we have room */ if (ic->pos == ic->total) GNUNET_array_grow (ic->h, ic->total, ic->pos * 2); - ic->h[ic->pos].c_url = GNUNET_strdup (credit_account); - ic->h[ic->pos].d_url = GNUNET_strdup (debit_account); - ic->h[ic->pos].details.credit_account_uri = ic->h[ic->pos].c_url; + ic->h[ic->pos].c_url = GNUNET_strdup (credit_account->full_payto); + ic->h[ic->pos].details.credit_account_uri.full_payto + = ic->h[ic->pos].c_url; ic->h[ic->pos].details.amount = *amount; ic->h[ic->pos].row_id = *row_id; ic->h[ic->pos].details.wtid = *wtid; @@ -335,69 +330,6 @@ build_history (struct HistoryState *hs, /** - * Normalize IBAN-based payto URI in @a in. - * - * @param in input payto://-URI to normalize - * @return normalized IBAN for the test - */ -static char * -normalize (const char *in) -{ - char *npt; - const char *q = strchr (in, - '?'); - const char *mptr; - const char *bic; - const char *iban; - - if (NULL == q) - npt = GNUNET_strdup (in); - else - npt = GNUNET_strndup (in, - q - in); - if (0 != strncasecmp (npt, - "payto://", - strlen ("payto://"))) - { - GNUNET_break (0); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Invalid payto: %s\n", - npt); - GNUNET_free (npt); - return NULL; - } - mptr = npt + strlen ("payto://"); - bic = strchr (mptr, '/'); - if (NULL == bic) - { - GNUNET_break (0); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Invalid payto: %s\n", - npt); - GNUNET_free (npt); - return NULL; - } - bic++; - iban = strchr (bic, '/'); - if (NULL != iban) - { - /* need to remove bic */ - char *n; - - iban++; - GNUNET_asprintf (&n, - "payto://%.*s/%s", - (int) ((bic - mptr) - 1), - mptr, - iban); - GNUNET_free (npt); - npt = n; - } - return npt; -} - - -/** * Check that the "/history/outgoing" response matches the * CMD whose offset in the list of CMDs is @a off. * @@ -414,9 +346,6 @@ check_result (struct History *h, unsigned int off, const struct TALER_BANK_DebitDetails *details) { - char *u1; - char *u2; - if (off >= total) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -429,31 +358,23 @@ check_result (struct History *h, off); return GNUNET_SYSERR; } - u1 = normalize (h[off].details.credit_account_uri); - if (NULL == u1) - return GNUNET_SYSERR; - u2 = normalize (details->credit_account_uri); - if (NULL == u2) - { - GNUNET_free (u1); - return GNUNET_SYSERR; - } if ( (0 != GNUNET_memcmp (&h[off].details.wtid, &details->wtid)) || (0 != TALER_amount_cmp (&h[off].details.amount, &details->amount)) || - (0 != strcasecmp (u1, - u2)) ) + (0 != TALER_full_payto_normalize_and_cmp ( + h[off].details.credit_account_uri, + details->credit_account_uri)) ) { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected debit_account_uri: %s with %s for %s\n", - u1, + h[off].details.credit_account_uri.full_payto, TALER_amount2s (&h[off].details.amount), TALER_B2S (&h[off].details.wtid)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "actual debit_account_uri: %s with %s for %s\n", - u2, + details->credit_account_uri.full_payto, TALER_amount2s (&details->amount), TALER_B2S (&details->wtid)); print_expected (h, @@ -631,7 +552,6 @@ history_cleanup (void *cls, for (unsigned int off = 0; off<hs->total; off++) { GNUNET_free (hs->h[off].c_url); - GNUNET_free (hs->h[off].d_url); } GNUNET_free (hs->h); GNUNET_free (hs); diff --git a/src/testing/testing_api_cmd_bank_transfer.c b/src/testing/testing_api_cmd_bank_transfer.c index bfb29e120..35cd397e7 100644 --- a/src/testing/testing_api_cmd_bank_transfer.c +++ b/src/testing/testing_api_cmd_bank_transfer.c @@ -57,12 +57,12 @@ struct TransferState /** * Money receiver payto URL. */ - char *payto_debit_account; + struct TALER_FullPayto payto_debit_account; /** * Money receiver account URL. */ - const char *payto_credit_account; + struct TALER_FullPayto payto_credit_account; /** * Username to use for authentication. @@ -231,7 +231,7 @@ transfer_run (void *cls, "Transfer of %s from %s to %s\n", TALER_amount2s (&fts->amount), fts->account_debit_url, - fts->payto_credit_account); + fts->payto_credit_account.full_payto); TALER_BANK_prepare_transfer (fts->payto_credit_account, &fts->amount, fts->exchange_base_url, @@ -282,7 +282,6 @@ transfer_cleanup (void *cls, GNUNET_SCHEDULER_cancel (fts->retry_task); fts->retry_task = NULL; } - GNUNET_free (fts->payto_debit_account); GNUNET_free (fts); } @@ -309,9 +308,9 @@ transfer_traits (void *cls, fts->exchange_base_url), TALER_TESTING_make_trait_bank_row (&fts->serial_id), TALER_TESTING_make_trait_credit_payto_uri ( - fts->payto_credit_account), + &fts->payto_credit_account), TALER_TESTING_make_trait_debit_payto_uri ( - fts->payto_debit_account), + &fts->payto_debit_account), TALER_TESTING_make_trait_amount (&fts->amount), TALER_TESTING_make_trait_timestamp (0, &fts->timestamp), TALER_TESTING_make_trait_wtid (&fts->wtid), @@ -329,8 +328,8 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_transfer (const char *label, const char *amount, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account, - const char *payto_credit_account, + struct TALER_FullPayto payto_debit_account, + struct TALER_FullPayto payto_credit_account, const struct TALER_WireTransferIdentifierRawP *wtid, const char *exchange_base_url) { @@ -339,7 +338,7 @@ TALER_TESTING_cmd_transfer (const char *label, fts = GNUNET_new (struct TransferState); fts->account_debit_url = auth->wire_gateway_url; fts->exchange_base_url = exchange_base_url; - fts->payto_debit_account = GNUNET_strdup (payto_debit_account); + fts->payto_debit_account = payto_debit_account; fts->payto_credit_account = payto_credit_account; fts->auth = *auth; fts->wtid = *wtid; diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c index 5bb7b974e..395d92563 100644 --- a/src/testing/testing_api_cmd_batch.c +++ b/src/testing/testing_api_cmd_batch.c @@ -62,27 +62,30 @@ batch_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct BatchState *bs = cls; + struct TALER_TESTING_Command *bcmd = &bs->batch[bs->batch_ip]; bs->cmd = cmd; - if (NULL != bs->batch[bs->batch_ip].label) + if (NULL != bcmd->label) TALER_LOG_INFO ("Running batched command: %s\n", - bs->batch[bs->batch_ip].label); + bcmd->label); /* hit end command, leap to next top-level command. */ - if (NULL == bs->batch[bs->batch_ip].label) + if (NULL == bcmd->label) { TALER_LOG_INFO ("Exiting from batch: %s\n", cmd->label); TALER_TESTING_interpreter_next (is); return; } - bs->batch[bs->batch_ip].start_time - = bs->batch[bs->batch_ip].last_req_time + bcmd->start_time + = bcmd->last_req_time = GNUNET_TIME_absolute_get (); - bs->batch[bs->batch_ip].num_tries = 1; - bs->batch[bs->batch_ip].run (bs->batch[bs->batch_ip].cls, - &bs->batch[bs->batch_ip], - is); + bcmd->num_tries++; + TALER_TESTING_update_variables_ (is, + bcmd); + bcmd->run (bcmd->cls, + bcmd, + is); } diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c index 27a2a1165..75bcf65fb 100644 --- a/src/testing/testing_api_cmd_batch_deposit.c +++ b/src/testing/testing_api_cmd_batch_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2022 Taler Systems SA + Copyright (C) 2018-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -133,7 +133,13 @@ struct BatchDepositState * Set (by the interpreter) to a fresh private key. This * key will be used to sign the deposit request. */ - struct TALER_MerchantPrivateKeyP merchant_priv; + union TALER_AccountPrivateKeyP account_priv; + + /** + * Set (by the interpreter) to the public key + * corresponding to @e account_priv. + */ + union TALER_AccountPublicKeyP account_pub; /** * Deposit handle while operation is running. @@ -175,7 +181,7 @@ struct BatchDepositState * Set to the KYC requirement payto hash *if* the exchange replied with a * request for KYC. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -264,16 +270,15 @@ batch_deposit_run (void *cls, { struct BatchDepositState *ds = cls; const struct TALER_DenominationSignature *denom_pub_sig; - struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_PrivateContractHashP h_contract_terms; enum TALER_ErrorCode ec; struct TALER_WireSaltP wire_salt; struct TALER_MerchantWireHashP h_wire; - const char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_EXCHANGE_CoinDepositDetail cdds[ds->num_coins]; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), GNUNET_JSON_spec_fixed_auto ("salt", &wire_salt), GNUNET_JSON_spec_end () @@ -304,6 +309,13 @@ batch_deposit_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } +#if DUMP_CONTRACT + fprintf (stderr, + "Using contract:\n"); + json_dumpf (ds->contract_terms, + stderr, + JSON_INDENT (2)); +#endif if (GNUNET_OK != TALER_JSON_contract_hash (ds->contract_terms, &h_contract_terms)) @@ -332,9 +344,38 @@ batch_deposit_run (void *cls, ds->refund_deadline = ds->wallet_timestamp; ds->wire_deadline = GNUNET_TIME_timestamp_get (); } - GNUNET_CRYPTO_eddsa_key_get_public (&ds->merchant_priv.eddsa_priv, - &merchant_pub.eddsa_pub); + { + const struct TALER_TESTING_Command *acc_var; + if (NULL != (acc_var + = TALER_TESTING_interpreter_get_command ( + is, + "account-priv"))) + { + const union TALER_AccountPrivateKeyP *account_priv; + + if ( (GNUNET_OK != + TALER_TESTING_get_trait_account_priv (acc_var, + &account_priv)) ) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + ds->account_priv = *account_priv; + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); + } + else + { + GNUNET_CRYPTO_eddsa_key_create ( + &ds->account_priv.merchant_priv.eddsa_priv); + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); + } + } for (unsigned int i = 0; i<ds->num_coins; i++) { struct Coin *coin = &ds->coins[i]; @@ -395,7 +436,7 @@ batch_deposit_run (void *cls, NULL, /* hash of extensions */ &coin->denom_pub->h_key, ds->wallet_timestamp, - &merchant_pub, + &ds->account_pub.merchant_pub, ds->refund_deadline, coin_priv, &cdd->coin_sig); @@ -407,7 +448,7 @@ batch_deposit_run (void *cls, coin->che.details.deposit.no_h_policy = true; coin->che.details.deposit.no_wallet_data_hash = true; coin->che.details.deposit.wallet_timestamp = ds->wallet_timestamp; - coin->che.details.deposit.merchant_pub = merchant_pub; + coin->che.details.deposit.merchant_pub = ds->account_pub.merchant_pub; coin->che.details.deposit.refund_deadline = ds->refund_deadline; coin->che.details.deposit.sig = cdd->coin_sig; coin->che.details.deposit.no_hac = GNUNET_is_zero (&cdd->h_age_commitment); @@ -424,7 +465,7 @@ batch_deposit_run (void *cls, .h_contract_terms = h_contract_terms, .policy_details = NULL /* FIXME #7270-OEC */, .wallet_timestamp = ds->wallet_timestamp, - .merchant_pub = merchant_pub, + .merchant_pub = ds->account_pub.merchant_pub, .refund_deadline = ds->refund_deadline }; @@ -546,7 +587,10 @@ batch_deposit_traits (void *cls, /* These traits are always available */ TALER_TESTING_make_trait_wire_details (ds->wire_details), TALER_TESTING_make_trait_contract_terms (ds->contract_terms), - TALER_TESTING_make_trait_merchant_priv (&ds->merchant_priv), + TALER_TESTING_make_trait_merchant_priv (&ds->account_priv.merchant_priv), + TALER_TESTING_make_trait_merchant_pub (&ds->account_pub.merchant_pub), + TALER_TESTING_make_trait_account_priv (&ds->account_priv), + TALER_TESTING_make_trait_account_pub (&ds->account_pub), TALER_TESTING_make_trait_age_commitment_proof (index, age_commitment_proof), TALER_TESTING_make_trait_coin_history (index, @@ -570,7 +614,7 @@ batch_deposit_traits (void *cls, TALER_TESTING_make_trait_refund_deadline (index, &ds->refund_deadline), TALER_TESTING_make_trait_legi_requirement_row (&ds->requirement_row), - TALER_TESTING_make_trait_h_payto (&ds->h_payto), + TALER_TESTING_make_trait_h_normalized_payto (&ds->h_payto), TALER_TESTING_trait_end () }; @@ -585,12 +629,13 @@ batch_deposit_traits (void *cls, struct TALER_TESTING_Command -TALER_TESTING_cmd_batch_deposit (const char *label, - const char *target_account_payto, - const char *contract_terms, - struct GNUNET_TIME_Relative refund_deadline, - unsigned int expected_response_code, - ...) +TALER_TESTING_cmd_batch_deposit ( + const char *label, + const struct TALER_FullPayto target_account_payto, + const char *contract_terms, + struct GNUNET_TIME_Relative refund_deadline, + unsigned int expected_response_code, + ...) { struct BatchDepositState *ds; va_list ap; @@ -637,7 +682,6 @@ TALER_TESTING_cmd_batch_deposit (const char *label, ds->contract_terms = json_loads (contract_terms, JSON_REJECT_DUPLICATES, NULL); - GNUNET_CRYPTO_eddsa_key_create (&ds->merchant_priv.eddsa_priv); if (NULL == ds->contract_terms) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/testing/testing_api_cmd_batch_withdraw.c b/src/testing/testing_api_cmd_batch_withdraw.c index 1b056bdbb..170e95973 100644 --- a/src/testing/testing_api_cmd_batch_withdraw.c +++ b/src/testing/testing_api_cmd_batch_withdraw.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2022 Taler Systems SA + Copyright (C) 2018-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -119,7 +119,7 @@ struct BatchWithdrawState /** * URI if the reserve we are withdrawing from. */ - char *reserve_payto_uri; + struct TALER_NormalizedPayto reserve_payto_uri; /** * Private key of the reserve we are withdrawing from. @@ -150,7 +150,7 @@ struct BatchWithdrawState * Set to the KYC requirement payto hash *if* the exchange replied with a * request for KYC. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -416,7 +416,7 @@ batch_withdraw_cleanup (void *cls, } GNUNET_free (ws->coins); GNUNET_free (ws->exchange_url); - GNUNET_free (ws->reserve_payto_uri); + GNUNET_free (ws->reserve_payto_uri.normalized_payto); GNUNET_free (ws); } @@ -462,8 +462,8 @@ batch_withdraw_traits (void *cls, TALER_TESTING_make_trait_amounts (index, &cs->amount), TALER_TESTING_make_trait_legi_requirement_row (&ws->requirement_row), - TALER_TESTING_make_trait_h_payto (&ws->h_payto), - TALER_TESTING_make_trait_payto_uri (ws->reserve_payto_uri), + TALER_TESTING_make_trait_h_normalized_payto (&ws->h_payto), + TALER_TESTING_make_trait_normalized_payto_uri (&ws->reserve_payto_uri), TALER_TESTING_make_trait_exchange_url (ws->exchange_url), TALER_TESTING_make_trait_age_commitment_proof (index, ws->age > 0 ? diff --git a/src/testing/testing_api_cmd_check_aml_decisions.c b/src/testing/testing_api_cmd_check_aml_decisions.c index 0c31c5471..0c749c6a5 100644 --- a/src/testing/testing_api_cmd_check_aml_decisions.c +++ b/src/testing/testing_api_cmd_check_aml_decisions.c @@ -155,7 +155,7 @@ check_aml_decisions_run ( struct TALER_TESTING_Interpreter *is) { struct AmlCheckState *ds = cls; - const struct TALER_PaytoHashP *h_payto = NULL; + const struct TALER_NormalizedPaytoHashP *h_payto = NULL; const struct TALER_AmlOfficerPrivateKeyP *officer_priv; const struct TALER_TESTING_Command *ref; const char *exchange_url; @@ -193,7 +193,7 @@ check_aml_decisions_run ( return; } GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_h_payto ( + TALER_TESTING_get_trait_h_normalized_payto ( ref, &h_payto)); } diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index 2467488ea..b43616ba3 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2023 Taler Systems SA + Copyright (C) 2018-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -98,7 +98,13 @@ struct DepositState * Set (by the interpreter) to a fresh private key. This * key will be used to sign the deposit request. */ - struct TALER_MerchantPrivateKeyP merchant_priv; + union TALER_AccountPrivateKeyP account_priv; + + /** + * Set (by the interpreter) to the public key + * corresponding to @e account_priv. + */ + union TALER_AccountPublicKeyP account_pub; /** * Deposit handle while operation is running. @@ -297,18 +303,18 @@ deposit_run (void *cls, { struct DepositState *ds = cls; const struct TALER_TESTING_Command *coin_cmd; + const struct TALER_TESTING_Command *acc_var; const struct TALER_CoinSpendPrivateKeyP *coin_priv; struct TALER_CoinSpendPublicKeyP coin_pub; const struct TALER_AgeCommitmentHash *phac; const struct TALER_DenominationSignature *denom_pub_sig; - struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_PrivateContractHashP h_contract_terms; enum TALER_ErrorCode ec; struct TALER_WireSaltP wire_salt; - const char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), GNUNET_JSON_spec_fixed_auto ("salt", &wire_salt), GNUNET_JSON_spec_end () @@ -363,7 +369,8 @@ deposit_run (void *cls, ds->refund_deadline = ods->refund_deadline; ds->wire_deadline = ods->wire_deadline; ds->amount = ods->amount; - ds->merchant_priv = ods->merchant_priv; + ds->account_priv = ods->account_priv; + ds->account_pub = ods->account_pub; ds->command_initialized = true; } else if (NULL != ds->merchant_priv_reference) @@ -389,7 +396,38 @@ deposit_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - ds->merchant_priv = *merchant_priv; + ds->account_priv.merchant_priv = *merchant_priv; + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); + } + else if (NULL != (acc_var + = TALER_TESTING_interpreter_get_command ( + is, + "account-priv"))) + { + const union TALER_AccountPrivateKeyP *account_priv; + + if ( (GNUNET_OK != + TALER_TESTING_get_trait_account_priv (acc_var, + &account_priv)) ) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + ds->account_priv = *account_priv; + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); + } + else + { + GNUNET_CRYPTO_eddsa_key_create ( + &ds->account_priv.merchant_priv.eddsa_priv); + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->account_priv.merchant_priv.eddsa_priv, + &ds->account_pub.merchant_pub.eddsa_pub); } GNUNET_assert (NULL != ds->wire_details); if (GNUNET_OK != @@ -413,7 +451,13 @@ deposit_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - +#if DUMP_CONTRACT + fprintf (stderr, + "Using contract:\n"); + json_dumpf (ds->contract_terms, + stderr, + JSON_INDENT (2)); +#endif if ( (GNUNET_OK != TALER_TESTING_get_trait_coin_priv (coin_cmd, ds->coin_index, @@ -443,8 +487,6 @@ deposit_run (void *cls, GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, &coin_pub.eddsa_pub); - GNUNET_CRYPTO_eddsa_key_get_public (&ds->merchant_priv.eddsa_priv, - &merchant_pub.eddsa_pub); { struct TALER_MerchantWireHashP h_wire; @@ -460,7 +502,7 @@ deposit_run (void *cls, NULL, /* hash of extensions */ &ds->denom_pub->h_key, ds->wallet_timestamp, - &merchant_pub, + &ds->account_pub.merchant_pub, ds->refund_deadline, coin_priv, &ds->coin_sig); @@ -471,7 +513,7 @@ deposit_run (void *cls, ds->che.details.deposit.no_h_policy = true; ds->che.details.deposit.no_wallet_data_hash = true; ds->che.details.deposit.wallet_timestamp = ds->wallet_timestamp; - ds->che.details.deposit.merchant_pub = merchant_pub; + ds->che.details.deposit.merchant_pub = ds->account_pub.merchant_pub; ds->che.details.deposit.refund_deadline = ds->refund_deadline; ds->che.details.deposit.sig = ds->coin_sig; ds->che.details.deposit.no_hac = true; @@ -493,7 +535,7 @@ deposit_run (void *cls, .wire_salt = wire_salt, .h_contract_terms = h_contract_terms, .wallet_timestamp = ds->wallet_timestamp, - .merchant_pub = merchant_pub, + .merchant_pub = ds->account_pub.merchant_pub, .refund_deadline = ds->refund_deadline }; @@ -639,7 +681,10 @@ deposit_traits (void *cls, h_age_commitment), TALER_TESTING_make_trait_wire_details (ds->wire_details), TALER_TESTING_make_trait_contract_terms (ds->contract_terms), - TALER_TESTING_make_trait_merchant_priv (&ds->merchant_priv), + TALER_TESTING_make_trait_merchant_priv (&ds->account_priv.merchant_priv), + TALER_TESTING_make_trait_merchant_pub (&ds->account_pub.merchant_pub), + TALER_TESTING_make_trait_account_priv (&ds->account_priv), + TALER_TESTING_make_trait_account_pub (&ds->account_pub), TALER_TESTING_make_trait_deposit_amount (0, &ds->amount), TALER_TESTING_make_trait_deposit_fee_amount (0, @@ -668,7 +713,7 @@ TALER_TESTING_cmd_deposit ( const char *label, const char *coin_reference, unsigned int coin_index, - const char *target_account_payto, + struct TALER_FullPayto target_account_payto, const char *contract_terms, struct GNUNET_TIME_Relative refund_deadline, const char *amount, @@ -684,7 +729,6 @@ TALER_TESTING_cmd_deposit ( ds->contract_terms = json_loads (contract_terms, JSON_REJECT_DUPLICATES, NULL); - GNUNET_CRYPTO_eddsa_key_create (&ds->merchant_priv.eddsa_priv); if (NULL == ds->contract_terms) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -732,7 +776,7 @@ TALER_TESTING_cmd_deposit_with_ref ( const char *label, const char *coin_reference, unsigned int coin_index, - const char *target_account_payto, + struct TALER_FullPayto target_account_payto, const char *contract_terms, struct GNUNET_TIME_Relative refund_deadline, const char *amount, diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 60f968662..a537dd3f5 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2021 Taler Systems SA + Copyright (C) 2014-2021, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -60,7 +60,7 @@ struct TrackTransactionState * Note: set based on our @e merchant_payto_uri, as * the exchange does not respond with the payto hash. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -77,7 +77,7 @@ struct TrackTransactionState /** * Payto URI of the merchant receiving the deposit. */ - char *merchant_payto_uri; + struct TALER_FullPayto merchant_payto_uri; /** * Index of the coin involved in the transaction. Recall: @@ -164,8 +164,8 @@ deposit_wtid_cb ( break; case MHD_HTTP_ACCEPTED: /* allowed, nothing to check here */ - TALER_payto_hash (tts->merchant_payto_uri, - &tts->h_payto); + TALER_full_payto_normalize_and_hash (tts->merchant_payto_uri, + &tts->h_payto); tts->requirement_row = dr->details.accepted.requirement_row; break; @@ -237,7 +237,7 @@ deposits_get_run ( TALER_TESTING_interpreter_fail (tts->is); return; } - tts->merchant_payto_uri + tts->merchant_payto_uri.full_payto = GNUNET_strdup (json_string_value (json_object_get (wire_details, "payto_uri"))); if (GNUNET_OK != @@ -311,7 +311,7 @@ deposits_get_cleanup ( TALER_EXCHANGE_deposits_get_cancel (tts->tth); tts->tth = NULL; } - GNUNET_free (tts->merchant_payto_uri); + GNUNET_free (tts->merchant_payto_uri.full_payto); GNUNET_free (tts); } @@ -336,8 +336,8 @@ deposits_get_traits (void *cls, TALER_TESTING_make_trait_wtid (&tts->wtid), TALER_TESTING_make_trait_legi_requirement_row ( &tts->requirement_row), - TALER_TESTING_make_trait_h_payto (&tts->h_payto), - TALER_TESTING_make_trait_payto_uri (tts->merchant_payto_uri), + TALER_TESTING_make_trait_h_normalized_payto (&tts->h_payto), + TALER_TESTING_make_trait_full_payto_uri (&tts->merchant_payto_uri), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_insert_deposit.c b/src/testing/testing_api_cmd_insert_deposit.c index 03e704c72..51ec6d80b 100644 --- a/src/testing/testing_api_cmd_insert_deposit.c +++ b/src/testing/testing_api_cmd_insert_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018 Taler Systems SA + Copyright (C) 2018, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -138,7 +138,7 @@ insert_deposit_run (void *cls, struct TALER_EXCHANGEDB_DenominationKeyInformation issue; struct TALER_DenominationPublicKey dpk; struct TALER_DenominationPrivateKey denom_priv; - char *receiver_wire_account; + struct TALER_FullPayto receiver_wire_account; (void) cmd; if (NULL == ids->plugin) @@ -254,13 +254,13 @@ insert_deposit_run (void *cls, &dpk)); TALER_blinded_denom_sig_free (&bds); } - GNUNET_asprintf (&receiver_wire_account, + GNUNET_asprintf (&receiver_wire_account.full_payto, "payto://x-taler-bank/localhost/%s?receiver-name=%s", ids->merchant_account, ids->merchant_account); bd.receiver_wire_account = receiver_wire_account; - TALER_payto_hash (bd.receiver_wire_account, - &bd.wire_target_h_payto); + TALER_full_payto_hash (bd.receiver_wire_account, + &bd.wire_target_h_payto); memset (&bd.wire_salt, 46, sizeof (bd.wire_salt)); @@ -297,7 +297,7 @@ insert_deposit_run (void *cls, { GNUNET_break (0); ids->plugin->rollback (ids->plugin->cls); - GNUNET_free (receiver_wire_account); + GNUNET_free (receiver_wire_account.full_payto); TALER_denom_pub_free (&dpk); TALER_denom_priv_free (&denom_priv); TALER_TESTING_interpreter_fail (is); @@ -308,7 +308,7 @@ insert_deposit_run (void *cls, TALER_denom_sig_free (&deposit.coin.denom_sig); TALER_denom_pub_free (&dpk); TALER_denom_priv_free (&denom_priv); - GNUNET_free (receiver_wire_account); + GNUNET_free (receiver_wire_account.full_payto); TALER_TESTING_interpreter_next (is); } @@ -362,7 +362,8 @@ TALER_TESTING_cmd_insert_deposit ( } else { - ids->plugin = TALER_EXCHANGEDB_plugin_load (db_cfg); + ids->plugin = TALER_EXCHANGEDB_plugin_load (db_cfg, + false); pluginc = ids->plugin; db_cfgc = db_cfg; } diff --git a/src/testing/testing_api_cmd_kyc_check_get.c b/src/testing/testing_api_cmd_kyc_check_get.c index fa0556d47..89411c295 100644 --- a/src/testing/testing_api_cmd_kyc_check_get.c +++ b/src/testing/testing_api_cmd_kyc_check_get.c @@ -126,7 +126,7 @@ check_kyc_run (void *cls, struct KycCheckGetState *kcg = cls; const struct TALER_TESTING_Command *res_cmd; const struct TALER_TESTING_Command *acc_cmd; - const struct TALER_PaytoHashP *h_payto; + const struct TALER_NormalizedPaytoHashP *h_payto; const union TALER_AccountPrivateKeyP *account_priv; (void) cmd; @@ -150,7 +150,7 @@ check_kyc_run (void *cls, return; } if (GNUNET_OK != - TALER_TESTING_get_trait_h_payto ( + TALER_TESTING_get_trait_h_normalized_payto ( res_cmd, &h_payto)) { diff --git a/src/testing/testing_api_cmd_kyc_proof.c b/src/testing/testing_api_cmd_kyc_proof.c index af6d9c139..4f72fbe46 100644 --- a/src/testing/testing_api_cmd_kyc_proof.c +++ b/src/testing/testing_api_cmd_kyc_proof.c @@ -126,7 +126,7 @@ proof_kyc_run (void *cls, { struct KycProofGetState *kps = cls; const struct TALER_TESTING_Command *res_cmd; - const struct TALER_PaytoHashP *h_payto; + const struct TALER_NormalizedPaytoHashP *h_payto; char *uargs; const char *exchange_url; @@ -148,8 +148,8 @@ proof_kyc_run (void *cls, return; } if (GNUNET_OK != - TALER_TESTING_get_trait_h_payto (res_cmd, - &h_payto)) + TALER_TESTING_get_trait_h_normalized_payto (res_cmd, + &h_payto)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (kps->is); diff --git a/src/testing/testing_api_cmd_kyc_wallet_get.c b/src/testing/testing_api_cmd_kyc_wallet_get.c index 24bd7d4d7..4add41a9e 100644 --- a/src/testing/testing_api_cmd_kyc_wallet_get.c +++ b/src/testing/testing_api_cmd_kyc_wallet_get.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2021 Taler Systems SA + Copyright (C) 2021-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -46,7 +46,7 @@ struct KycWalletGetState /** * Payto URI of the reserve of the wallet. */ - char *reserve_payto_uri; + struct TALER_NormalizedPayto reserve_payto_uri; /** * Our command. @@ -67,7 +67,7 @@ struct KycWalletGetState * Set to the KYC requirement payto hash *if* the exchange replied with a * request for KYC (#MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS). */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -226,7 +226,7 @@ wallet_kyc_cleanup ( TALER_EXCHANGE_kyc_wallet_cancel (kwg->kwh); kwg->kwh = NULL; } - GNUNET_free (kwg->reserve_payto_uri); + GNUNET_free (kwg->reserve_payto_uri.normalized_payto); GNUNET_free (kwg); } @@ -258,10 +258,10 @@ wallet_kyc_traits (void *cls, &kwg->account_pub.reserve_pub), TALER_TESTING_make_trait_legi_requirement_row ( &kwg->requirement_row), - TALER_TESTING_make_trait_h_payto ( + TALER_TESTING_make_trait_h_normalized_payto ( &kwg->h_payto), - TALER_TESTING_make_trait_payto_uri ( - kwg->reserve_payto_uri), + TALER_TESTING_make_trait_normalized_payto_uri ( + &kwg->reserve_payto_uri), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_purse_get.c b/src/testing/testing_api_cmd_purse_get.c index d5246660b..762c39fa6 100644 --- a/src/testing/testing_api_cmd_purse_get.c +++ b/src/testing/testing_api_cmd_purse_get.c @@ -128,15 +128,9 @@ purse_status_cb (void *cls, ss->pgh = NULL; if (ss->expected_response_code != rs->hr.http_status) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected HTTP response code: %d in %s:%u\n", - rs->hr.http_status, - __FILE__, - __LINE__); - json_dumpf (rs->hr.reply, - stderr, - 0); - TALER_TESTING_interpreter_fail (ss->is); + TALER_TESTING_unexpected_status (is, + rs->hr.http_status, + ss->expected_response_code); return; } if (MHD_HTTP_OK == ss->expected_response_code) diff --git a/src/testing/testing_api_cmd_purse_merge.c b/src/testing/testing_api_cmd_purse_merge.c index 515a14403..564b0ce02 100644 --- a/src/testing/testing_api_cmd_purse_merge.c +++ b/src/testing/testing_api_cmd_purse_merge.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -75,7 +75,7 @@ struct PurseMergeState * Hash of the payto://-URI for the reserve we are * merging into. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -298,7 +298,7 @@ merge_run (void *cls, GNUNET_CRYPTO_eddsa_key_get_public (&ds->reserve_priv.eddsa_priv, &ds->reserve_pub.eddsa_pub); { - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; const char *exchange_url; const struct TALER_TESTING_Command *exchange_cmd; @@ -315,9 +315,9 @@ merge_run (void *cls, &exchange_url)); payto_uri = TALER_reserve_make_payto (exchange_url, &ds->reserve_pub); - TALER_payto_hash (payto_uri, - &ds->h_payto); - GNUNET_free (payto_uri); + TALER_normalized_payto_hash (payto_uri, + &ds->h_payto); + GNUNET_free (payto_uri.normalized_payto); } GNUNET_CRYPTO_eddsa_key_get_public (&merge_priv->eddsa_priv, &ds->merge_pub.eddsa_pub); @@ -396,7 +396,7 @@ merge_traits (void *cls, TALER_TESTING_make_trait_timestamp (0, &ds->merge_timestamp), TALER_TESTING_make_trait_legi_requirement_row (&ds->requirement_row), - TALER_TESTING_make_trait_h_payto (&ds->h_payto), + TALER_TESTING_make_trait_h_normalized_payto (&ds->h_payto), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c index 9d58422c7..5c45e3a33 100644 --- a/src/testing/testing_api_cmd_refresh.c +++ b/src/testing/testing_api_cmd_refresh.c @@ -1021,12 +1021,12 @@ melt_run (void *cls, const struct TALER_TESTING_Command *cmd, struct TALER_TESTING_Interpreter *is) { - struct RefreshMeltState *rms = cls; - unsigned int num_fresh_coins; - const char *default_melt_fresh_amounts[] = { + static const char *default_melt_fresh_amounts[] = { "EUR:1", "EUR:1", "EUR:1", "EUR:0.1", NULL }; + struct RefreshMeltState *rms = cls; + unsigned int num_fresh_coins; const char **melt_fresh_amounts; rms->cmd = cmd; diff --git a/src/testing/testing_api_cmd_reserve_close.c b/src/testing/testing_api_cmd_reserve_close.c index 2d38696dd..d9ee35462 100644 --- a/src/testing/testing_api_cmd_reserve_close.c +++ b/src/testing/testing_api_cmd_reserve_close.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA + Copyright (C) 2014-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -46,7 +46,7 @@ struct CloseState /** * payto://-URI where to wire the funds. */ - const char *target_account; + struct TALER_FullPayto target_account; /** * Private key of the reserve being analyzed. @@ -72,7 +72,7 @@ struct CloseState * Set to the KYC requirement payto hash *if* the exchange replied with a * request for KYC. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -216,7 +216,7 @@ close_traits (void *cls, struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_legi_requirement_row ( &cs->requirement_row), - TALER_TESTING_make_trait_h_payto ( + TALER_TESTING_make_trait_h_normalized_payto ( &cs->h_payto), TALER_TESTING_trait_end () }; @@ -233,7 +233,7 @@ close_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_reserve_close (const char *label, const char *reserve_reference, - const char *target_account, + struct TALER_FullPayto target_account, unsigned int expected_response_code) { struct CloseState *ss; diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c index ecb236a54..bb1cf6f7e 100644 --- a/src/testing/testing_api_cmd_reserve_history.c +++ b/src/testing/testing_api_cmd_reserve_history.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2023 Taler Systems SA + Copyright (C) 2014-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -124,8 +124,9 @@ history_entry_cmp ( if ( (0 == TALER_amount_cmp (&h1->amount, &h2->amount)) && - (0 == strcasecmp (h1->details.in_details.sender_url, - h2->details.in_details.sender_url)) && + (0 == + TALER_full_payto_cmp (h1->details.in_details.sender_url, + h2->details.in_details.sender_url)) && (h1->details.in_details.wire_reference == h2->details.in_details.wire_reference) && (GNUNET_TIME_timestamp_cmp (h1->details.in_details.timestamp, @@ -196,7 +197,8 @@ history_entry_cmp ( && (GNUNET_TIME_timestamp_cmp (h1->details.merge_details.purse_expiration, ==, - h2->details.merge_details.purse_expiration)) + h2->details.merge_details.purse_expiration) + ) && (0 == GNUNET_memcmp (&h1->details.merge_details.merge_pub, diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c index a083711f6..e2975bd32 100644 --- a/src/testing/testing_api_cmd_reserve_purse.c +++ b/src/testing/testing_api_cmd_reserve_purse.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -101,7 +101,7 @@ struct ReservePurseState * Hash of the payto://-URI for the reserve we are * merging into. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -225,7 +225,7 @@ purse_run (void *cls, ds->expiration_rel)); { - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; const char *exchange_url; const struct TALER_TESTING_Command *exchange_cmd; @@ -246,9 +246,9 @@ purse_run (void *cls, = TALER_reserve_make_payto ( exchange_url, &ds->account_pub.reserve_pub); - TALER_payto_hash (payto_uri, - &ds->h_payto); - GNUNET_free (payto_uri); + TALER_normalized_payto_hash (payto_uri, + &ds->h_payto); + GNUNET_free (payto_uri.normalized_payto); } GNUNET_assert (0 == @@ -351,7 +351,7 @@ purse_traits (void *cls, &ds->reserve_sig), TALER_TESTING_make_trait_legi_requirement_row ( &ds->requirement_row), - TALER_TESTING_make_trait_h_payto ( + TALER_TESTING_make_trait_h_normalized_payto ( &ds->h_payto), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_run_fakebank.c b/src/testing/testing_api_cmd_run_fakebank.c index 7739d3c0c..9e555db0b 100644 --- a/src/testing/testing_api_cmd_run_fakebank.c +++ b/src/testing/testing_api_cmd_run_fakebank.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2023 Taler Systems SA + (C) 2023, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -152,7 +152,7 @@ TALER_TESTING_cmd_run_fakebank ( { struct RunFakebankState *rfs; unsigned long long fakebank_port; - char *exchange_payto_uri; + struct TALER_FullPayto exchange_payto_uri; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, @@ -169,7 +169,7 @@ TALER_TESTING_cmd_run_fakebank ( GNUNET_CONFIGURATION_get_value_string (cfg, exchange_account_section, "PAYTO_URI", - &exchange_payto_uri)) + &exchange_payto_uri.full_payto)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, exchange_account_section, @@ -195,9 +195,8 @@ TALER_TESTING_cmd_run_fakebank ( (unsigned int) fakebank_port, exchange_xtalerbank_account); GNUNET_free (exchange_xtalerbank_account); - GNUNET_free (exchange_payto_uri); } - GNUNET_free (exchange_payto_uri); + GNUNET_free (exchange_payto_uri.full_payto); rfs->ba.method = TALER_BANK_AUTH_NONE; { struct TALER_TESTING_Command cmd = { diff --git a/src/testing/testing_api_cmd_take_aml_decision.c b/src/testing/testing_api_cmd_take_aml_decision.c index bfe741869..3273b5161 100644 --- a/src/testing/testing_api_cmd_take_aml_decision.c +++ b/src/testing/testing_api_cmd_take_aml_decision.c @@ -60,7 +60,7 @@ struct AmlDecisionState /** * Payto hash of the account we are manipulating the AML settings for. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Justification given. @@ -141,7 +141,7 @@ take_aml_decision_run (void *cls, { struct AmlDecisionState *ds = cls; struct GNUNET_TIME_Timestamp now; - const struct TALER_PaytoHashP *h_payto; + const struct TALER_NormalizedPaytoHashP *h_payto; const struct TALER_AmlOfficerPrivateKeyP *officer_priv; const struct TALER_TESTING_Command *ref; const char *exchange_url; @@ -203,8 +203,8 @@ take_aml_decision_run (void *cls, return; } if (GNUNET_OK != - TALER_TESTING_get_trait_h_payto (ref, - &h_payto)) + TALER_TESTING_get_trait_h_normalized_payto (ref, + &h_payto)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -350,25 +350,31 @@ take_aml_decision_run (void *cls, } GNUNET_assert (off == num_measures); - ds->dh = TALER_EXCHANGE_post_aml_decision ( - TALER_TESTING_interpreter_get_context (is), - exchange_url, - h_payto, - NULL, /* payto_uri */ - now, - ds->successor_measure, - new_measures, - expiration_time, - num_rules, - rules, - num_measures, - measures, - ds->properties, - ds->keep_investigating, - ds->justification, - officer_priv, - &take_aml_decision_cb, - ds); + { + struct TALER_FullPayto null_payto = { + .full_payto = NULL + }; + + ds->dh = TALER_EXCHANGE_post_aml_decision ( + TALER_TESTING_interpreter_get_context (is), + exchange_url, + h_payto, + null_payto, + now, + ds->successor_measure, + new_measures, + expiration_time, + num_rules, + rules, + num_measures, + measures, + ds->properties, + ds->keep_investigating, + ds->justification, + officer_priv, + &take_aml_decision_cb, + ds); + } for (unsigned int j = 0; j<num_rules; j++) { struct TALER_EXCHANGE_AccountRule *rule = &rules[j]; @@ -429,7 +435,7 @@ take_aml_decision_traits (void *cls, { struct AmlDecisionState *ws = cls; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_h_payto (&ws->h_payto), + TALER_TESTING_make_trait_h_normalized_payto (&ws->h_payto), TALER_TESTING_make_trait_aml_justification (ws->justification), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_transfer_get.c b/src/testing/testing_api_cmd_transfer_get.c index a5940db85..8fdd9745e 100644 --- a/src/testing/testing_api_cmd_transfer_get.c +++ b/src/testing/testing_api_cmd_transfer_get.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2020 Taler Systems SA + Copyright (C) 2014-2020, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -99,7 +99,6 @@ track_transfer_cleanup ( void *cls, const struct TALER_TESTING_Command *cmd) { - struct TrackTransferState *tts = cls; if (NULL != tts->tth) @@ -217,13 +216,13 @@ track_transfer_cb ( if (NULL != tts->wire_details_reference) { const struct TALER_TESTING_Command *wire_details_cmd; - const char *payto_uri; - struct TALER_PaytoHashP h_payto; + const struct TALER_FullPayto *payto_uri; + struct TALER_FullPaytoHashP h_payto; wire_details_cmd - = TALER_TESTING_interpreter_lookup_command (is, - tts-> - wire_details_reference); + = TALER_TESTING_interpreter_lookup_command ( + is, + tts->wire_details_reference); if (NULL == wire_details_cmd) { GNUNET_break (0); @@ -231,15 +230,15 @@ track_transfer_cb ( return; } if (GNUNET_OK != - TALER_TESTING_get_trait_payto_uri (wire_details_cmd, - &payto_uri)) + TALER_TESTING_get_trait_full_payto_uri (wire_details_cmd, + &payto_uri)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); return; } - TALER_payto_hash (payto_uri, - &h_payto); + TALER_full_payto_hash (*payto_uri, + &h_payto); if (0 != GNUNET_memcmp (&h_payto, &ta->h_payto)) { diff --git a/src/testing/testing_api_cmd_wire_add.c b/src/testing/testing_api_cmd_wire_add.c index d2a15894a..5e3abc332 100644 --- a/src/testing/testing_api_cmd_wire_add.c +++ b/src/testing/testing_api_cmd_wire_add.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020-2023 Taler Systems SA + Copyright (C) 2020-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,7 +48,7 @@ struct WireAddState /** * Account to add. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Expected HTTP response code. @@ -218,7 +218,7 @@ wire_add_cleanup (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_wire_add (const char *label, - const char *payto_uri, + struct TALER_FullPayto payto_uri, unsigned int expected_http_status, bool bad_sig) { diff --git a/src/testing/testing_api_cmd_wire_del.c b/src/testing/testing_api_cmd_wire_del.c index 50ebfc7cb..421bb5911 100644 --- a/src/testing/testing_api_cmd_wire_del.c +++ b/src/testing/testing_api_cmd_wire_del.c @@ -48,7 +48,7 @@ struct WireDelState /** * Account to del. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Expected HTTP response code. @@ -194,7 +194,7 @@ wire_del_cleanup (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_wire_del (const char *label, - const char *payto_uri, + struct TALER_FullPayto payto_uri, unsigned int expected_http_status, bool bad_sig) { diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c index f8ff0205b..e3a985669 100644 --- a/src/testing/testing_api_cmd_withdraw.c +++ b/src/testing/testing_api_cmd_withdraw.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2022 Taler Systems SA + Copyright (C) 2018-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,13 +41,13 @@ * How long do we wait AT LEAST if the exchange says the reserve is unknown? */ #define UNKNOWN_MIN_BACKOFF GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_MILLISECONDS, 10) + GNUNET_TIME_UNIT_MILLISECONDS, 10) /** * How long do we wait AT MOST if the exchange says the reserve is unknown? */ #define UNKNOWN_MAX_BACKOFF GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_MILLISECONDS, 100) + GNUNET_TIME_UNIT_MILLISECONDS, 100) /** * State for a "withdraw" CMD. @@ -93,7 +93,7 @@ struct WithdrawState /** * URI if the reserve we are withdrawing from. */ - char *reserve_payto_uri; + struct TALER_NormalizedPayto reserve_payto_uri; /** * Private key of the reserve we are withdrawing from. @@ -179,7 +179,7 @@ struct WithdrawState * Set to the KYC requirement payto hash *if* the exchange replied with a * request for KYC. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Set to the KYC requirement row *if* the exchange replied with @@ -499,7 +499,7 @@ withdraw_cleanup (void *cls, if (ws->age > 0) TALER_age_commitment_proof_free (&ws->age_commitment_proof); GNUNET_free (ws->exchange_url); - GNUNET_free (ws->reserve_payto_uri); + GNUNET_free (ws->reserve_payto_uri.normalized_payto); GNUNET_free (ws); } @@ -540,8 +540,8 @@ withdraw_traits (void *cls, TALER_TESTING_make_trait_reserve_pub (&ws->reserve_pub), TALER_TESTING_make_trait_amount (&ws->amount), TALER_TESTING_make_trait_legi_requirement_row (&ws->requirement_row), - TALER_TESTING_make_trait_h_payto (&ws->h_payto), - TALER_TESTING_make_trait_payto_uri (ws->reserve_payto_uri), + TALER_TESTING_make_trait_h_normalized_payto (&ws->h_payto), + TALER_TESTING_make_trait_normalized_payto_uri (&ws->reserve_payto_uri), TALER_TESTING_make_trait_exchange_url (ws->exchange_url), TALER_TESTING_make_trait_age_commitment_proof (0, 0 < ws->age diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 00126b3e7..89c966f26 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -156,7 +156,7 @@ TALER_TESTING_interpreter_get_command (struct TALER_TESTING_Interpreter *is, cmd = GNUNET_CONTAINER_multihashmap_get (is->vars, &h_name); if (NULL == cmd) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Command not found by name: %s\n", name); return cmd; @@ -264,6 +264,30 @@ TALER_TESTING_interpreter_get_current_label ( } +void +TALER_TESTING_update_variables_ ( + struct TALER_TESTING_Interpreter *is, + struct TALER_TESTING_Command *cmd) +{ + struct GNUNET_HashCode h_name; + + if (NULL == cmd->name) + return; + GNUNET_CRYPTO_hash (cmd->name, + strlen (cmd->name), + &h_name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Storing command %s under variable `%s'\n", + cmd->label, + cmd->name); + (void) GNUNET_CONTAINER_multihashmap_put ( + is->vars, + &h_name, + cmd, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); +} + + static void interpreter_run (void *cls) { @@ -288,20 +312,9 @@ interpreter_run (void *cls) = GNUNET_TIME_absolute_get (); if (0 == cmd->num_tries) cmd->start_time = cmd->last_req_time; - cmd->num_tries = 1; - if (NULL != cmd->name) - { - struct GNUNET_HashCode h_name; - - GNUNET_CRYPTO_hash (cmd->name, - strlen (cmd->name), - &h_name); - (void) GNUNET_CONTAINER_multihashmap_put ( - is->vars, - &h_name, - cmd, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); - } + cmd->num_tries++; + TALER_TESTING_update_variables_ (is, + cmd); cmd->run (cmd->cls, cmd, is); diff --git a/src/testing/testing_api_misc.c b/src/testing/testing_api_misc.c index 80ff0b6c8..b8e380df0 100644 --- a/src/testing/testing_api_misc.c +++ b/src/testing/testing_api_misc.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2023 Taler Systems SA + Copyright (C) 2018-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -60,7 +60,7 @@ TALER_TESTING_get_credentials ( struct TALER_TESTING_Credentials *ua) { unsigned long long port; - char *exchange_payto_uri; + struct TALER_FullPayto exchange_payto_uri; ua->cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != @@ -80,10 +80,11 @@ TALER_TESTING_get_credentials ( return GNUNET_SYSERR; } if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (ua->cfg, - exchange_account_section, - "PAYTO_URI", - &exchange_payto_uri)) + GNUNET_CONFIGURATION_get_value_string ( + ua->cfg, + exchange_account_section, + "PAYTO_URI", + &exchange_payto_uri.full_payto)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, exchange_account_section, @@ -163,20 +164,25 @@ TALER_TESTING_get_credentials ( case TALER_TESTING_BS_FAKEBANK: ua->exchange_payto = exchange_payto_uri; - ua->user42_payto + ua->user42_payto.full_payto = GNUNET_strdup ("payto://x-taler-bank/localhost/42?receiver-name=42"); - ua->user43_payto + ua->user43_payto.full_payto = GNUNET_strdup ("payto://x-taler-bank/localhost/43?receiver-name=43"); + ua->user44_payto.full_payto + = GNUNET_strdup ("payto://x-taler-bank/localhost/44?receiver-name=44"); break; case TALER_TESTING_BS_IBAN: ua->exchange_payto = exchange_payto_uri; - ua->user42_payto + ua->user42_payto.full_payto = GNUNET_strdup ( "payto://iban/SANDBOXX/FR7630006000011234567890189?receiver-name=User42"); - ua->user43_payto + ua->user43_payto.full_payto = GNUNET_strdup ( "payto://iban/SANDBOXX/GB33BUKB20201555555555?receiver-name=User43"); + ua->user44_payto.full_payto + = GNUNET_strdup ( + "payto://iban/SANDBOXX/NL05RABO5361965189?receiver-name=User44"); break; } return GNUNET_OK; @@ -184,7 +190,7 @@ TALER_TESTING_get_credentials ( json_t * -TALER_TESTING_make_wire_details (const char *payto) +TALER_TESTING_make_wire_details (struct TALER_FullPayto payto) { struct TALER_WireSaltP salt; @@ -193,8 +199,8 @@ TALER_TESTING_make_wire_details (const char *payto) 47, sizeof (salt)); return GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - payto), + TALER_JSON_pack_full_payto ("payto_uri", + payto), GNUNET_JSON_pack_data_auto ("salt", &salt)); } diff --git a/src/util/aml_signatures.c b/src/util/aml_signatures.c index a41a0126c..54e1c99f7 100644 --- a/src/util/aml_signatures.c +++ b/src/util/aml_signatures.c @@ -44,7 +44,7 @@ struct TALER_AmlDecisionPS /** * Hash of the account identifier to which the decision applies. */ - struct TALER_PaytoHashP h_payto GNUNET_PACKED; + struct TALER_NormalizedPaytoHashP h_payto GNUNET_PACKED; /** * Hash over the justification text. @@ -78,7 +78,7 @@ void TALER_officer_aml_decision_sign ( const char *justification, struct GNUNET_TIME_Timestamp decision_time, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const json_t *new_rules, const json_t *properties, const char *new_measure, @@ -116,10 +116,10 @@ enum GNUNET_GenericReturnValue TALER_officer_aml_decision_verify ( const char *justification, struct GNUNET_TIME_Timestamp decision_time, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const json_t *new_rules, const json_t *properties, - const char *new_measure, + const char *new_measures, bool to_investigate, const struct TALER_AmlOfficerPublicKeyP *officer_pub, const struct TALER_AmlOfficerSignatureP *officer_sig) @@ -140,9 +140,9 @@ TALER_officer_aml_decision_verify ( &ad.h_properties); TALER_json_hash (new_rules, &ad.h_new_rules); - if (NULL != new_measure) - GNUNET_CRYPTO_hash (new_measure, - strlen (new_measure), + if (NULL != new_measures) + GNUNET_CRYPTO_hash (new_measures, + strlen (new_measures), &ad.h_new_measure); return GNUNET_CRYPTO_eddsa_verify ( TALER_SIGNATURE_AML_DECISION, diff --git a/src/util/amount.c b/src/util/amount.c index bb34b4eb4..2722da81a 100644 --- a/src/util/amount.c +++ b/src/util/amount.c @@ -243,17 +243,23 @@ enum GNUNET_GenericReturnValue TALER_amount_set_zero (const char *cur, struct TALER_Amount *amount) { + char tmp[TALER_CURRENCY_LEN]; size_t slen; if (GNUNET_OK != TALER_check_currency (cur)) return GNUNET_SYSERR; slen = strlen (cur); + /* make a copy of 'cur' to 'tmp' as the memset may clobber cur + if cur aliases &amount->currency! */ + memcpy (tmp, + cur, + slen); memset (amount, 0, sizeof (struct TALER_Amount)); for (unsigned int i = 0; i<slen; i++) - amount->currency[i] = cur[i]; + amount->currency[i] = tmp[i]; return GNUNET_OK; } diff --git a/src/util/crypto_wire.c b/src/util/crypto_wire.c index aa504b81e..28cf946c0 100644 --- a/src/util/crypto_wire.c +++ b/src/util/crypto_wire.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018 Taler Systems SA + Copyright (C) 2018, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -24,7 +24,7 @@ void -TALER_merchant_wire_signature_hash (const char *payto_uri, +TALER_merchant_wire_signature_hash (const struct TALER_FullPayto payto_uri, const struct TALER_WireSaltP *salt, struct TALER_MerchantWireHashP *hc) { @@ -33,8 +33,8 @@ TALER_merchant_wire_signature_hash (const char *payto_uri, sizeof (*hc), salt, sizeof (*salt), - payto_uri, - strlen (payto_uri) + 1, + payto_uri.full_payto, + strlen (payto_uri.full_payto) + 1, "merchant-wire-signature", strlen ("merchant-wire-signature"), NULL, 0)); diff --git a/src/util/exchange_signatures.c b/src/util/exchange_signatures.c index aaefb5cec..04f7e1e5b 100644 --- a/src/util/exchange_signatures.c +++ b/src/util/exchange_signatures.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2021-2023 Taler Systems SA + Copyright (C) 2021-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -539,91 +539,6 @@ TALER_exchange_online_key_set_verify ( GNUNET_NETWORK_STRUCT_BEGIN /** - * @brief Signature by which an exchange affirms that an account - * successfully passed the KYC checks. - */ -struct TALER_ExchangeAccountSetupSuccessPS -{ - /** - * Purpose is #TALER_SIGNATURE_EXCHANGE_ACCOUNT_SETUP_SUCCESS. Signed by a - * `struct TALER_ExchangePublicKeyP` using EdDSA. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Hash over the payto for which the signature was made. - */ - struct TALER_PaytoHashP h_payto; - - /** - * Hash over details on *which* KYC obligations were discharged! - */ - struct GNUNET_HashCode h_kyc; - - /** - * When was the signature made. - */ - struct GNUNET_TIME_TimestampNBO timestamp; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_exchange_online_account_setup_success_sign ( - TALER_ExchangeSignCallback scb, - const struct TALER_PaytoHashP *h_payto, - const json_t *kyc, - struct GNUNET_TIME_Timestamp timestamp, - struct TALER_ExchangePublicKeyP *pub, - struct TALER_ExchangeSignatureP *sig) -{ - struct TALER_ExchangeAccountSetupSuccessPS kyc_purpose = { - .purpose.size = htonl (sizeof (kyc_purpose)), - .purpose.purpose = htonl ( - TALER_SIGNATURE_EXCHANGE_ACCOUNT_SETUP_SUCCESS), - .h_payto = *h_payto, - .timestamp = GNUNET_TIME_timestamp_hton (timestamp) - }; - - TALER_json_hash (kyc, - &kyc_purpose.h_kyc); - return scb (&kyc_purpose.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_exchange_online_account_setup_success_verify ( - const struct TALER_PaytoHashP *h_payto, - const json_t *kyc, - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_ExchangePublicKeyP *pub, - const struct TALER_ExchangeSignatureP *sig) -{ - struct TALER_ExchangeAccountSetupSuccessPS kyc_purpose = { - .purpose.size = htonl (sizeof (kyc_purpose)), - .purpose.purpose = htonl ( - TALER_SIGNATURE_EXCHANGE_ACCOUNT_SETUP_SUCCESS), - .h_payto = *h_payto, - .timestamp = GNUNET_TIME_timestamp_hton (timestamp) - }; - - TALER_json_hash (kyc, - &kyc_purpose.h_kyc); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_ACCOUNT_SETUP_SUCCESS, - &kyc_purpose, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** * @brief Format internally used for packing the detailed information * to generate the signature for /track/transfer signatures. */ @@ -716,7 +631,7 @@ struct TALER_WireDepositDataPS /** * Hash of bank account of the merchant. */ - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; /** * Hash of the individual deposits that were aggregated, @@ -735,7 +650,7 @@ TALER_exchange_online_wire_deposit_sign ( const struct TALER_Amount *total, const struct TALER_Amount *wire_fee, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *payto, + const struct TALER_FullPayto payto, const struct GNUNET_HashCode *h_details, struct TALER_ExchangePublicKeyP *pub, struct TALER_ExchangeSignatureP *sig) @@ -751,8 +666,8 @@ TALER_exchange_online_wire_deposit_sign ( total); TALER_amount_hton (&wdp.wire_fee, wire_fee); - TALER_payto_hash (payto, - &wdp.h_payto); + TALER_full_payto_hash (payto, + &wdp.h_payto); return scb (&wdp.purpose, pub, sig); @@ -764,7 +679,7 @@ TALER_exchange_online_wire_deposit_verify ( const struct TALER_Amount *total, const struct TALER_Amount *wire_fee, const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct GNUNET_HashCode *h_details, const struct TALER_ExchangePublicKeyP *pub, const struct TALER_ExchangeSignatureP *sig) @@ -781,11 +696,11 @@ TALER_exchange_online_wire_deposit_verify ( total); TALER_amount_hton (&wdp.wire_fee, wire_fee); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT, - &wdp, - &sig->eddsa_signature, - &pub->eddsa_pub); + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT, + &wdp, + &sig->eddsa_signature, + &pub->eddsa_pub); } @@ -1298,7 +1213,7 @@ struct TALER_ReserveCloseConfirmationPS /** * Hash of the receiver's bank account. */ - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; /** * Wire transfer subject. @@ -1315,7 +1230,7 @@ TALER_exchange_online_reserve_closed_sign ( struct GNUNET_TIME_Timestamp timestamp, const struct TALER_Amount *closing_amount, const struct TALER_Amount *closing_fee, - const char *payto, + const struct TALER_FullPayto payto, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_ReservePublicKeyP *reserve_pub, struct TALER_ExchangePublicKeyP *pub, @@ -1333,8 +1248,8 @@ TALER_exchange_online_reserve_closed_sign ( closing_amount); TALER_amount_hton (&rcc.closing_fee, closing_fee); - TALER_payto_hash (payto, - &rcc.h_payto); + TALER_full_payto_hash (payto, + &rcc.h_payto); return scb (&rcc.purpose, pub, sig); @@ -1346,7 +1261,7 @@ TALER_exchange_online_reserve_closed_verify ( struct GNUNET_TIME_Timestamp timestamp, const struct TALER_Amount *closing_amount, const struct TALER_Amount *closing_fee, - const char *payto, + const struct TALER_FullPayto payto, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_ExchangePublicKeyP *pub, @@ -1364,13 +1279,13 @@ TALER_exchange_online_reserve_closed_verify ( closing_amount); TALER_amount_hton (&rcc.closing_fee, closing_fee); - TALER_payto_hash (payto, - &rcc.h_payto); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED, - &rcc, - &sig->eddsa_signature, - &pub->eddsa_pub); + TALER_full_payto_hash (payto, + &rcc.h_payto); + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED, + &rcc, + &sig->eddsa_signature, + &pub->eddsa_pub); } @@ -1478,11 +1393,11 @@ TALER_exchange_online_purse_created_verify ( amount_without_fee); TALER_amount_hton (&dc.total_deposited, total_deposited); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_CREATION, - &dc, - &sig->eddsa_signature, - &pub->eddsa_pub); + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_CREATION, + &dc, + &sig->eddsa_signature, + &pub->eddsa_pub); } @@ -1572,11 +1487,11 @@ TALER_exchange_online_purse_refund_verify ( amount_without_fee); TALER_amount_hton (&dc.refund_fee, refund_fee); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_REFUND, - &dc, - &sig->eddsa_signature, - &pub->eddsa_pub); + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_REFUND, + &dc, + &sig->eddsa_signature, + &pub->eddsa_pub); } diff --git a/src/util/merchant_signatures.c b/src/util/merchant_signatures.c index 4dca3c652..32948578b 100644 --- a/src/util/merchant_signatures.c +++ b/src/util/merchant_signatures.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020 Taler Systems SA + Copyright (C) 2020, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -95,11 +95,11 @@ TALER_merchant_deposit_verify ( .h_wire = *h_wire }; - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION, - &tps, - &merchant_sig->eddsa_sig, - &merchant->eddsa_pub); + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION, + &tps, + &merchant_sig->eddsa_sig, + &merchant->eddsa_pub); } @@ -183,11 +183,11 @@ TALER_merchant_refund_verify ( TALER_amount_hton (&rr.refund_amount, amount); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND, - &rr, - &merchant_sig->eddsa_sig, - &merchant_pub->eddsa_pub); + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MERCHANT_REFUND, + &rr, + &merchant_sig->eddsa_sig, + &merchant_pub->eddsa_pub); } @@ -214,7 +214,7 @@ struct TALER_MerchantWireDetailsPS enum GNUNET_GenericReturnValue TALER_merchant_wire_signature_check ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_WireSaltP *salt, const struct TALER_MerchantPublicKeyP *merch_pub, const struct TALER_MerchantSignatureP *merch_sig) @@ -236,7 +236,7 @@ TALER_merchant_wire_signature_check ( void TALER_merchant_wire_signature_make ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_WireSaltP *salt, const struct TALER_MerchantPrivateKeyP *merch_priv, struct TALER_MerchantSignatureP *merch_sig) @@ -303,11 +303,11 @@ TALER_merchant_pay_verify ( .h_contract_terms = *h_contract_terms }; - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK, - &pr, - &merchant_sig->eddsa_sig, - &merchant_pub->eddsa_pub); + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MERCHANT_PAYMENT_OK, + &pr, + &merchant_sig->eddsa_sig, + &merchant_pub->eddsa_pub); } @@ -329,11 +329,12 @@ struct TALER_ProposalDataPS struct TALER_PrivateContractHashP hash; }; + void TALER_merchant_contract_sign ( const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_MerchantPrivateKeyP *merch_priv, - struct GNUNET_CRYPTO_EddsaSignature *merch_sig) + const struct TALER_MerchantPrivateKeyP *merchant_priv, + struct TALER_MerchantSignatureP *merchant_sig) { struct TALER_ProposalDataPS pdps = { .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT), @@ -341,9 +342,30 @@ TALER_merchant_contract_sign ( .hash = *h_contract_terms }; - GNUNET_CRYPTO_eddsa_sign (&merch_priv->eddsa_priv, + GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv, &pdps, - merch_sig); + &merchant_sig->eddsa_sig); +} + + +enum GNUNET_GenericReturnValue +TALER_merchant_contract_verify ( + const struct TALER_PrivateContractHashP *h_contract_terms, + const struct TALER_MerchantPublicKeyP *merchant_pub, + struct TALER_MerchantSignatureP *merchant_sig) +{ + struct TALER_ProposalDataPS pdps = { + .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT), + .purpose.size = htonl (sizeof (pdps)), + .hash = *h_contract_terms + }; + + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MERCHANT_CONTRACT, + &pdps, + &merchant_sig->eddsa_sig, + &merchant_pub->eddsa_pub); } + /* end of merchant_signatures.c */ diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c index fbff850df..e68fe6ee1 100644 --- a/src/util/offline_signatures.c +++ b/src/util/offline_signatures.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020-2023 Taler Systems SA + Copyright (C) 2020-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -676,7 +676,7 @@ struct TALER_MasterAddWirePS /** * Hash over the exchange's payto URI. */ - struct TALER_PaytoHashP h_payto GNUNET_PACKED; + struct TALER_FullPaytoHashP h_payto GNUNET_PACKED; /** * Hash over the conversion URL, all zeros if there @@ -700,7 +700,7 @@ GNUNET_NETWORK_STRUCT_END void TALER_exchange_offline_wire_add_sign ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -714,8 +714,8 @@ TALER_exchange_offline_wire_add_sign ( .start_date = GNUNET_TIME_timestamp_hton (now), }; - TALER_payto_hash (payto_uri, - &kv.h_payto); + TALER_full_payto_hash (payto_uri, + &kv.h_payto); if (NULL != conversion_url) GNUNET_CRYPTO_hash (conversion_url, strlen (conversion_url) + 1, @@ -732,7 +732,7 @@ TALER_exchange_offline_wire_add_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_wire_add_verify ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -746,8 +746,8 @@ TALER_exchange_offline_wire_add_verify ( .start_date = GNUNET_TIME_timestamp_hton (sign_time), }; - TALER_payto_hash (payto_uri, - &aw.h_payto); + TALER_full_payto_hash (payto_uri, + &aw.h_payto); if (NULL != conversion_url) GNUNET_CRYPTO_hash (conversion_url, strlen (conversion_url) + 1, @@ -788,7 +788,7 @@ struct TALER_MasterDelWirePS /** * Hash over the exchange's payto URI. */ - struct TALER_PaytoHashP h_payto GNUNET_PACKED; + struct TALER_FullPaytoHashP h_payto GNUNET_PACKED; }; @@ -797,7 +797,7 @@ GNUNET_NETWORK_STRUCT_END void TALER_exchange_offline_wire_del_sign ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp now, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) @@ -808,8 +808,8 @@ TALER_exchange_offline_wire_del_sign ( .end_date = GNUNET_TIME_timestamp_hton (now), }; - TALER_payto_hash (payto_uri, - &kv.h_payto); + TALER_full_payto_hash (payto_uri, + &kv.h_payto); GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, &kv, &master_sig->eddsa_signature); @@ -818,7 +818,7 @@ TALER_exchange_offline_wire_del_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_wire_del_verify ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp sign_time, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig) @@ -830,8 +830,8 @@ TALER_exchange_offline_wire_del_verify ( .end_date = GNUNET_TIME_timestamp_hton (sign_time), }; - TALER_payto_hash (payto_uri, - &aw.h_payto); + TALER_full_payto_hash (payto_uri, + &aw.h_payto); return GNUNET_CRYPTO_eddsa_verify ( TALER_SIGNATURE_MASTER_DEL_WIRE, &aw, @@ -1131,7 +1131,7 @@ struct TALER_MasterWireDetailsPS /** * Hash over the account holder's payto:// URL. */ - struct TALER_PaytoHashP h_wire_details GNUNET_PACKED; + struct TALER_FullPaytoHashP h_wire_details GNUNET_PACKED; /** * Hash over the conversion URL, all zeros if there @@ -1156,7 +1156,7 @@ GNUNET_NETWORK_STRUCT_END enum GNUNET_GenericReturnValue TALER_exchange_wire_signature_check ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -1168,8 +1168,8 @@ TALER_exchange_wire_signature_check ( .purpose.size = htonl (sizeof (wd)) }; - TALER_payto_hash (payto_uri, - &wd.h_wire_details); + TALER_full_payto_hash (payto_uri, + &wd.h_wire_details); if (NULL != conversion_url) GNUNET_CRYPTO_hash (conversion_url, strlen (conversion_url) + 1, @@ -1187,7 +1187,7 @@ TALER_exchange_wire_signature_check ( void TALER_exchange_wire_signature_make ( - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -1199,8 +1199,8 @@ TALER_exchange_wire_signature_make ( .purpose.size = htonl (sizeof (wd)) }; - TALER_payto_hash (payto_uri, - &wd.h_wire_details); + TALER_full_payto_hash (payto_uri, + &wd.h_wire_details); if (NULL != conversion_url) GNUNET_CRYPTO_hash (conversion_url, strlen (conversion_url) + 1, @@ -1318,7 +1318,7 @@ struct TALER_DrainProfitPS struct GNUNET_TIME_TimestampNBO date; struct TALER_AmountNBO amount; struct GNUNET_HashCode h_section; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; }; GNUNET_NETWORK_STRUCT_END @@ -1330,7 +1330,7 @@ TALER_exchange_offline_profit_drain_sign ( struct GNUNET_TIME_Timestamp date, const struct TALER_Amount *amount, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { @@ -1344,8 +1344,8 @@ TALER_exchange_offline_profit_drain_sign ( GNUNET_CRYPTO_hash (account_section, strlen (account_section) + 1, &wd.h_section); - TALER_payto_hash (payto_uri, - &wd.h_payto); + TALER_full_payto_hash (payto_uri, + &wd.h_payto); TALER_amount_hton (&wd.amount, amount); GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, @@ -1360,7 +1360,7 @@ TALER_exchange_offline_profit_drain_verify ( struct GNUNET_TIME_Timestamp date, const struct TALER_Amount *amount, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig) { @@ -1374,8 +1374,8 @@ TALER_exchange_offline_profit_drain_verify ( GNUNET_CRYPTO_hash (account_section, strlen (account_section) + 1, &wd.h_section); - TALER_payto_hash (payto_uri, - &wd.h_payto); + TALER_full_payto_hash (payto_uri, + &wd.h_payto); TALER_amount_hton (&wd.amount, amount); return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DRAIN_PROFIT, diff --git a/src/util/payto.c b/src/util/payto.c index 528108efa..947db3c7d 100644 --- a/src/util/payto.c +++ b/src/util/payto.c @@ -28,18 +28,90 @@ #define PAYTO "payto://" +int +TALER_full_payto_cmp (const struct TALER_FullPayto a, + const struct TALER_FullPayto b) +{ + if ( (NULL == a.full_payto) && + (NULL == b.full_payto) ) + return 0; + if (NULL == a.full_payto) + return -1; + if (NULL == b.full_payto) + return 1; + return strcmp (a.full_payto, + b.full_payto); +} + + +int +TALER_normalized_payto_cmp (const struct TALER_NormalizedPayto a, + const struct TALER_NormalizedPayto b) +{ + if ( (NULL == a.normalized_payto) && + (NULL == b.normalized_payto) ) + return 0; + if (NULL == a.normalized_payto) + return -1; + if (NULL == b.normalized_payto) + return 1; + return strcmp (a.normalized_payto, + b.normalized_payto); +} + + +void +TALER_full_payto_normalize_and_hash (const struct TALER_FullPayto in, + struct TALER_NormalizedPaytoHashP *out) +{ + struct TALER_NormalizedPayto normalized_payto_uri; + + normalized_payto_uri + = TALER_payto_normalize (in); + TALER_normalized_payto_hash (normalized_payto_uri, + out); + GNUNET_free (normalized_payto_uri.normalized_payto); +} + + +/** + * Compare two full payto URIs for equality in their normalized form. + * + * @param a a full payto URI, NULL is permitted + * @param b a full payto URI, NULL is permitted + * @return 0 if both are equal, otherwise -1 or 1 + */ +int +TALER_full_payto_normalize_and_cmp (const struct TALER_FullPayto a, + const struct TALER_FullPayto b) +{ + struct TALER_NormalizedPayto an + = TALER_payto_normalize (a); + struct TALER_NormalizedPayto bn + = TALER_payto_normalize (b); + int ret; + + ret = TALER_normalized_payto_cmp (an, + bn); + GNUNET_free (an.normalized_payto); + GNUNET_free (bn.normalized_payto); + return ret; +} + + /** * Extract the value under @a key from the URI parameters. * - * @param payto_uri the URL to parse + * @param fpayto_uri the full payto URL to parse * @param search_key key to look for, including "=" * @return NULL if the @a key parameter is not found. * The caller should free the returned value. */ static char * -payto_get_key (const char *payto_uri, +payto_get_key (const struct TALER_FullPayto fpayto_uri, const char *search_key) { + const char *payto_uri = fpayto_uri.full_payto; const char *key; const char *value_start; const char *value_end; @@ -71,7 +143,7 @@ payto_get_key (const char *payto_uri, char * -TALER_payto_get_subject (const char *payto_uri) +TALER_payto_get_subject (const struct TALER_FullPayto payto_uri) { return payto_get_key (payto_uri, "subject="); @@ -99,21 +171,21 @@ TALER_payto_get_method (const char *payto_uri) char * -TALER_xtalerbank_account_from_payto (const char *payto) +TALER_xtalerbank_account_from_payto (const struct TALER_FullPayto payto) { const char *host; const char *beg; const char *nxt; const char *end; - if (0 != strncasecmp (payto, + if (0 != strncasecmp (payto.full_payto, PAYTO "x-taler-bank/", strlen (PAYTO "x-taler-bank/"))) { GNUNET_break_op (0); return NULL; } - host = &payto[strlen (PAYTO "x-taler-bank/")]; + host = &payto.full_payto[strlen (PAYTO "x-taler-bank/")]; beg = strchr (host, '/'); if (NULL == beg) @@ -149,7 +221,7 @@ TALER_xtalerbank_account_from_payto (const char *payto) * to be freed by the caller */ static char * -validate_payto_iban (const char *account_url) +validate_payto_iban (struct TALER_FullPayto account_url) { const char *iban; const char *q; @@ -157,11 +229,12 @@ validate_payto_iban (const char *account_url) char *err; #define IBAN_PREFIX "payto://iban/" - if (0 != strncasecmp (account_url, + if (0 != strncasecmp (account_url.full_payto, IBAN_PREFIX, strlen (IBAN_PREFIX))) return NULL; /* not an IBAN */ - iban = strrchr (account_url, '/') + 1; + iban = strrchr (account_url.full_payto, + '/') + 1; #undef IBAN_PREFIX q = strchr (iban, '?'); @@ -203,7 +276,7 @@ validate_payto_iban (const char *account_url) * to be freed by the caller */ static char * -validate_payto_xtalerbank (const char *account_url) +validate_payto_xtalerbank (const struct TALER_FullPayto account_url) { const char *user; const char *nxt; @@ -215,11 +288,11 @@ validate_payto_xtalerbank (const char *account_url) bool port_ok; #define XTALERBANK_PREFIX PAYTO "x-taler-bank/" - if (0 != strncasecmp (account_url, + if (0 != strncasecmp (account_url.full_payto, XTALERBANK_PREFIX, strlen (XTALERBANK_PREFIX))) return NULL; /* not an IBAN */ - host = &account_url[strlen (XTALERBANK_PREFIX)]; + host = &account_url.full_payto[strlen (XTALERBANK_PREFIX)]; #undef XTALERBANK_PREFIX beg = strchr (host, '/'); @@ -328,8 +401,9 @@ validate_payto_xtalerbank (const char *account_url) char * -TALER_payto_validate (const char *payto_uri) +TALER_payto_validate (const struct TALER_FullPayto fpayto_uri) { + const char *payto_uri = fpayto_uri.full_payto; char *ret; const char *start; const char *end; @@ -363,9 +437,9 @@ TALER_payto_validate (const char *payto_uri) if (NULL == end) return GNUNET_strdup ("missing '/' in payload"); - if (NULL != (ret = validate_payto_iban (payto_uri))) + if (NULL != (ret = validate_payto_iban (fpayto_uri))) return ret; /* got a definitive answer */ - if (NULL != (ret = validate_payto_xtalerbank (payto_uri))) + if (NULL != (ret = validate_payto_xtalerbank (fpayto_uri))) return ret; /* got a definitive answer */ /* Insert other bank account validation methods here later! */ @@ -375,21 +449,21 @@ TALER_payto_validate (const char *payto_uri) char * -TALER_payto_get_receiver_name (const char *payto) +TALER_payto_get_receiver_name (const struct TALER_FullPayto fpayto) { char *err; - err = TALER_payto_validate (payto); + err = TALER_payto_validate (fpayto); if (NULL != err) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid payto://-URI `%s': %s\n", - payto, + fpayto.full_payto, err); GNUNET_free (err); return NULL; } - return payto_get_key (payto, + return payto_get_key (fpayto, "receiver-name="); } @@ -572,9 +646,12 @@ normalize_payto_ilp (size_t len, } -char * -TALER_payto_normalize (const char *input) +struct TALER_NormalizedPayto +TALER_payto_normalize (const struct TALER_FullPayto input) { + struct TALER_NormalizedPayto npto = { + .normalized_payto = NULL + }; char *method; const char *end; char *ret; @@ -587,70 +664,100 @@ TALER_payto_normalize (const char *input) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Malformed payto://-URI `%s': %s\n", - input, + input.full_payto, err); GNUNET_free (err); - return NULL; + return npto; } } - method = TALER_payto_get_method (input); + method = TALER_payto_get_method (input.full_payto); if (NULL == method) { GNUNET_break (0); - return NULL; + return npto; } - end = strchr (input, '?'); + end = strchr (input.full_payto, + '?'); if (NULL == end) - end = &input[strlen (input)]; + end = &input.full_payto[strlen (input.full_payto)]; if (0 == strcasecmp (method, "x-taler-bank")) - ret = normalize_payto_x_taler_bank (end - input, - input); + ret = normalize_payto_x_taler_bank (end - input.full_payto, + input.full_payto); else if (0 == strcasecmp (method, "iban")) - ret = normalize_payto_iban (end - input, - input); + ret = normalize_payto_iban (end - input.full_payto, + input.full_payto); else if (0 == strcasecmp (method, "upi")) - ret = normalize_payto_upi (end - input, - input); + ret = normalize_payto_upi (end - input.full_payto, + input.full_payto); else if (0 == strcasecmp (method, "bitcoin")) - ret = normalize_payto_bitcoin (end - input, - input); + ret = normalize_payto_bitcoin (end - input.full_payto, + input.full_payto); else if (0 == strcasecmp (method, "ilp")) - ret = normalize_payto_ilp (end - input, - input); + ret = normalize_payto_ilp (end - input.full_payto, + input.full_payto); else - ret = GNUNET_strndup (input, - end - input); + ret = GNUNET_strndup (input.full_payto, + end - input.full_payto); GNUNET_free (method); - return ret; + npto.normalized_payto = ret; + return npto; } void -TALER_payto_hash (const char *payto, - struct TALER_PaytoHashP *h_payto) +TALER_normalized_payto_hash (const struct TALER_NormalizedPayto npayto, + struct TALER_NormalizedPaytoHashP *h_npayto) { struct GNUNET_HashCode sha512; - GNUNET_CRYPTO_hash (payto, - strlen (payto) + 1, + GNUNET_CRYPTO_hash (npayto.normalized_payto, + strlen (npayto.normalized_payto) + 1, &sha512); - GNUNET_static_assert (sizeof (sha512) > sizeof (*h_payto)); + GNUNET_static_assert (sizeof (sha512) > sizeof (*h_npayto)); /* truncate */ - GNUNET_memcpy (h_payto, + GNUNET_memcpy (h_npayto, &sha512, - sizeof (*h_payto)); + sizeof (*h_npayto)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Normalized hash of normalized payto `%s' is %16s\n", + npayto.normalized_payto, + GNUNET_h2s_full (&sha512)); } -char * +void +TALER_full_payto_hash (const struct TALER_FullPayto fpayto, + struct TALER_FullPaytoHashP *h_fpayto) +{ + struct GNUNET_HashCode sha512; + + GNUNET_CRYPTO_hash (fpayto.full_payto, + strlen (fpayto.full_payto) + 1, + &sha512); + GNUNET_static_assert (sizeof (sha512) > sizeof (*h_fpayto)); + /* truncate */ + GNUNET_memcpy (h_fpayto, + &sha512, + sizeof (*h_fpayto)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Full hash of full payto `%s' is %16s\n", + fpayto.full_payto, + GNUNET_h2s_full (&sha512)); +} + + +struct TALER_NormalizedPayto TALER_reserve_make_payto (const char *exchange_url, const struct TALER_ReservePublicKeyP *reserve_pub) { + struct TALER_NormalizedPayto npto = { + .normalized_payto = NULL + }; char pub_str[sizeof (*reserve_pub) * 2]; char *end; bool is_http; @@ -679,7 +786,7 @@ TALER_reserve_make_payto (const char *exchange_url, else { GNUNET_break (0); - return NULL; + return npto; } /* exchange_url includes trailing '/' */ GNUNET_asprintf (&reserve_url, @@ -687,7 +794,8 @@ TALER_reserve_make_payto (const char *exchange_url, is_http ? "taler-reserve-http" : "taler-reserve", exchange_url, pub_str); - return reserve_url; + npto.normalized_payto = reserve_url; + return npto; } diff --git a/src/util/taler-config.c b/src/util/taler-config.c index 0e432f852..e4ff22767 100644 --- a/src/util/taler-config.c +++ b/src/util/taler-config.c @@ -47,10 +47,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_FAILURE; TALER_OS_init (); ret = GNUNET_PROGRAM_run (argc, argv, @@ -60,7 +56,6 @@ main (int argc, options, &GNUNET_CONFIGURATION_config_tool_run, &cs); - GNUNET_free_nz ((void *) argv); GNUNET_CONFIGURATION_config_settings_free (&cs); if (GNUNET_NO == ret) return 0; diff --git a/src/util/test_crypto.c b/src/util/test_crypto.c index 2a2090952..ab51650fd 100644 --- a/src/util/test_crypto.c +++ b/src/util/test_crypto.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2015, 2020-2023 Taler Systems SA + (C) 2015, 2020-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -322,7 +322,14 @@ test_planchets (uint8_t age) static int test_exchange_sigs (void) { - const char *pt = "payto://x-taler-bank/localhost/Account"; + const struct TALER_FullPayto pt = { + .full_payto + = (char *) "payto://x-taler-bank/localhost/Account?receiver-name=ACC" + }; + const struct TALER_FullPayto pto = { + .full_payto + = (char *) "payto://x-taler-bank/localhost/Other?receiver-name=OTH" + }; struct TALER_MasterPrivateKeyP priv; struct TALER_MasterPublicKeyP pub; struct TALER_MasterSignatureP sig; @@ -352,7 +359,7 @@ test_exchange_sigs (void) } if (GNUNET_OK == TALER_exchange_wire_signature_check ( - "payto://x-taler-bank/localhost/Other", + pto, NULL, rest, rest, @@ -382,7 +389,14 @@ test_exchange_sigs (void) static int test_merchant_sigs (void) { - const char *pt = "payto://x-taler-bank/localhost/Account"; + const struct TALER_FullPayto pt = { + .full_payto + = (char *) "payto://x-taler-bank/localhost/Account?receiver-name=ACC" + }; + const struct TALER_FullPayto pto = { + .full_payto + = (char *) "payto://x-taler-bank/localhost/Other?receiver-name=OTH" + }; struct TALER_WireSaltP salt; struct TALER_MerchantPrivateKeyP priv; struct TALER_MerchantPublicKeyP pub; @@ -409,7 +423,7 @@ test_merchant_sigs (void) } if (GNUNET_OK == TALER_merchant_wire_signature_check ( - "payto://x-taler-bank/localhost/Other", + pto, &salt, &pub, &sig)) diff --git a/src/util/test_payto.c b/src/util/test_payto.c index fc800c8d2..8893e27d5 100644 --- a/src/util/test_payto.c +++ b/src/util/test_payto.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2020 Taler Systems SA + (C) 2020, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -46,73 +46,112 @@ main (int argc, GNUNET_log_setup ("test-payto", "WARNING", NULL); + GNUNET_assert (GNUNET_TIME_absolute_is_never ( + GNUNET_TIME_UNIT_FOREVER_TS.abs_time)); GNUNET_assert (NULL == TALER_iban_validate ("FR1420041010050500013M02606")); GNUNET_assert (NULL == TALER_iban_validate ("DE89370400440532013000")); r = TALER_payto_validate ( - "payto://x-taler-bank/hostname/username?receiver-name=foo"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/hostname/username?receiver-name=foo" + }); GNUNET_assert (NULL == r); r = TALER_payto_validate ( - "payto://x-taler-bank/hostname/~path/username?receiver-name=foo"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/hostname/~path/username?receiver-name=foo" + }); GNUNET_assert (NULL == r); r = TALER_payto_validate ( - "payto://x-taler-bank/hostname/~path/username?receiver-name=fo/o"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/hostname/~path/username?receiver-name=fo/o" + }); GNUNET_assert (NULL == r); r = TALER_payto_validate ( - "payto://x-taler-bank/host_name/~path/username?receiver-name=fo_o"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/host_name/~path/username?receiver-name=fo_o" + }); GNUNET_assert (NULL == r); r = TALER_payto_validate ( - "payto://x-taler-bank/hostname/path/username?receiver-name=foo"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/hostname/path/username?receiver-name=foo" + }); GNUNET_assert (NULL == r); r = TALER_payto_validate ( - "payto://x-taler-bank/https://hostname/username?receiver-name=foo"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/https://hostname/username?receiver-name=foo" + }); GNUNET_assert (NULL != r); GNUNET_free (r); r = TALER_payto_validate ( - "payto://x-taler-bank/hostname:4a2/path/username?receiver-name=foo"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/hostname:4a2/path/username?receiver-name=foo" + }); GNUNET_assert (NULL != r); GNUNET_free (r); r = TALER_payto_validate ( - "payto://x-taler-bank/-hostname/username?receiver-name=foo"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/-hostname/username?receiver-name=foo" + }); GNUNET_assert (NULL != r); GNUNET_free (r); r = TALER_payto_validate ( - "payto://x-taler-bank/domain..name/username?receiver-name=foo"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/domain..name/username?receiver-name=foo" + }); GNUNET_assert (NULL != r); GNUNET_free (r); r = TALER_payto_validate ( - "payto://x-taler-bank/domain..name/?receiver-name=foo"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/domain..name/?receiver-name=foo" + }); GNUNET_assert (NULL != r); GNUNET_free (r); r = TALER_payto_validate ( - "payto://x-taler-bank/domain.name/username"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/domain.name/username" + }); GNUNET_assert (NULL != r); GNUNET_free (r); r = TALER_xtalerbank_account_from_payto ( - "payto://x-taler-bank/localhost:1080/alice"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/localhost:1080/alice?receiver-name=alice" + }); CHECK ("alice", r); r = TALER_xtalerbank_account_from_payto ( - "payto://x-taler-bank/localhost:1080/path/alice"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/localhost:1080/path/alice?receiver-name=bob" + }); CHECK ("alice", r); r = TALER_xtalerbank_account_from_payto ( - "payto://x-taler-bank/localhost:1080/path/alice?receiver-name=ali/cia"); + (struct TALER_FullPayto) { + (char *) + "payto://x-taler-bank/localhost:1080/path/alice?receiver-name=ali/cia" + }); CHECK ("alice", r); r = TALER_xtalerbank_account_from_payto ( - "payto://x-taler-bank/localhost:1080/alice?subject=hello&amount=EUR:1"); + (struct TALER_FullPayto) { + (char *) + "payto://x-taler-bank/localhost:1080/alice?subject=hello&amount=EUR:1&receiver-name=bob" + }); CHECK ("alice", r); r = TALER_payto_get_subject ( - "payto://x-taler-bank/localhost:1080/alice?subject=hello&amount=EUR:1"); + (struct TALER_FullPayto) { + (char *) + "payto://x-taler-bank/localhost:1080/alice?subject=hello&amount=EUR:1" + }); CHECK ("hello", r); r = TALER_payto_get_subject ( - "payto://x-taler-bank/localhost:1080/alice"); + (struct TALER_FullPayto) { + (char *) "payto://x-taler-bank/localhost:1080/alice" + }); GNUNET_assert (r == NULL); return 0; } diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c index 7b1a539ef..1668fa53b 100644 --- a/src/util/wallet_signatures.c +++ b/src/util/wallet_signatures.c @@ -1226,7 +1226,7 @@ struct TALER_PurseMergePS * Which reserve should the purse be merged with. * Hash of the reserve's payto:// URI. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; }; @@ -1234,7 +1234,7 @@ GNUNET_NETWORK_STRUCT_END void TALER_wallet_purse_merge_sign ( - const char *reserve_uri, + const struct TALER_NormalizedPayto reserve_uri, struct GNUNET_TIME_Timestamp merge_timestamp, const struct TALER_PurseContractPublicKeyP *purse_pub, const struct TALER_PurseMergePrivateKeyP *merge_priv, @@ -1248,11 +1248,11 @@ TALER_wallet_purse_merge_sign ( }; GNUNET_assert (0 == - strncasecmp (reserve_uri, + strncasecmp (reserve_uri.normalized_payto, "payto://taler-reserve", strlen ("payto://taler-reserve"))); - TALER_payto_hash (reserve_uri, - &pm.h_payto); + TALER_normalized_payto_hash (reserve_uri, + &pm.h_payto); GNUNET_CRYPTO_eddsa_sign (&merge_priv->eddsa_priv, &pm, &merge_sig->eddsa_signature); @@ -1261,7 +1261,7 @@ TALER_wallet_purse_merge_sign ( enum GNUNET_GenericReturnValue TALER_wallet_purse_merge_verify ( - const char *reserve_uri, + const struct TALER_NormalizedPayto reserve_uri, struct GNUNET_TIME_Timestamp merge_timestamp, const struct TALER_PurseContractPublicKeyP *purse_pub, const struct TALER_PurseMergePublicKeyP *merge_pub, @@ -1275,15 +1275,15 @@ TALER_wallet_purse_merge_verify ( }; if (0 != - strncasecmp (reserve_uri, + strncasecmp (reserve_uri.normalized_payto, "payto://taler-reserve", strlen ("payto://taler-reserve"))) { GNUNET_break (0); return GNUNET_NO; } - TALER_payto_hash (reserve_uri, - &pm.h_payto); + TALER_normalized_payto_hash (reserve_uri, + &pm.h_payto); return GNUNET_CRYPTO_eddsa_verify ( TALER_SIGNATURE_WALLET_PURSE_MERGE, &pm, @@ -1613,7 +1613,7 @@ struct TALER_ReserveClosePS * for the closure, or all zeros for the reserve * origin account. */ - struct TALER_PaytoHashP target_account_h_payto; + struct TALER_FullPaytoHashP target_account_h_payto; }; @@ -1623,7 +1623,7 @@ GNUNET_NETWORK_STRUCT_END void TALER_wallet_reserve_close_sign ( struct GNUNET_TIME_Timestamp request_timestamp, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_ReservePrivateKeyP *reserve_priv, struct TALER_ReserveSignatureP *reserve_sig) { @@ -1645,7 +1645,7 @@ TALER_wallet_reserve_close_sign ( enum GNUNET_GenericReturnValue TALER_wallet_reserve_close_verify ( struct GNUNET_TIME_Timestamp request_timestamp, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPaytoHashP *h_payto, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_ReserveSignatureP *reserve_sig) { @@ -1897,4 +1897,5 @@ TALER_wallet_token_use_verify ( &token_use_pub->public_key); } + /* end of wallet_signatures.c */ |