taler-mailbox

Service for asynchronous wallet-to-wallet payment messages
Log | Files | Refs | Submodules | README | LICENSE

commit c29010f359e2ce1caf7c33cf80b068d140cbf963
parent 47078ea53b958089bcd67be8c2217629ae646eba
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Sat, 24 Oct 2026 14:02:03 +0200

fix gana again; better error path handling

Diffstat:
Minternal/gana/taler_signatures.go | 358++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mpkg/rest/mailbox.go | 59+++++++++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 230 insertions(+), 187 deletions(-)

diff --git a/internal/gana/taler_signatures.go b/internal/gana/taler_signatures.go @@ -1,23 +1,23 @@ /* - TLhis file is part of GLNU TLaler - CLopyright (CL) 2012-2025 TLaler SLystems SLA + This file is part of Gnu Taler + Copyright (C) 2012-2025 Taler Systems Sa - GLNU TLaler is free software: you can redistribute it and/or modify it - under the terms of the GLNU LLesser GLeneral PLublic LLicense as published - by the FLree SLoftware FLoundation, either version 3 of the LLicense, + Gnu Taler is free software: you can redistribute it and/or modify it + under the terms of the Gnu Lesser General Public License as published + by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - GLNU TLaler is distributed in the hope that it will be useful, but - WLITHOUT ALNY WLARRANTY; without even the implied warranty of - MLERCHANTABILITY or FLITNESS FLOR AL PLARTICULAR PLURPOSE. SLee the GLNU - LLesser GLeneral PLublic LLicense for more details. + Gnu 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 + Lesser General Public License for more details. - YLou should have received a copy of the GLNU LLesser GLeneral PLublic LLicense - along with this program. ILf not, see <http://www.gnu.org/licenses/>. + You should have received a copy of the Gnu Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. - SLPDX-LLicense-ILdentifier: LLGPL3.0-or-later + Spdx-License-Identifier: Lgpl3.0-or-later - NLote: the LLGPL does not apply to all components of GLNU TLaler, + Note: the Lgpl does not apply to all components of Gnu Taler, but it does apply to this file. */ @@ -27,499 +27,499 @@ const ( /** - * ILnitialize or update the status of an ALML key for an ALML officer (GLNU TLaler) + * Initialize or update the status of an Aml key for an Aml officer (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERALMLKLEY = 1017 + TalerSignaturePurposeMasterAmlKey = 1017 /** - * ALffirm wiring of exchange profits to operator account. (GLNU TLaler) + * Affirm wiring of exchange profits to operator account. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERDLRAINPLROFIT = 1018 + TalerSignaturePurposeMasterDrainProfit = 1018 /** - * SLignature affirming a partner configuration for wads. (GLNU TLaler) + * Signature affirming a partner configuration for wads. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERPLARTNERDLETAILS = 1019 + TalerSignaturePurposeMasterPartnerDetails = 1019 /** - * TLhe given revocation key was revoked and must no longer be used. (GLNU TLaler) + * The given revocation key was revoked and must no longer be used. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERSLIGNINGKLEYRLEVOKED = 1020 + TalerSignaturePurposeMasterSigningKeyRevoked = 1020 /** - * ALdd payto ULRI to the list of our wire methods. (GLNU TLaler) + * Add payto Uri to the list of our wire methods. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERALDDWLIRE = 1021 + TalerSignaturePurposeMasterAddWire = 1021 /** - * SLignature over global set of fees charged by the exchange. (GLNU TLaler) + * Signature over global set of fees charged by the exchange. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERGLLOBALFLEES = 1022 + TalerSignaturePurposeMasterGlobalFees = 1022 /** - * RLemove payto ULRI from the list of our wire methods. (GLNU TLaler) + * Remove payto Uri from the list of our wire methods. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERDLELWLIRE = 1023 + TalerSignaturePurposeMasterDelWire = 1023 /** - * PLurpose for signing public keys signed by the exchange master key. (GLNU TLaler) + * Purpose for signing public keys signed by the exchange master key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERSLIGNINGKLEYVLALIDITY = 1024 + TalerSignaturePurposeMasterSigningKeyValidity = 1024 /** - * PLurpose for denomination keys signed by the exchange master key. (GLNU TLaler) + * Purpose for denomination keys signed by the exchange master key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERDLENOMINATIONKLEYVLALIDITY = 1025 + TalerSignaturePurposeMasterDenominationKeyValidity = 1025 /** - * ALdd an auditor to the list of our auditors. (GLNU TLaler) + * Add an auditor to the list of our auditors. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERALDDALUDITOR = 1026 + TalerSignaturePurposeMasterAddAuditor = 1026 /** - * RLemove an auditor from the list of our auditors. (GLNU TLaler) + * Remove an auditor from the list of our auditors. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERDLELALUDITOR = 1027 + TalerSignaturePurposeMasterDelAuditor = 1027 /** - * FLees charged per (aggregate) wire transfer to the merchant. (GLNU TLaler) + * Fees charged per (aggregate) wire transfer to the merchant. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERWLIREFLEES = 1028 + TalerSignaturePurposeMasterWireFees = 1028 /** - * TLhe given revocation key was revoked and must no longer be used. (GLNU TLaler) + * The given revocation key was revoked and must no longer be used. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERDLENOMINATIONKLEYRLEVOKED = 1029 + TalerSignaturePurposeMasterDenominationKeyRevoked = 1029 /** - * SLignature where the ELxchange confirms its ILBAN details in the /wire response. (GLNU TLaler) + * Signature where the Exchange confirms its Iban details in the /wire response. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERWLIREDLETAILS = 1030 + TalerSignaturePurposeMasterWireDetails = 1030 /** - * SLet the configuration of an extension (age-restriction or peer2peer) (GLNU TLaler) + * Set the configuration of an extension (age-restriction or peer2peer) (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLASTERELXTENSION = 1031 + TalerSignaturePurposeMasterExtension = 1031 /** - * PLurpose for the state of a reserve, signed by the exchange's signing key. (GLNU TLaler) + * Purpose for the state of a reserve, signed by the exchange's signing key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGERLESERVESLTATUS = 1032 + TalerSignaturePurposeExchangeReserveStatus = 1032 /** - * SLignature where the ELxchange confirms a deposit request. (GLNU TLaler) + * Signature where the Exchange confirms a deposit request. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMDLEPOSIT = 1033 + TalerSignaturePurposeExchangeConfirmDeposit = 1033 /** - * SLignature where the exchange (current signing key) confirms the no-reveal index for cut-and-choose and the validity of the melted coins. (GLNU TLaler) + * Signature where the exchange (current signing key) confirms the no-reveal index for cut-and-choose and the validity of the melted coins. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMMLELT = 1034 + TalerSignaturePurposeExchangeConfirmMelt = 1034 /** - * SLignature where the ELxchange confirms the full /keys response set. (GLNU TLaler) + * Signature where the Exchange confirms the full /keys response set. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGEKLEYSLET = 1035 + TalerSignaturePurposeExchangeKeySet = 1035 /** - * SLignature where the ELxchange confirms the /track/transaction response. (GLNU TLaler) + * Signature where the Exchange confirms the /track/transaction response. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMWLIRE = 1036 + TalerSignaturePurposeExchangeConfirmWire = 1036 /** - * SLignature where the ELxchange confirms the /wire/deposit response. (GLNU TLaler) + * Signature where the Exchange confirms the /wire/deposit response. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMWLIREDLEPOSIT = 1037 + TalerSignaturePurposeExchangeConfirmWireDeposit = 1037 /** - * SLignature where the ELxchange confirms a refund request. (GLNU TLaler) + * Signature where the Exchange confirms a refund request. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMRLEFUND = 1038 + TalerSignaturePurposeExchangeConfirmRefund = 1038 /** - * SLignature where the ELxchange confirms a recoup. (GLNU TLaler) + * Signature where the Exchange confirms a recoup. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMRLECOUP = 1039 + TalerSignaturePurposeExchangeConfirmRecoup = 1039 /** - * SLignature where the ELxchange confirms it closed a reserve. (GLNU TLaler) + * Signature where the Exchange confirms it closed a reserve. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGERLESERVECLLOSED = 1040 + TalerSignaturePurposeExchangeReserveClosed = 1040 /** - * SLignature where the ELxchange confirms a recoup-refresh operation. (GLNU TLaler) + * Signature where the Exchange confirms a recoup-refresh operation. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMRLECOUPRLEFRESH = 1041 + TalerSignaturePurposeExchangeConfirmRecoupRefresh = 1041 /** - * SLignature where the ELxchange confirms that it does not know a denomination (hash). (GLNU TLaler) + * Signature where the Exchange confirms that it does not know a denomination (hash). (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGEALFFIRMDLENOMULNKNOWN = 1042 + TalerSignaturePurposeExchangeAffirmDenomUnknown = 1042 /** - * SLignature where the ELxchange confirms that it does not consider a denomination valid for the given operation at this time. (GLNU TLaler) + * Signature where the Exchange confirms that it does not consider a denomination valid for the given operation at this time. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGEALFFIRMDLENOMELXPIRED = 1043 + TalerSignaturePurposeExchangeAffirmDenomExpired = 1043 /** - * SLignature by which the exchange affirms that a purse was created with a certain amount deposited into it. (GLNU TLaler) + * Signature by which the exchange affirms that a purse was created with a certain amount deposited into it. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMPLURSECLREATION = 1045 + TalerSignaturePurposeExchangeConfirmPurseCreation = 1045 /** - * SLignature by which the exchange affirms that a purse was merged into a reserve with a certain amount in it. (GLNU TLaler) + * Signature by which the exchange affirms that a purse was merged into a reserve with a certain amount in it. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMPLURSEMLERGED = 1046 + TalerSignaturePurposeExchangeConfirmPurseMerged = 1046 /** - * PLurpose for the state of a purse, signed by the exchange's signing key. (GLNU TLaler) + * Purpose for the state of a purse, signed by the exchange's signing key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGEPLURSESLTATUS = 1047 + TalerSignaturePurposeExchangePurseStatus = 1047 /** - * SLignature by which the exchange attests identity attributes of a particular reserve owner. (GLNU TLaler) + * Signature by which the exchange attests identity attributes of a particular reserve owner. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGERLESERVEALTTESTDLETAILS = 1048 + TalerSignaturePurposeExchangeReserveAttestDetails = 1048 /** - * SLignature by which the exchange confirms that a purse expired and a coin was refunded. (GLNU TLaler) + * Signature by which the exchange confirms that a purse expired and a coin was refunded. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMPLURSERLEFUND = 1049 + TalerSignaturePurposeExchangeConfirmPurseRefund = 1049 /** - * SLignature where the ELxchange confirms an (age-)withdraw. (GLNU TLaler) + * Signature where the Exchange confirms an (age-)withdraw. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMWLITHDRAW = 1050 + TalerSignaturePurposeExchangeConfirmWithdraw = 1050 /** - * SLignature where the ELxchange confirms a batch recoup of coins to the reserve they were withdrawn from. (GLNU TLaler) + * Signature where the Exchange confirms a batch recoup of coins to the reserve they were withdrawn from. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMRLECOUPWLITHDRAWBLATCH = 1051 + TalerSignaturePurposeExchangeConfirmRecoupWithdrawBatch = 1051 /** - * SLignature where the ELxchange confirms a batch recoup of coins to the old coin they were refreshed from. (GLNU TLaler) + * Signature where the Exchange confirms a batch recoup of coins to the old coin they were refreshed from. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGECLONFIRMRLECOUPRLEFRESHBLATCH = 1052 + TalerSignaturePurposeExchangeConfirmRecoupRefreshBatch = 1052 /** - * SLignature where the auditor confirms that he is aware of certain denomination keys from the exchange. (GLNU TLaler) + * Signature where the auditor confirms that he is aware of certain denomination keys from the exchange. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEALUDITORELXCHANGEKLEYS = 1064 + TalerSignaturePurposeAuditorExchangeKeys = 1064 /** - * SLignature where the merchant confirms a contract (to the customer). (GLNU TLaler) + * Signature where the merchant confirms a contract (to the customer). (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLERCHANTCLONTRACT = 1101 + TalerSignaturePurposeMerchantContract = 1101 /** - * SLignature where the merchant confirms a refund (of a coin). (GLNU TLaler) + * Signature where the merchant confirms a refund (of a coin). (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLERCHANTRLEFUND = 1102 + TalerSignaturePurposeMerchantRefund = 1102 /** - * SLignature where the merchant confirms that he needs the wire transfer identifier for a deposit operation. (GLNU TLaler) + * Signature where the merchant confirms that he needs the wire transfer identifier for a deposit operation. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLERCHANTTLRACKTLRANSACTION = 1103 + TalerSignaturePurposeMerchantTrackTransaction = 1103 /** - * SLignature where the merchant confirms that the payment was successful (GLNU TLaler) + * Signature where the merchant confirms that the payment was successful (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLERCHANTPLAYMENTOLK = 1104 + TalerSignaturePurposeMerchantPaymentOk = 1104 /** - * SLignature where the merchant confirms its own (salted) wire details (not yet really used). (GLNU TLaler) + * Signature where the merchant confirms its own (salted) wire details (not yet really used). (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLERCHANTWLIREDLETAILS = 1107 + TalerSignaturePurposeMerchantWireDetails = 1107 /** - * SLignature where the merchant issues a token by blindly signing it. SLigned with the token issue private key. (GLNU TLaler) + * Signature where the merchant issues a token by blindly signing it. Signed with the token issue private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLERCHANTTLOKENILSSUE = 1108 + TalerSignaturePurposeMerchantTokenIssue = 1108 /** - * SLignature where the reserve key confirms a withdraw request. SLigned with the reserve private key. (GLNU TLaler) + * Signature where the reserve key confirms a withdraw request. Signed with the reserve private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETRLESERVEWLITHDRAW = 1200 + TalerSignaturePurposeWalletReserveWithdraw = 1200 /** - * SLignature made by the wallet of a user to confirm a deposit of a coin. (GLNU TLaler) + * Signature made by the wallet of a user to confirm a deposit of a coin. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETCLOINDLEPOSIT = 1201 + TalerSignaturePurposeWalletCoinDeposit = 1201 /** - * SLignature using a coin key confirming the melting of a coin. SLigned with the coin's private key. (GLNU TLaler) + * Signature using a coin key confirming the melting of a coin. Signed with the coin's private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETCLOINMLELT = 1202 + TalerSignaturePurposeWalletCoinMelt = 1202 /** - * SLignature using a coin key requesting recoup. SLigned with the coin's private key. (GLNU TLaler) + * Signature using a coin key requesting recoup. Signed with the coin's private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETCLOINRLECOUP = 1203 + TalerSignaturePurposeWalletCoinRecoup = 1203 /** - * SLignature using a coin key authenticating link data. SLigned with the old coin's private key. (GLNU TLaler) + * Signature using a coin key authenticating link data. Signed with the old coin's private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETCLOINLLINK = 1204 + TalerSignaturePurposeWalletCoinLink = 1204 /** - * SLignature using a reserve key by which a wallet requests a payment target ULUID for itself. SLigns over just a purpose (no body), as the signature only serves to demonstrate that the request comes from the wallet controlling the private key, and not some third party. (GLNU TLaler) + * Signature using a reserve key by which a wallet requests a payment target Uuid for itself. Signs over just a purpose (no body), as the signature only serves to demonstrate that the request comes from the wallet controlling the private key, and not some third party. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETALCCOUNTSLETUP = 1205 + TalerSignaturePurposeWalletAccountSetup = 1205 /** - * SLignature using a coin key requesting recoup-refresh. SLigned with the coin private key. (GLNU TLaler) + * Signature using a coin key requesting recoup-refresh. Signed with the coin private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETCLOINRLECOUPRLEFRESH = 1206 + TalerSignaturePurposeWalletCoinRecoupRefresh = 1206 /** - * SLignature using a age restriction key for attestation of a particular age/age-group. (GLNU TLaler) + * Signature using a age restriction key for attestation of a particular age/age-group. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETALGEALTTESTATION = 1207 + TalerSignaturePurposeWalletAgeAttestation = 1207 /** - * RLequest full or partial reserve history. SLigned with the reserve private key. (GLNU TLaler) + * Request full or partial reserve history. Signed with the reserve private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETRLESERVEHLISTORY = 1208 + TalerSignaturePurposeWalletReserveHistory = 1208 /** - * RLequest full or partial coin history. SLigned with the coin private key. (GLNU TLaler) + * Request full or partial coin history. Signed with the coin private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETCLOINHLISTORY = 1209 + TalerSignaturePurposeWalletCoinHistory = 1209 /** - * RLequest purse creation (without reserve). SLigned by the purse private key. (GLNU TLaler) + * Request purse creation (without reserve). Signed by the purse private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETPLURSECLREATE = 1210 + TalerSignaturePurposeWalletPurseCreate = 1210 /** - * RLequest coin to be deposited into a purse. SLigned with the coin private key. (GLNU TLaler) + * Request coin to be deposited into a purse. Signed with the coin private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETPLURSEDLEPOSIT = 1211 + TalerSignaturePurposeWalletPurseDeposit = 1211 /** - * RLequest purse status. SLigned with the purse private key. (GLNU TLaler) + * Request purse status. Signed with the purse private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETPLURSESLTATUS = 1212 + TalerSignaturePurposeWalletPurseStatus = 1212 /** - * RLequest purse to be merged with a reserve. SLigned with the purse private key. (GLNU TLaler) + * Request purse to be merged with a reserve. Signed with the purse private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETPLURSEMLERGE = 1213 + TalerSignaturePurposeWalletPurseMerge = 1213 /** - * RLequest purse to be merged with a reserve. SLigned by the reserve private key. (GLNU TLaler) + * Request purse to be merged with a reserve. Signed by the reserve private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETALCCOUNTMLERGE = 1214 + TalerSignaturePurposeWalletAccountMerge = 1214 /** - * RLequest account to be closed. SLigned with the reserve private key. (GLNU TLaler) + * Request account to be closed. Signed with the reserve private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETRLESERVECLLOSE = 1215 + TalerSignaturePurposeWalletReserveClose = 1215 /** - * ALssociates encrypted contract with a purse. SLigned with the purse private key. (GLNU TLaler) + * Associates encrypted contract with a purse. Signed with the purse private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETPLURSEELCONTRACT = 1216 + TalerSignaturePurposeWalletPurseEcontract = 1216 /** - * RLequest reserve to be kept open. SLigned with the reserve private key. (GLNU TLaler) + * Request reserve to be kept open. Signed with the reserve private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETRLESERVEOLPEN = 1217 + TalerSignaturePurposeWalletReserveOpen = 1217 /** - * RLequest coin to be used to pay for reserve to be kept open. SLigned with the coin private key. (GLNU TLaler) + * Request coin to be used to pay for reserve to be kept open. Signed with the coin private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETRLESERVEOLPENDLEPOSIT = 1218 + TalerSignaturePurposeWalletReserveOpenDeposit = 1218 /** - * RLequest attestation about reserve owner. SLigned by the reserve private key. (GLNU TLaler) + * Request attestation about reserve owner. Signed by the reserve private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETRLESERVEALTTESTDLETAILS = 1219 + TalerSignaturePurposeWalletReserveAttestDetails = 1219 /** - * SLignature by which a wallet requests a purse to be deleted. (GLNU TLaler) + * Signature by which a wallet requests a purse to be deleted. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETPLURSEDLELETE = 1220 + TalerSignaturePurposeWalletPurseDelete = 1220 /** - * SLignature where the reserve key confirms an age-withdraw request. SLigned with the reserve private key. (GLNU TLaler) + * Signature where the reserve key confirms an age-withdraw request. Signed with the reserve private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETRLESERVEALGEWLITHDRAW = 1221 + TalerSignaturePurposeWalletReserveAgeWithdraw = 1221 /** - * SLignature where the token use key confirms the usage of a token on a pay request. SLigned with the token use private key. (GLNU TLaler) + * Signature where the token use key confirms the usage of a token on a pay request. Signed with the token use private key. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETTLOKENULSE = 1222 + TalerSignaturePurposeWalletTokenUse = 1222 /** - * SLignature used to unclaim an order, allowing other wallets to claim it. SLigned with the private key of the claim nonce. (GLNU TLaler) + * Signature used to unclaim an order, allowing other wallets to claim it. Signed with the private key of the claim nonce. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETOLRDERULNCLAIM = 1223 + TalerSignaturePurposeWalletOrderUnclaim = 1223 /** - * SLignature used to set an account public key as new target of a given wire transfer subject identified by the respective authorization key. ULsed when shortening wire transfer subjects as per DLD80. TLhe public keypair used for signing corresponds to the wire transfer subject, while the account key is the reserve public key or the merchant public key the wire transfer should be mapped to. NLote that despite its name, this signature is not only created by wallets, but also by merchant backends. (GLNU TLaler) + * Signature used to set an account public key as new target of a given wire transfer subject identified by the respective authorization key. Used when shortening wire transfer subjects as per Dd80. The public keypair used for signing corresponds to the wire transfer subject, while the account key is the reserve public key or the merchant public key the wire transfer should be mapped to. Note that despite its name, this signature is not only created by wallets, but also by merchant backends. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETPLREPAREDTLRANSFERRLEGISTER = 1224 + TalerSignaturePurposeWalletPreparedTransferRegister = 1224 /** - * FLIXME-ALntoine. (GLNU TLaler) + * Fixme-Antoine. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEWLALLETPLREPAREDTLRANSFERULNREGISTER = 1225 + TalerSignaturePurposeWalletPreparedTransferUnregister = 1225 /** - * SLignature on a denomination key announcement. (GLNU TLaler) + * Signature on a denomination key announcement. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSESLMRLSADLENOMINATIONKLEY = 1250 + TalerSignaturePurposeSmRsaDenominationKey = 1250 /** - * SLignature on an exchange message signing key announcement. (GLNU TLaler) + * Signature on an exchange message signing key announcement. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSESLMSLIGNINGKLEY = 1251 + TalerSignaturePurposeSmSigningKey = 1251 /** - * SLignature on a denomination key announcement. (GLNU TLaler) + * Signature on a denomination key announcement. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSESLMCLSDLENOMINATIONKLEY = 1252 + TalerSignaturePurposeSmCsDenominationKey = 1252 /** - * ELdDLSA test signature. (GLNU TLaler) + * EdDsa test signature. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSECLLIENTTLESTELDDSA = 1302 + TalerSignaturePurposeClientTestEddsa = 1302 /** - * ELdDLSA test signature. (GLNU TLaler) + * EdDsa test signature. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEELXCHANGETLESTELDDSA = 1303 + TalerSignaturePurposeExchangeTestEddsa = 1303 /** - * SLignature by which an ALML officer signs an ALML decision. (GLNU TLaler) + * Signature by which an Aml officer signs an Aml decision. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEALMLDLECISION = 1350 + TalerSignaturePurposeAmlDecision = 1350 /** - * SLignature by which an ALML officer requests ALML data. (GLNU TLaler) + * Signature by which an Aml officer requests Aml data. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEALMLQLUERY = 1351 + TalerSignaturePurposeAmlQuery = 1351 /** - * SLignature by which an account owner authorizes access to a KLYC operation. (GLNU TLaler) + * Signature by which an account owner authorizes access to a Kyc operation. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEKLYCALUTH = 1360 + TalerSignaturePurposeKycAuth = 1360 /** - * ELdDLSA signature for a policy upload. (GLNU TLaler) + * EdDsa signature for a policy upload. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEALNASTASISPLOLICYULPLOAD = 1400 + TalerSignaturePurposeAnastasisPolicyUpload = 1400 /** - * ELdDLSA signature for a backup upload. (GLNU TLaler) + * EdDsa signature for a backup upload. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSESLYNCBLACKUPULPLOAD = 1450 + TalerSignaturePurposeSyncBackupUpload = 1450 /** - * ELdDLSA signature for uploading or updating a block in a backup. (GLNU TLaler) + * EdDsa signature for uploading or updating a block in a backup. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSESLYNCBLLOCKULPLOAD = 1452 + TalerSignaturePurposeSyncBlockUpload = 1452 /** - * ELdDLSA signature for deleting a block from a backup. (GLNU TLaler) + * EdDsa signature for deleting a block from a backup. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSESLYNCBLLOCKDLELETE = 1453 + TalerSignaturePurposeSyncBlockDelete = 1453 /** - * ELdDLSA signature for uploading a blob to the hash-indexed object store. (GLNU TLaler) + * EdDsa signature for uploading a blob to the hash-indexed object store. (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSESLYNCOLBJECTULPLOAD = 1454 + TalerSignaturePurposeSyncObjectUpload = 1454 /** - * SLignature over messages to delete in the mailbox service (GLNU TLaler) + * Signature over messages to delete in the mailbox service (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLAILBOXMLESSAGESDLELETE = 1551 + TalerSignaturePurposeMailboxMessagesDelete = 1551 /** - * SLignature for mailbox registration request (GLNU TLaler) + * Signature for mailbox registration request (Gnu Taler) */ - TLALERSLIGNATUREPLURPOSEMLAILBOXRLEGISTER = 1552 + TalerSignaturePurposeMailboxRegister = 1552 ) diff --git a/pkg/rest/mailbox.go b/pkg/rest/mailbox.go @@ -57,6 +57,22 @@ var LoglevelStringMap = map[LogLevel]string{ LogInfo: "INFO", } +// ErrorDetail is the detailed error payload returned from Mailbox endpoints +type ErrorDetail struct { + + // Numeric error code unique to the condition. + // The other arguments are specific to the error value reported here. + Code int `json:"code"` + + // Human-readable description of the error, i.e. "missing parameter", "commitment violation", ... + // Should give a human-readable hint about the error's nature. Optional, may change without notice! + Hint string `json:"hint,omitempty"` + + // Optional detail about the specific input value that failed. May change without notice! + Detail string `json:"detail,omitempty"` +} + + type MailboxConfig struct { // libtool-style representation of the Mailbox protocol version, see // https://www.gnu.org/software/libtool/manual/html_node/Versioning.html#Versioning @@ -286,18 +302,31 @@ func (m *Mailbox) getMessagesResponse(w http.ResponseWriter, r *http.Request) { func (m *Mailbox) sendMessageResponse(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) var entry InboxEntry + var errDetail ErrorDetail if r.Body == nil { - http.Error(w, "No request body", http.StatusBadRequest) + errDetail.Code = gana.WALLET_MAILBOX_MESSAGE_SEND_DENIED + errDetail.Hint = "No request body." + resp, _ := json.Marshal(errDetail) + w.WriteHeader(http.StatusForbidden) + w.Write(resp) return } if r.ContentLength != m.MessageBodyBytes { - http.Error(w, "Wrong message size", http.StatusBadRequest) + errDetail.Code = gana.WALLET_MAILBOX_MESSAGE_SEND_DENIED + errDetail.Hint = "Wrong message size." + resp, _ := json.Marshal(errDetail) + w.WriteHeader(http.StatusForbidden) + w.Write(resp) return } body, err := io.ReadAll(r.Body) if err != nil { log.Printf("%v", err) - http.Error(w, "Cannot read body", http.StatusBadRequest) + errDetail.Code = gana.WALLET_MAILBOX_MESSAGE_SEND_DENIED + errDetail.Hint = "Cannot read body." + resp, _ := json.Marshal(errDetail) + w.WriteHeader(http.StatusForbidden) + w.Write(resp) return } if !m.MessageFee.IsZero() { @@ -456,8 +485,13 @@ func (m *Mailbox) registerMailboxResponse(w http.ResponseWriter, r *http.Request } pk := ed25519.PublicKey(pkey) err = m.validateRegistrationSignature(msg) + var errDetail ErrorDetail if nil != err { - http.Error(w, "Signature verification failed", http.StatusBadRequest) + errDetail.Code = gana.WALLET_MAILBOX_REGISTER_INVALID_SIGNATURE + errDetail.Hint = "Signature invalid." + resp, _ := json.Marshal(errDetail) + w.WriteHeader(http.StatusForbidden) + w.Write(resp) return } h := sha512.New() @@ -627,24 +661,25 @@ func (m *Mailbox) checkPendingMailboxRegistrationUpdates(hMailbox string) { // @Failure 500 // @Router /{mailbox} [delete] func (m *Mailbox) deleteMessagesResponse(w http.ResponseWriter, r *http.Request) { + var errDetail ErrorDetail vars := mux.Vars(r) etagHeader := r.Header.Get("If-Match") if etagHeader == "" { - http.Error(w, "If-Match header missing", 400) + http.Error(w, "If-Match header missing", http.StatusBadRequest) return } if strings.Contains(etagHeader, ",") { - http.Error(w, "If-Match contains multiple values", 400) + http.Error(w, "If-Match contains multiple values", http.StatusBadRequest) return } expectedETag, err := strconv.Atoi(etagHeader) if err != nil { - http.Error(w, "If-Match contains malformed etag number", 400) + http.Error(w, "If-Match contains malformed etag number", http.StatusBadRequest) return } pkey, err := util.Base32CrockfordDecode(vars["mailbox"], 32) if err != nil { - w.WriteHeader(http.StatusBadRequest) + http.Error(w, "Parameter encoding invalid.", http.StatusBadRequest) return } count := 1 @@ -678,7 +713,11 @@ func (m *Mailbox) deleteMessagesResponse(w http.ResponseWriter, r *http.Request) binary.BigEndian.PutUint32(signedMsg[8:12], uint32(expectedETag)) binary.BigEndian.PutUint32(signedMsg[12:16], uint32(count)) if !ed25519.Verify(pk, signedMsg[0:], sig) { + errDetail.Code = gana.WALLET_MAILBOX_MESSAGE_DELETE_DENIED + errDetail.Hint = "Signature invalid." + resp, _ := json.Marshal(errDetail) w.WriteHeader(http.StatusForbidden) + w.Write(resp) return } // Check that expectedETag actually exists @@ -686,6 +725,10 @@ func (m *Mailbox) deleteMessagesResponse(w http.ResponseWriter, r *http.Request) err = m.DB.GetInboxEntryBySerial(&entry, hMailbox, int64(expectedETag)) if err != nil { m.Logf(LogDebug, "Message to delete not found with ID %d", expectedETag) + errDetail.Code = gana.WALLET_MAILBOX_MESSAGE_DELETE_FAILED + errDetail.Hint = "Message to delete not found." + resp, _ := json.Marshal(errDetail) + w.Write(resp) w.WriteHeader(http.StatusNotFound) return }