taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit 68b53c8f4d4c9f1d66d3f9bcd1017b704e2d5355
parent 9e66175e6fc767d6d518e67b89dc4598a756c839
Author: Antoine A <>
Date:   Wed,  4 Dec 2024 15:40:25 +0100

init rust utils & API

Diffstat:
A.gitignore | 3+++
ACargo.lock | 2905+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ACargo.toml | 16++++++++++++++++
AMakefile | 14++++++++++++++
AREADME.md | 238+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/Cargo.toml | 27+++++++++++++++++++++++++++
Ataler-api/schema.sql | 176+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/src/auth.rs | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/src/constants.rs | 20++++++++++++++++++++
Ataler-api/src/db.rs | 325+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/src/db/query_helper.rs | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/src/db/type_helper.rs | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/src/error.rs | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/src/lib.rs | 430+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/src/notification.rs | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/tests/api.rs | 369+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-api/tests/common.rs | 191+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-common/Cargo.toml | 15+++++++++++++++
Ataler-common/src/amount.rs | 306+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-common/src/api_common.rs | 296+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-common/src/api_params.rs | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-common/src/api_wire.rs | 175+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-common/src/error_code.rs | 1954+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ataler-common/src/lib.rs | 27+++++++++++++++++++++++++++
Atest-utils/Cargo.toml | 12++++++++++++
Atest-utils/src/helpers.rs | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atest-utils/src/json.rs | 42++++++++++++++++++++++++++++++++++++++++++
Atest-utils/src/lib.rs | 20++++++++++++++++++++
Atest-utils/src/routine.rs | 243+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29 files changed, 8502 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +.env +target +\ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock @@ -0,0 +1,2905 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" + +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "async-trait" +version = "0.1.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "auto-future" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1e7e457ea78e524f48639f551fd79703ac3f2237f5ecccdf4708f8a75ad373" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http 1.2.0", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper 1.0.2", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.2.0", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 1.0.2", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-test" +version = "16.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "017cbca2776229a7100ebee44e065fcf5baccea6fc4cb9e5bea8328d83863a03" +dependencies = [ + "anyhow", + "assert-json-diff", + "auto-future", + "axum", + "bytes", + "bytesize", + "cookie", + "http 1.2.0", + "http-body-util", + "hyper", + "hyper-util", + "mime", + "pretty_assertions", + "reserve-port", + "rust-multipart-rfc7578_2", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "tokio", + "tower", + "url", +] + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "base32" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "022dfe9eb35f19ebbcb51e0b40a5ab759f46ad60cadf7297e0bd085afb50e076" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +dependencies = [ + "serde", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" + +[[package]] +name = "bytesize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" + +[[package]] +name = "cc" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.52.6", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +dependencies = [ + "time", + "version_check", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +dependencies = [ + "serde", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "5.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" + +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.2.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.2.0", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.2.0", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.2.0", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +dependencies = [ + "equivalent", + "hashbrown 0.15.2", + "serde", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "js-sys" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.167" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" + +[[package]] +name = "libdeflate-sys" +version = "1.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4ae7b48098016dc3bc64a35605668f0af4425ec1a4a175ce2d0c1129067932" +dependencies = [ + "cc", +] + +[[package]] +name = "libdeflater" +version = "1.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567ff5eb948d34d3f93d8da568e72db0f5a12c89efb6c3913e4d6b142cc7ec34" +dependencies = [ + "libdeflate-sys", +] + +[[package]] +name = "libm" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "listenfd" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0500463acd96259d219abb05dc57e5a076ef04b2db9a2112846929b5f174c96" +dependencies = [ + "libc", + "uuid", + "winapi", +] + +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.52.0", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "proc-macro2" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reserve-port" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9838134a2bfaa8e1f40738fcc972ac799de6e0e06b5157acb95fc2b05a0ea283" +dependencies = [ + "lazy_static", + "thiserror 1.0.69", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rsa" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rust-multipart-rfc7578_2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b748410c0afdef2ebbe3685a6a862e2ee937127cdaae623336a459451c8d57" +dependencies = [ + "bytes", + "futures-core", + "futures-util", + "http 0.2.12", + "mime", + "mime_guess", + "rand", + "thiserror 1.0.69", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustix" +version = "0.38.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.23.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +dependencies = [ + "base64", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.7.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlformat" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bba3a93db0cc4f7bdece8bb09e77e2e785c20bfebf79eb8340ed80708048790" +dependencies = [ + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93334716a037193fac19df402f8571269c84a00852f6a7066b5d2616dcd64d3e" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d8060b456358185f7d50c55d9b5066ad956956fddec42ee2e8567134a8936e" +dependencies = [ + "atoi", + "byteorder", + "bytes", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.14.5", + "hashlink", + "hex", + "indexmap 2.7.0", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror 1.0.69", + "tokio", + "tokio-stream", + "tracing", + "url", + "webpki-roots", +] + +[[package]] +name = "sqlx-macros" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cac0692bcc9de3b073e8d747391827297e075c7710ff6276d9f7a1f3d58c6657" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" +dependencies = [ + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64bb4714269afa44aef2755150a0fc19d756fb580a67db8885608cf02f47d06a" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "bytes", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror 1.0.69", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fa91a732d854c5d7726349bb4bb879bb9478993ceb764247660aee25f67c2f8" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror 1.0.69", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5b2cf34a45953bfd3daaf3db0f7a7878ab9b7a6b91b422d24a7a9e4c857b680" +dependencies = [ + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "serde_urlencoded", + "sqlx-core", + "tracing", + "url", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "taler-api" +version = "0.1.0" +dependencies = [ + "axum", + "dashmap", + "http-body-util", + "libdeflater", + "listenfd", + "serde", + "serde_json", + "sqlx", + "taler-common", + "test-utils", + "tokio", + "tracing", + "tracing-subscriber", + "tracing-test", + "url", +] + +[[package]] +name = "taler-common" +version = "0.1.0" +dependencies = [ + "base32", + "fastrand", + "rand", + "serde", + "serde_json", + "serde_with", + "sqlx", + "thiserror 2.0.4", + "url", +] + +[[package]] +name = "tempfile" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "test-utils" +version = "0.1.0" +dependencies = [ + "axum", + "axum-test", + "serde", + "serde_json", + "taler-common", + "tokio", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +dependencies = [ + "thiserror-impl 2.0.4", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "tracing-test" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "557b891436fe0d5e0e363427fc7f217abf9ccd510d5136549847bdcbcd011d68" +dependencies = [ + "tracing-core", + "tracing-subscriber", + "tracing-test-macro", +] + +[[package]] +name = "tracing-test-macro" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicase" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" + +[[package]] +name = "unicode-bidi" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" + +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" + +[[package]] +name = "webpki-roots" +version = "0.26.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "whoami" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" +dependencies = [ + "redox_syscall", + "wasite", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml @@ -0,0 +1,15 @@ +[workspace] +resolver = "2" +members = ["taler-api", "taler-common", "test-utils"] + +[profile.dev] +debug = true + +[workspace.dependencies] +thiserror = "2.0.4" +serde_json = "1.0" +serde = "1.0" +tokio = { version = "1.42", features = ["macros"]} +axum = "0.7.9" +sqlx = "0.8" +url = { version = "2.2", features = ["serde"] } +\ No newline at end of file diff --git a/Makefile b/Makefile @@ -0,0 +1,13 @@ +all: build + +.PHONY: build +build: + cargo build + +.PHONY: check +check: + cargo test + +.PHONY: doc +doc: + cargo doc +\ No newline at end of file diff --git a/README.md b/README.md @@ -0,0 +1,237 @@ +# Depolymerization + +## Project structure + +- **wire-gateway**: + [Taler Wire Gateway HTTP API](https://docs.taler.net/core/api-wire.html) + server +- **btc-wire**: Taler wire implementation for + [bitcoincore](https://bitcoincore.org/en/about/) node +- **eth-wire**: Taler wire implementation for + [go-ethereum](https://geth.ethereum.org/) node +- **uri-pack**: Efficient probabilistic binary encoding for URI +- **db**: Database schemas +- **docs**: Documentation files +- **test**: Test scripts +- **instrumentation**: Instrumentation test tool + +## Install from source + +Cargo version 1.72.1 or above is required. You can get rustup from your +distribution package manager or from [rustup.rs](https://rustup.rs/). + +``` +git clone https://git.taler.net/depolymerization.git/ +cd depolymerization +make install +``` + +## Getting started + +### Dependencies + +Depolymerizer require: + +- taler-config from [Taler exchange](https://git.taler.net/exchange.git/) + ap +- PostgreSQL + +#### Bitcoin + +[Bitcoind](https://bitcoincore.org/) version 28.0 is expected + +#### Ethereum + +[Geth](https://geth.ethereum.org/) version 1.13.5 is expected + +### Initialization + +We expect you to already have written a [configuration](#configuration) and +that PostgreSQL and the node (bitcoind or geth) is configured and running. + +We will use `btc-wire` in command, but you can use `eth-wire` interchangeably to +depolymerize Ethereum. + +If you want to use a specific configuration file, you can add `-c CONF_PATH` to +every command. + +#### Database initialization + +``` +btc-wire initdb +``` + +#### Wallet initialization + +Depolymerization uses an encrypted wallet, so you need to provide a password in +the environment variable `PASSWORD`. + +``` +btc-wire initwallet +``` + +You then need to update your configuration with the provided `PAYTO` config +value. + +#### Start depolymerization + +``` +btc-wire +``` + +You also need to run the wire gateway `wire-gateway`. It can run from another +user as long it can access the database and the configuration file. + +## Configuration + +The configuration is based on +[taler.conf](https://docs.taler.net/manpages/taler.conf.5.html). + +You can find configurations example for each implementation: + +- btc-wire: [minimal](docs/taler-btc-min.conf) or + [full](docs/taler-btc-full.conf) +- eth-wire: [minimal](docs/taler-eth-min.conf) or + [full](docs/taler-eth-full.conf) + +### Initialization + +This is the required configuration for initialization: + +```ini +# taler.conf - (fill all ___) +[taler] +# Exchange currency +CURRENCY = ___ + +[exchange] +# Exchange base url +BASE_URL = ___ + +[depolymerizer-___] +# Postgres connection URL +DB_URL = ___ +``` + +`PAYTO` is to be added after wallet initialization. + +### Currency + +Unlike Bitcoin or Ethereum, we differentiate currencies between networks. The +following currencies are supported: + +- Bitcoin currencies (btc-wire): + - BITCOINBTC for main network + - TESTBTC for test network + - DEVBTC for regtest network +- Ethereum currencies (eth-wire): + - ETHEREUMETH for main network + - ROPSTENETH for ropsten network + - DEVETH for dev network + +### btc-wire + +btc-wire will automatically read the bitcoin configuration file (bitcoin.conf) +to connect to the RPC server. Two flags are mandatory: + +- `txindex=1`: btc-wire needs access to transactions not linked to the wire + wallet +- `maxtxfee=?`: bitcoin transactions fees can exceed taler wire fees, putting + your wire in bankruptcy. You must specify an acceptable transaction fee cap. + +It is also recommended to disable RPC client timeout with `rpcservertimeout=0` +or to set a timeout delay superior than the block delay (e.g +`rpcservertimeout=720`) to prevent recurrent "Broken pipe" errors. + +```ini +[depolymerizer-bitcoin] +# Datadir or configuration file path +CONF_PATH = ~/.bitcoin +# Number of blocks to consider a transactions durable +CONFIRMATION = 6 +# Amount to keep when bouncing malformed credit +BOUNCE_FEE = 0.00001 +``` + +### eth-wire + +```ini +[depolymerizer-ethereum] +# Datadir or ipc file path +IPC_PATH = ~/.ethereum/geth/geth.ipc +# Number of blocks to consider a transactions durable +CONFIRMATION = 37 +# Amount to keep when bouncing malformed credit +BOUNCE_FEE = 0.00001 +``` + +### Wire gateway + +```ini +[depolymerizer-___] +# Port on which the server listen +PORT = 8080 +# Path on which the server listen (replace port) +UNIXPATH = +# HTTP Authentication Scheme (basic or none) +AUTH_METHOD = +# Authentification token (base64 for basic auth) +AUTH_TOKEN = +``` + +### Process lifetime + +You may want to restart depolymerization processes regularly to improve +stability (ex. fix memory fragmentation). It is possible to configure a lifetime +that triggers a graceful shutdown every time a specific amount of work has been +done. + +```ini +[depolymerizer-___] +# Number of requests to serve before gateway shutdown (0 mean never) +HTTP_LIFETIME = 0 +# Number of worker's loops before wire implementation shutdown (0 mean never) +WIRE_LIFETIME = 0 +``` + +### Stuck transaction + +When we send a transaction with a fee too small, it may not be confirmed in a +timely fashion. To unstuck those transactions, it is possible to replace them +with other transactions with more fees. Depolymerizer can be configured to do +this automatically: + +```ini +[depolymerizer-___] +# Delay in seconds before bumping an unconfirmed transaction fee (0 mean never) +BUMP_DELAY = 0 +``` + +## Security + +Depolymerizer only use an encrypted wallet and provides an easy way to create +them. It is the administrator's responsibility to back up his wallet and +password. + +Only the wire adapter needs to have the password stored in its environment. + +## Log format + +Wire logs use an ASCII code for transaction logs: + +- `<<` for a credit +- `>>` for a debit +- `||` for a bounce + +You can have an additional context: + +- `bump ` a stuck transaction has been bumped +- `conflict ` a transaction has been canceled by a conflicting blockchain + transaction +- `recovered ` a successful transaction that we failed to register in the local + database has been found in the blockchain +- `onchain ` an unknown transaction has been found in the blockchain + +## Test + +Instrumentation test documentation can be founded in the [instrumentation](instrumentation/README.md) directory. +\ No newline at end of file diff --git a/taler-api/Cargo.toml b/taler-api/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "taler-api" +version = "0.1.0" +edition = "2021" + +[dependencies] +listenfd = "1.0.0" +tracing = "0.1" +tracing-subscriber = "0.3" +tracing-test = "0.2" +dashmap = "6.1" +sqlx = { workspace = true, features = [ + "postgres", + "runtime-tokio-rustls", + "tls-rustls-ring", +] } +http-body-util = "0.1.2" +libdeflater = "1.22.0" +tokio = { workspace = true, features = ["rt-multi-thread", "macros", "signal"] } +serde = { workspace = true, features = ["derive"] } +serde_json.workspace = true +axum.workspace = true +url.workspace = true +taler-common = { path = "../taler-common" } + +[dev-dependencies] +test-utils = { path = "../test-utils" } diff --git a/taler-api/schema.sql b/taler-api/schema.sql @@ -0,0 +1,175 @@ +BEGIN; +DROP SCHEMA public CASCADE; +CREATE SCHEMA public; + +CREATE TYPE taler_amount + AS (val INT8, frac INT4); +COMMENT ON TYPE taler_amount + IS 'Stores an amount, fraction is in units of 1/100000000 of the base value'; + +CREATE TYPE transfer_status AS ENUM ( + 'pending' + ,'transient_failure' + ,'permanent_failure' + ,'success' +); + +CREATE TABLE transfers ( + transfer_id INT8 PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY + ,amount taler_amount NOT NULL + ,exchange_base_url TEXT NOT NULL + ,subject TEXT NOT NULL + ,credit_payto TEXT NOT NULL + ,request_uid BYTEA UNIQUE NOT NULL CHECK (LENGTH(request_uid)=64) + ,wtid BYTEA UNIQUE NOT NULL CHECK (LENGTH(wtid)=32) + ,status transfer_status NOT NULL + ,status_msg TEXT + ,transfer_time INT8 NOT NULL +); + +CREATE TYPE incoming_type AS ENUM + ('reserve' ,'kyc', 'wad'); +CREATE TABLE incoming_transactions ( + incoming_transaction_id INT8 PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY + ,amount taler_amount NOT NULL + ,debit_payto TEXT NOT NULL + ,creation_time INT8 NOT NULL + ,type incoming_type NOT NULL + ,reserve_pub BYTEA UNIQUE CHECK (LENGTH(reserve_pub)=32) + ,account_pub BYTEA CHECK (LENGTH(account_pub)=32) + ,wad_id BYTEA CHECK (LENGTH(wad_id)=24) + ,origin_exchange_url TEXT + ,CONSTRAINT incoming_polymorphism CHECK( + CASE type + WHEN 'reserve' THEN reserve_pub IS NOT NULL AND account_pub IS NULL AND origin_exchange_url IS NULL AND wad_id IS NULL + WHEN 'kyc' THEN reserve_pub IS NULL AND account_pub IS NOT NULL AND origin_exchange_url IS NULL AND wad_id IS NULL + WHEN 'wad' THEN reserve_pub IS NULL AND account_pub IS NULL AND origin_exchange_url IS NOT NULL AND wad_id IS NOT NULL + END + ) +); + +CREATE FUNCTION taler_transfer( + IN in_amount taler_amount, + IN in_exchange_base_url TEXT, + IN in_subject TEXT, + IN in_credit_payto TEXT, + IN in_request_uid BYTEA, + IN in_wtid BYTEA, + IN in_timestamp INT8, + -- Error status + OUT out_request_uid_reuse BOOLEAN, + -- Success return + OUT out_tx_row_id INT8, + OUT out_timestamp INT8 +) +LANGUAGE plpgsql AS $$ +BEGIN +-- Check for idempotence and conflict +SELECT (amount != in_amount + OR credit_payto != in_credit_payto + OR exchange_base_url != in_exchange_base_url + OR wtid != in_wtid) + ,transfer_id, transfer_time + INTO out_request_uid_reuse, out_tx_row_id, out_timestamp + FROM transfers + WHERE request_uid = in_request_uid; +IF found THEN + RETURN; +END IF; +out_request_uid_reuse=false; +out_timestamp=in_timestamp; +-- Register exchange +INSERT INTO transfers ( + amount, + exchange_base_url, + subject, + credit_payto, + request_uid, + wtid, + status, + status_msg, + transfer_time +) VALUES ( + in_amount, + in_exchange_base_url, + in_subject, + in_credit_payto, + in_request_uid, + in_wtid, + 'success', + NULL, + in_timestamp +) RETURNING transfer_id INTO out_tx_row_id; +-- Notify new transaction +PERFORM pg_notify('outgoing_tx', out_tx_row_id || ''); +END $$; +COMMENT ON FUNCTION taler_transfer IS 'Create an outgoing taler transaction and register it'; + +CREATE FUNCTION add_incoming( + IN in_key BYTEA, + IN in_subject TEXT, + IN in_amount taler_amount, + IN in_debit_payto TEXT, + IN in_timestamp INT8, + IN in_type incoming_type, + -- Error status + OUT out_reserve_pub_reuse BOOLEAN, + -- Success return + OUT out_tx_row_id INT8 +) +LANGUAGE plpgsql AS $$ +BEGIN +-- Check conflict +SELECT in_type = 'reserve'::incoming_type AND EXISTS(SELECT FROM incoming_transactions WHERE reserve_pub = in_key) + INTO out_reserve_pub_reuse; +IF out_reserve_pub_reuse THEN + RETURN; +END IF; +-- Register incoming transaction +CASE in_type + WHEN 'reserve' THEN INSERT INTO incoming_transactions ( + amount, + debit_payto, + creation_time, + type, + reserve_pub, + account_pub, + wad_id, + origin_exchange_url + ) VALUES ( + in_amount, + in_debit_payto, + in_timestamp, + in_type, + in_key, + NULL, + NULL, + NULL + ) RETURNING incoming_transaction_id INTO out_tx_row_id; + WHEN 'kyc' THEN INSERT INTO incoming_transactions ( + amount, + debit_payto, + creation_time, + type, + reserve_pub, + account_pub, + wad_id, + origin_exchange_url + ) VALUES ( + in_amount, + in_debit_payto, + in_timestamp, + in_type, + NULL, + in_key, + NULL, + NULL + ) RETURNING incoming_transaction_id INTO out_tx_row_id; + ELSE RAISE EXCEPTION 'Unsupported incoming type %', in_type; +END CASE; +-- Notify new incoming transaction +PERFORM pg_notify('incoming_tx', out_tx_row_id || ''); +END $$; +COMMENT ON FUNCTION add_incoming IS 'Create an incoming taler transaction and register it'; + +COMMIT; +\ No newline at end of file diff --git a/taler-api/src/auth.rs b/taler-api/src/auth.rs @@ -0,0 +1,90 @@ +/* + 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 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/> +*/ + +use std::sync::Arc; + +use axum::{ + extract::{Request, State}, + http::header::{self}, + middleware::Next, + response::{IntoResponse, Response}, +}; +use taler_common::error_code::ErrorCode; + +use crate::error::{failure, failure_code}; + +pub enum AuthMethod { + Basic(String), + Bearer(String), + None, +} + +pub async fn auth_middleware( + State(method): State<Arc<AuthMethod>>, + req: Request, + next: Next, +) -> Response { + fn parse_auth<'a>(req: &'a Request, scheme: &str) -> Result<&'a str, crate::error::ApiError> { + let Some(authorisation) = req.headers().get(header::AUTHORIZATION) else { + // TODO WWWAuthenticate challenge + return Err(failure( + ErrorCode::GENERIC_UNAUTHORIZED, + "Authorization header not found", + )); + }; + + let Some((hscheme, parameter)) = authorisation + .to_str() + .ok() + .and_then(|it| it.split_once(' ')) + else { + return Err(failure( + ErrorCode::GENERIC_UNAUTHORIZED, + "Authorization header is malformed", + )); + }; + + if scheme != hscheme { + return Err(failure( + ErrorCode::GENERIC_UNAUTHORIZED, + format!("Authorization method '{hscheme}' wrong or not supported"), + )); + } + + Ok(parameter) + } + + match method.as_ref() { + AuthMethod::Basic(token) => match parse_auth(&req, "Basic") { + Ok(htoken) => { + if htoken != token { + return failure_code(ErrorCode::GENERIC_TOKEN_UNKNOWN).into_response(); + } + } + Err(err) => return err.into_response(), + }, + AuthMethod::Bearer(token) => match parse_auth(&req, "Bearer") { + Ok(htoken) => { + if htoken != token { + return failure_code(ErrorCode::GENERIC_TOKEN_UNKNOWN).into_response(); + } + } + Err(err) => return err.into_response(), + }, + AuthMethod::None => {} + } + next.run(req).await +} diff --git a/taler-api/src/constants.rs b/taler-api/src/constants.rs @@ -0,0 +1,20 @@ +/* + 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 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/> +*/ + +pub const WIRE_GATEWAY_API_VERSION: &str = "0:0:0"; +pub const MAX_PAGE_SIZE: i64 = 1024; +pub const MAX_TIMEOUT_MS: u64 = 60 * 60 * 10; // 1H +pub const MAX_BODY_LENGTH: usize = 4 * 1024; // 4kB diff --git a/taler-api/src/db.rs b/taler-api/src/db.rs @@ -0,0 +1,325 @@ +/* + 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 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/> +*/ + +use query_helper::{history, SqlQueryHelper}; +use sqlx::{ + postgres::{PgListener, PgRow}, + QueryBuilder, Row, +}; +use sqlx::{PgPool, Postgres}; +use taler_common::{ + amount::Amount, + api_common::{EddsaPublicKey, SafeU64, Timestamp}, + api_params::{History, Page}, + api_wire::{ + IncomingBankTransaction, OutgoingBankTransaction, TransferListStatus, TransferRequest, + TransferResponse, TransferState, TransferStatus, + }, +}; +use tokio::sync::watch::{Receiver, Sender}; +use tracing::debug; +use type_helper::SqlTypeHelper; +use url::Url; + +use crate::error::{ApiError, ApiResult}; + +pub type PgQueryBuilder<'b> = QueryBuilder<'b, Postgres>; + +pub mod query_helper; +pub mod type_helper; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, sqlx::Type)] +#[allow(non_camel_case_types)] +#[sqlx(type_name = "incoming_type")] +pub enum IncomingType { + reserve, + kyc, + wad, +} + +pub async fn notification_listener( + pool: PgPool, + outgoing_channel: Sender<i64>, + incoming_channel: Sender<i64>, +) -> Result<(), ApiError> { + let mut listener = PgListener::connect_with(&pool).await?; + listener.listen_all(["outgoing_tx", "incoming_tx"]).await?; + loop { + while let Some(notification) = listener.try_recv().await? { + debug!( + "db notification: {} - {}", + notification.channel(), + notification.payload() + ); + match notification.channel() { + "outgoing_tx" => { + let row_id: i64 = notification.payload().parse().unwrap(); + outgoing_channel.send_replace(row_id); + } + "incoming_tx" => { + let row_id: i64 = notification.payload().parse().unwrap(); + incoming_channel.send_replace(row_id); + } + unknown => unreachable!("{}", unknown), + } + } + // TODO wait before reconnect + } +} + +pub enum TransferResult { + Success(TransferResponse), + RequestUidReuse, +} + +pub async fn transfer(db: &PgPool, transfer: TransferRequest) -> ApiResult<TransferResult> { + Ok(sqlx::query( + " + SELECT out_request_uid_reuse, out_tx_row_id, out_timestamp + FROM taler_transfer(($1, $2)::taler_amount, $3, $4, $5, $6, $7, $8) + ", + ) + .bind(transfer.amount.value as i64) + .bind(transfer.amount.fraction as i32) + .bind(transfer.exchange_base_url.as_str()) + .bind(format!("{} {}", transfer.wtid, transfer.exchange_base_url)) + .bind(transfer.credit_account.as_str()) + .bind(transfer.request_uid.as_slice()) + .bind(transfer.wtid.as_slice()) + .bind(Timestamp::now().as_sql_micros()) + .try_map(|r: PgRow| { + Ok(if r.try_get("out_request_uid_reuse")? { + TransferResult::RequestUidReuse + } else { + TransferResult::Success(TransferResponse { + timestamp: r.try_get_timestamp("out_timestamp")?, + row_id: r.try_get_safeu64("out_tx_row_id")?, + }) + }) + }) + .fetch_one(db) + .await?) +} + +pub async fn transfer_page( + db: &PgPool, + status: &Option<TransferState>, + page: &Page, + currency: &str, +) -> ApiResult<Vec<TransferListStatus>> { + let mut builder = QueryBuilder::new( + " + SELECT + transfer_id, + status, + (amount).val as amount_val, + (amount).frac as amount_frac, + credit_payto, + transfer_time + FROM transfers WHERE + ", + ); + if let Some(status) = status { + builder.push(" status = ").push_bind(status).push(" AND "); + } + Ok(builder + .page("transfer_id", page) + .build() + .try_map(|r: PgRow| { + Ok(TransferListStatus { + row_id: r.try_get_safeu64("transfer_id")?, + status: r.try_get("status")?, + amount: r.try_get_amount("amount", currency)?, + credit_account: r.try_get_url("credit_payto")?, + timestamp: r.try_get_timestamp("transfer_time")?, + }) + }) + .fetch_all(db) + .await?) +} + +pub async fn transfer_by_id( + db: &PgPool, + id: u64, + currency: &str, +) -> ApiResult<Option<TransferStatus>> { + Ok(sqlx::query( + " + SELECT + status, + status_msg, + (amount).val as amount_val, + (amount).frac as amount_frac, + exchange_base_url, + wtid, + credit_payto, + transfer_time + FROM transfers WHERE transfer_id = $1 + ", + ) + .bind(id as i64) + .try_map(|r: PgRow| { + Ok(TransferStatus { + status: r.try_get("status")?, + status_msg: r.try_get("status_msg")?, + amount: r.try_get_amount("amount", currency)?, + origin_exchange_url: r.try_get("exchange_base_url")?, + wtid: r.try_get_base32("wtid")?, + credit_account: r.try_get_url("credit_payto")?, + timestamp: r.try_get_timestamp("transfer_time")?, + }) + }) + .fetch_optional(db) + .await?) +} + +pub async fn outgoing_page( + db: &PgPool, + params: &History, + currency: &str, + listen: impl FnOnce() -> Receiver<i64>, +) -> ApiResult<Vec<OutgoingBankTransaction>> { + Ok(history( + db, + "transfer_id", + params, + listen, + || { + QueryBuilder::new( + " + SELECT + transfer_id, + (amount).val as amount_val, + (amount).frac as amount_frac, + exchange_base_url, + wtid, + credit_payto, + transfer_time + FROM transfers WHERE status = 'success' AND + ", + ) + }, + |r| { + Ok(OutgoingBankTransaction { + amount: r.try_get_amount("amount", currency)?, + wtid: r.try_get_base32("wtid")?, + credit_account: r.try_get_url("credit_payto")?, + row_id: r.try_get_safeu64("transfer_id")?, + date: r.try_get_timestamp("transfer_time")?, + exchange_base_url: r.try_get_url("exchange_base_url")?, + }) + }, + ) + .await?) +} + +pub enum AddIncomingResult { + Success(SafeU64), + ReservePubReuse, +} + +pub async fn add_incoming( + db: &PgPool, + amount: &Amount, + debit_account: &Url, + subject: &str, + timestamp: &Timestamp, + kind: IncomingType, + key: &EddsaPublicKey, +) -> ApiResult<AddIncomingResult> { + Ok(sqlx::query( + " + SELECT out_reserve_pub_reuse, out_tx_row_id + FROM add_incoming($1, $2, ($3, $4)::taler_amount, $5, $6, $7) + ", + ) + .bind(key.as_slice()) + .bind(subject) + .bind(amount.value as i64) + .bind(amount.fraction as i32) + .bind(debit_account.as_str()) + .bind(timestamp.as_sql_micros()) + .bind(kind) + .try_map(|r: PgRow| { + Ok(if r.try_get("out_reserve_pub_reuse")? { + AddIncomingResult::ReservePubReuse + } else { + AddIncomingResult::Success(r.try_get_safeu64("out_tx_row_id")?) + }) + }) + .fetch_one(db) + .await?) +} + +pub async fn incoming_page( + db: &PgPool, + params: &History, + currency: &str, + listen: impl FnOnce() -> Receiver<i64>, +) -> ApiResult<Vec<IncomingBankTransaction>> { + Ok(history( + db, + "incoming_transaction_id", + params, + listen, + || { + QueryBuilder::new( + " + SELECT + type, + incoming_transaction_id, + (amount).val as amount_val, + (amount).frac as amount_frac, + creation_time, + debit_payto, + reserve_pub, + account_pub, + wad_id, + origin_exchange_url + FROM incoming_transactions WHERE + ", + ) + }, + |r: PgRow| { + let kind: IncomingType = r.try_get("type")?; + Ok(match kind { + IncomingType::reserve => IncomingBankTransaction::IncomingReserveTransaction { + row_id: r.try_get_safeu64("incoming_transaction_id")?, + date: r.try_get_timestamp("creation_time")?, + amount: r.try_get_amount("amount", currency)?, + debit_account: r.try_get_url("debit_payto")?, + reserve_pub: r.try_get_base32("reserve_pub")?, + }, + IncomingType::kyc => IncomingBankTransaction::IncomingKycAuthTransaction { + row_id: r.try_get_safeu64("incoming_transaction_id")?, + date: r.try_get_timestamp("creation_time")?, + amount: r.try_get_amount("amount", currency)?, + debit_account: r.try_get_url("debit_payto")?, + account_pub: r.try_get_base32("account_pub")?, + }, + IncomingType::wad => IncomingBankTransaction::IncomingWadTransaction { + row_id: r.try_get_safeu64("incoming_transaction_id")?, + date: r.try_get_timestamp("creation_time")?, + amount: r.try_get_amount("amount", currency)?, + debit_account: r.try_get_url("debit_payto")?, + origin_exchange_url: r.try_get_url("origin_exchange_url")?, + wad_id: r.try_get_base32("wa_id")?, + }, + }) + }, + ) + .await?) +} diff --git a/taler-api/src/db/query_helper.rs b/taler-api/src/db/query_helper.rs @@ -0,0 +1,91 @@ +/* + 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 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/> +*/ + +use std::time::Duration; + +use sqlx::{postgres::PgRow, Error, PgPool, Postgres, QueryBuilder}; +use taler_common::api_params::{History, Page}; +use tokio::sync::watch::Receiver; + +use super::PgQueryBuilder; + +pub trait SqlQueryHelper { + fn page(&mut self, id_col: &str, params: &Page) -> &mut Self; +} + +impl SqlQueryHelper for PgQueryBuilder<'_> { + fn page(&mut self, id_col: &str, params: &Page) -> &mut Self { + if let Some(offset) = params.offset { + self.push(format_args!( + " {id_col} {}", + if params.backward() { '<' } else { '>' } + )) + .push_bind(offset); + } else { + self.push("TRUE"); + } + self.push(format_args!( + " ORDER BY {id_col} {} LIMIT ", + if params.backward() { "DESC" } else { "ASC" } + )) + .push_bind(params.limit.abs()) + } +} + +pub async fn history<'a, R: Send + Unpin>( + pool: &PgPool, + id_col: &str, + params: &History, + listen: impl FnOnce() -> Receiver<i64>, + prepare: impl Fn() -> QueryBuilder<'a, Postgres>, + map: impl Fn(PgRow) -> Result<R, Error> + Send + Copy, +) -> Result<Vec<R>, Error> { + let load = || async { + prepare() + .page(id_col, &params.page) + .build() + .try_map(map) + .fetch_all(pool) + .await + }; + + // When going backward there is always at least one transaction or none + if params.page.limit >= 0 && params.timeout_ms.is_some_and(|it| it > 0) { + let mut listener = listen(); + let init = load().await?; + // Long polling if we found no transactions + if init.is_empty() { + let pooling = tokio::time::timeout( + Duration::from_millis(params.timeout_ms.unwrap_or(0)), + async { + listener + .wait_for(|id| params.page.offset.is_none_or(|offset| *id > offset)) + .await + .ok(); + }, + ) + .await; + match pooling { + Ok(_) => load().await, + Err(_) => Ok(init), + } + } else { + Ok(init) + } + } else { + load().await + } +} diff --git a/taler-api/src/db/type_helper.rs b/taler-api/src/db/type_helper.rs @@ -0,0 +1,85 @@ +/* + 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 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/> +*/ + +use sqlx::{error::BoxDynError, postgres::PgRow, Decode, Postgres, Row, Type}; +use taler_common::{ + amount::Amount, + api_common::{Base32, SafeU64, Timestamp}, +}; +use url::Url; + +pub trait SqlTypeHelper { + fn try_get_map< + 'r, + I: sqlx::ColumnIndex<Self>, + T: Decode<'r, Postgres> + Type<Postgres>, + E: Into<BoxDynError>, + R, + M: FnOnce(T) -> Result<R, E>, + >( + &'r self, + index: I, + map: M, + ) -> sqlx::Result<R>; + fn try_get_timestamp<I: sqlx::ColumnIndex<Self>>(&self, index: I) -> sqlx::Result<Timestamp> { + self.try_get_map(index, Timestamp::from_sql_micros) + } + fn try_get_safeu64<I: sqlx::ColumnIndex<Self>>(&self, index: I) -> sqlx::Result<SafeU64> { + self.try_get_map(index, |signed: i64| SafeU64::try_from(signed)) + } + fn try_get_base32<I: sqlx::ColumnIndex<Self>, const L: usize>( + &self, + index: I, + ) -> sqlx::Result<Base32<L>> { + self.try_get_map(index, |slice: &[u8]| Base32::try_from(slice)) + } + fn try_get_url<I: sqlx::ColumnIndex<Self>>(&self, index: I) -> sqlx::Result<Url> { + self.try_get_map(index, Url::parse) + } + fn try_get_amount(&self, index: &str, currency: &str) -> sqlx::Result<Amount>; +} + +impl SqlTypeHelper for PgRow { + fn try_get_map< + 'r, + I: sqlx::ColumnIndex<Self>, + T: Decode<'r, Postgres> + Type<Postgres>, + E: Into<BoxDynError>, + R, + M: FnOnce(T) -> Result<R, E>, + >( + &'r self, + index: I, + map: M, + ) -> sqlx::Result<R> { + let primitive: T = self.try_get(&index)?; + map(primitive).map_err(|source| sqlx::Error::ColumnDecode { + index: format!("{index:?}"), + source: source.into(), + }) + } + + fn try_get_amount(&self, index: &str, currency: &str) -> sqlx::Result<Amount> { + let val_idx = format!("{index}_val"); + let frac_idx = format!("{index}_frac"); + let val_idx = val_idx.as_str(); + let frac_idx = frac_idx.as_str(); + let val: i64 = self.try_get(val_idx)?; + let frac: i32 = self.try_get(frac_idx)?; + + Ok(Amount::new(currency, val as u64, frac as u32)) + } +} diff --git a/taler-api/src/error.rs b/taler-api/src/error.rs @@ -0,0 +1,124 @@ +/* + 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 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/> +*/ + +use axum::{ + http::StatusCode, + response::{IntoResponse, Response}, + Json, +}; +use taler_common::{api_common::ErrorDetail, api_params::ParamsError, error_code::ErrorCode}; + +pub type ApiResult<T> = Result<T, ApiError>; + +pub struct ApiError { + code: ErrorCode, + hint: Option<String>, + log: Option<String>, + status: Option<StatusCode>, +} + +impl From<sqlx::Error> for ApiError { + fn from(value: sqlx::Error) -> Self { + let (code, status) = match value { + sqlx::Error::Configuration(_) => { + (ErrorCode::GENERIC_DB_SETUP_FAILED, StatusCode::BAD_GATEWAY) + } + sqlx::Error::Database(_) | sqlx::Error::Io(_) | sqlx::Error::Tls(_) => { + (ErrorCode::GENERIC_DB_FETCH_FAILED, StatusCode::BAD_GATEWAY) + } + sqlx::Error::PoolTimedOut => todo!(), + _ => ( + ErrorCode::BANK_UNMANAGED_EXCEPTION, + StatusCode::INTERNAL_SERVER_ERROR, + ), + }; + Self { + code, + hint: None, + status: Some(status), + log: Some(format!("db: {value}")), + } + } +} + +impl From<ParamsError> for ApiError { + fn from(value: ParamsError) -> Self { + Self { + code: ErrorCode::GENERIC_PARAMETER_MALFORMED, + hint: Some(value.0), + log: None, + status: None, + } + } +} + +impl IntoResponse for ApiError { + fn into_response(self) -> Response { + if let Some(log) = self.log.as_deref().or(self.hint.as_deref()) { + tracing::error!("{log}"); + } + let status_code = self.status.unwrap_or_else(|| { + let (status_code, _) = self.code.metadata(); + StatusCode::from_u16(status_code).expect("Invalid status code") + }); + + ( + status_code, + Json(ErrorDetail { + code: self.code as u32, + hint: self.hint, + detail: None, + parameter: None, + path: None, + offset: None, + index: None, + object: None, + currency: None, + type_expected: None, + type_actual: None, + extra: None, + }), + ) + .into_response() + } +} + +pub fn failure_code(code: ErrorCode) -> ApiError { + ApiError { + code, + hint: None, + log: None, + status: None, + } +} + +pub fn failure(code: ErrorCode, hint: impl Into<String>) -> ApiError { + ApiError { + code, + hint: Some(hint.into()), + log: None, + status: None, + } +} + +pub fn failure_status(code: ErrorCode, hint: impl Into<String>, status: StatusCode) -> ApiError { + ApiError { + code, + hint: Some(hint.into()), + log: None, + status: Some(status), + } +} diff --git a/taler-api/src/lib.rs b/taler-api/src/lib.rs @@ -0,0 +1,430 @@ +/* + 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 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/> +*/ + +use std::{ + sync::{ + atomic::{AtomicU32, Ordering}, + Arc, + }, + time::Instant, +}; + +use auth::{auth_middleware, AuthMethod}; +use axum::{ + async_trait, + body::Bytes, + extract::{FromRequest, Path, Query, Request, State}, + http::{header, StatusCode}, + middleware::{self, Next}, + response::{IntoResponse, Response}, + routing::{get, post}, + Json, Router, +}; +use constants::{MAX_BODY_LENGTH, MAX_PAGE_SIZE, MAX_TIMEOUT_MS, WIRE_GATEWAY_API_VERSION}; +use error::{failure, failure_code, ApiError, ApiResult}; +use http_body_util::BodyExt; +use serde::de::DeserializeOwned; +use taler_common::{ + amount::Amount, + api_params::{History, HistoryParams, Page, TransferParams}, + api_wire::{ + AddIncomingRequest, AddIncomingResponse, AddKycauthRequest, AddKycauthResponse, + IncomingHistory, OutgoingHistory, TransferList, TransferRequest, TransferResponse, + TransferState, TransferStatus, WireConfig, + }, + error_code::ErrorCode, +}; +use tokio::{net::TcpListener, signal}; +use tracing::info; + +pub mod auth; +mod constants; +pub mod db; +pub mod error; +pub mod notification; + +#[derive(Debug, Clone, Copy, Default)] +#[must_use] +pub struct Req<T>(pub T); + +#[async_trait] +impl<T, S> FromRequest<S> for Req<T> +where + T: DeserializeOwned, + S: Send + Sync, +{ + type Rejection = ApiError; + + async fn from_request(req: Request, _state: &S) -> Result<Self, Self::Rejection> { + // TODO UNSUPPORTED_MEDIA_TYPE & UNPROCESSABLE_ENTITY + // Check content type + match req + .headers() + .get(header::CONTENT_TYPE) + .map(|it| it == "application/json") + { + Some(true) => {} + Some(false) => { + return Err(failure( + ErrorCode::GENERIC_JSON_INVALID, + "Bad Content-Type header", + )) + } + None => { + return Err(failure( + ErrorCode::GENERIC_JSON_INVALID, + "Missing Content-Type header", + )) + } + } + + // Check content length if present and wellformed + if let Some(lenght) = req + .headers() + .get(header::CONTENT_LENGTH) + .and_then(|it| it.to_str().ok()) + .and_then(|it| it.parse::<usize>().ok()) + { + if lenght > MAX_BODY_LENGTH { + return Err(failure( + ErrorCode::GENERIC_JSON_INVALID, + format!("Body is suspiciously big > {MAX_BODY_LENGTH}B"), + )); + } + } + + // Check compression + let compressed = if let Some(encoding) = req.headers().get(header::CONTENT_ENCODING) { + if encoding == "deflate" { + true + } else { + return Err(failure( + ErrorCode::GENERIC_COMPRESSION_INVALID, + format!( + "Unsupported encoding '{}'", + String::from_utf8_lossy(encoding.as_bytes()) + ), + )); + } + } else { + false + }; + + // Buffer body + let (_, body) = req.into_parts(); + let body = http_body_util::Limited::new(body, MAX_BODY_LENGTH); + let bytes = match body.collect().await { + Ok(chunks) => chunks.to_bytes(), + Err(it) => match it.downcast::<http_body_util::LengthLimitError>() { + Ok(_) => { + return Err(failure( + ErrorCode::GENERIC_JSON_INVALID, + format!("Body is suspiciously big > {MAX_BODY_LENGTH}B"), + )) + } + Err(err) => { + return Err(failure( + ErrorCode::GENERIC_UNEXPECTED_REQUEST_ERROR, + format!("Failed to read body: {}", err), + )) + } + }, + }; + + let bytes = if compressed { + let mut buf = vec![0; MAX_BODY_LENGTH]; + match libdeflater::Decompressor::new().zlib_decompress(&bytes, &mut buf) { + Ok(it) => Bytes::copy_from_slice(&buf[..it]), + Err(it) => match it { + libdeflater::DecompressionError::BadData => { + return Err(failure( + ErrorCode::GENERIC_COMPRESSION_INVALID, + "Failed to decompress body: invalid gzip", + )) + } + libdeflater::DecompressionError::InsufficientSpace => { + return Err(failure( + ErrorCode::GENERIC_JSON_INVALID, + format!("Body is suspiciously big > {MAX_BODY_LENGTH}B"), + )) + } + }, + } + } else { + bytes + }; + match serde_json::de::from_slice(&bytes) { + Ok(it) => Ok(Req(it)), + Err(err) => return Err(failure(ErrorCode::GENERIC_JSON_INVALID, format!("{err}"))), + } + } +} + +pub trait WireGatewayImpl: Send + Sync { + fn currency(&self) -> &str; + fn implementation(&self) -> Option<&str>; + fn transfer( + &self, + req: TransferRequest, + ) -> impl std::future::Future<Output = ApiResult<TransferResponse>> + Send; + fn transfer_page( + &self, + page: Page, + status: Option<TransferState>, + ) -> impl std::future::Future<Output = ApiResult<TransferList>> + Send; + fn transfer_by_id( + &self, + id: u64, + ) -> impl std::future::Future<Output = ApiResult<Option<TransferStatus>>> + Send; + fn outgoing_history( + &self, + params: History, + ) -> impl std::future::Future<Output = ApiResult<OutgoingHistory>> + Send; + fn incoming_history( + &self, + params: History, + ) -> impl std::future::Future<Output = ApiResult<IncomingHistory>> + Send; + fn add_incoming_reserve( + &self, + req: AddIncomingRequest, + ) -> impl std::future::Future<Output = ApiResult<AddIncomingResponse>> + Send; + fn add_incoming_kyc( + &self, + req: AddKycauthRequest, + ) -> impl std::future::Future<Output = ApiResult<AddKycauthResponse>> + Send; + + fn check_currency(&self, amount: &Amount) -> ApiResult<()> { + let currency = self.currency(); + if amount.currency.as_ref() != currency { + Err(failure( + ErrorCode::GENERIC_CURRENCY_MISMATCH, + format!( + "Wrong currency: expected {} got {}", + currency, amount.currency + ), + )) + } else { + Ok(()) + } + } +} + +pub fn standard_layer(router: Router, auth: AuthMethod) -> Router { + router + .method_not_allowed_fallback(|| async { failure_code(ErrorCode::GENERIC_METHOD_INVALID) }) + .fallback(|| async { failure_code(ErrorCode::GENERIC_ENDPOINT_UNKNOWN) }) + .layer(middleware::from_fn_with_state( + Arc::new(auth), + auth_middleware, + )) +} + +pub async fn server( + tcp_listener: TcpListener, + mut router: Router, + auth: AuthMethod, + lifetime_counter: Option<AtomicU32>, +) -> Result<(), std::io::Error> { + let notify = Arc::new(tokio::sync::Notify::new()); + if let Some(lifetime) = lifetime_counter { + router = router.layer(middleware::from_fn_with_state( + Arc::new(LifetimeMiddlewareState { + notify: notify.clone(), + lifetime, + }), + lifetime_middleware, + )) + } + let router = standard_layer(router, auth); + + axum::serve( + tcp_listener, + router.layer(middleware::from_fn(logger_middleware)), + ) + .with_graceful_shutdown(shutdown_signal(notify)) + .await +} + +struct LifetimeMiddlewareState { + lifetime: AtomicU32, + notify: Arc<tokio::sync::Notify>, +} + +async fn lifetime_middleware( + State(state): State<Arc<LifetimeMiddlewareState>>, + request: Request, + next: Next, +) -> Response { + let mut current = state.lifetime.load(Ordering::Relaxed); + while current != 0 { + match state.lifetime.compare_exchange_weak( + current, + current - 1, + Ordering::Relaxed, + Ordering::Relaxed, + ) { + Ok(_) => break, + Err(new) => current = new, + } + } + if current == 0 { + state.notify.notify_one(); + } + next.run(request).await +} + +/** Wait for manual shutdown or system signal shutdown */ +async fn shutdown_signal(manual_shutdown: Arc<tokio::sync::Notify>) { + let ctrl_c = async { + signal::ctrl_c() + .await + .expect("failed to install Ctrl+C handler"); + }; + + #[cfg(unix)] + let terminate = async { + signal::unix::signal(signal::unix::SignalKind::terminate()) + .expect("failed to install signal handler") + .recv() + .await; + }; + + #[cfg(not(unix))] + let terminate = std::future::pending::<()>(); + + let manual = async { manual_shutdown.notified().await }; + + tokio::select! { + _ = ctrl_c => {}, + _ = terminate => {}, + _ = manual => {} + } +} + +/** Taler API logger */ +async fn logger_middleware(request: Request, next: Next) -> Response { + let request_info = format!("{} {}", request.method(), request.uri().path()); + let now = Instant::now(); + let response = next.run(request).await; + let elapsed = now.elapsed(); + // TODO log error message + info!( + "{} {request_info} {}ms", + response.status(), + elapsed.as_millis() + ); + response +} + +pub fn wire_gateway_api<I: WireGatewayImpl + 'static>(wg: Arc<I>) -> Router { + Router::new() + .route( + "/config", + get(|State(state): State<Arc<I>>| async move { + Json(WireConfig { + name: "taler-wire-gateway", + version: WIRE_GATEWAY_API_VERSION, + currency: state.currency(), + implementation: state.implementation(), + }) + .into_response() + }), + ) + .route( + "/transfer", + post( + |State(state): State<Arc<I>>, Req(req): Req<TransferRequest>| async move { + state.check_currency(&req.amount)?; + ApiResult::Ok(Json(state.transfer(req).await?)) + }, + ), + ) + .route( + "/transfers", + get( + |State(state): State<Arc<I>>, Query(params): Query<TransferParams>| async move { + let page = params.pagination.check(MAX_PAGE_SIZE)?; + let list = state.transfer_page(page, params.status).await?; + ApiResult::Ok(if list.transfers.is_empty() { + StatusCode::NO_CONTENT.into_response() + } else { + Json(list).into_response() + }) + }, + ), + ) + .route( + "/transfers/:id", + get( + |State(state): State<Arc<I>>, Path(id): Path<u64>| async move { + match state.transfer_by_id(id).await? { + Some(it) => Ok(Json(it)), + None => Err(failure( + ErrorCode::BANK_TRANSACTION_NOT_FOUND, + format!("Transfer '{id}' not found"), + )), + } + }, + ), + ) + .route( + "/history/incoming", + get( + |State(state): State<Arc<I>>, Query(params): Query<HistoryParams>| async move { + let params = params.check(MAX_PAGE_SIZE, MAX_TIMEOUT_MS)?; + let history = state.incoming_history(params).await?; + ApiResult::Ok(if history.incoming_transactions.is_empty() { + StatusCode::NO_CONTENT.into_response() + } else { + Json(history).into_response() + }) + }, + ), + ) + .route( + "/history/outgoing", + get( + |State(state): State<Arc<I>>, Query(params): Query<HistoryParams>| async move { + let params = params.check(MAX_PAGE_SIZE, MAX_TIMEOUT_MS)?; + let history = state.outgoing_history(params).await?; + ApiResult::Ok(if history.outgoing_transactions.is_empty() { + StatusCode::NO_CONTENT.into_response() + } else { + Json(history).into_response() + }) + }, + ), + ) + .route( + "/admin/add-incoming", + post( + |State(state): State<Arc<I>>, Req(req): Req<AddIncomingRequest>| async move { + state.check_currency(&req.amount)?; + ApiResult::Ok(Json(state.add_incoming_reserve(req).await?)) + }, + ), + ) + .route( + "/admin/add-kycauth", + post( + |State(state): State<Arc<I>>, Req(req): Req<AddKycauthRequest>| async move { + state.check_currency(&req.amount)?; + ApiResult::Ok(Json(state.add_incoming_kyc(req).await?)) + }, + ), + ) + .with_state(wg) +} diff --git a/taler-api/src/notification.rs b/taler-api/src/notification.rs @@ -0,0 +1,102 @@ +/* + 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 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/> +*/ + +use std::hash::Hash; +use std::sync::Arc; + +use dashmap::DashMap; +use tokio::sync::watch; + +type CountedNotify<T> = watch::Sender<Option<T>>; + +#[derive(Default)] +pub struct NotificationChannel<K: Eq + Hash, V> { + map: Arc<DashMap<K, CountedNotify<V>>>, +} + +pub struct Listener<K: Eq + Hash + Clone, V> { + map: Arc<DashMap<K, CountedNotify<V>>>, + channel: watch::Receiver<Option<V>>, + key: K, +} + +impl<K: Eq + Hash + Clone, V> Listener<K, V> { + pub async fn wait_for(mut self, filter: impl Fn(&V) -> bool) { + self.channel + .wait_for(|it| it.as_ref().map(&filter).unwrap_or(false)) + .await + .ok(); // If the channel is closed we cannot wait efficiently + } +} + +impl<K: Eq + Hash + Clone, V> Drop for Listener<K, V> { + fn drop(&mut self) { + self.map + .remove_if(&self.key, |_, it| it.receiver_count() == 1); + } +} + +impl<K: Eq + Hash + Clone, V> NotificationChannel<K, V> { + pub fn listener(&self, key: K) -> Listener<K, V> { + let entry = self.map.entry(key.clone()).or_insert_with(|| { + let (sender, _) = watch::channel(None); + sender + }); + Listener { + map: self.map.clone(), + channel: entry.subscribe(), + key, + } + } +} + +#[tokio::test] +async fn channel_gc() { + use std::time::Duration; + + let channel = NotificationChannel::default(); + assert_eq!(0, channel.map.len()); + + // Clean in future + let listener = channel.listener("test"); + assert_eq!(1, channel.map.len()); + tokio::time::timeout(Duration::from_millis(0), listener.wait_for(|it| it == 42)) + .await + .unwrap_err(); + assert_eq!(0, channel.map.len()); + + // Clean on drop + let first = channel.listener("test"); + let second = channel.listener("test"); + assert_eq!(1, channel.map.len()); + tokio::time::timeout(Duration::from_millis(0), first.wait_for(|it| it == 42)) + .await + .unwrap_err(); + assert_eq!(1, channel.map.len()); + drop(second); + assert_eq!(0, channel.map.len()); +} + +#[tokio::test] +async fn wake() { + let channel = NotificationChannel::default(); + let listener = channel.listener("test"); + let task = tokio::spawn(listener.wait_for(|it| *it == 42)); + channel.map.entry("test").and_modify(|it| { + it.send(Some(42)).unwrap(); + }); + task.await.unwrap(); +} diff --git a/taler-api/tests/api.rs b/taler-api/tests/api.rs @@ -0,0 +1,369 @@ +/* + 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 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/> +*/ + +use common::sample_wire_gateway_api; +use sqlx::PgPool; +use taler_api::{auth::AuthMethod, db::IncomingType, standard_layer}; +use taler_common::{ + amount::amount, + api_common::{Base32, EddsaPublicKey, HashCode, ShortHashCode}, + api_wire::{ + IncomingBankTransaction, IncomingHistory, OutgoingHistory, TransferList, TransferResponse, + TransferState, TransferStatus, + }, + error_code::ErrorCode, +}; +use test_utils::{ + axum_test::TestServer, + helpers::TestResponseHelper, + json, + routine::{routine_history, routine_pagination}, +}; +use url::Url; + +mod common; + +async fn setup(pool: PgPool) -> TestServer { + TestServer::new(standard_layer( + sample_wire_gateway_api(Some(pool), "EUR".to_string()).await, + AuthMethod::None, + )) + .unwrap() +} + +fn url(url: &str) -> Url { + url.parse().expect("Invalid url") +} + +#[sqlx::test] +async fn errors(pool: PgPool) { + let server = setup(pool).await; + server + .get("/unknown") + .await + .assert_error(ErrorCode::GENERIC_ENDPOINT_UNKNOWN); + server + .post("/config") + .await + .assert_error(ErrorCode::GENERIC_METHOD_INVALID); +} + +#[sqlx::test] +async fn config(pool: PgPool) { + let server = setup(pool).await; + server.get("/config").await.assert_status_ok(); +} + +#[sqlx::test] +async fn transfer(pool: PgPool) { + let valid_request = json!({ + "request_uid": HashCode::rand(), + "amount": "EUR:42", + "exchange_base_url": "http://exchange.taler", + "wtid": ShortHashCode::rand(), + "credit_account": "payto://todo", + }); + let server = setup(pool).await; + + // Check OK + let first = server + .post("/transfer") + .json(&valid_request) + .await + .assert_ok_json::<TransferResponse>(); + // Check idempotent + let second = server + .post("/transfer") + .json(&valid_request) + .await + .assert_ok_json::<TransferResponse>(); + assert_eq!(first.row_id, second.row_id); + assert_eq!(first.timestamp, second.timestamp); + + // Check request uid reuse + server + .post("/transfer") + .json(&json!(valid_request + { + "wtid": ShortHashCode::rand() + })) + .await + .assert_error(ErrorCode::BANK_TRANSFER_REQUEST_UID_REUSED); + + // Check currency mismatch + server + .post("/transfer") + .json(&json!(valid_request + { + "amount": "CHF:42" + })) + .await + .assert_error(ErrorCode::GENERIC_CURRENCY_MISMATCH); +} + +#[sqlx::test] +async fn transfer_by_id(pool: PgPool) { + let wtid = ShortHashCode::rand(); + + let server = setup(pool).await; + let resp = server + .post("/transfer") + .json(&json!({ + "request_uid": HashCode::rand(), + "amount": "EUR:55", + "exchange_base_url": "http://exchange.taler", + "wtid": wtid, + "credit_account": "payto://todo", + })) + .await + .assert_ok_json::<TransferResponse>(); + + // Check OK + let tx = server + .get(&format!("/transfers/{}", resp.row_id)) + .await + .assert_ok_json::<TransferStatus>(); + assert_eq!(TransferState::success, tx.status); + assert_eq!(amount("EUR:55"), tx.amount); + assert_eq!("http://exchange.taler/", tx.origin_exchange_url); + assert_eq!(wtid, tx.wtid); + assert_eq!(resp.timestamp, tx.timestamp); + + // Check unknown transaction + server + .get("/transfers/42") + .await + .assert_error(ErrorCode::BANK_TRANSACTION_NOT_FOUND); +} + +#[sqlx::test] +async fn transfer_page(pool: PgPool) { + let server = setup(pool).await; + server.get("/transfers").await.assert_no_content(); + server + .get("/transfers?status=success") + .await + .assert_no_content(); + + for _ in 0..6 { + server + .post("/transfer") + .json(&json!({ + "request_uid": HashCode::rand(), + "amount": "EUR:55", + "exchange_base_url": "http://exchange.taler", + "wtid": ShortHashCode::rand(), + "credit_account": "payto://todo", + })) + .await + .assert_ok_json::<TransferResponse>(); + } + { + let list = server + .get("/transfers") + .await + .assert_ok_json::<TransferList>(); + assert_eq!(list.transfers.len(), 6); + assert_eq!( + list, + server + .get("/transfers?status=success") + .await + .assert_ok_json::<TransferList>() + ); + } + + // Pagination test + routine_pagination::<TransferList, _>( + &server, + "/transfers", + |it| { + it.transfers + .into_iter() + .map(|it| *it.row_id as i64) + .collect() + }, + |server, i| async move { + server + .post("/transfer") + .json(&json!({ + "request_uid": HashCode::rand(), + "amount": amount(&format!("EUR:0.0{i}")), + "exchange_base_url": url("http://exchange.taler"), + "wtid": ShortHashCode::rand(), + "credit_account": url("payto://todo"), + })) + .await + .assert_ok_json::<TransferResponse>(); + }, + ) + .await; +} + +#[sqlx::test] +async fn outgoing_history(pool: PgPool) { + let server = setup(pool).await; + server.get("/history/outgoing").await.assert_no_content(); + + routine_pagination::<OutgoingHistory, _>( + &server, + "/history/outgoing", + |it| { + it.outgoing_transactions + .into_iter() + .map(|it| *it.row_id as i64) + .collect() + }, + |server, i| async move { + server + .post("/transfer") + .json(&json!({ + "request_uid": HashCode::rand(), + "amount": amount(&format!("EUR:0.0{i}")), + "exchange_base_url": url("http://exchange.taler"), + "wtid": ShortHashCode::rand(), + "credit_account": url("payto://todo"), + })) + .await + .assert_ok_json::<TransferResponse>(); + }, + ) + .await; +} + +#[sqlx::test] +async fn incoming_history(pool: PgPool) { + let server = setup(pool).await; + server.get("/history/incoming").await.assert_no_content(); + + routine_history( + &server, + "/history/incoming", + |it: IncomingHistory| { + it.incoming_transactions + .into_iter() + .map(|it| match it { + IncomingBankTransaction::IncomingReserveTransaction { row_id, .. } + | IncomingBankTransaction::IncomingWadTransaction { row_id, .. } + | IncomingBankTransaction::IncomingKycAuthTransaction { row_id, .. } => { + *row_id as i64 + } + }) + .collect() + }, + 2, + |server, i| async move { + if i % 2 == 0 { + server + .post("/admin/add-incoming") + .json(&json!({ + "amount": format!("EUR:0.0{i}"), + "reserve_pub": EddsaPublicKey::rand(), + "debit_account": "payto://todo", + })) + .await + .assert_ok_json::<TransferResponse>(); + } else { + server + .post("/admin/add-kycauth") + .json(&json!({ + "amount": format!("EUR:0.0{i}"), + "account_pub": EddsaPublicKey::rand(), + "debit_account": "payto://todo", + })) + .await + .assert_ok_json::<TransferResponse>(); + } + }, + 0, + |_, _| async move {}, + ) + .await; +} + +async fn add_incoming_routine(server: TestServer, kind: IncomingType) { + let (path, key) = match kind { + IncomingType::reserve => ("/admin/add-incoming", "reserve_pub"), + IncomingType::kyc => ("/admin/add-kycauth", "account_pub"), + IncomingType::wad => unreachable!(), + }; + let valid_req = json!({ + "amount": "EUR:44", + key: EddsaPublicKey::rand(), + "debit_account": "payto://todo", + }); + + // Check OK + server.post(&path).json(&valid_req).await.assert_ok(); + + match kind { + IncomingType::reserve => { + // Trigger conflict due to reused reserve_pub + server + .post(&path) + .json(&valid_req) + .await + .assert_error(ErrorCode::BANK_DUPLICATE_RESERVE_PUB_SUBJECT) + } + IncomingType::kyc => { + // Non conflict on reuse + server.post(&path).json(&valid_req).await.assert_ok(); + } + IncomingType::wad => unreachable!(), + } + + // Currency mismatch + server + .post(&path) + .json(&json!(valid_req + { + "amount": "CHF:33" + })) + .await + .assert_error(ErrorCode::GENERIC_CURRENCY_MISMATCH); + + // Bad BASE32 reserve_pub + server + .post(&path) + .json(&json!(valid_req + { + key: "I love chocolate" + })) + .await + .assert_error(ErrorCode::GENERIC_JSON_INVALID); + + server + .post(&path) + .json(&json!(valid_req + { + key: Base32::<31>::rand() + })) + .await + .assert_error(ErrorCode::GENERIC_JSON_INVALID); + /* + // Bad payto kind + client.postA("/taler-wire-gateway/admin/$path") { + json(valid_req) { + "debit_account" to "payto://x-taler-bank/bank.hostname.test/bar" + } + }.assertBadRequest()*/ +} + +#[sqlx::test] +async fn add_incoming_reserve(pool: PgPool) { + let server = setup(pool).await; + add_incoming_routine(server, IncomingType::reserve).await; +} +#[sqlx::test] +async fn add_incoming_kyc(pool: PgPool) { + let server = setup(pool).await; + add_incoming_routine(server, IncomingType::kyc).await; +} diff --git a/taler-api/tests/common.rs b/taler-api/tests/common.rs @@ -0,0 +1,191 @@ +/* + 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 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/> +*/ + +use std::sync::Arc; + +use axum::Router; +use sqlx::PgPool; +use taler_api::{ + db::{self, notification_listener}, + error::{failure, ApiResult}, + wire_gateway_api, WireGatewayImpl, +}; +use taler_common::{ + api_common::Timestamp, + api_params::{History, Page}, + api_wire::{ + AddIncomingRequest, AddIncomingResponse, AddKycauthRequest, AddKycauthResponse, + IncomingHistory, OutgoingHistory, TransferList, TransferRequest, TransferResponse, + TransferState, TransferStatus, + }, + error_code::ErrorCode, +}; +use tokio::sync::watch::Sender; +use url::Url; + +/// Sample Wire Gateway implementation for tests +pub struct SampleState { + currency: String, + pool: PgPool, + outgoing_channel: Sender<i64>, + incoming_channel: Sender<i64>, +} + +impl WireGatewayImpl for SampleState { + fn currency(&self) -> &str { + &self.currency + } + + fn implementation(&self) -> Option<&str> { + None + } + + async fn transfer(&self, req: TransferRequest) -> ApiResult<TransferResponse> { + let result = db::transfer(&self.pool, req).await?; + match result { + db::TransferResult::Success(transfer_response) => Ok(transfer_response), + db::TransferResult::RequestUidReuse => Err(failure( + ErrorCode::BANK_TRANSFER_REQUEST_UID_REUSED, + "request_uid used already", + )), + } + } + + async fn transfer_page( + &self, + page: Page, + status: Option<TransferState>, + ) -> ApiResult<TransferList> { + Ok(TransferList { + transfers: db::transfer_page(&self.pool, &status, &page, &self.currency).await?, + debit_account: Url::parse("payto://todo").unwrap(), + }) + } + + async fn transfer_by_id(&self, id: u64) -> ApiResult<Option<TransferStatus>> { + db::transfer_by_id(&self.pool, id, &self.currency).await + } + + async fn outgoing_history(&self, params: History) -> ApiResult<OutgoingHistory> { + let txs = db::outgoing_page(&self.pool, &params, &self.currency, || { + self.outgoing_channel.subscribe() + }) + .await?; + Ok(OutgoingHistory { + outgoing_transactions: txs, + debit_account: Url::parse("payto://todo").unwrap(), + }) + } + + async fn incoming_history(&self, params: History) -> ApiResult<IncomingHistory> { + let txs = db::incoming_page(&self.pool, &params, &self.currency, || { + self.incoming_channel.subscribe() + }) + .await?; + Ok(IncomingHistory { + incoming_transactions: txs, + credit_account: Url::parse("payto://todo").unwrap(), + }) + } + + async fn add_incoming_reserve( + &self, + req: AddIncomingRequest, + ) -> ApiResult<AddIncomingResponse> { + let timestamp = Timestamp::now(); + let res = db::add_incoming( + &self.pool, + &req.amount, + &req.debit_account, + "", + &timestamp, + db::IncomingType::reserve, + &req.reserve_pub, + ) + .await?; + match res { + db::AddIncomingResult::Success(row_id) => Ok(AddIncomingResponse { timestamp, row_id }), + db::AddIncomingResult::ReservePubReuse => Err(failure( + ErrorCode::BANK_DUPLICATE_RESERVE_PUB_SUBJECT, + "reserve_pub used already".to_owned(), + )), + } + } + + async fn add_incoming_kyc(&self, req: AddKycauthRequest) -> ApiResult<AddKycauthResponse> { + let timestamp = Timestamp::now(); + let res = db::add_incoming( + &self.pool, + &req.amount, + &req.debit_account, + "", + &timestamp, + db::IncomingType::kyc, + &req.account_pub, + ) + .await?; + match res { + db::AddIncomingResult::Success(row_id) => Ok(AddKycauthResponse { timestamp, row_id }), + db::AddIncomingResult::ReservePubReuse => Err(failure( + ErrorCode::BANK_DUPLICATE_RESERVE_PUB_SUBJECT, + "reserve_pub used already".to_owned(), + )), + } + } + + fn check_currency(&self, amount: &taler_common::amount::Amount) -> ApiResult<()> { + let currency = self.currency(); + if amount.currency.as_ref() != currency { + Err(failure( + ErrorCode::GENERIC_CURRENCY_MISMATCH, + std::format!( + "Wrong currency: expected {} got {}", + currency, + amount.currency + ), + )) + } else { + Ok(()) + } + } +} + +pub async fn sample_wire_gateway_api(pool: Option<PgPool>, currency: String) -> Router { + // Create pool + let pool = match pool { + Some(it) => it, + None => PgPool::connect("postgre:///magnetcheck").await.unwrap(), + }; + // Reset db + sqlx::raw_sql(include_str!("../schema.sql")) + .execute(&pool) + .await + .unwrap(); + let outgoing_channel = Sender::new(0); + let incoming_channel = Sender::new(0); + let wg = SampleState { + currency, + pool: pool.clone(), + outgoing_channel: outgoing_channel.clone(), + incoming_channel: incoming_channel.clone(), + }; + tokio::spawn(notification_listener( + pool, + outgoing_channel, + incoming_channel, + )); + wire_gateway_api(Arc::new(wg)) +} diff --git a/taler-common/Cargo.toml b/taler-common/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "taler-common" +version = "0.1.0" +edition = "2021" + +[dependencies] +base32 = "0.5.1" +serde_with = "3.11.0" +rand = "0.8" +fastrand = "2.2.0" +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true, features = ["raw_value"] } +url.workspace = true +thiserror.workspace = true +sqlx.workspace = true diff --git a/taler-common/src/amount.rs b/taler-common/src/amount.rs @@ -0,0 +1,306 @@ +/* + 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 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/> +*/ + +//! Type for the Taler Amount <https://docs.taler.net/core/api-common.html#tsref-type-Amount> + +use std::{ + fmt::{Debug, Display}, + num::ParseIntError, + str::FromStr, +}; + +const CURRENCY_LEN: usize = 12; +const MAX_VALUE: u64 = 2 << 52; +const FRACTION_BASE: u32 = 100_000_000; + +#[derive(Clone, PartialEq, Eq, serde_with::DeserializeFromStr, serde_with::SerializeDisplay)] +/// Inlined ISO 4217 currency string +pub struct Currency { + /// Len of currency string in buf + len: u8, + /// Buffer of currency bytes, left adjusted and zero padded + buf: [u8; CURRENCY_LEN], +} + +impl AsRef<str> for Currency { + fn as_ref(&self) -> &str { + // SAFETY: len <= CURRENCY_LEN && buf[..len] are all ASCII uppercase + unsafe { std::str::from_utf8_unchecked(self.buf.get_unchecked(..self.len as usize)) } + } +} + +impl FromStr for Currency { + type Err = ParseCurrencyError; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + let bytes = s.as_bytes(); + let len = bytes.len(); + if bytes.is_empty() { + Err(ParseCurrencyError::Empty) + } else if len > CURRENCY_LEN { + Err(ParseCurrencyError::Big) + } else if !bytes.iter().all(|c| c.is_ascii_uppercase()) { + Err(ParseCurrencyError::Invalid) + } else { + let mut buf = [0; CURRENCY_LEN]; + buf[..len].copy_from_slice(bytes); + Ok(Self { + len: len as u8, + buf, + }) + } + } +} + +impl Debug for Currency { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + Debug::fmt(&self.as_ref(), f) + } +} + +impl Display for Currency { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + Display::fmt(&self.as_ref(), f) + } +} + +#[derive(Debug, thiserror::Error)] +pub enum ParseCurrencyError { + #[error("invalid currency")] + Invalid, + #[error("currency is longer than {CURRENCY_LEN} chars")] + Big, + #[error("currency is empty")] + Empty, +} + +/// <https://docs.taler.net/core/api-common.html#tsref-type-Amount> +#[derive( + Debug, Clone, PartialEq, Eq, serde_with::DeserializeFromStr, serde_with::SerializeDisplay, +)] +pub struct Amount { + pub currency: Currency, + pub value: u64, + pub fraction: u32, +} + +impl Amount { + pub fn new(currency: impl AsRef<str>, value: u64, fraction: u32) -> Self { + let currency = currency.as_ref().parse().expect("Invalid currency"); + Self { + value, + fraction, + currency, + } + } + + pub fn max(currency: impl AsRef<str>) -> Self { + Self::new(currency, MAX_VALUE, FRACTION_BASE - 1) + } + + pub fn zero(currency: impl AsRef<str>) -> Self { + Self::new(currency, 0, 0) + } + + fn normalize(mut self) -> Option<Self> { + self.value = self + .value + .checked_add((self.fraction / FRACTION_BASE) as u64)?; + self.fraction %= FRACTION_BASE; + if self.value > MAX_VALUE { + return None; + } + Some(self) + } + + pub fn add(mut self, rhs: &Self) -> Option<Self> { + assert_eq!(self.currency, rhs.currency); + self.value = self.value.checked_add(rhs.value)?; + self.fraction = self + .fraction + .checked_add(rhs.fraction) + .expect("amount fraction overflow should never happen with normalized amounts"); + self.normalize() + } +} + +#[track_caller] +pub fn amount(amount: impl AsRef<str>) -> Amount { + amount.as_ref().parse().expect("Invalid amount constant") +} + +#[derive(Debug, thiserror::Error)] +pub enum ParseAmountError { + #[error("Invalid amount format")] + FormatAmount, + #[error("Amount overflow")] + AmountOverflow, + #[error(transparent)] + Format(#[from] ParseIntError), +} + +impl FromStr for Amount { + type Err = ParseAmountError; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + let (currency, amount) = s + .trim() + .split_once(':') + .ok_or(ParseAmountError::FormatAmount)?; + if currency.len() > CURRENCY_LEN { + return Err(ParseAmountError::FormatAmount); + } + let (value, fraction) = amount.split_once('.').unwrap_or((amount, "")); + + let value: u64 = value.parse().map_err(|_| ParseAmountError::FormatAmount)?; + if value > MAX_VALUE { + return Err(ParseAmountError::FormatAmount); + } + + if fraction.len() > 8 { + return Err(ParseAmountError::FormatAmount); + } + let fraction: u32 = if fraction.is_empty() { + 0 + } else { + fraction + .parse::<u32>() + .map_err(|_| ParseAmountError::FormatAmount)? + * 10_u32.pow((8 - fraction.len()) as u32) + }; + + Ok(Self::new(currency, value, fraction)) + } +} + +impl Display for Amount { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!( + "{}:{}.{:08}", + self.currency, self.value, self.fraction + )) + } +} + +#[test] +fn test_amount_parse() { + const TALER_AMOUNT_FRAC_BASE: u32 = 100000000; + // https://git.taler.net/exchange.git/tree/src/util/test_amount.c + + const INVALID_AMOUNTS: [&str; 6] = [ + "EUR:4a", // non-numeric, + "EUR:4.4a", // non-numeric + "EUR:4.a4", // non-numeric + ":4.a4", // no currency + "EUR:4.123456789", // precision to high + "EUR:1234567890123456789012345678901234567890123456789012345678901234567890", // value to big + ]; + + for str in INVALID_AMOUNTS { + let amount = Amount::from_str(str); + assert!(amount.is_err(), "invalid {} got {:?}", str, amount); + } + + let valid_amounts: Vec<(&str, Amount)> = vec![ + ("EUR:4", Amount::new("EUR", 4, 0)), // without fraction + ( + "EUR:0.02", + Amount::new("EUR", 0, TALER_AMOUNT_FRAC_BASE / 100 * 2), + ), // leading zero fraction + ( + " EUR:4.12", + Amount::new("EUR", 4, TALER_AMOUNT_FRAC_BASE / 100 * 12), + ), // leading space and fraction + ( + " LOCAL:4444.1000", + Amount::new("LOCAL", 4444, TALER_AMOUNT_FRAC_BASE / 10), + ), // local currency + ]; + for (str, goal) in valid_amounts { + let amount = Amount::from_str(str); + assert!(amount.is_ok(), "Valid {} got {:?}", str, amount); + assert_eq!( + *amount.as_ref().unwrap(), + goal, + "Expected {:?} got {:?} for {}", + goal, + amount, + str + ); + let amount = amount.unwrap(); + let str = amount.to_string(); + assert_eq!(amount, Amount::from_str(&str).unwrap(), "{:?}", str); + } +} + +#[test] +fn test_amount_add() { + assert_eq!( + Amount::max("EUR").add(&Amount::zero("EUR")), + Some(Amount::max("EUR")) + ); + assert_eq!( + Amount::zero("EUR").add(&Amount::zero("EUR")), + Some(Amount::zero("EUR")) + ); + assert_eq!( + amount("EUR:6.41").add(&amount("EUR:4.69")), + Some(amount("EUR:11.1")) + ); + assert_eq!( + amount(format!("EUR:{MAX_VALUE}")).add(&amount("EUR:0.99999999")), + Some(Amount::max("EUR")) + ); + + assert_eq!( + amount(format!("EUR:{}", MAX_VALUE - 5)).add(&amount("EUR:6")), + None + ); + assert_eq!(Amount::new("EUR", u64::MAX, 0).add(&amount("EUR:1")), None); + assert_eq!( + amount(format!("EUR:{}.{}", MAX_VALUE - 5, FRACTION_BASE - 1)) + .add(&amount("EUR:5.00000002")), + None + ); +} + +#[test] +fn test_amount_normalize() { + assert_eq!( + Amount::new("EUR", 4, 2 * FRACTION_BASE).normalize(), + Some(amount("EUR:6")) + ); + assert_eq!( + Amount::new("EUR", 4, 2 * FRACTION_BASE + 1).normalize(), + Some(amount("EUR:6.00000001")) + ); + assert_eq!( + Amount::new("EUR", MAX_VALUE, FRACTION_BASE - 1).normalize(), + Some(Amount::new("EUR", MAX_VALUE, FRACTION_BASE - 1)) + ); + assert_eq!( + Amount::new("EUR", u64::MAX, FRACTION_BASE).normalize(), + None + ); + assert_eq!( + Amount::new("EUR", MAX_VALUE, FRACTION_BASE).normalize(), + None + ); + + for amount in [Amount::max("EUR"), Amount::zero("EUR")] { + assert_eq!(amount.clone().normalize(), Some(amount)) + } +} diff --git a/taler-common/src/api_common.rs b/taler-common/src/api_common.rs @@ -0,0 +1,296 @@ +/* + 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 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/> +*/ + +use std::{ + fmt::Display, + ops::Deref, + str::FromStr, + time::{Duration, SystemTime}, +}; + +use serde::{de::Error, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer}; +use serde_json::{value::RawValue, Value}; + +/// <https://docs.taler.net/core/api-common.html#tsref-type-ErrorDetail> +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ErrorDetail { + pub code: u32, + pub hint: Option<String>, + pub detail: Option<String>, + pub parameter: Option<String>, + pub path: Option<String>, + pub offset: Option<String>, + pub index: Option<String>, + pub object: Option<String>, + pub currency: Option<String>, + pub type_expected: Option<String>, + pub type_actual: Option<String>, + pub extra: Option<Box<RawValue>>, +} + +/// <https://docs.taler.net/core/api-common.html#tsref-type-Timestamp> +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Timestamp { + Never, + Time(SystemTime), +} + +#[derive(Serialize, Deserialize)] +struct TimestampImpl { + t_s: Value, +} + +impl Timestamp { + pub fn now() -> Self { + Self::Time(SystemTime::now()) + } + + pub fn as_sql_micros(&self) -> i64 { + // TODO fail is i64::MAX + match self { + Timestamp::Never => i64::MAX, + Timestamp::Time(system_time) => system_time + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_micros() as i64, + } + } + + pub fn from_sql_micros(micros: i64) -> Result<Self, String> { + if micros == i64::MAX { + Ok(Self::Never) + } else { + let micros = u64::try_from(micros) + .map_err(|_| format!("expected timestamp micros got negative value {micros}"))?; + Ok(Self::Time( + SystemTime::UNIX_EPOCH + .checked_add(Duration::from_micros(micros)) + .ok_or_else(|| format!("expected timestamp micros got overflowing {micros}"))?, + )) + } + } +} + +impl<'de> Deserialize<'de> for Timestamp { + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> + where + D: Deserializer<'de>, + { + let tmp = TimestampImpl::deserialize(deserializer)?; + match tmp.t_s { + Value::Number(s) => { + if let Some(since_epoch_s) = s.as_u64() { + Ok(Self::Time( + SystemTime::UNIX_EPOCH + Duration::from_secs(since_epoch_s), + )) + } else { + Err(Error::custom("Expected epoch time")) + } + } + Value::String(str) if str == "never" => Ok(Self::Never), + _ => Err(Error::custom("Expected epoch time or 'never'")), + } + } +} + +impl Serialize for Timestamp { + fn serialize<S>(&self, se: S) -> Result<S::Ok, S::Error> + where + S: Serializer, + { + let mut se_struct = se.serialize_struct("Timestamp", 1)?; + match self { + Timestamp::Never => se_struct.serialize_field("t_s", "never")?, + Timestamp::Time(time) => se_struct.serialize_field( + "t_s", + &time + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs(), + )?, + }; + + se_struct.end() + } +} + +impl From<SystemTime> for Timestamp { + fn from(time: SystemTime) -> Self { + Self::Time(time) + } +} + +/// <https://docs.taler.net/core/api-common.html#tsref-type-SafeUint64> +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)] +pub struct SafeU64(u64); + +impl Deref for SafeU64 { + type Target = u64; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +#[derive(Debug, thiserror::Error)] +pub enum SafeU64Error { + #[error("{0} unsafe, {0} > (2^53 - 1)")] + Unsafe(u64), + #[error("{0} is negative")] + Negative(i64), +} + +impl TryFrom<u64> for SafeU64 { + type Error = SafeU64Error; + + fn try_from(nb: u64) -> Result<Self, Self::Error> { + if nb < (1 << 53) - 1 { + Ok(SafeU64(nb)) + } else { + Err(SafeU64Error::Unsafe(nb)) + } + } +} + +impl TryFrom<i64> for SafeU64 { + type Error = SafeU64Error; + + fn try_from(nb: i64) -> Result<Self, Self::Error> { + u64::try_from(nb) + .map_err(|_| SafeU64Error::Negative(nb)) + .and_then(|it| it.try_into()) + } +} + +impl TryFrom<i32> for SafeU64 { + type Error = SafeU64Error; + + fn try_from(nb: i32) -> Result<Self, Self::Error> { + u64::try_from(nb) + .map_err(|_| SafeU64Error::Negative(nb as i64)) + .and_then(|it| it.try_into()) + } +} + +impl<'de> Deserialize<'de> for SafeU64 { + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> + where + D: Deserializer<'de>, + { + SafeU64::try_from(u64::deserialize(deserializer)?).map_err(D::Error::custom) + } +} + +impl Display for SafeU64 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + +#[derive(Debug, thiserror::Error)] +pub enum Base32Error<const L: usize> { + #[error("Invalid Crockford’s base32 format")] + Format, + #[error("Invalid length: expected {L} bytess got {0}")] + Length(usize), +} + +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub struct Base32<const L: usize>([u8; L]); + +impl<const L: usize> Base32<L> { + pub fn rand() -> Self { + let mut bytes = [0; L]; + fastrand::fill(&mut bytes); + Self(bytes) + } +} + +impl<const L: usize> From<[u8; L]> for Base32<L> { + fn from(array: [u8; L]) -> Self { + Self(array) + } +} + +impl<const L: usize> Deref for Base32<L> { + type Target = [u8; L]; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl<const L: usize> FromStr for Base32<L> { + type Err = Base32Error<L>; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + let bytes = base32::decode(base32::Alphabet::Crockford, s).ok_or(Base32Error::Format)?; + let exact: [u8; L] = bytes + .try_into() + .map_err(|vec: Vec<u8>| Base32Error::Length(vec.len()))?; + Ok(Self(exact)) + } +} + +pub fn base32(bytes: &[u8]) -> String { + base32::encode(base32::Alphabet::Crockford, bytes) +} + +impl<const L: usize> Display for Base32<L> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&base32(&self.0)) + } +} + +impl<const L: usize> Serialize for Base32<L> { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: Serializer, + { + serializer.serialize_str(&self.to_string()) + } +} + +impl<'de, const L: usize> Deserialize<'de> for Base32<L> { + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> + where + D: Deserializer<'de>, + { + Base32::from_str(&String::deserialize(deserializer)?).map_err(D::Error::custom) + } +} + +impl<'a, const L: usize> TryFrom<&'a [u8]> for Base32<L> { + type Error = Base32Error<L>; + + fn try_from(value: &'a [u8]) -> Result<Self, Self::Error> { + Ok(Self( + value + .try_into() + .map_err(|_| Base32Error::Length(value.len()))?, + )) + } +} + +/// EdDSA and ECDHE public keys always point on Curve25519 +/// and represented using the standard 256 bits Ed25519 compact format, +/// converted to Crockford Base32. +pub type EddsaPublicKey = Base32<32>; +/// 64-byte hash code +pub type HashCode = Base32<64>; +/// 32-bytes hash code +pub type ShortHashCode = Base32<32>; +pub type WadId = Base32<24>; diff --git a/taler-common/src/api_params.rs b/taler-common/src/api_params.rs @@ -0,0 +1,107 @@ +/* + 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 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/> +*/ + +use serde::Deserialize; +use serde_with::{serde_as, DisplayFromStr}; + +use crate::api_wire::TransferState; + +#[derive(Debug, thiserror::Error)] +#[error("{0}")] +pub struct ParamsError(pub String); + +#[serde_as] +#[derive(Debug, Clone, Deserialize)] +/// <https://docs.taler.net/core/api-common.html#row-id-pagination> +pub struct PageParams { + #[serde_as(as = "Option<DisplayFromStr>")] + #[serde(alias = "delta")] + pub limit: Option<i64>, + #[serde_as(as = "Option<DisplayFromStr>")] + #[serde(alias = "start")] + pub offset: Option<i64>, +} + +impl PageParams { + pub fn check(self, max_page_size: i64) -> Result<Page, ParamsError> { + let limit = self.limit.unwrap_or(-20); + if limit == 0 { + return Err(ParamsError(format!( + "Param 'limit' must be non-zero got {limit}" + ))); + } else if limit > max_page_size { + return Err(ParamsError(format!( + "Param 'limit' must be <= {max_page_size} for {limit}" + ))); + } + if let Some(offset) = self.offset { + if offset < 0 { + return Err(ParamsError(format!( + "Param 'offset' must be positive got {offset}" + ))); + } + } + + Ok(Page { + limit, + offset: self.offset, + }) + } +} + +#[derive(Debug)] +pub struct Page { + pub limit: i64, + pub offset: Option<i64>, +} + +impl Page { + pub fn backward(&self) -> bool { + self.limit < 0 + } +} + +#[derive(Debug, Clone, Deserialize)] +/// <https://docs.taler.net/core/api-common.html#long-polling> +pub struct HistoryParams { + #[serde(flatten)] + pub pagination: PageParams, + #[serde(alias = "long_poll_ms")] + pub timeout_ms: Option<u64>, +} + +impl HistoryParams { + pub fn check(self, max_page_size: i64, max_timeout_ms: u64) -> Result<History, ParamsError> { + let timeout_ms = self.timeout_ms.map(|it| it.min(max_timeout_ms)); + Ok(History { + page: self.pagination.check(max_page_size)?, + timeout_ms, + }) + } +} + +#[derive(Debug)] +pub struct History { + pub page: Page, + pub timeout_ms: Option<u64>, +} + +#[derive(Debug, Clone, Deserialize)] +pub struct TransferParams { + #[serde(flatten)] + pub pagination: PageParams, + pub status: Option<TransferState>, +} diff --git a/taler-common/src/api_wire.rs b/taler-common/src/api_wire.rs @@ -0,0 +1,175 @@ +/* + 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 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/> +*/ + +//! Type for the Taler Wire Gateway HTTP API <https://docs.taler.net/core/api-bank-wire.html#taler-wire-gateway-http-api> + +use url::Url; + +use crate::amount::Amount; + +use super::api_common::{EddsaPublicKey, HashCode, SafeU64, ShortHashCode, Timestamp, WadId}; +use serde::{Deserialize, Serialize}; + +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-WireConfig> +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct WireConfig<'a> { + pub name: &'a str, + pub version: &'a str, + pub currency: &'a str, + pub implementation: Option<&'a str>, +} + +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-TransferResponse> +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TransferResponse { + pub timestamp: Timestamp, + pub row_id: SafeU64, +} + +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-TransferRequest> +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct TransferRequest { + pub request_uid: HashCode, + pub amount: Amount, + pub exchange_base_url: Url, + pub wtid: ShortHashCode, + pub credit_account: Url, +} + +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-TransferList> +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct TransferList { + pub transfers: Vec<TransferListStatus>, + pub debit_account: Url, +} + +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-TransferListStatus> +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct TransferListStatus { + pub row_id: SafeU64, + pub status: TransferState, + pub amount: Amount, + pub credit_account: Url, + pub timestamp: Timestamp, +} + +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-TransfertSatus> +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct TransferStatus { + pub status: TransferState, + pub status_msg: Option<String>, + pub amount: Amount, + pub origin_exchange_url: String, + pub wtid: ShortHashCode, + pub credit_account: Url, + pub timestamp: Timestamp, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-OutgoingHistory> +pub struct OutgoingHistory { + pub outgoing_transactions: Vec<OutgoingBankTransaction>, + pub debit_account: Url, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-OutgoingBankTransaction> +pub struct OutgoingBankTransaction { + pub row_id: SafeU64, + pub date: Timestamp, + pub amount: Amount, + pub credit_account: Url, + pub wtid: ShortHashCode, + pub exchange_base_url: Url, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-IncomingHistory> +pub struct IncomingHistory { + pub credit_account: Url, + pub incoming_transactions: Vec<IncomingBankTransaction>, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(tag = "type")] +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-IncomingBankTransaction> +pub enum IncomingBankTransaction { + #[serde(rename = "RESERVE")] + IncomingReserveTransaction { + row_id: SafeU64, + date: Timestamp, + amount: Amount, + debit_account: Url, + reserve_pub: EddsaPublicKey, + }, + #[serde(rename = "WAD")] + IncomingWadTransaction { + row_id: SafeU64, + date: Timestamp, + amount: Amount, + debit_account: Url, + origin_exchange_url: Url, + wad_id: WadId, + }, + #[serde(rename = "KYCAUTH")] + IncomingKycAuthTransaction { + row_id: SafeU64, + date: Timestamp, + amount: Amount, + debit_account: Url, + account_pub: EddsaPublicKey, + }, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-AddIncomingRequest> +pub struct AddIncomingRequest { + pub amount: Amount, + pub reserve_pub: EddsaPublicKey, + pub debit_account: Url, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-AddIncomingResponse> +pub struct AddIncomingResponse { + pub row_id: SafeU64, + pub timestamp: Timestamp, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-AddKycauthRequest> +pub struct AddKycauthRequest { + pub amount: Amount, + pub account_pub: EddsaPublicKey, + pub debit_account: Url, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-AddKycauthResponse> +pub struct AddKycauthResponse { + pub row_id: SafeU64, + pub timestamp: Timestamp, +} + +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, sqlx::Type)] +#[allow(non_camel_case_types)] +#[sqlx(type_name = "transfer_status")] +pub enum TransferState { + pending, + transient_failure, + permanent_failure, + success, +} diff --git a/taler-common/src/error_code.rs b/taler-common/src/error_code.rs @@ -0,0 +1,1954 @@ +/* + This file is part of GNU Taler + Copyright (C) 2024 Taler Systems SA + + 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. + + 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. + + 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/>. + + SPDX-License-Identifier: LGPL3.0-or-later + + Note: the LGPL does not apply to all components of GNU Taler, + but it does apply to this file. +*/ + +/// Error codes used by GNU Taler +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[allow(non_camel_case_types, clippy::zero_prefixed_literal)] +#[repr(u16)] +pub enum ErrorCode { + /** Special code to indicate success (no error). */ + NONE = 0000, + /** An error response did not include an error code in the format expected by the client. Most likely, the server does not speak the GNU Taler protocol. Check the URL and/or the network connection to the server. */ + INVALID = 0001, + /** An internal failure happened on the client side. Details should be in the local logs. Check if you are using the latest available version or file a report with the developers. */ + GENERIC_CLIENT_INTERNAL_ERROR = 0002, + /** The client does not support the protocol version advertised by the server. */ + GENERIC_CLIENT_UNSUPPORTED_PROTOCOL_VERSION = 0003, + /** The response we got from the server was not in the expected format. Most likely, the server does not speak the GNU Taler protocol. Check the URL and/or the network connection to the server. */ + GENERIC_INVALID_RESPONSE = 0010, + /** The operation timed out. Trying again might help. Check the network connection. */ + GENERIC_TIMEOUT = 0011, + /** The protocol version given by the server does not follow the required format. Most likely, the server does not speak the GNU Taler protocol. Check the URL and/or the network connection to the server. */ + GENERIC_VERSION_MALFORMED = 0012, + /** The service responded with a reply that was in the right data format, but the content did not satisfy the protocol. Please file a bug report. */ + GENERIC_REPLY_MALFORMED = 0013, + /** There is an error in the client-side configuration, for example an option is set to an invalid value. Check the logs and fix the local configuration. */ + GENERIC_CONFIGURATION_INVALID = 0014, + /** The client made a request to a service, but received an error response it does not know how to handle. Please file a bug report. */ + GENERIC_UNEXPECTED_REQUEST_ERROR = 0015, + /** The token used by the client to authorize the request does not grant the required permissions for the request. Check the requirements and obtain a suitable authorization token to proceed. */ + GENERIC_TOKEN_PERMISSION_INSUFFICIENT = 0016, + /** The HTTP method used is invalid for this endpoint. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_METHOD_INVALID = 0020, + /** There is no endpoint defined for the URL provided by the client. Check if you used the correct URL and/or file a report with the developers of the client software. */ + GENERIC_ENDPOINT_UNKNOWN = 0021, + /** The JSON in the client's request was malformed. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_JSON_INVALID = 0022, + /** Some of the HTTP headers provided by the client were malformed and caused the server to not be able to handle the request. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_HTTP_HEADERS_MALFORMED = 0023, + /** The payto:// URI provided by the client is malformed. Check that you are using the correct syntax as of RFC 8905 and/or that you entered the bank account number correctly. */ + GENERIC_PAYTO_URI_MALFORMED = 0024, + /** A required parameter in the request was missing. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_PARAMETER_MISSING = 0025, + /** A parameter in the request was malformed. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_PARAMETER_MALFORMED = 0026, + /** The reserve public key was malformed. */ + GENERIC_RESERVE_PUB_MALFORMED = 0027, + /** The body in the request could not be decompressed by the server. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_COMPRESSION_INVALID = 0028, + /** A segment in the path of the URL provided by the client is malformed. Check that you are using the correct encoding for the URL. */ + GENERIC_PATH_SEGMENT_MALFORMED = 0029, + /** The currency involved in the operation is not acceptable for this server. Check your configuration and make sure the currency specified for a given service provider is one of the currencies supported by that provider. */ + GENERIC_CURRENCY_MISMATCH = 0030, + /** The URI is longer than the longest URI the HTTP server is willing to parse. If you believe this was a legitimate request, contact the server administrators and/or the software developers to increase the limit. */ + GENERIC_URI_TOO_LONG = 0031, + /** The body is too large to be permissible for the endpoint. If you believe this was a legitimate request, contact the server administrators and/or the software developers to increase the limit. */ + GENERIC_UPLOAD_EXCEEDS_LIMIT = 0032, + /** The service refused the request due to lack of proper authorization. */ + GENERIC_UNAUTHORIZED = 0040, + /** The service refused the request as the given authorization token is unknown. */ + GENERIC_TOKEN_UNKNOWN = 0041, + /** The service refused the request as the given authorization token expired. */ + GENERIC_TOKEN_EXPIRED = 0042, + /** The service refused the request as the given authorization token is malformed. */ + GENERIC_TOKEN_MALFORMED = 0043, + /** The service refused the request due to lack of proper rights on the resource. */ + GENERIC_FORBIDDEN = 0044, + /** The service failed initialize its connection to the database. The system administrator should check that the service has permissions to access the database and that the database is running. */ + GENERIC_DB_SETUP_FAILED = 0050, + /** The service encountered an error event to just start the database transaction. The system administrator should check that the database is running. */ + GENERIC_DB_START_FAILED = 0051, + /** The service failed to store information in its database. The system administrator should check that the database is running and review the service logs. */ + GENERIC_DB_STORE_FAILED = 0052, + /** The service failed to fetch information from its database. The system administrator should check that the database is running and review the service logs. */ + GENERIC_DB_FETCH_FAILED = 0053, + /** The service encountered an unrecoverable error trying to commit a transaction to the database. The system administrator should check that the database is running and review the service logs. */ + GENERIC_DB_COMMIT_FAILED = 0054, + /** The service encountered an error event to commit the database transaction, even after repeatedly retrying it there was always a conflicting transaction. This indicates a repeated serialization error; it should only happen if some client maliciously tries to create conflicting concurrent transactions. It could also be a sign of a missing index. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_DB_SOFT_FAILURE = 0055, + /** The service's database is inconsistent and violates service-internal invariants. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_DB_INVARIANT_FAILURE = 0056, + /** The HTTP server experienced an internal invariant failure (bug). Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_INTERNAL_INVARIANT_FAILURE = 0060, + /** The service could not compute a cryptographic hash over some JSON value. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_FAILED_COMPUTE_JSON_HASH = 0061, + /** The service could not compute an amount. Check if you are using the latest available version and/or file a report with the developers. */ + GENERIC_FAILED_COMPUTE_AMOUNT = 0062, + /** The HTTP server had insufficient memory to parse the request. Restarting services periodically can help, especially if Postgres is using excessive amounts of memory. Check with the system administrator to investigate. */ + GENERIC_PARSER_OUT_OF_MEMORY = 0070, + /** The HTTP server failed to allocate memory. Restarting services periodically can help, especially if Postgres is using excessive amounts of memory. Check with the system administrator to investigate. */ + GENERIC_ALLOCATION_FAILURE = 0071, + /** The HTTP server failed to allocate memory for building JSON reply. Restarting services periodically can help, especially if Postgres is using excessive amounts of memory. Check with the system administrator to investigate. */ + GENERIC_JSON_ALLOCATION_FAILURE = 0072, + /** The HTTP server failed to allocate memory for making a CURL request. Restarting services periodically can help, especially if Postgres is using excessive amounts of memory. Check with the system administrator to investigate. */ + GENERIC_CURL_ALLOCATION_FAILURE = 0073, + /** The backend could not locate a required template to generate an HTML reply. The system administrator should check if the resource files are installed in the correct location and are readable to the service. */ + GENERIC_FAILED_TO_LOAD_TEMPLATE = 0074, + /** The backend could not expand the template to generate an HTML reply. The system administrator should investigate the logs and check if the templates are well-formed. */ + GENERIC_FAILED_TO_EXPAND_TEMPLATE = 0075, + /** Exchange is badly configured and thus cannot operate. */ + EXCHANGE_GENERIC_BAD_CONFIGURATION = 1000, + /** Operation specified unknown for this endpoint. */ + EXCHANGE_GENERIC_OPERATION_UNKNOWN = 1001, + /** The number of segments included in the URI does not match the number of segments expected by the endpoint. */ + EXCHANGE_GENERIC_WRONG_NUMBER_OF_SEGMENTS = 1002, + /** The same coin was already used with a different denomination previously. */ + EXCHANGE_GENERIC_COIN_CONFLICTING_DENOMINATION_KEY = 1003, + /** The public key of given to a "/coins/" endpoint of the exchange was malformed. */ + EXCHANGE_GENERIC_COINS_INVALID_COIN_PUB = 1004, + /** The exchange is not aware of the denomination key the wallet requested for the operation. */ + EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN = 1005, + /** The signature of the denomination key over the coin is not valid. */ + EXCHANGE_DENOMINATION_SIGNATURE_INVALID = 1006, + /** The exchange failed to perform the operation as it could not find the private keys. This is a problem with the exchange setup, not with the client's request. */ + EXCHANGE_GENERIC_KEYS_MISSING = 1007, + /** Validity period of the denomination lies in the future. */ + EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE = 1008, + /** Denomination key of the coin is past its expiration time for the requested operation. */ + EXCHANGE_GENERIC_DENOMINATION_EXPIRED = 1009, + /** Denomination key of the coin has been revoked. */ + EXCHANGE_GENERIC_DENOMINATION_REVOKED = 1010, + /** An operation where the exchange interacted with a security module timed out. */ + EXCHANGE_GENERIC_SECMOD_TIMEOUT = 1011, + /** The respective coin did not have sufficient residual value for the operation. The "history" in this response provides the "residual_value" of the coin, which may be less than its "original_value". */ + EXCHANGE_GENERIC_INSUFFICIENT_FUNDS = 1012, + /** The exchange had an internal error reconstructing the transaction history of the coin that was being processed. */ + EXCHANGE_GENERIC_COIN_HISTORY_COMPUTATION_FAILED = 1013, + /** The exchange failed to obtain the transaction history of the given coin from the database while generating an insufficient funds errors. */ + EXCHANGE_GENERIC_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS = 1014, + /** The same coin was already used with a different age hash previously. */ + EXCHANGE_GENERIC_COIN_CONFLICTING_AGE_HASH = 1015, + /** The requested operation is not valid for the cipher used by the selected denomination. */ + EXCHANGE_GENERIC_INVALID_DENOMINATION_CIPHER_FOR_OPERATION = 1016, + /** The provided arguments for the operation use inconsistent ciphers. */ + EXCHANGE_GENERIC_CIPHER_MISMATCH = 1017, + /** The number of denominations specified in the request exceeds the limit of the exchange. */ + EXCHANGE_GENERIC_NEW_DENOMS_ARRAY_SIZE_EXCESSIVE = 1018, + /** The coin is not known to the exchange (yet). */ + EXCHANGE_GENERIC_COIN_UNKNOWN = 1019, + /** The time at the server is too far off from the time specified in the request. Most likely the client system time is wrong. */ + EXCHANGE_GENERIC_CLOCK_SKEW = 1020, + /** The specified amount for the coin is higher than the value of the denomination of the coin. */ + EXCHANGE_GENERIC_AMOUNT_EXCEEDS_DENOMINATION_VALUE = 1021, + /** The exchange was not properly configured with global fees. */ + EXCHANGE_GENERIC_GLOBAL_FEES_MISSING = 1022, + /** The exchange was not properly configured with wire fees. */ + EXCHANGE_GENERIC_WIRE_FEES_MISSING = 1023, + /** The purse public key was malformed. */ + EXCHANGE_GENERIC_PURSE_PUB_MALFORMED = 1024, + /** The purse is unknown. */ + EXCHANGE_GENERIC_PURSE_UNKNOWN = 1025, + /** The purse has expired. */ + EXCHANGE_GENERIC_PURSE_EXPIRED = 1026, + /** The exchange has no information about the "reserve_pub" that was given. */ + EXCHANGE_GENERIC_RESERVE_UNKNOWN = 1027, + /** The exchange is not allowed to proceed with the operation until the client has satisfied a KYC check. */ + EXCHANGE_GENERIC_KYC_REQUIRED = 1028, + /** Inconsistency between provided age commitment and attest: either none or both must be provided */ + EXCHANGE_PURSE_DEPOSIT_COIN_CONFLICTING_ATTEST_VS_AGE_COMMITMENT = 1029, + /** The provided attestation for the minimum age couldn't be verified by the exchange. */ + EXCHANGE_PURSE_DEPOSIT_COIN_AGE_ATTESTATION_FAILURE = 1030, + /** The purse was deleted. */ + EXCHANGE_GENERIC_PURSE_DELETED = 1031, + /** The public key of the AML officer in the URL was malformed. */ + EXCHANGE_GENERIC_AML_OFFICER_PUB_MALFORMED = 1032, + /** The signature affirming the GET request of the AML officer is invalid. */ + EXCHANGE_GENERIC_AML_OFFICER_GET_SIGNATURE_INVALID = 1033, + /** The specified AML officer does not have access at this time. */ + EXCHANGE_GENERIC_AML_OFFICER_ACCESS_DENIED = 1034, + /** The requested operation is denied pending the resolution of an anti-money laundering investigation by the exchange operator. This is a manual process, please wait and retry later. */ + EXCHANGE_GENERIC_AML_PENDING = 1035, + /** The requested operation is denied as the account was frozen on suspicion of money laundering. Please contact the exchange operator. */ + EXCHANGE_GENERIC_AML_FROZEN = 1036, + /** The exchange failed to start a KYC attribute conversion helper process. It is likely configured incorrectly. */ + EXCHANGE_GENERIC_KYC_CONVERTER_FAILED = 1037, + /** The KYC operation failed. This could be because the KYC provider rejected the KYC data provided, or because the user aborted the KYC process. */ + EXCHANGE_GENERIC_KYC_FAILED = 1038, + /** A fallback measure for a KYC operation failed. This is a bug. Users should contact the exchange operator. */ + EXCHANGE_GENERIC_KYC_FALLBACK_FAILED = 1039, + /** The specified fallback measure for a KYC operation is unknown. This is a bug. Users should contact the exchange operator. */ + EXCHANGE_GENERIC_KYC_FALLBACK_UNKNOWN = 1040, + /** The exchange is not aware of the bank account (payto URI or hash thereof) specified in the request and thus cannot perform the requested operation. The client should check that the select account is correct. */ + EXCHANGE_GENERIC_BANK_ACCOUNT_UNKNOWN = 1041, + /** The exchange did not find information about the specified transaction in the database. */ + EXCHANGE_DEPOSITS_GET_NOT_FOUND = 1100, + /** The wire hash of given to a "/deposits/" handler was malformed. */ + EXCHANGE_DEPOSITS_GET_INVALID_H_WIRE = 1101, + /** The merchant key of given to a "/deposits/" handler was malformed. */ + EXCHANGE_DEPOSITS_GET_INVALID_MERCHANT_PUB = 1102, + /** The hash of the contract terms given to a "/deposits/" handler was malformed. */ + EXCHANGE_DEPOSITS_GET_INVALID_H_CONTRACT_TERMS = 1103, + /** The coin public key of given to a "/deposits/" handler was malformed. */ + EXCHANGE_DEPOSITS_GET_INVALID_COIN_PUB = 1104, + /** The signature returned by the exchange in a /deposits/ request was malformed. */ + EXCHANGE_DEPOSITS_GET_INVALID_SIGNATURE_BY_EXCHANGE = 1105, + /** The signature of the merchant is invalid. */ + EXCHANGE_DEPOSITS_GET_MERCHANT_SIGNATURE_INVALID = 1106, + /** The provided policy data was not accepted */ + EXCHANGE_DEPOSITS_POLICY_NOT_ACCEPTED = 1107, + /** The given reserve does not have sufficient funds to admit the requested withdraw operation at this time. The response includes the current "balance" of the reserve as well as the transaction "history" that lead to this balance. */ + EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS = 1150, + /** The given reserve does not have sufficient funds to admit the requested age-withdraw operation at this time. The response includes the current "balance" of the reserve as well as the transaction "history" that lead to this balance. */ + EXCHANGE_AGE_WITHDRAW_INSUFFICIENT_FUNDS = 1151, + /** The amount to withdraw together with the fee exceeds the numeric range for Taler amounts. This is not a client failure, as the coin value and fees come from the exchange's configuration. */ + EXCHANGE_WITHDRAW_AMOUNT_FEE_OVERFLOW = 1152, + /** The exchange failed to create the signature using the denomination key. */ + EXCHANGE_WITHDRAW_SIGNATURE_FAILED = 1153, + /** The signature of the reserve is not valid. */ + EXCHANGE_WITHDRAW_RESERVE_SIGNATURE_INVALID = 1154, + /** When computing the reserve history, we ended up with a negative overall balance, which should be impossible. */ + EXCHANGE_RESERVE_HISTORY_ERROR_INSUFFICIENT_FUNDS = 1155, + /** The reserve did not have sufficient funds in it to pay for a full reserve history statement. */ + EXCHANGE_GET_RESERVE_HISTORY_ERROR_INSUFFICIENT_BALANCE = 1156, + /** Withdraw period of the coin to be withdrawn is in the past. */ + EXCHANGE_WITHDRAW_DENOMINATION_KEY_LOST = 1158, + /** The client failed to unblind the blind signature. */ + EXCHANGE_WITHDRAW_UNBLIND_FAILURE = 1159, + /** The client re-used a withdraw nonce, which is not allowed. */ + EXCHANGE_WITHDRAW_NONCE_REUSE = 1160, + /** The client provided an unknown commitment for an age-withdraw request. */ + EXCHANGE_AGE_WITHDRAW_COMMITMENT_UNKNOWN = 1161, + /** The total sum of amounts from the denominations did overflow. */ + EXCHANGE_AGE_WITHDRAW_AMOUNT_OVERFLOW = 1162, + /** The total sum of value and fees from the denominations differs from the committed amount with fees. */ + EXCHANGE_AGE_WITHDRAW_AMOUNT_INCORRECT = 1163, + /** The original commitment differs from the calculated hash */ + EXCHANGE_AGE_WITHDRAW_REVEAL_INVALID_HASH = 1164, + /** The maximum age in the commitment is too large for the reserve */ + EXCHANGE_AGE_WITHDRAW_MAXIMUM_AGE_TOO_LARGE = 1165, + /** The batch withdraw included a planchet that was already withdrawn. This is not allowed. */ + EXCHANGE_WITHDRAW_BATCH_IDEMPOTENT_PLANCHET = 1175, + /** The signature made by the coin over the deposit permission is not valid. */ + EXCHANGE_DEPOSIT_COIN_SIGNATURE_INVALID = 1205, + /** The same coin was already deposited for the same merchant and contract with other details. */ + EXCHANGE_DEPOSIT_CONFLICTING_CONTRACT = 1206, + /** The stated value of the coin after the deposit fee is subtracted would be negative. */ + EXCHANGE_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE = 1207, + /** The stated refund deadline is after the wire deadline. */ + EXCHANGE_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE = 1208, + /** The stated wire deadline is "never", which makes no sense. */ + EXCHANGE_DEPOSIT_WIRE_DEADLINE_IS_NEVER = 1209, + /** The exchange failed to canonicalize and hash the given wire format. For example, the merchant failed to provide the "salt" or a valid payto:// URI in the wire details. Note that while the exchange will do some basic sanity checking on the wire details, it cannot warrant that the banking system will ultimately be able to route to the specified address, even if this check passed. */ + EXCHANGE_DEPOSIT_INVALID_WIRE_FORMAT_JSON = 1210, + /** The hash of the given wire address does not match the wire hash specified in the proposal data. */ + EXCHANGE_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT = 1211, + /** The signature provided by the exchange is not valid. */ + EXCHANGE_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE = 1221, + /** The deposited amount is smaller than the deposit fee, which would result in a negative contribution. */ + EXCHANGE_DEPOSIT_FEE_ABOVE_AMOUNT = 1222, + /** The proof of policy fulfillment was invalid. */ + EXCHANGE_EXTENSIONS_INVALID_FULFILLMENT = 1240, + /** The coin history was requested with a bad signature. */ + EXCHANGE_COIN_HISTORY_BAD_SIGNATURE = 1251, + /** The reserve history was requested with a bad signature. */ + EXCHANGE_RESERVE_HISTORY_BAD_SIGNATURE = 1252, + /** The exchange encountered melt fees exceeding the melted coin's contribution. */ + EXCHANGE_MELT_FEES_EXCEED_CONTRIBUTION = 1302, + /** The signature made with the coin to be melted is invalid. */ + EXCHANGE_MELT_COIN_SIGNATURE_INVALID = 1303, + /** The denomination of the given coin has past its expiration date and it is also not a valid zombie (that is, was not refreshed with the fresh coin being subjected to recoup). */ + EXCHANGE_MELT_COIN_EXPIRED_NO_ZOMBIE = 1305, + /** The signature returned by the exchange in a melt request was malformed. */ + EXCHANGE_MELT_INVALID_SIGNATURE_BY_EXCHANGE = 1306, + /** The provided transfer keys do not match up with the original commitment. Information about the original commitment is included in the response. */ + EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION = 1353, + /** Failed to produce the blinded signatures over the coins to be returned. */ + EXCHANGE_REFRESHES_REVEAL_SIGNING_ERROR = 1354, + /** The exchange is unaware of the refresh session specified in the request. */ + EXCHANGE_REFRESHES_REVEAL_SESSION_UNKNOWN = 1355, + /** The size of the cut-and-choose dimension of the private transfer keys request does not match #TALER_CNC_KAPPA - 1. */ + EXCHANGE_REFRESHES_REVEAL_CNC_TRANSFER_ARRAY_SIZE_INVALID = 1356, + /** The number of envelopes given does not match the number of denomination keys given. */ + EXCHANGE_REFRESHES_REVEAL_NEW_DENOMS_ARRAY_SIZE_MISMATCH = 1358, + /** The exchange encountered a numeric overflow totaling up the cost for the refresh operation. */ + EXCHANGE_REFRESHES_REVEAL_COST_CALCULATION_OVERFLOW = 1359, + /** The exchange's cost calculation shows that the melt amount is below the costs of the transaction. */ + EXCHANGE_REFRESHES_REVEAL_AMOUNT_INSUFFICIENT = 1360, + /** The signature made with the coin over the link data is invalid. */ + EXCHANGE_REFRESHES_REVEAL_LINK_SIGNATURE_INVALID = 1361, + /** The refresh session hash given to a /refreshes/ handler was malformed. */ + EXCHANGE_REFRESHES_REVEAL_INVALID_RCH = 1362, + /** Operation specified invalid for this endpoint. */ + EXCHANGE_REFRESHES_REVEAL_OPERATION_INVALID = 1363, + /** The client provided age commitment data, but age restriction is not supported on this server. */ + EXCHANGE_REFRESHES_REVEAL_AGE_RESTRICTION_NOT_SUPPORTED = 1364, + /** The client provided invalid age commitment data: missing, not an array, or array of invalid size. */ + EXCHANGE_REFRESHES_REVEAL_AGE_RESTRICTION_COMMITMENT_INVALID = 1365, + /** The coin specified in the link request is unknown to the exchange. */ + EXCHANGE_LINK_COIN_UNKNOWN = 1400, + /** The public key of given to a /transfers/ handler was malformed. */ + EXCHANGE_TRANSFERS_GET_WTID_MALFORMED = 1450, + /** The exchange did not find information about the specified wire transfer identifier in the database. */ + EXCHANGE_TRANSFERS_GET_WTID_NOT_FOUND = 1451, + /** The exchange did not find information about the wire transfer fees it charged. */ + EXCHANGE_TRANSFERS_GET_WIRE_FEE_NOT_FOUND = 1452, + /** The exchange found a wire fee that was above the total transfer value (and thus could not have been charged). */ + EXCHANGE_TRANSFERS_GET_WIRE_FEE_INCONSISTENT = 1453, + /** The wait target of the URL was not in the set of expected values. */ + EXCHANGE_PURSES_INVALID_WAIT_TARGET = 1475, + /** The signature on the purse status returned by the exchange was invalid. */ + EXCHANGE_PURSES_GET_INVALID_SIGNATURE_BY_EXCHANGE = 1476, + /** The exchange knows literally nothing about the coin we were asked to refund. But without a transaction history, we cannot issue a refund. This is kind-of OK, the owner should just refresh it directly without executing the refund. */ + EXCHANGE_REFUND_COIN_NOT_FOUND = 1500, + /** We could not process the refund request as the coin's transaction history does not permit the requested refund because then refunds would exceed the deposit amount. The "history" in the response proves this. */ + EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT = 1501, + /** The exchange knows about the coin we were asked to refund, but not about the specific /deposit operation. Hence, we cannot issue a refund (as we do not know if this merchant public key is authorized to do a refund). */ + EXCHANGE_REFUND_DEPOSIT_NOT_FOUND = 1502, + /** The exchange can no longer refund the customer/coin as the money was already transferred (paid out) to the merchant. (It should be past the refund deadline.) */ + EXCHANGE_REFUND_MERCHANT_ALREADY_PAID = 1503, + /** The refund fee specified for the request is lower than the refund fee charged by the exchange for the given denomination key of the refunded coin. */ + EXCHANGE_REFUND_FEE_TOO_LOW = 1504, + /** The refunded amount is smaller than the refund fee, which would result in a negative refund. */ + EXCHANGE_REFUND_FEE_ABOVE_AMOUNT = 1505, + /** The signature of the merchant is invalid. */ + EXCHANGE_REFUND_MERCHANT_SIGNATURE_INVALID = 1506, + /** Merchant backend failed to create the refund confirmation signature. */ + EXCHANGE_REFUND_MERCHANT_SIGNING_FAILED = 1507, + /** The signature returned by the exchange in a refund request was malformed. */ + EXCHANGE_REFUND_INVALID_SIGNATURE_BY_EXCHANGE = 1508, + /** The failure proof returned by the exchange is incorrect. */ + EXCHANGE_REFUND_INVALID_FAILURE_PROOF_BY_EXCHANGE = 1509, + /** Conflicting refund granted before with different amount but same refund transaction ID. */ + EXCHANGE_REFUND_INCONSISTENT_AMOUNT = 1510, + /** The given coin signature is invalid for the request. */ + EXCHANGE_RECOUP_SIGNATURE_INVALID = 1550, + /** The exchange could not find the corresponding withdraw operation. The request is denied. */ + EXCHANGE_RECOUP_WITHDRAW_NOT_FOUND = 1551, + /** The coin's remaining balance is zero. The request is denied. */ + EXCHANGE_RECOUP_COIN_BALANCE_ZERO = 1552, + /** The exchange failed to reproduce the coin's blinding. */ + EXCHANGE_RECOUP_BLINDING_FAILED = 1553, + /** The coin's remaining balance is zero. The request is denied. */ + EXCHANGE_RECOUP_COIN_BALANCE_NEGATIVE = 1554, + /** The coin's denomination has not been revoked yet. */ + EXCHANGE_RECOUP_NOT_ELIGIBLE = 1555, + /** The given coin signature is invalid for the request. */ + EXCHANGE_RECOUP_REFRESH_SIGNATURE_INVALID = 1575, + /** The exchange could not find the corresponding melt operation. The request is denied. */ + EXCHANGE_RECOUP_REFRESH_MELT_NOT_FOUND = 1576, + /** The exchange failed to reproduce the coin's blinding. */ + EXCHANGE_RECOUP_REFRESH_BLINDING_FAILED = 1578, + /** The coin's denomination has not been revoked yet. */ + EXCHANGE_RECOUP_REFRESH_NOT_ELIGIBLE = 1580, + /** This exchange does not allow clients to request /keys for times other than the current (exchange) time. */ + EXCHANGE_KEYS_TIMETRAVEL_FORBIDDEN = 1600, + /** A signature in the server's response was malformed. */ + EXCHANGE_WIRE_SIGNATURE_INVALID = 1650, + /** No bank accounts are enabled for the exchange. The administrator should enable-account using the taler-exchange-offline tool. */ + EXCHANGE_WIRE_NO_ACCOUNTS_CONFIGURED = 1651, + /** The payto:// URI stored in the exchange database for its bank account is malformed. */ + EXCHANGE_WIRE_INVALID_PAYTO_CONFIGURED = 1652, + /** No wire fees are configured for an enabled wire method of the exchange. The administrator must set the wire-fee using the taler-exchange-offline tool. */ + EXCHANGE_WIRE_FEES_NOT_CONFIGURED = 1653, + /** This purse was previously created with different meta data. */ + EXCHANGE_RESERVES_PURSE_CREATE_CONFLICTING_META_DATA = 1675, + /** This purse was previously merged with different meta data. */ + EXCHANGE_RESERVES_PURSE_MERGE_CONFLICTING_META_DATA = 1676, + /** The reserve has insufficient funds to create another purse. */ + EXCHANGE_RESERVES_PURSE_CREATE_INSUFFICIENT_FUNDS = 1677, + /** The purse fee specified for the request is lower than the purse fee charged by the exchange at this time. */ + EXCHANGE_RESERVES_PURSE_FEE_TOO_LOW = 1678, + /** The payment request cannot be deleted anymore, as it either already completed or timed out. */ + EXCHANGE_PURSE_DELETE_ALREADY_DECIDED = 1679, + /** The signature affirming the purse deletion is invalid. */ + EXCHANGE_PURSE_DELETE_SIGNATURE_INVALID = 1680, + /** Withdrawal from the reserve requires age restriction to be set. */ + EXCHANGE_RESERVES_AGE_RESTRICTION_REQUIRED = 1681, + /** The exchange failed to talk to the process responsible for its private denomination keys or the helpers had no denominations (properly) configured. */ + EXCHANGE_DENOMINATION_HELPER_UNAVAILABLE = 1700, + /** The response from the denomination key helper process was malformed. */ + EXCHANGE_DENOMINATION_HELPER_BUG = 1701, + /** The helper refuses to sign with the key, because it is too early: the validity period has not yet started. */ + EXCHANGE_DENOMINATION_HELPER_TOO_EARLY = 1702, + /** The signature of the exchange on the reply was invalid. */ + EXCHANGE_PURSE_DEPOSIT_EXCHANGE_SIGNATURE_INVALID = 1725, + /** The exchange failed to talk to the process responsible for its private signing keys. */ + EXCHANGE_SIGNKEY_HELPER_UNAVAILABLE = 1750, + /** The response from the online signing key helper process was malformed. */ + EXCHANGE_SIGNKEY_HELPER_BUG = 1751, + /** The helper refuses to sign with the key, because it is too early: the validity period has not yet started. */ + EXCHANGE_SIGNKEY_HELPER_TOO_EARLY = 1752, + /** The purse expiration time is in the past at the time of its creation. */ + EXCHANGE_RESERVES_PURSE_EXPIRATION_BEFORE_NOW = 1775, + /** The purse expiration time is set to never, which is not allowed. */ + EXCHANGE_RESERVES_PURSE_EXPIRATION_IS_NEVER = 1776, + /** The signature affirming the merge of the purse is invalid. */ + EXCHANGE_RESERVES_PURSE_MERGE_SIGNATURE_INVALID = 1777, + /** The signature by the reserve affirming the merge is invalid. */ + EXCHANGE_RESERVES_RESERVE_MERGE_SIGNATURE_INVALID = 1778, + /** The signature by the reserve affirming the open operation is invalid. */ + EXCHANGE_RESERVES_OPEN_BAD_SIGNATURE = 1785, + /** The signature by the reserve affirming the close operation is invalid. */ + EXCHANGE_RESERVES_CLOSE_BAD_SIGNATURE = 1786, + /** The signature by the reserve affirming the attestion request is invalid. */ + EXCHANGE_RESERVES_ATTEST_BAD_SIGNATURE = 1787, + /** The exchange does not know an origin account to which the remaining reserve balance could be wired to, and the wallet failed to provide one. */ + EXCHANGE_RESERVES_CLOSE_NO_TARGET_ACCOUNT = 1788, + /** The reserve balance is insufficient to pay for the open operation. */ + EXCHANGE_RESERVES_OPEN_INSUFFICIENT_FUNDS = 1789, + /** The auditor that was supposed to be disabled is unknown to this exchange. */ + EXCHANGE_MANAGEMENT_AUDITOR_NOT_FOUND = 1800, + /** The exchange has a more recently signed conflicting instruction and is thus refusing the current change (replay detected). */ + EXCHANGE_MANAGEMENT_AUDITOR_MORE_RECENT_PRESENT = 1801, + /** The signature to add or enable the auditor does not validate. */ + EXCHANGE_MANAGEMENT_AUDITOR_ADD_SIGNATURE_INVALID = 1802, + /** The signature to disable the auditor does not validate. */ + EXCHANGE_MANAGEMENT_AUDITOR_DEL_SIGNATURE_INVALID = 1803, + /** The signature to revoke the denomination does not validate. */ + EXCHANGE_MANAGEMENT_DENOMINATION_REVOKE_SIGNATURE_INVALID = 1804, + /** The signature to revoke the online signing key does not validate. */ + EXCHANGE_MANAGEMENT_SIGNKEY_REVOKE_SIGNATURE_INVALID = 1805, + /** The exchange has a more recently signed conflicting instruction and is thus refusing the current change (replay detected). */ + EXCHANGE_MANAGEMENT_WIRE_MORE_RECENT_PRESENT = 1806, + /** The signingkey specified is unknown to the exchange. */ + EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_UNKNOWN = 1807, + /** The signature to publish wire account does not validate. */ + EXCHANGE_MANAGEMENT_WIRE_DETAILS_SIGNATURE_INVALID = 1808, + /** The signature to add the wire account does not validate. */ + EXCHANGE_MANAGEMENT_WIRE_ADD_SIGNATURE_INVALID = 1809, + /** The signature to disable the wire account does not validate. */ + EXCHANGE_MANAGEMENT_WIRE_DEL_SIGNATURE_INVALID = 1810, + /** The wire account to be disabled is unknown to the exchange. */ + EXCHANGE_MANAGEMENT_WIRE_NOT_FOUND = 1811, + /** The signature to affirm wire fees does not validate. */ + EXCHANGE_MANAGEMENT_WIRE_FEE_SIGNATURE_INVALID = 1812, + /** The signature conflicts with a previous signature affirming different fees. */ + EXCHANGE_MANAGEMENT_WIRE_FEE_MISMATCH = 1813, + /** The signature affirming the denomination key is invalid. */ + EXCHANGE_MANAGEMENT_KEYS_DENOMKEY_ADD_SIGNATURE_INVALID = 1814, + /** The signature affirming the signing key is invalid. */ + EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_ADD_SIGNATURE_INVALID = 1815, + /** The signature conflicts with a previous signature affirming different fees. */ + EXCHANGE_MANAGEMENT_GLOBAL_FEE_MISMATCH = 1816, + /** The signature affirming the fee structure is invalid. */ + EXCHANGE_MANAGEMENT_GLOBAL_FEE_SIGNATURE_INVALID = 1817, + /** The signature affirming the profit drain is invalid. */ + EXCHANGE_MANAGEMENT_DRAIN_PROFITS_SIGNATURE_INVALID = 1818, + /** The signature affirming the AML decision is invalid. */ + EXCHANGE_AML_DECISION_ADD_SIGNATURE_INVALID = 1825, + /** The AML officer specified is not allowed to make AML decisions right now. */ + EXCHANGE_AML_DECISION_INVALID_OFFICER = 1826, + /** There is a more recent AML decision on file. The decision was rejected as timestamps of AML decisions must be monotonically increasing. */ + EXCHANGE_AML_DECISION_MORE_RECENT_PRESENT = 1827, + /** There AML decision would impose an AML check of a type that is not provided by any KYC provider known to the exchange. */ + EXCHANGE_AML_DECISION_UNKNOWN_CHECK = 1828, + /** The signature affirming the change in the AML officer status is invalid. */ + EXCHANGE_MANAGEMENT_UPDATE_AML_OFFICER_SIGNATURE_INVALID = 1830, + /** A more recent decision about the AML officer status is known to the exchange. */ + EXCHANGE_MANAGEMENT_AML_OFFICERS_MORE_RECENT_PRESENT = 1831, + /** The purse was previously created with different meta data. */ + EXCHANGE_PURSE_CREATE_CONFLICTING_META_DATA = 1850, + /** The purse was previously created with a different contract. */ + EXCHANGE_PURSE_CREATE_CONFLICTING_CONTRACT_STORED = 1851, + /** A coin signature for a deposit into the purse is invalid. */ + EXCHANGE_PURSE_CREATE_COIN_SIGNATURE_INVALID = 1852, + /** The purse expiration time is in the past. */ + EXCHANGE_PURSE_CREATE_EXPIRATION_BEFORE_NOW = 1853, + /** The purse expiration time is "never". */ + EXCHANGE_PURSE_CREATE_EXPIRATION_IS_NEVER = 1854, + /** The purse signature over the purse meta data is invalid. */ + EXCHANGE_PURSE_CREATE_SIGNATURE_INVALID = 1855, + /** The signature over the encrypted contract is invalid. */ + EXCHANGE_PURSE_ECONTRACT_SIGNATURE_INVALID = 1856, + /** The signature from the exchange over the confirmation is invalid. */ + EXCHANGE_PURSE_CREATE_EXCHANGE_SIGNATURE_INVALID = 1857, + /** The coin was previously deposited with different meta data. */ + EXCHANGE_PURSE_DEPOSIT_CONFLICTING_META_DATA = 1858, + /** The encrypted contract was previously uploaded with different meta data. */ + EXCHANGE_PURSE_ECONTRACT_CONFLICTING_META_DATA = 1859, + /** The deposited amount is less than the purse fee. */ + EXCHANGE_CREATE_PURSE_NEGATIVE_VALUE_AFTER_FEE = 1860, + /** The signature using the merge key is invalid. */ + EXCHANGE_PURSE_MERGE_INVALID_MERGE_SIGNATURE = 1876, + /** The signature using the reserve key is invalid. */ + EXCHANGE_PURSE_MERGE_INVALID_RESERVE_SIGNATURE = 1877, + /** The targeted purse is not yet full and thus cannot be merged. Retrying the request later may succeed. */ + EXCHANGE_PURSE_NOT_FULL = 1878, + /** The signature from the exchange over the confirmation is invalid. */ + EXCHANGE_PURSE_MERGE_EXCHANGE_SIGNATURE_INVALID = 1879, + /** The exchange of the target account is not a partner of this exchange. */ + EXCHANGE_MERGE_PURSE_PARTNER_UNKNOWN = 1880, + /** The signature affirming the new partner is invalid. */ + EXCHANGE_MANAGEMENT_ADD_PARTNER_SIGNATURE_INVALID = 1890, + /** Conflicting data for the partner already exists with the exchange. */ + EXCHANGE_MANAGEMENT_ADD_PARTNER_DATA_CONFLICT = 1891, + /** The auditor signature over the denomination meta data is invalid. */ + EXCHANGE_AUDITORS_AUDITOR_SIGNATURE_INVALID = 1900, + /** The auditor that was specified is unknown to this exchange. */ + EXCHANGE_AUDITORS_AUDITOR_UNKNOWN = 1901, + /** The auditor that was specified is no longer used by this exchange. */ + EXCHANGE_AUDITORS_AUDITOR_INACTIVE = 1902, + /** The KYC info access token is not recognized. Hence the request was denied. */ + EXCHANGE_KYC_INFO_AUTHORIZATION_FAILED = 1919, + /** The exchange got stuck in a long series of (likely recursive) KYC rules without user-inputs that did not result in a timely conclusion. This is a configuration failure. Please contact the administrator. */ + EXCHANGE_KYC_RECURSIVE_RULE_DETECTED = 1920, + /** The submitted KYC data lacks an attribute that is required by the KYC form. Please submit the complete form. */ + EXCHANGE_KYC_AML_FORM_INCOMPLETE = 1921, + /** The request requires an AML program which is no longer configured at the exchange. Contact the exchange operator to address the configuration issue. */ + EXCHANGE_KYC_GENERIC_AML_PROGRAM_GONE = 1922, + /** The given check is not of type 'form' and thus using this handler for form submission is incorrect. */ + EXCHANGE_KYC_NOT_A_FORM = 1923, + /** The request requires a check which is no longer configured at the exchange. Contact the exchange operator to address the configuration issue. */ + EXCHANGE_KYC_GENERIC_CHECK_GONE = 1924, + /** The signature affirming the wallet's KYC request was invalid. */ + EXCHANGE_KYC_WALLET_SIGNATURE_INVALID = 1925, + /** The exchange received an unexpected malformed response from its KYC backend. */ + EXCHANGE_KYC_PROOF_BACKEND_INVALID_RESPONSE = 1926, + /** The backend signaled an unexpected failure. */ + EXCHANGE_KYC_PROOF_BACKEND_ERROR = 1927, + /** The backend signaled an authorization failure. */ + EXCHANGE_KYC_PROOF_BACKEND_AUTHORIZATION_FAILED = 1928, + /** The exchange is unaware of having made an the authorization request. */ + EXCHANGE_KYC_PROOF_REQUEST_UNKNOWN = 1929, + /** The KYC authorization signature was invalid. Hence the request was denied. */ + EXCHANGE_KYC_CHECK_AUTHORIZATION_FAILED = 1930, + /** The request used a logic specifier that is not known to the exchange. */ + EXCHANGE_KYC_GENERIC_LOGIC_UNKNOWN = 1931, + /** The request requires a logic which is no longer configured at the exchange. */ + EXCHANGE_KYC_GENERIC_LOGIC_GONE = 1932, + /** The logic plugin had a bug in its interaction with the KYC provider. */ + EXCHANGE_KYC_GENERIC_LOGIC_BUG = 1933, + /** The exchange could not process the request with its KYC provider because the provider refused access to the service. This indicates some configuration issue at the Taler exchange operator. */ + EXCHANGE_KYC_GENERIC_PROVIDER_ACCESS_REFUSED = 1934, + /** There was a timeout in the interaction between the exchange and the KYC provider. The most likely cause is some networking problem. Trying again later might succeed. */ + EXCHANGE_KYC_GENERIC_PROVIDER_TIMEOUT = 1935, + /** The KYC provider responded with a status that was completely unexpected by the KYC logic of the exchange. */ + EXCHANGE_KYC_GENERIC_PROVIDER_UNEXPECTED_REPLY = 1936, + /** The rate limit of the exchange at the KYC provider has been exceeded. Trying much later might work. */ + EXCHANGE_KYC_GENERIC_PROVIDER_RATE_LIMIT_EXCEEDED = 1937, + /** The request to the webhook lacked proper authorization or authentication data. */ + EXCHANGE_KYC_WEBHOOK_UNAUTHORIZED = 1938, + /** The exchange is unaware of the requested payto URI with respect to the KYC status. */ + EXCHANGE_KYC_CHECK_REQUEST_UNKNOWN = 1939, + /** The exchange has no account public key to check the KYC authorization signature against. Hence the request was denied. The user should do a wire transfer to the exchange with the KYC authorization key in the subject. */ + EXCHANGE_KYC_CHECK_AUTHORIZATION_KEY_UNKNOWN = 1940, + /** The form has been previously uploaded, and may only be filed once. The user should be redirected to their main KYC page and see if any other steps need to be taken. */ + EXCHANGE_KYC_FORM_ALREADY_UPLOADED = 1941, + /** The internal state of the exchange specifying KYC measures is malformed. Please contact technical support. */ + EXCHANGE_KYC_MEASURES_MALFORMED = 1942, + /** The specified index does not refer to a valid KYC measure. Please check the URL. */ + EXCHANGE_KYC_MEASURE_INDEX_INVALID = 1943, + /** The operation is not supported by the selected KYC logic. This is either caused by a configuration change or some invalid use of the API. Please contact technical support. */ + EXCHANGE_KYC_INVALID_LOGIC_TO_CHECK = 1944, + /** The AML program failed. This is either caused by a configuration change or a bug. Please contact technical support. */ + EXCHANGE_KYC_AML_PROGRAM_FAILURE = 1945, + /** The AML program returned a malformed result. This is a bug. Please contact technical support. */ + EXCHANGE_KYC_AML_PROGRAM_MALFORMED_RESULT = 1946, + /** The response from the KYC provider lacked required attributes. Please contact technical support. */ + EXCHANGE_KYC_GENERIC_PROVIDER_INCOMPLETE_REPLY = 1947, + /** The context of the KYC check lacked required fields. This is a bug. Please contact technical support. */ + EXCHANGE_KYC_GENERIC_PROVIDER_INCOMPLETE_CONTEXT = 1948, + /** The logic plugin had a bug in its AML processing. This is a bug. Please contact technical support. */ + EXCHANGE_KYC_GENERIC_AML_LOGIC_BUG = 1949, + /** The exchange does not know a contract under the given contract public key. */ + EXCHANGE_CONTRACTS_UNKNOWN = 1950, + /** The URL does not encode a valid exchange public key in its path. */ + EXCHANGE_CONTRACTS_INVALID_CONTRACT_PUB = 1951, + /** The returned encrypted contract did not decrypt. */ + EXCHANGE_CONTRACTS_DECRYPTION_FAILED = 1952, + /** The signature on the encrypted contract did not validate. */ + EXCHANGE_CONTRACTS_SIGNATURE_INVALID = 1953, + /** The decrypted contract was malformed. */ + EXCHANGE_CONTRACTS_DECODING_FAILED = 1954, + /** A coin signature for a deposit into the purse is invalid. */ + EXCHANGE_PURSE_DEPOSIT_COIN_SIGNATURE_INVALID = 1975, + /** It is too late to deposit coins into the purse. */ + EXCHANGE_PURSE_DEPOSIT_DECIDED_ALREADY = 1976, + /** TOTP key is not valid. */ + EXCHANGE_TOTP_KEY_INVALID = 1980, + /** The backend could not find the merchant instance specified in the request. */ + MERCHANT_GENERIC_INSTANCE_UNKNOWN = 2000, + /** The start and end-times in the wire fee structure leave a hole. This is not allowed. */ + MERCHANT_GENERIC_HOLE_IN_WIRE_FEE_STRUCTURE = 2001, + /** The merchant was unable to obtain a valid answer to /wire from the exchange. */ + MERCHANT_GENERIC_EXCHANGE_WIRE_REQUEST_FAILED = 2002, + /** The product category is not known to the backend. */ + MERCHANT_GENERIC_CATEGORY_UNKNOWN = 2003, + /** The proposal is not known to the backend. */ + MERCHANT_GENERIC_ORDER_UNKNOWN = 2005, + /** The order provided to the backend could not be completed, because a product to be completed via inventory data is not actually in our inventory. */ + MERCHANT_GENERIC_PRODUCT_UNKNOWN = 2006, + /** The reward ID is unknown. This could happen if the reward has expired. */ + MERCHANT_GENERIC_REWARD_ID_UNKNOWN = 2007, + /** The contract obtained from the merchant backend was malformed. */ + MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID = 2008, + /** The order we found does not match the provided contract hash. */ + MERCHANT_GENERIC_CONTRACT_HASH_DOES_NOT_MATCH_ORDER = 2009, + /** The exchange failed to provide a valid response to the merchant's /keys request. */ + MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE = 2010, + /** The exchange failed to respond to the merchant on time. */ + MERCHANT_GENERIC_EXCHANGE_TIMEOUT = 2011, + /** The merchant failed to talk to the exchange. */ + MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE = 2012, + /** The exchange returned a maformed response. */ + MERCHANT_GENERIC_EXCHANGE_REPLY_MALFORMED = 2013, + /** The exchange returned an unexpected response status. */ + MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS = 2014, + /** The merchant refused the request due to lack of authorization. */ + MERCHANT_GENERIC_UNAUTHORIZED = 2015, + /** The merchant instance specified in the request was deleted. */ + MERCHANT_GENERIC_INSTANCE_DELETED = 2016, + /** The backend could not find the inbound wire transfer specified in the request. */ + MERCHANT_GENERIC_TRANSFER_UNKNOWN = 2017, + /** The backend could not find the template(id) because it is not exist. */ + MERCHANT_GENERIC_TEMPLATE_UNKNOWN = 2018, + /** The backend could not find the webhook(id) because it is not exist. */ + MERCHANT_GENERIC_WEBHOOK_UNKNOWN = 2019, + /** The backend could not find the webhook(serial) because it is not exist. */ + MERCHANT_GENERIC_PENDING_WEBHOOK_UNKNOWN = 2020, + /** The backend could not find the OTP device(id) because it is not exist. */ + MERCHANT_GENERIC_OTP_DEVICE_UNKNOWN = 2021, + /** The account is not known to the backend. */ + MERCHANT_GENERIC_ACCOUNT_UNKNOWN = 2022, + /** The wire hash was malformed. */ + MERCHANT_GENERIC_H_WIRE_MALFORMED = 2023, + /** The currency specified in the operation does not work with the current state of the given resource. */ + MERCHANT_GENERIC_CURRENCY_MISMATCH = 2024, + /** The exchange specified in the operation is not trusted by this exchange. The client should limit its operation to exchanges enabled by the merchant, or ask the merchant to enable additional exchanges in the configuration. */ + MERCHANT_GENERIC_EXCHANGE_UNTRUSTED = 2025, + /** The exchange failed to provide a valid answer to the tracking request, thus those details are not in the response. */ + MERCHANT_GET_ORDERS_EXCHANGE_TRACKING_FAILURE = 2100, + /** The merchant backend failed to construct the request for tracking to the exchange, thus tracking details are not in the response. */ + MERCHANT_GET_ORDERS_ID_EXCHANGE_REQUEST_FAILURE = 2103, + /** The merchant backend failed trying to contact the exchange for tracking details, thus those details are not in the response. */ + MERCHANT_GET_ORDERS_ID_EXCHANGE_LOOKUP_START_FAILURE = 2104, + /** The claim token used to authenticate the client is invalid for this order. */ + MERCHANT_GET_ORDERS_ID_INVALID_TOKEN = 2105, + /** The contract terms hash used to authenticate the client is invalid for this order. */ + MERCHANT_GET_ORDERS_ID_INVALID_CONTRACT_HASH = 2106, + /** The exchange responded saying that funds were insufficient (for example, due to double-spending). */ + MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_FUNDS = 2150, + /** The denomination key used for payment is not listed among the denomination keys of the exchange. */ + MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND = 2151, + /** The denomination key used for payment is not audited by an auditor approved by the merchant. */ + MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_AUDITOR_FAILURE = 2152, + /** There was an integer overflow totaling up the amounts or deposit fees in the payment. */ + MERCHANT_POST_ORDERS_ID_PAY_AMOUNT_OVERFLOW = 2153, + /** The deposit fees exceed the total value of the payment. */ + MERCHANT_POST_ORDERS_ID_PAY_FEES_EXCEED_PAYMENT = 2154, + /** After considering deposit and wire fees, the payment is insufficient to satisfy the required amount for the contract. The client should revisit the logic used to calculate fees it must cover. */ + MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_DUE_TO_FEES = 2155, + /** Even if we do not consider deposit and wire fees, the payment is insufficient to satisfy the required amount for the contract. */ + MERCHANT_POST_ORDERS_ID_PAY_PAYMENT_INSUFFICIENT = 2156, + /** The signature over the contract of one of the coins was invalid. */ + MERCHANT_POST_ORDERS_ID_PAY_COIN_SIGNATURE_INVALID = 2157, + /** When we tried to find information about the exchange to issue the deposit, we failed. This usually only happens if the merchant backend is somehow unable to get its own HTTP client logic to work. */ + MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_LOOKUP_FAILED = 2158, + /** The refund deadline in the contract is after the transfer deadline. */ + MERCHANT_POST_ORDERS_ID_PAY_REFUND_DEADLINE_PAST_WIRE_TRANSFER_DEADLINE = 2159, + /** The order was already paid (maybe by another wallet). */ + MERCHANT_POST_ORDERS_ID_PAY_ALREADY_PAID = 2160, + /** The payment is too late, the offer has expired. */ + MERCHANT_POST_ORDERS_ID_PAY_OFFER_EXPIRED = 2161, + /** The "merchant" field is missing in the proposal data. This is an internal error as the proposal is from the merchant's own database at this point. */ + MERCHANT_POST_ORDERS_ID_PAY_MERCHANT_FIELD_MISSING = 2162, + /** Failed to locate merchant's account information matching the wire hash given in the proposal. */ + MERCHANT_POST_ORDERS_ID_PAY_WIRE_HASH_UNKNOWN = 2163, + /** The deposit time for the denomination has expired. */ + MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_DEPOSIT_EXPIRED = 2165, + /** The exchange of the deposited coin charges a wire fee that could not be added to the total (total amount too high). */ + MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_WIRE_FEE_ADDITION_FAILED = 2166, + /** The contract was not fully paid because of refunds. Note that clients MAY treat this as paid if, for example, contracts must be executed despite of refunds. */ + MERCHANT_POST_ORDERS_ID_PAY_REFUNDED = 2167, + /** According to our database, we have refunded more than we were paid (which should not be possible). */ + MERCHANT_POST_ORDERS_ID_PAY_REFUNDS_EXCEED_PAYMENTS = 2168, + /** Legacy stuff. Remove me with protocol v1. */ + DEAD_QQQ_PAY_MERCHANT_POST_ORDERS_ID_ABORT_REFUND_REFUSED_PAYMENT_COMPLETE = 2169, + /** The payment failed at the exchange. */ + MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_FAILED = 2170, + /** The payment required a minimum age but one of the coins (of a denomination with support for age restriction) did not provide any age_commitment. */ + MERCHANT_POST_ORDERS_ID_PAY_AGE_COMMITMENT_MISSING = 2171, + /** The payment required a minimum age but one of the coins provided an age_commitment that contained a wrong number of public keys compared to the number of age groups defined in the denomination of the coin. */ + MERCHANT_POST_ORDERS_ID_PAY_AGE_COMMITMENT_SIZE_MISMATCH = 2172, + /** The payment required a minimum age but one of the coins provided a minimum_age_sig that couldn't be verified with the given age_commitment for that particular minimum age. */ + MERCHANT_POST_ORDERS_ID_PAY_AGE_VERIFICATION_FAILED = 2173, + /** The payment required no minimum age but one of the coins (of a denomination with support for age restriction) did not provide the required h_age_commitment. */ + MERCHANT_POST_ORDERS_ID_PAY_AGE_COMMITMENT_HASH_MISSING = 2174, + /** The exchange does not support the selected bank account of the merchant. Likely the merchant had stale data on the bank accounts of the exchange and thus selected an inappropriate exchange when making the offer. */ + MERCHANT_POST_ORDERS_ID_PAY_WIRE_METHOD_UNSUPPORTED = 2175, + /** The payment requires the wallet to select a choice from the choices array and pass it in the 'choice_index' field of the request. */ + MERCHANT_POST_ORDERS_ID_PAY_CHOICE_INDEX_MISSING = 2176, + /** The 'choice_index' field is invalid. */ + MERCHANT_POST_ORDERS_ID_PAY_CHOICE_INDEX_OUT_OF_BOUNDS = 2177, + /** The provided 'tokens' array does not match with the required input tokens of the order. */ + MERCHANT_POST_ORDERS_ID_PAY_INPUT_TOKENS_MISMATCH = 2178, + /** Invalid token issue signature (blindly signed by merchant) for provided token. */ + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_ISSUE_SIG_INVALID = 2179, + /** Invalid token use signature (EdDSA, signed by wallet) for provided token. */ + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_USE_SIG_INVALID = 2180, + /** The provided number of tokens does not match the required number. */ + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_COUNT_MISMATCH = 2181, + /** The provided number of token envelopes does not match the specified number. */ + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_ENVELOPE_COUNT_MISMATCH = 2182, + /** Invalid token because it was already used, is expired or not yet valid. */ + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_INVALID = 2183, + /** The payment violates a transaction limit configured at the given exchange. The wallet has a bug in that it failed to check exchange limits during coin selection. Please report the bug to your wallet developer. */ + MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_TRANSACTION_LIMIT_VIOLATION = 2184, + /** The contract hash does not match the given order ID. */ + MERCHANT_POST_ORDERS_ID_PAID_CONTRACT_HASH_MISMATCH = 2200, + /** The signature of the merchant is not valid for the given contract hash. */ + MERCHANT_POST_ORDERS_ID_PAID_COIN_SIGNATURE_INVALID = 2201, + /** A token family with this ID but conflicting data exists. */ + MERCHANT_POST_TOKEN_FAMILY_CONFLICT = 2225, + /** The backend is unaware of a token family with the given ID. */ + MERCHANT_PATCH_TOKEN_FAMILY_NOT_FOUND = 2226, + /** The merchant failed to send the exchange the refund request. */ + MERCHANT_POST_ORDERS_ID_ABORT_EXCHANGE_REFUND_FAILED = 2251, + /** The merchant failed to find the exchange to process the lookup. */ + MERCHANT_POST_ORDERS_ID_ABORT_EXCHANGE_LOOKUP_FAILED = 2252, + /** The merchant could not find the contract. */ + MERCHANT_POST_ORDERS_ID_ABORT_CONTRACT_NOT_FOUND = 2253, + /** The payment was already completed and thus cannot be aborted anymore. */ + MERCHANT_POST_ORDERS_ID_ABORT_REFUND_REFUSED_PAYMENT_COMPLETE = 2254, + /** The hash provided by the wallet does not match the order. */ + MERCHANT_POST_ORDERS_ID_ABORT_CONTRACT_HASH_MISSMATCH = 2255, + /** The array of coins cannot be empty. */ + MERCHANT_POST_ORDERS_ID_ABORT_COINS_ARRAY_EMPTY = 2256, + /** We are waiting for the exchange to provide us with key material before checking the wire transfer. */ + MERCHANT_EXCHANGE_TRANSFERS_AWAITING_KEYS = 2258, + /** We are waiting for the exchange to provide us with the list of aggregated transactions. */ + MERCHANT_EXCHANGE_TRANSFERS_AWAITING_LIST = 2259, + /** The endpoint indicated in the wire transfer does not belong to a GNU Taler exchange. */ + MERCHANT_EXCHANGE_TRANSFERS_FATAL_NO_EXCHANGE = 2260, + /** The exchange indicated in the wire transfer claims to know nothing about the wire transfer. */ + MERCHANT_EXCHANGE_TRANSFERS_FATAL_NOT_FOUND = 2261, + /** The interaction with the exchange is delayed due to rate limiting. */ + MERCHANT_EXCHANGE_TRANSFERS_RATE_LIMITED = 2262, + /** We experienced a transient failure in our interaction with the exchange. */ + MERCHANT_EXCHANGE_TRANSFERS_TRANSIENT_FAILURE = 2263, + /** The response from the exchange was unacceptable and should be reviewed with an auditor. */ + MERCHANT_EXCHANGE_TRANSFERS_HARD_FAILURE = 2264, + /** We could not claim the order because the backend is unaware of it. */ + MERCHANT_POST_ORDERS_ID_CLAIM_NOT_FOUND = 2300, + /** We could not claim the order because someone else claimed it first. */ + MERCHANT_POST_ORDERS_ID_CLAIM_ALREADY_CLAIMED = 2301, + /** The client-side experienced an internal failure. */ + MERCHANT_POST_ORDERS_ID_CLAIM_CLIENT_INTERNAL_FAILURE = 2302, + /** The backend failed to sign the refund request. */ + MERCHANT_POST_ORDERS_ID_REFUND_SIGNATURE_FAILED = 2350, + /** The client failed to unblind the signature returned by the merchant. */ + MERCHANT_REWARD_PICKUP_UNBLIND_FAILURE = 2400, + /** The exchange returned a failure code for the withdraw operation. */ + MERCHANT_REWARD_PICKUP_EXCHANGE_ERROR = 2403, + /** The merchant failed to add up the amounts to compute the pick up value. */ + MERCHANT_REWARD_PICKUP_SUMMATION_FAILED = 2404, + /** The reward expired. */ + MERCHANT_REWARD_PICKUP_HAS_EXPIRED = 2405, + /** The requested withdraw amount exceeds the amount remaining to be picked up. */ + MERCHANT_REWARD_PICKUP_AMOUNT_EXCEEDS_REWARD_REMAINING = 2406, + /** The merchant did not find the specified denomination key in the exchange's key set. */ + MERCHANT_REWARD_PICKUP_DENOMINATION_UNKNOWN = 2407, + /** The merchant instance has no active bank accounts configured. However, at least one bank account must be available to create new orders. */ + MERCHANT_PRIVATE_POST_ORDERS_INSTANCE_CONFIGURATION_LACKS_WIRE = 2500, + /** The proposal had no timestamp and the merchant backend failed to obtain the current local time. */ + MERCHANT_PRIVATE_POST_ORDERS_NO_LOCALTIME = 2501, + /** The order provided to the backend could not be parsed; likely some required fields were missing or ill-formed. */ + MERCHANT_PRIVATE_POST_ORDERS_PROPOSAL_PARSE_ERROR = 2502, + /** A conflicting order (sharing the same order identifier) already exists at this merchant backend instance. */ + MERCHANT_PRIVATE_POST_ORDERS_ALREADY_EXISTS = 2503, + /** The order creation request is invalid because the given wire deadline is before the refund deadline. */ + MERCHANT_PRIVATE_POST_ORDERS_REFUND_AFTER_WIRE_DEADLINE = 2504, + /** The order creation request is invalid because the delivery date given is in the past. */ + MERCHANT_PRIVATE_POST_ORDERS_DELIVERY_DATE_IN_PAST = 2505, + /** The order creation request is invalid because a wire deadline of "never" is not allowed. */ + MERCHANT_PRIVATE_POST_ORDERS_WIRE_DEADLINE_IS_NEVER = 2506, + /** The order creation request is invalid because the given payment deadline is in the past. */ + MERCHANT_PRIVATE_POST_ORDERS_PAY_DEADLINE_IN_PAST = 2507, + /** The order creation request is invalid because the given refund deadline is in the past. */ + MERCHANT_PRIVATE_POST_ORDERS_REFUND_DEADLINE_IN_PAST = 2508, + /** The backend does not trust any exchange that would allow funds to be wired to any bank account of this instance using the wire method specified with the order. Note that right now, we do not support the use of exchange bank accounts with mandatory currency conversion. */ + MERCHANT_PRIVATE_POST_ORDERS_NO_EXCHANGES_FOR_WIRE_METHOD = 2509, + /** One of the paths to forget is malformed. */ + MERCHANT_PRIVATE_PATCH_ORDERS_ID_FORGET_PATH_SYNTAX_INCORRECT = 2510, + /** One of the paths to forget was not marked as forgettable. */ + MERCHANT_PRIVATE_PATCH_ORDERS_ID_FORGET_PATH_NOT_FORGETTABLE = 2511, + /** The refund amount would violate a refund transaction limit configured at the given exchange. Please find another way to refund the customer, and inquire with your legislator why they make strange banking regulations. */ + MERCHANT_POST_ORDERS_ID_REFUND_EXCHANGE_TRANSACTION_LIMIT_VIOLATION = 2512, + /** The total order amount exceeds hard legal transaction limits from the available exchanges, thus a customer could never legally make this payment. You may try to increase your limits by passing legitimization checks with exchange operators. You could also inquire with your legislator why the limits are prohibitively low for your business. */ + MERCHANT_PRIVATE_POST_ORDERS_AMOUNT_EXCEEDS_LEGAL_LIMITS = 2513, + /** The order provided to the backend could not be deleted, our offer is still valid and awaiting payment. Deletion may work later after the offer has expired if it remains unpaid. */ + MERCHANT_PRIVATE_DELETE_ORDERS_AWAITING_PAYMENT = 2520, + /** The order provided to the backend could not be deleted as the order was already paid. */ + MERCHANT_PRIVATE_DELETE_ORDERS_ALREADY_PAID = 2521, + /** The amount to be refunded is inconsistent: either is lower than the previous amount being awarded, or it exceeds the original price paid by the customer. */ + MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_INCONSISTENT_AMOUNT = 2530, + /** Only paid orders can be refunded, and the frontend specified an unpaid order to issue a refund for. */ + MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_ORDER_UNPAID = 2531, + /** The refund delay was set to 0 and thus no refunds are ever allowed for this order. */ + MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_NOT_ALLOWED_BY_CONTRACT = 2532, + /** The token family slug provided in this order could not be found in the merchant database. */ + MERCHANT_PRIVATE_POST_ORDERS_TOKEN_FAMILY_SLUG_UNKNOWN = 2533, + /** A token family referenced in this order is either expired or not valid yet. */ + MERCHANT_PRIVATE_POST_ORDERS_TOKEN_FAMILY_NOT_VALID = 2534, + /** The exchange says it does not know this transfer. */ + MERCHANT_PRIVATE_POST_TRANSFERS_EXCHANGE_UNKNOWN = 2550, + /** We internally failed to execute the /track/transfer request. */ + MERCHANT_PRIVATE_POST_TRANSFERS_REQUEST_ERROR = 2551, + /** The amount transferred differs between what was submitted and what the exchange claimed. */ + MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_TRANSFERS = 2552, + /** The exchange gave conflicting information about a coin which has been wire transferred. */ + MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_REPORTS = 2553, + /** The exchange charged a different wire fee than what it originally advertised, and it is higher. */ + MERCHANT_PRIVATE_POST_TRANSFERS_BAD_WIRE_FEE = 2554, + /** We did not find the account that the transfer was made to. */ + MERCHANT_PRIVATE_POST_TRANSFERS_ACCOUNT_NOT_FOUND = 2555, + /** The backend could not delete the transfer as the echange already replied to our inquiry about it and we have integrated the result. */ + MERCHANT_PRIVATE_DELETE_TRANSFERS_ALREADY_CONFIRMED = 2556, + /** The backend was previously informed about a wire transfer with the same ID but a different amount. Multiple wire transfers with the same ID are not allowed. If the new amount is correct, the old transfer should first be deleted. */ + MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_SUBMISSION = 2557, + /** The amount transferred differs between what was submitted and what the exchange claimed. */ + MERCHANT_EXCHANGE_TRANSFERS_CONFLICTING_TRANSFERS = 2563, + /** The merchant backend cannot create an instance under the given identifier as one already exists. Use PATCH to modify the existing entry. */ + MERCHANT_PRIVATE_POST_INSTANCES_ALREADY_EXISTS = 2600, + /** The merchant backend cannot create an instance because the authentication configuration field is malformed. */ + MERCHANT_PRIVATE_POST_INSTANCES_BAD_AUTH = 2601, + /** The merchant backend cannot update an instance's authentication settings because the provided authentication settings are malformed. */ + MERCHANT_PRIVATE_POST_INSTANCE_AUTH_BAD_AUTH = 2602, + /** The merchant backend cannot create an instance under the given identifier, the previous one was deleted but must be purged first. */ + MERCHANT_PRIVATE_POST_INSTANCES_PURGE_REQUIRED = 2603, + /** The merchant backend cannot update an instance under the given identifier, the previous one was deleted but must be purged first. */ + MERCHANT_PRIVATE_PATCH_INSTANCES_PURGE_REQUIRED = 2625, + /** The bank account referenced in the requested operation was not found. */ + MERCHANT_PRIVATE_ACCOUNT_DELETE_UNKNOWN_ACCOUNT = 2626, + /** The bank account specified in the request already exists at the merchant. */ + MERCHANT_PRIVATE_ACCOUNT_EXISTS = 2627, + /** The product ID exists. */ + MERCHANT_PRIVATE_POST_PRODUCTS_CONFLICT_PRODUCT_EXISTS = 2650, + /** A category with the same name exists already. */ + MERCHANT_PRIVATE_POST_CATEGORIES_CONFLICT_CATEGORY_EXISTS = 2651, + /** The update would have reduced the total amount of product lost, which is not allowed. */ + MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_REDUCED = 2660, + /** The update would have mean that more stocks were lost than what remains from total inventory after sales, which is not allowed. */ + MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_EXCEEDS_STOCKS = 2661, + /** The update would have reduced the total amount of product in stock, which is not allowed. */ + MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_STOCKED_REDUCED = 2662, + /** The update would have reduced the total amount of product sold, which is not allowed. */ + MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_SOLD_REDUCED = 2663, + /** The lock request is for more products than we have left (unlocked) in stock. */ + MERCHANT_PRIVATE_POST_PRODUCTS_LOCK_INSUFFICIENT_STOCKS = 2670, + /** The deletion request is for a product that is locked. */ + MERCHANT_PRIVATE_DELETE_PRODUCTS_CONFLICTING_LOCK = 2680, + /** The requested wire method is not supported by the exchange. */ + MERCHANT_PRIVATE_POST_RESERVES_UNSUPPORTED_WIRE_METHOD = 2700, + /** The requested exchange does not allow rewards. */ + MERCHANT_PRIVATE_POST_RESERVES_REWARDS_NOT_ALLOWED = 2701, + /** The reserve could not be deleted because it is unknown. */ + MERCHANT_PRIVATE_DELETE_RESERVES_NO_SUCH_RESERVE = 2710, + /** The reserve that was used to fund the rewards has expired. */ + MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_EXPIRED = 2750, + /** The reserve that was used to fund the rewards was not found in the DB. */ + MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_UNKNOWN = 2751, + /** The backend knows the instance that was supposed to support the reward, and it was configured for rewardping. However, the funds remaining are insufficient to cover the reward, and the merchant should top up the reserve. */ + MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_INSUFFICIENT_FUNDS = 2752, + /** The backend failed to find a reserve needed to authorize the reward. */ + MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_NOT_FOUND = 2753, + /** The merchant backend encountered a failure in computing the deposit total. */ + MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE = 2800, + /** The template ID already exists. */ + MERCHANT_PRIVATE_POST_TEMPLATES_CONFLICT_TEMPLATE_EXISTS = 2850, + /** The OTP device ID already exists. */ + MERCHANT_PRIVATE_POST_OTP_DEVICES_CONFLICT_OTP_DEVICE_EXISTS = 2851, + /** Amount given in the using template and in the template contract. There is a conflict. */ + MERCHANT_POST_USING_TEMPLATES_AMOUNT_CONFLICT_TEMPLATES_CONTRACT_AMOUNT = 2860, + /** Subject given in the using template and in the template contract. There is a conflict. */ + MERCHANT_POST_USING_TEMPLATES_SUMMARY_CONFLICT_TEMPLATES_CONTRACT_SUBJECT = 2861, + /** Amount not given in the using template and in the template contract. There is a conflict. */ + MERCHANT_POST_USING_TEMPLATES_NO_AMOUNT = 2862, + /** Subject not given in the using template and in the template contract. There is a conflict. */ + MERCHANT_POST_USING_TEMPLATES_NO_SUMMARY = 2863, + /** The webhook ID elready exists. */ + MERCHANT_PRIVATE_POST_WEBHOOKS_CONFLICT_WEBHOOK_EXISTS = 2900, + /** The webhook serial elready exists. */ + MERCHANT_PRIVATE_POST_PENDING_WEBHOOKS_CONFLICT_PENDING_WEBHOOK_EXISTS = 2910, + /** The auditor refused the connection due to a lack of authorization. */ + AUDITOR_GENERIC_UNAUTHORIZED = 3001, + /** This method is not allowed here. */ + AUDITOR_GENERIC_METHOD_NOT_ALLOWED = 3002, + /** The signature from the exchange on the deposit confirmation is invalid. */ + AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID = 3100, + /** The exchange key used for the signature on the deposit confirmation was revoked. */ + AUDITOR_EXCHANGE_SIGNING_KEY_REVOKED = 3101, + /** The requested resource could not be found. */ + AUDITOR_RESOURCE_NOT_FOUND = 3102, + /** The URI is missing a path component. */ + AUDITOR_URI_MISSING_PATH_COMPONENT = 3103, + /** Wire transfer attempted with credit and debit party being the same bank account. */ + BANK_SAME_ACCOUNT = 5101, + /** Wire transfer impossible, due to financial limitation of the party that attempted the payment. */ + BANK_UNALLOWED_DEBIT = 5102, + /** Negative numbers are not allowed (as value and/or fraction) to instantiate an amount object. */ + BANK_NEGATIVE_NUMBER_AMOUNT = 5103, + /** A too big number was used (as value and/or fraction) to instantiate an amount object. */ + BANK_NUMBER_TOO_BIG = 5104, + /** The bank account referenced in the requested operation was not found. */ + BANK_UNKNOWN_ACCOUNT = 5106, + /** The transaction referenced in the requested operation (typically a reject operation), was not found. */ + BANK_TRANSACTION_NOT_FOUND = 5107, + /** Bank received a malformed amount string. */ + BANK_BAD_FORMAT_AMOUNT = 5108, + /** The client does not own the account credited by the transaction which is to be rejected, so it has no rights do reject it. */ + BANK_REJECT_NO_RIGHTS = 5109, + /** This error code is returned when no known exception types captured the exception. */ + BANK_UNMANAGED_EXCEPTION = 5110, + /** This error code is used for all those exceptions that do not really need a specific error code to return to the client. Used for example when a client is trying to register with a unavailable username. */ + BANK_SOFT_EXCEPTION = 5111, + /** The request UID for a request to transfer funds has already been used, but with different details for the transfer. */ + BANK_TRANSFER_REQUEST_UID_REUSED = 5112, + /** The withdrawal operation already has a reserve selected. The current request conflicts with the existing selection. */ + BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT = 5113, + /** The wire transfer subject duplicates an existing reserve public key. But wire transfer subjects must be unique. */ + BANK_DUPLICATE_RESERVE_PUB_SUBJECT = 5114, + /** The client requested a transaction that is so far in the past, that it has been forgotten by the bank. */ + BANK_ANCIENT_TRANSACTION_GONE = 5115, + /** The client attempted to abort a transaction that was already confirmed. */ + BANK_ABORT_CONFIRM_CONFLICT = 5116, + /** The client attempted to confirm a transaction that was already aborted. */ + BANK_CONFIRM_ABORT_CONFLICT = 5117, + /** The client attempted to register an account with the same name. */ + BANK_REGISTER_CONFLICT = 5118, + /** The client attempted to confirm a withdrawal operation before the wallet posted the required details. */ + BANK_POST_WITHDRAWAL_OPERATION_REQUIRED = 5119, + /** The client tried to register a new account under a reserved username (like 'admin' for example). */ + BANK_RESERVED_USERNAME_CONFLICT = 5120, + /** The client tried to register a new account with an username already in use. */ + BANK_REGISTER_USERNAME_REUSE = 5121, + /** The client tried to register a new account with a payto:// URI already in use. */ + BANK_REGISTER_PAYTO_URI_REUSE = 5122, + /** The client tried to delete an account with a non null balance. */ + BANK_ACCOUNT_BALANCE_NOT_ZERO = 5123, + /** The client tried to create a transaction or an operation that credit an unknown account. */ + BANK_UNKNOWN_CREDITOR = 5124, + /** The client tried to create a transaction or an operation that debit an unknown account. */ + BANK_UNKNOWN_DEBTOR = 5125, + /** The client tried to perform an action prohibited for exchange accounts. */ + BANK_ACCOUNT_IS_EXCHANGE = 5126, + /** The client tried to perform an action reserved for exchange accounts. */ + BANK_ACCOUNT_IS_NOT_EXCHANGE = 5127, + /** Received currency conversion is wrong. */ + BANK_BAD_CONVERSION = 5128, + /** The account referenced in this operation is missing tan info for the chosen channel. */ + BANK_MISSING_TAN_INFO = 5129, + /** The client attempted to confirm a transaction with incomplete info. */ + BANK_CONFIRM_INCOMPLETE = 5130, + /** The request rate is too high. The server is refusing requests to guard against brute-force attacks. */ + BANK_TAN_RATE_LIMITED = 5131, + /** This TAN channel is not supported. */ + BANK_TAN_CHANNEL_NOT_SUPPORTED = 5132, + /** Failed to send TAN using the helper script. Either script is not found, or script timeout, or script terminated with a non-successful result. */ + BANK_TAN_CHANNEL_SCRIPT_FAILED = 5133, + /** The client's response to the challenge was invalid. */ + BANK_TAN_CHALLENGE_FAILED = 5134, + /** A non-admin user has tried to change their legal name. */ + BANK_NON_ADMIN_PATCH_LEGAL_NAME = 5135, + /** A non-admin user has tried to change their debt limit. */ + BANK_NON_ADMIN_PATCH_DEBT_LIMIT = 5136, + /** A non-admin user has tried to change their password whihout providing the current one. */ + BANK_NON_ADMIN_PATCH_MISSING_OLD_PASSWORD = 5137, + /** Provided old password does not match current password. */ + BANK_PATCH_BAD_OLD_PASSWORD = 5138, + /** An admin user has tried to become an exchange. */ + BANK_PATCH_ADMIN_EXCHANGE = 5139, + /** A non-admin user has tried to change their cashout account. */ + BANK_NON_ADMIN_PATCH_CASHOUT = 5140, + /** A non-admin user has tried to change their contact info. */ + BANK_NON_ADMIN_PATCH_CONTACT = 5141, + /** The client tried to create a transaction that credit the admin account. */ + BANK_ADMIN_CREDITOR = 5142, + /** The referenced challenge was not found. */ + BANK_CHALLENGE_NOT_FOUND = 5143, + /** The referenced challenge has expired. */ + BANK_TAN_CHALLENGE_EXPIRED = 5144, + /** A non-admin user has tried to create an account with 2fa. */ + BANK_NON_ADMIN_SET_TAN_CHANNEL = 5145, + /** A non-admin user has tried to set their minimum cashout amount. */ + BANK_NON_ADMIN_SET_MIN_CASHOUT = 5146, + /** Amount of currency conversion it less than the minimum allowed. */ + BANK_CONVERSION_AMOUNT_TO_SMALL = 5147, + /** Specified amount will not work for this withdrawal. */ + BANK_AMOUNT_DIFFERS = 5148, + /** The backend requires an amount to be specified. */ + BANK_AMOUNT_REQUIRED = 5149, + /** The sync service failed find the account in its database. */ + SYNC_ACCOUNT_UNKNOWN = 6100, + /** The SHA-512 hash provided in the If-None-Match header is malformed. */ + SYNC_BAD_IF_NONE_MATCH = 6101, + /** The SHA-512 hash provided in the If-Match header is malformed or missing. */ + SYNC_BAD_IF_MATCH = 6102, + /** The signature provided in the "Sync-Signature" header is malformed or missing. */ + SYNC_BAD_SYNC_SIGNATURE = 6103, + /** The signature provided in the "Sync-Signature" header does not match the account, old or new Etags. */ + SYNC_INVALID_SIGNATURE = 6104, + /** The "Content-length" field for the upload is not a number. */ + SYNC_MALFORMED_CONTENT_LENGTH = 6105, + /** The "Content-length" field for the upload is too big based on the server's terms of service. */ + SYNC_EXCESSIVE_CONTENT_LENGTH = 6106, + /** The server is out of memory to handle the upload. Trying again later may succeed. */ + SYNC_OUT_OF_MEMORY_ON_CONTENT_LENGTH = 6107, + /** The uploaded data does not match the Etag. */ + SYNC_INVALID_UPLOAD = 6108, + /** HTTP server experienced a timeout while awaiting promised payment. */ + SYNC_PAYMENT_GENERIC_TIMEOUT = 6109, + /** Sync could not setup the payment request with its own backend. */ + SYNC_PAYMENT_CREATE_BACKEND_ERROR = 6110, + /** The sync service failed find the backup to be updated in its database. */ + SYNC_PREVIOUS_BACKUP_UNKNOWN = 6111, + /** The "Content-length" field for the upload is missing. */ + SYNC_MISSING_CONTENT_LENGTH = 6112, + /** Sync had problems communicating with its payment backend. */ + SYNC_GENERIC_BACKEND_ERROR = 6113, + /** Sync experienced a timeout communicating with its payment backend. */ + SYNC_GENERIC_BACKEND_TIMEOUT = 6114, + /** The wallet does not implement a version of the exchange protocol that is compatible with the protocol version of the exchange. */ + WALLET_EXCHANGE_PROTOCOL_VERSION_INCOMPATIBLE = 7000, + /** The wallet encountered an unexpected exception. This is likely a bug in the wallet implementation. */ + WALLET_UNEXPECTED_EXCEPTION = 7001, + /** The wallet received a response from a server, but the response can't be parsed. */ + WALLET_RECEIVED_MALFORMED_RESPONSE = 7002, + /** The wallet tried to make a network request, but it received no response. */ + WALLET_NETWORK_ERROR = 7003, + /** The wallet tried to make a network request, but it was throttled. */ + WALLET_HTTP_REQUEST_THROTTLED = 7004, + /** The wallet made a request to a service, but received an error response it does not know how to handle. */ + WALLET_UNEXPECTED_REQUEST_ERROR = 7005, + /** The denominations offered by the exchange are insufficient. Likely the exchange is badly configured or not maintained. */ + WALLET_EXCHANGE_DENOMINATIONS_INSUFFICIENT = 7006, + /** The wallet does not support the operation requested by a client. */ + WALLET_CORE_API_OPERATION_UNKNOWN = 7007, + /** The given taler://pay URI is invalid. */ + WALLET_INVALID_TALER_PAY_URI = 7008, + /** The signature on a coin by the exchange's denomination key is invalid after unblinding it. */ + WALLET_EXCHANGE_COIN_SIGNATURE_INVALID = 7009, + /** The exchange does not know about the reserve (yet), and thus withdrawal can't progress. */ + WALLET_EXCHANGE_WITHDRAW_RESERVE_UNKNOWN_AT_EXCHANGE = 7010, + /** The wallet core service is not available. */ + WALLET_CORE_NOT_AVAILABLE = 7011, + /** The bank has aborted a withdrawal operation, and thus a withdrawal can't complete. */ + WALLET_WITHDRAWAL_OPERATION_ABORTED_BY_BANK = 7012, + /** An HTTP request made by the wallet timed out. */ + WALLET_HTTP_REQUEST_GENERIC_TIMEOUT = 7013, + /** The order has already been claimed by another wallet. */ + WALLET_ORDER_ALREADY_CLAIMED = 7014, + /** A group of withdrawal operations (typically for the same reserve at the same exchange) has errors and will be tried again later. */ + WALLET_WITHDRAWAL_GROUP_INCOMPLETE = 7015, + /** The signature on a coin by the exchange's denomination key (obtained through the merchant via a reward) is invalid after unblinding it. */ + WALLET_REWARD_COIN_SIGNATURE_INVALID = 7016, + /** The wallet does not implement a version of the bank integration API that is compatible with the version offered by the bank. */ + WALLET_BANK_INTEGRATION_PROTOCOL_VERSION_INCOMPATIBLE = 7017, + /** The wallet processed a taler://pay URI, but the merchant base URL in the downloaded contract terms does not match the merchant base URL derived from the URI. */ + WALLET_CONTRACT_TERMS_BASE_URL_MISMATCH = 7018, + /** The merchant's signature on the contract terms is invalid. */ + WALLET_CONTRACT_TERMS_SIGNATURE_INVALID = 7019, + /** The contract terms given by the merchant are malformed. */ + WALLET_CONTRACT_TERMS_MALFORMED = 7020, + /** A pending operation failed, and thus the request can't be completed. */ + WALLET_PENDING_OPERATION_FAILED = 7021, + /** A payment was attempted, but the merchant had an internal server error (5xx). */ + WALLET_PAY_MERCHANT_SERVER_ERROR = 7022, + /** The crypto worker failed. */ + WALLET_CRYPTO_WORKER_ERROR = 7023, + /** The crypto worker received a bad request. */ + WALLET_CRYPTO_WORKER_BAD_REQUEST = 7024, + /** A KYC step is required before withdrawal can proceed. */ + WALLET_WITHDRAWAL_KYC_REQUIRED = 7025, + /** The wallet does not have sufficient balance to create a deposit group. */ + WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE = 7026, + /** The wallet does not have sufficient balance to create a peer push payment. */ + WALLET_PEER_PUSH_PAYMENT_INSUFFICIENT_BALANCE = 7027, + /** The wallet does not have sufficient balance to pay for an invoice. */ + WALLET_PEER_PULL_PAYMENT_INSUFFICIENT_BALANCE = 7028, + /** A group of refresh operations has errors and will be tried again later. */ + WALLET_REFRESH_GROUP_INCOMPLETE = 7029, + /** The exchange's self-reported base URL does not match the one that the wallet is using. */ + WALLET_EXCHANGE_BASE_URL_MISMATCH = 7030, + /** The order has already been paid by another wallet. */ + WALLET_ORDER_ALREADY_PAID = 7031, + /** An exchange that is required for some request is currently not available. */ + WALLET_EXCHANGE_UNAVAILABLE = 7032, + /** An exchange entry is still used by the exchange, thus it can't be deleted without purging. */ + WALLET_EXCHANGE_ENTRY_USED = 7033, + /** The wallet database is unavailable and the wallet thus is not operational. */ + WALLET_DB_UNAVAILABLE = 7034, + /** A taler:// URI is malformed and can't be parsed. */ + WALLET_TALER_URI_MALFORMED = 7035, + /** A wallet-core request was cancelled and thus can't provide a response. */ + WALLET_CORE_REQUEST_CANCELLED = 7036, + /** A wallet-core request failed because the user needs to first accept the exchange's terms of service. */ + WALLET_EXCHANGE_TOS_NOT_ACCEPTED = 7037, + /** An exchange entry could not be updated, as the exchange's new details conflict with the new details. */ + WALLET_EXCHANGE_ENTRY_UPDATE_CONFLICT = 7038, + /** The wallet's information about the exchange is outdated. */ + WALLET_EXCHANGE_ENTRY_OUTDATED = 7039, + /** The merchant needs to do KYC first, the payment could not be completed. */ + WALLET_PAY_MERCHANT_KYC_MISSING = 7040, + /** A peer-pull-debit transaction was aborted because the exchange reported the purse as gone. */ + WALLET_PEER_PULL_DEBIT_PURSE_GONE = 7041, + /** A transaction was aborted on explicit request by the user. */ + WALLET_TRANSACTION_ABORTED_BY_USER = 7042, + /** A transaction was abandoned on explicit request by the user. */ + WALLET_TRANSACTION_ABANDONED_BY_USER = 7043, + /** We encountered a timeout with our payment backend. */ + ANASTASIS_GENERIC_BACKEND_TIMEOUT = 8000, + /** The backend requested payment, but the request is malformed. */ + ANASTASIS_GENERIC_INVALID_PAYMENT_REQUEST = 8001, + /** The backend got an unexpected reply from the payment processor. */ + ANASTASIS_GENERIC_BACKEND_ERROR = 8002, + /** The "Content-length" field for the upload is missing. */ + ANASTASIS_GENERIC_MISSING_CONTENT_LENGTH = 8003, + /** The "Content-length" field for the upload is malformed. */ + ANASTASIS_GENERIC_MALFORMED_CONTENT_LENGTH = 8004, + /** The backend failed to setup an order with the payment processor. */ + ANASTASIS_GENERIC_ORDER_CREATE_BACKEND_ERROR = 8005, + /** The backend was not authorized to check for payment with the payment processor. */ + ANASTASIS_GENERIC_PAYMENT_CHECK_UNAUTHORIZED = 8006, + /** The backend could not check payment status with the payment processor. */ + ANASTASIS_GENERIC_PAYMENT_CHECK_START_FAILED = 8007, + /** The Anastasis provider could not be reached. */ + ANASTASIS_GENERIC_PROVIDER_UNREACHABLE = 8008, + /** HTTP server experienced a timeout while awaiting promised payment. */ + ANASTASIS_PAYMENT_GENERIC_TIMEOUT = 8009, + /** The key share is unknown to the provider. */ + ANASTASIS_TRUTH_UNKNOWN = 8108, + /** The authorization method used for the key share is no longer supported by the provider. */ + ANASTASIS_TRUTH_AUTHORIZATION_METHOD_NO_LONGER_SUPPORTED = 8109, + /** The client needs to respond to the challenge. */ + ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED = 8110, + /** The client's response to the challenge was invalid. */ + ANASTASIS_TRUTH_CHALLENGE_FAILED = 8111, + /** The backend is not aware of having issued the provided challenge code. Either this is the wrong code, or it has expired. */ + ANASTASIS_TRUTH_CHALLENGE_UNKNOWN = 8112, + /** The backend failed to initiate the authorization process. */ + ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED = 8114, + /** The authorization succeeded, but the key share is no longer available. */ + ANASTASIS_TRUTH_KEY_SHARE_GONE = 8115, + /** The backend forgot the order we asked the client to pay for */ + ANASTASIS_TRUTH_ORDER_DISAPPEARED = 8116, + /** The backend itself reported a bad exchange interaction. */ + ANASTASIS_TRUTH_BACKEND_EXCHANGE_BAD = 8117, + /** The backend reported a payment status we did not expect. */ + ANASTASIS_TRUTH_UNEXPECTED_PAYMENT_STATUS = 8118, + /** The backend failed to setup the order for payment. */ + ANASTASIS_TRUTH_PAYMENT_CREATE_BACKEND_ERROR = 8119, + /** The decryption of the key share failed with the provided key. */ + ANASTASIS_TRUTH_DECRYPTION_FAILED = 8120, + /** The request rate is too high. The server is refusing requests to guard against brute-force attacks. */ + ANASTASIS_TRUTH_RATE_LIMITED = 8121, + /** A request to issue a challenge is not valid for this authentication method. */ + ANASTASIS_TRUTH_CHALLENGE_WRONG_METHOD = 8123, + /** The backend failed to store the key share because the UUID is already in use. */ + ANASTASIS_TRUTH_UPLOAD_UUID_EXISTS = 8150, + /** The backend failed to store the key share because the authorization method is not supported. */ + ANASTASIS_TRUTH_UPLOAD_METHOD_NOT_SUPPORTED = 8151, + /** The provided phone number is not an acceptable number. */ + ANASTASIS_SMS_PHONE_INVALID = 8200, + /** Failed to run the SMS transmission helper process. */ + ANASTASIS_SMS_HELPER_EXEC_FAILED = 8201, + /** Provider failed to send SMS. Helper terminated with a non-successful result. */ + ANASTASIS_SMS_HELPER_COMMAND_FAILED = 8202, + /** The provided email address is not an acceptable address. */ + ANASTASIS_EMAIL_INVALID = 8210, + /** Failed to run the E-mail transmission helper process. */ + ANASTASIS_EMAIL_HELPER_EXEC_FAILED = 8211, + /** Provider failed to send E-mail. Helper terminated with a non-successful result. */ + ANASTASIS_EMAIL_HELPER_COMMAND_FAILED = 8212, + /** The provided postal address is not an acceptable address. */ + ANASTASIS_POST_INVALID = 8220, + /** Failed to run the mail transmission helper process. */ + ANASTASIS_POST_HELPER_EXEC_FAILED = 8221, + /** Provider failed to send mail. Helper terminated with a non-successful result. */ + ANASTASIS_POST_HELPER_COMMAND_FAILED = 8222, + /** The provided IBAN address is not an acceptable IBAN. */ + ANASTASIS_IBAN_INVALID = 8230, + /** The provider has not yet received the IBAN wire transfer authorizing the disclosure of the key share. */ + ANASTASIS_IBAN_MISSING_TRANSFER = 8231, + /** The backend did not find a TOTP key in the data provided. */ + ANASTASIS_TOTP_KEY_MISSING = 8240, + /** The key provided does not satisfy the format restrictions for an Anastasis TOTP key. */ + ANASTASIS_TOTP_KEY_INVALID = 8241, + /** The given if-none-match header is malformed. */ + ANASTASIS_POLICY_BAD_IF_NONE_MATCH = 8301, + /** The server is out of memory to handle the upload. Trying again later may succeed. */ + ANASTASIS_POLICY_OUT_OF_MEMORY_ON_CONTENT_LENGTH = 8304, + /** The signature provided in the "Anastasis-Policy-Signature" header is malformed or missing. */ + ANASTASIS_POLICY_BAD_SIGNATURE = 8305, + /** The given if-match header is malformed. */ + ANASTASIS_POLICY_BAD_IF_MATCH = 8306, + /** The uploaded data does not match the Etag. */ + ANASTASIS_POLICY_INVALID_UPLOAD = 8307, + /** The provider is unaware of the requested policy. */ + ANASTASIS_POLICY_NOT_FOUND = 8350, + /** The given action is invalid for the current state of the reducer. */ + ANASTASIS_REDUCER_ACTION_INVALID = 8400, + /** The given state of the reducer is invalid. */ + ANASTASIS_REDUCER_STATE_INVALID = 8401, + /** The given input to the reducer is invalid. */ + ANASTASIS_REDUCER_INPUT_INVALID = 8402, + /** The selected authentication method does not work for the Anastasis provider. */ + ANASTASIS_REDUCER_AUTHENTICATION_METHOD_NOT_SUPPORTED = 8403, + /** The given input and action do not work for the current state. */ + ANASTASIS_REDUCER_INPUT_INVALID_FOR_STATE = 8404, + /** We experienced an unexpected failure interacting with the backend. */ + ANASTASIS_REDUCER_BACKEND_FAILURE = 8405, + /** The contents of a resource file did not match our expectations. */ + ANASTASIS_REDUCER_RESOURCE_MALFORMED = 8406, + /** A required resource file is missing. */ + ANASTASIS_REDUCER_RESOURCE_MISSING = 8407, + /** An input did not match the regular expression. */ + ANASTASIS_REDUCER_INPUT_REGEX_FAILED = 8408, + /** An input did not match the custom validation logic. */ + ANASTASIS_REDUCER_INPUT_VALIDATION_FAILED = 8409, + /** Our attempts to download the recovery document failed with all providers. Most likely the personal information you entered differs from the information you provided during the backup process and you should go back to the previous step. Alternatively, if you used a backup provider that is unknown to this application, you should add that provider manually. */ + ANASTASIS_REDUCER_POLICY_LOOKUP_FAILED = 8410, + /** Anastasis provider reported a fatal failure. */ + ANASTASIS_REDUCER_BACKUP_PROVIDER_FAILED = 8411, + /** Anastasis provider failed to respond to the configuration request. */ + ANASTASIS_REDUCER_PROVIDER_CONFIG_FAILED = 8412, + /** The policy we downloaded is malformed. Must have been a client error while creating the backup. */ + ANASTASIS_REDUCER_POLICY_MALFORMED = 8413, + /** We failed to obtain the policy, likely due to a network issue. */ + ANASTASIS_REDUCER_NETWORK_FAILED = 8414, + /** The recovered secret did not match the required syntax. */ + ANASTASIS_REDUCER_SECRET_MALFORMED = 8415, + /** The challenge data provided is too large for the available providers. */ + ANASTASIS_REDUCER_CHALLENGE_DATA_TOO_BIG = 8416, + /** The provided core secret is too large for some of the providers. */ + ANASTASIS_REDUCER_SECRET_TOO_BIG = 8417, + /** The provider returned in invalid configuration. */ + ANASTASIS_REDUCER_PROVIDER_INVALID_CONFIG = 8418, + /** The reducer encountered an internal error, likely a bug that needs to be reported. */ + ANASTASIS_REDUCER_INTERNAL_ERROR = 8419, + /** The reducer already synchronized with all providers. */ + ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED = 8420, + /** The Donau failed to perform the operation as it could not find the private keys. This is a problem with the Donau setup, not with the client's request. */ + DONAU_GENERIC_KEYS_MISSING = 8607, + /** The signature of the charity key is not valid. */ + DONAU_CHARITY_SIGNATURE_INVALID = 8608, + /** The charity is unknown. */ + DONAU_CHARITY_NOT_FOUND = 8609, + /** The donation amount specified in the request exceeds the limit of the charity. */ + DONAU_EXCEEDING_DONATION_LIMIT = 8610, + /** The Donau is not aware of the donation unit requested for the operation. */ + DONAU_GENERIC_DONATION_UNIT_UNKNOWN = 8611, + /** The Donau failed to talk to the process responsible for its private donation unit keys or the helpers had no donation units (properly) configured. */ + DONAU_DONATION_UNIT_HELPER_UNAVAILABLE = 8612, + /** The Donau failed to talk to the process responsible for its private signing keys. */ + DONAU_SIGNKEY_HELPER_UNAVAILABLE = 8613, + /** The response from the online signing key helper process was malformed. */ + DONAU_SIGNKEY_HELPER_BUG = 8614, + /** The number of segments included in the URI does not match the number of segments expected by the endpoint. */ + DONAU_GENERIC_WRONG_NUMBER_OF_SEGMENTS = 8615, + /** The signature of the donation receipt is not valid. */ + DONAU_DONATION_RECEIPT_SIGNATURE_INVALID = 8616, + /** The client re-used a unique donor identifier nonce, which is not allowed. */ + DONAU_DONOR_IDENTIFIER_NONCE_REUSE = 8617, + /** A generic error happened in the LibEuFin nexus. See the enclose details JSON for more information. */ + LIBEUFIN_NEXUS_GENERIC_ERROR = 9000, + /** An uncaught exception happened in the LibEuFin nexus service. */ + LIBEUFIN_NEXUS_UNCAUGHT_EXCEPTION = 9001, + /** A generic error happened in the LibEuFin sandbox. See the enclose details JSON for more information. */ + LIBEUFIN_SANDBOX_GENERIC_ERROR = 9500, + /** An uncaught exception happened in the LibEuFin sandbox service. */ + LIBEUFIN_SANDBOX_UNCAUGHT_EXCEPTION = 9501, + /** This validation method is not supported by the service. */ + TALDIR_METHOD_NOT_SUPPORTED = 9600, + /** Number of allowed attempts for initiating a challenge exceeded. */ + TALDIR_REGISTER_RATE_LIMITED = 9601, + /** The client is unknown or unauthorized. */ + CHALLENGER_GENERIC_CLIENT_UNKNOWN = 9750, + /** The client is not authorized to use the given redirect URI. */ + CHALLENGER_GENERIC_CLIENT_FORBIDDEN_BAD_REDIRECT_URI = 9751, + /** The service failed to execute its helper process to send the challenge. */ + CHALLENGER_HELPER_EXEC_FAILED = 9752, + /** The grant is unknown to the service (it could also have expired). */ + CHALLENGER_GRANT_UNKNOWN = 9753, + /** The code given is not even well-formed. */ + CHALLENGER_CLIENT_FORBIDDEN_BAD_CODE = 9754, + /** The service is not aware of the referenced validation process. */ + CHALLENGER_GENERIC_VALIDATION_UNKNOWN = 9755, + /** The code given is not valid. */ + CHALLENGER_CLIENT_FORBIDDEN_INVALID_CODE = 9756, + /** Too many attempts have been made, validation is temporarily disabled for this address. */ + CHALLENGER_TOO_MANY_ATTEMPTS = 9757, + /** The PIN code provided is incorrect. */ + CHALLENGER_INVALID_PIN = 9758, + /** The token cannot be valid as no address was ever provided by the client. */ + CHALLENGER_MISSING_ADDRESS = 9759, + /** End of error code range. */ + END = 9999, +} + +impl ErrorCode { + pub fn metadata(&self) -> (u16, &'static str) { + use ErrorCode::*; + match self { + NONE => (0, "Special code to indicate success (no error)."), + INVALID => (0, "An error response did not include an error code in the format expected by the client. Most likely, the server does not speak the GNU Taler protocol. Check the URL and/or the network connection to the server."), + GENERIC_CLIENT_INTERNAL_ERROR => (0, "An internal failure happened on the client side. Details should be in the local logs. Check if you are using the latest available version or file a report with the developers."), + GENERIC_CLIENT_UNSUPPORTED_PROTOCOL_VERSION => (0, "The client does not support the protocol version advertised by the server."), + GENERIC_INVALID_RESPONSE => (0, "The response we got from the server was not in the expected format. Most likely, the server does not speak the GNU Taler protocol. Check the URL and/or the network connection to the server."), + GENERIC_TIMEOUT => (0, "The operation timed out. Trying again might help. Check the network connection."), + GENERIC_VERSION_MALFORMED => (0, "The protocol version given by the server does not follow the required format. Most likely, the server does not speak the GNU Taler protocol. Check the URL and/or the network connection to the server."), + GENERIC_REPLY_MALFORMED => (0, "The service responded with a reply that was in the right data format, but the content did not satisfy the protocol. Please file a bug report."), + GENERIC_CONFIGURATION_INVALID => (0, "There is an error in the client-side configuration, for example an option is set to an invalid value. Check the logs and fix the local configuration."), + GENERIC_UNEXPECTED_REQUEST_ERROR => (0, "The client made a request to a service, but received an error response it does not know how to handle. Please file a bug report."), + GENERIC_TOKEN_PERMISSION_INSUFFICIENT => (403, "The token used by the client to authorize the request does not grant the required permissions for the request. Check the requirements and obtain a suitable authorization token to proceed."), + GENERIC_METHOD_INVALID => (405, "The HTTP method used is invalid for this endpoint. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_ENDPOINT_UNKNOWN => (404, "There is no endpoint defined for the URL provided by the client. Check if you used the correct URL and/or file a report with the developers of the client software."), + GENERIC_JSON_INVALID => (400, "The JSON in the client's request was malformed. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_HTTP_HEADERS_MALFORMED => (400, "Some of the HTTP headers provided by the client were malformed and caused the server to not be able to handle the request. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_PAYTO_URI_MALFORMED => (400, "The payto:// URI provided by the client is malformed. Check that you are using the correct syntax as of RFC 8905 and/or that you entered the bank account number correctly."), + GENERIC_PARAMETER_MISSING => (400, "A required parameter in the request was missing. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_PARAMETER_MALFORMED => (400, "A parameter in the request was malformed. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_RESERVE_PUB_MALFORMED => (400, "The reserve public key was malformed."), + GENERIC_COMPRESSION_INVALID => (400, "The body in the request could not be decompressed by the server. This is likely a bug in the client implementation. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_PATH_SEGMENT_MALFORMED => (400, "A segment in the path of the URL provided by the client is malformed. Check that you are using the correct encoding for the URL."), + GENERIC_CURRENCY_MISMATCH => (400, "The currency involved in the operation is not acceptable for this server. Check your configuration and make sure the currency specified for a given service provider is one of the currencies supported by that provider."), + GENERIC_URI_TOO_LONG => (414, "The URI is longer than the longest URI the HTTP server is willing to parse. If you believe this was a legitimate request, contact the server administrators and/or the software developers to increase the limit."), + GENERIC_UPLOAD_EXCEEDS_LIMIT => (413, "The body is too large to be permissible for the endpoint. If you believe this was a legitimate request, contact the server administrators and/or the software developers to increase the limit."), + GENERIC_UNAUTHORIZED => (401, "The service refused the request due to lack of proper authorization."), + GENERIC_TOKEN_UNKNOWN => (401, "The service refused the request as the given authorization token is unknown."), + GENERIC_TOKEN_EXPIRED => (401, "The service refused the request as the given authorization token expired."), + GENERIC_TOKEN_MALFORMED => (401, "The service refused the request as the given authorization token is malformed."), + GENERIC_FORBIDDEN => (403, "The service refused the request due to lack of proper rights on the resource."), + GENERIC_DB_SETUP_FAILED => (500, "The service failed initialize its connection to the database. The system administrator should check that the service has permissions to access the database and that the database is running."), + GENERIC_DB_START_FAILED => (500, "The service encountered an error event to just start the database transaction. The system administrator should check that the database is running."), + GENERIC_DB_STORE_FAILED => (500, "The service failed to store information in its database. The system administrator should check that the database is running and review the service logs."), + GENERIC_DB_FETCH_FAILED => (500, "The service failed to fetch information from its database. The system administrator should check that the database is running and review the service logs."), + GENERIC_DB_COMMIT_FAILED => (500, "The service encountered an unrecoverable error trying to commit a transaction to the database. The system administrator should check that the database is running and review the service logs."), + GENERIC_DB_SOFT_FAILURE => (500, "The service encountered an error event to commit the database transaction, even after repeatedly retrying it there was always a conflicting transaction. This indicates a repeated serialization error; it should only happen if some client maliciously tries to create conflicting concurrent transactions. It could also be a sign of a missing index. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_DB_INVARIANT_FAILURE => (500, "The service's database is inconsistent and violates service-internal invariants. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_INTERNAL_INVARIANT_FAILURE => (500, "The HTTP server experienced an internal invariant failure (bug). Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_FAILED_COMPUTE_JSON_HASH => (500, "The service could not compute a cryptographic hash over some JSON value. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_FAILED_COMPUTE_AMOUNT => (500, "The service could not compute an amount. Check if you are using the latest available version and/or file a report with the developers."), + GENERIC_PARSER_OUT_OF_MEMORY => (500, "The HTTP server had insufficient memory to parse the request. Restarting services periodically can help, especially if Postgres is using excessive amounts of memory. Check with the system administrator to investigate."), + GENERIC_ALLOCATION_FAILURE => (500, "The HTTP server failed to allocate memory. Restarting services periodically can help, especially if Postgres is using excessive amounts of memory. Check with the system administrator to investigate."), + GENERIC_JSON_ALLOCATION_FAILURE => (500, "The HTTP server failed to allocate memory for building JSON reply. Restarting services periodically can help, especially if Postgres is using excessive amounts of memory. Check with the system administrator to investigate."), + GENERIC_CURL_ALLOCATION_FAILURE => (500, "The HTTP server failed to allocate memory for making a CURL request. Restarting services periodically can help, especially if Postgres is using excessive amounts of memory. Check with the system administrator to investigate."), + GENERIC_FAILED_TO_LOAD_TEMPLATE => (406, "The backend could not locate a required template to generate an HTML reply. The system administrator should check if the resource files are installed in the correct location and are readable to the service."), + GENERIC_FAILED_TO_EXPAND_TEMPLATE => (500, "The backend could not expand the template to generate an HTML reply. The system administrator should investigate the logs and check if the templates are well-formed."), + EXCHANGE_GENERIC_BAD_CONFIGURATION => (500, "Exchange is badly configured and thus cannot operate."), + EXCHANGE_GENERIC_OPERATION_UNKNOWN => (404, "Operation specified unknown for this endpoint."), + EXCHANGE_GENERIC_WRONG_NUMBER_OF_SEGMENTS => (404, "The number of segments included in the URI does not match the number of segments expected by the endpoint."), + EXCHANGE_GENERIC_COIN_CONFLICTING_DENOMINATION_KEY => (409, "The same coin was already used with a different denomination previously."), + EXCHANGE_GENERIC_COINS_INVALID_COIN_PUB => (400, "The public key of given to a \"/coins/\" endpoint of the exchange was malformed."), + EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN => (404, "The exchange is not aware of the denomination key the wallet requested for the operation."), + EXCHANGE_DENOMINATION_SIGNATURE_INVALID => (403, "The signature of the denomination key over the coin is not valid."), + EXCHANGE_GENERIC_KEYS_MISSING => (503, "The exchange failed to perform the operation as it could not find the private keys. This is a problem with the exchange setup, not with the client's request."), + EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE => (412, "Validity period of the denomination lies in the future."), + EXCHANGE_GENERIC_DENOMINATION_EXPIRED => (410, "Denomination key of the coin is past its expiration time for the requested operation."), + EXCHANGE_GENERIC_DENOMINATION_REVOKED => (410, "Denomination key of the coin has been revoked."), + EXCHANGE_GENERIC_SECMOD_TIMEOUT => (500, "An operation where the exchange interacted with a security module timed out."), + EXCHANGE_GENERIC_INSUFFICIENT_FUNDS => (409, "The respective coin did not have sufficient residual value for the operation. The \"history\" in this response provides the \"residual_value\" of the coin, which may be less than its \"original_value\"."), + EXCHANGE_GENERIC_COIN_HISTORY_COMPUTATION_FAILED => (500, "The exchange had an internal error reconstructing the transaction history of the coin that was being processed."), + EXCHANGE_GENERIC_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS => (500, "The exchange failed to obtain the transaction history of the given coin from the database while generating an insufficient funds errors."), + EXCHANGE_GENERIC_COIN_CONFLICTING_AGE_HASH => (409, "The same coin was already used with a different age hash previously."), + EXCHANGE_GENERIC_INVALID_DENOMINATION_CIPHER_FOR_OPERATION => (400, "The requested operation is not valid for the cipher used by the selected denomination."), + EXCHANGE_GENERIC_CIPHER_MISMATCH => (400, "The provided arguments for the operation use inconsistent ciphers."), + EXCHANGE_GENERIC_NEW_DENOMS_ARRAY_SIZE_EXCESSIVE => (400, "The number of denominations specified in the request exceeds the limit of the exchange."), + EXCHANGE_GENERIC_COIN_UNKNOWN => (404, "The coin is not known to the exchange (yet)."), + EXCHANGE_GENERIC_CLOCK_SKEW => (400, "The time at the server is too far off from the time specified in the request. Most likely the client system time is wrong."), + EXCHANGE_GENERIC_AMOUNT_EXCEEDS_DENOMINATION_VALUE => (400, "The specified amount for the coin is higher than the value of the denomination of the coin."), + EXCHANGE_GENERIC_GLOBAL_FEES_MISSING => (500, "The exchange was not properly configured with global fees."), + EXCHANGE_GENERIC_WIRE_FEES_MISSING => (500, "The exchange was not properly configured with wire fees."), + EXCHANGE_GENERIC_PURSE_PUB_MALFORMED => (400, "The purse public key was malformed."), + EXCHANGE_GENERIC_PURSE_UNKNOWN => (404, "The purse is unknown."), + EXCHANGE_GENERIC_PURSE_EXPIRED => (410, "The purse has expired."), + EXCHANGE_GENERIC_RESERVE_UNKNOWN => (404, "The exchange has no information about the \"reserve_pub\" that was given."), + EXCHANGE_GENERIC_KYC_REQUIRED => (451, "The exchange is not allowed to proceed with the operation until the client has satisfied a KYC check."), + EXCHANGE_PURSE_DEPOSIT_COIN_CONFLICTING_ATTEST_VS_AGE_COMMITMENT => (400, "Inconsistency between provided age commitment and attest: either none or both must be provided"), + EXCHANGE_PURSE_DEPOSIT_COIN_AGE_ATTESTATION_FAILURE => (400, "The provided attestation for the minimum age couldn't be verified by the exchange."), + EXCHANGE_GENERIC_PURSE_DELETED => (410, "The purse was deleted."), + EXCHANGE_GENERIC_AML_OFFICER_PUB_MALFORMED => (400, "The public key of the AML officer in the URL was malformed."), + EXCHANGE_GENERIC_AML_OFFICER_GET_SIGNATURE_INVALID => (403, "The signature affirming the GET request of the AML officer is invalid."), + EXCHANGE_GENERIC_AML_OFFICER_ACCESS_DENIED => (403, "The specified AML officer does not have access at this time."), + EXCHANGE_GENERIC_AML_PENDING => (451, "The requested operation is denied pending the resolution of an anti-money laundering investigation by the exchange operator. This is a manual process, please wait and retry later."), + EXCHANGE_GENERIC_AML_FROZEN => (451, "The requested operation is denied as the account was frozen on suspicion of money laundering. Please contact the exchange operator."), + EXCHANGE_GENERIC_KYC_CONVERTER_FAILED => (500, "The exchange failed to start a KYC attribute conversion helper process. It is likely configured incorrectly."), + EXCHANGE_GENERIC_KYC_FAILED => (0, "The KYC operation failed. This could be because the KYC provider rejected the KYC data provided, or because the user aborted the KYC process."), + EXCHANGE_GENERIC_KYC_FALLBACK_FAILED => (0, "A fallback measure for a KYC operation failed. This is a bug. Users should contact the exchange operator."), + EXCHANGE_GENERIC_KYC_FALLBACK_UNKNOWN => (0, "The specified fallback measure for a KYC operation is unknown. This is a bug. Users should contact the exchange operator."), + EXCHANGE_GENERIC_BANK_ACCOUNT_UNKNOWN => (404, "The exchange is not aware of the bank account (payto URI or hash thereof) specified in the request and thus cannot perform the requested operation. The client should check that the select account is correct."), + EXCHANGE_DEPOSITS_GET_NOT_FOUND => (404, "The exchange did not find information about the specified transaction in the database."), + EXCHANGE_DEPOSITS_GET_INVALID_H_WIRE => (400, "The wire hash of given to a \"/deposits/\" handler was malformed."), + EXCHANGE_DEPOSITS_GET_INVALID_MERCHANT_PUB => (400, "The merchant key of given to a \"/deposits/\" handler was malformed."), + EXCHANGE_DEPOSITS_GET_INVALID_H_CONTRACT_TERMS => (400, "The hash of the contract terms given to a \"/deposits/\" handler was malformed."), + EXCHANGE_DEPOSITS_GET_INVALID_COIN_PUB => (400, "The coin public key of given to a \"/deposits/\" handler was malformed."), + EXCHANGE_DEPOSITS_GET_INVALID_SIGNATURE_BY_EXCHANGE => (0, "The signature returned by the exchange in a /deposits/ request was malformed."), + EXCHANGE_DEPOSITS_GET_MERCHANT_SIGNATURE_INVALID => (403, "The signature of the merchant is invalid."), + EXCHANGE_DEPOSITS_POLICY_NOT_ACCEPTED => (400, "The provided policy data was not accepted"), + EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS => (409, "The given reserve does not have sufficient funds to admit the requested withdraw operation at this time. The response includes the current \"balance\" of the reserve as well as the transaction \"history\" that lead to this balance."), + EXCHANGE_AGE_WITHDRAW_INSUFFICIENT_FUNDS => (409, "The given reserve does not have sufficient funds to admit the requested age-withdraw operation at this time. The response includes the current \"balance\" of the reserve as well as the transaction \"history\" that lead to this balance."), + EXCHANGE_WITHDRAW_AMOUNT_FEE_OVERFLOW => (500, "The amount to withdraw together with the fee exceeds the numeric range for Taler amounts. This is not a client failure, as the coin value and fees come from the exchange's configuration."), + EXCHANGE_WITHDRAW_SIGNATURE_FAILED => (500, "The exchange failed to create the signature using the denomination key."), + EXCHANGE_WITHDRAW_RESERVE_SIGNATURE_INVALID => (403, "The signature of the reserve is not valid."), + EXCHANGE_RESERVE_HISTORY_ERROR_INSUFFICIENT_FUNDS => (500, "When computing the reserve history, we ended up with a negative overall balance, which should be impossible."), + EXCHANGE_GET_RESERVE_HISTORY_ERROR_INSUFFICIENT_BALANCE => (409, "The reserve did not have sufficient funds in it to pay for a full reserve history statement."), + EXCHANGE_WITHDRAW_DENOMINATION_KEY_LOST => (410, "Withdraw period of the coin to be withdrawn is in the past."), + EXCHANGE_WITHDRAW_UNBLIND_FAILURE => (0, "The client failed to unblind the blind signature."), + EXCHANGE_WITHDRAW_NONCE_REUSE => (409, "The client re-used a withdraw nonce, which is not allowed."), + EXCHANGE_AGE_WITHDRAW_COMMITMENT_UNKNOWN => (400, "The client provided an unknown commitment for an age-withdraw request."), + EXCHANGE_AGE_WITHDRAW_AMOUNT_OVERFLOW => (500, "The total sum of amounts from the denominations did overflow."), + EXCHANGE_AGE_WITHDRAW_AMOUNT_INCORRECT => (400, "The total sum of value and fees from the denominations differs from the committed amount with fees."), + EXCHANGE_AGE_WITHDRAW_REVEAL_INVALID_HASH => (400, "The original commitment differs from the calculated hash"), + EXCHANGE_AGE_WITHDRAW_MAXIMUM_AGE_TOO_LARGE => (409, "The maximum age in the commitment is too large for the reserve"), + EXCHANGE_WITHDRAW_BATCH_IDEMPOTENT_PLANCHET => (409, "The batch withdraw included a planchet that was already withdrawn. This is not allowed."), + EXCHANGE_DEPOSIT_COIN_SIGNATURE_INVALID => (403, "The signature made by the coin over the deposit permission is not valid."), + EXCHANGE_DEPOSIT_CONFLICTING_CONTRACT => (409, "The same coin was already deposited for the same merchant and contract with other details."), + EXCHANGE_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE => (400, "The stated value of the coin after the deposit fee is subtracted would be negative."), + EXCHANGE_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE => (400, "The stated refund deadline is after the wire deadline."), + EXCHANGE_DEPOSIT_WIRE_DEADLINE_IS_NEVER => (400, "The stated wire deadline is \"never\", which makes no sense."), + EXCHANGE_DEPOSIT_INVALID_WIRE_FORMAT_JSON => (400, "The exchange failed to canonicalize and hash the given wire format. For example, the merchant failed to provide the \"salt\" or a valid payto:// URI in the wire details. Note that while the exchange will do some basic sanity checking on the wire details, it cannot warrant that the banking system will ultimately be able to route to the specified address, even if this check passed."), + EXCHANGE_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT => (400, "The hash of the given wire address does not match the wire hash specified in the proposal data."), + EXCHANGE_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE => (0, "The signature provided by the exchange is not valid."), + EXCHANGE_DEPOSIT_FEE_ABOVE_AMOUNT => (400, "The deposited amount is smaller than the deposit fee, which would result in a negative contribution."), + EXCHANGE_EXTENSIONS_INVALID_FULFILLMENT => (400, "The proof of policy fulfillment was invalid."), + EXCHANGE_COIN_HISTORY_BAD_SIGNATURE => (403, "The coin history was requested with a bad signature."), + EXCHANGE_RESERVE_HISTORY_BAD_SIGNATURE => (403, "The reserve history was requested with a bad signature."), + EXCHANGE_MELT_FEES_EXCEED_CONTRIBUTION => (400, "The exchange encountered melt fees exceeding the melted coin's contribution."), + EXCHANGE_MELT_COIN_SIGNATURE_INVALID => (403, "The signature made with the coin to be melted is invalid."), + EXCHANGE_MELT_COIN_EXPIRED_NO_ZOMBIE => (400, "The denomination of the given coin has past its expiration date and it is also not a valid zombie (that is, was not refreshed with the fresh coin being subjected to recoup)."), + EXCHANGE_MELT_INVALID_SIGNATURE_BY_EXCHANGE => (0, "The signature returned by the exchange in a melt request was malformed."), + EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION => (409, "The provided transfer keys do not match up with the original commitment. Information about the original commitment is included in the response."), + EXCHANGE_REFRESHES_REVEAL_SIGNING_ERROR => (500, "Failed to produce the blinded signatures over the coins to be returned."), + EXCHANGE_REFRESHES_REVEAL_SESSION_UNKNOWN => (404, "The exchange is unaware of the refresh session specified in the request."), + EXCHANGE_REFRESHES_REVEAL_CNC_TRANSFER_ARRAY_SIZE_INVALID => (400, "The size of the cut-and-choose dimension of the private transfer keys request does not match #TALER_CNC_KAPPA - 1."), + EXCHANGE_REFRESHES_REVEAL_NEW_DENOMS_ARRAY_SIZE_MISMATCH => (400, "The number of envelopes given does not match the number of denomination keys given."), + EXCHANGE_REFRESHES_REVEAL_COST_CALCULATION_OVERFLOW => (500, "The exchange encountered a numeric overflow totaling up the cost for the refresh operation."), + EXCHANGE_REFRESHES_REVEAL_AMOUNT_INSUFFICIENT => (400, "The exchange's cost calculation shows that the melt amount is below the costs of the transaction."), + EXCHANGE_REFRESHES_REVEAL_LINK_SIGNATURE_INVALID => (403, "The signature made with the coin over the link data is invalid."), + EXCHANGE_REFRESHES_REVEAL_INVALID_RCH => (400, "The refresh session hash given to a /refreshes/ handler was malformed."), + EXCHANGE_REFRESHES_REVEAL_OPERATION_INVALID => (400, "Operation specified invalid for this endpoint."), + EXCHANGE_REFRESHES_REVEAL_AGE_RESTRICTION_NOT_SUPPORTED => (400, "The client provided age commitment data, but age restriction is not supported on this server."), + EXCHANGE_REFRESHES_REVEAL_AGE_RESTRICTION_COMMITMENT_INVALID => (400, "The client provided invalid age commitment data: missing, not an array, or array of invalid size."), + EXCHANGE_LINK_COIN_UNKNOWN => (404, "The coin specified in the link request is unknown to the exchange."), + EXCHANGE_TRANSFERS_GET_WTID_MALFORMED => (400, "The public key of given to a /transfers/ handler was malformed."), + EXCHANGE_TRANSFERS_GET_WTID_NOT_FOUND => (404, "The exchange did not find information about the specified wire transfer identifier in the database."), + EXCHANGE_TRANSFERS_GET_WIRE_FEE_NOT_FOUND => (500, "The exchange did not find information about the wire transfer fees it charged."), + EXCHANGE_TRANSFERS_GET_WIRE_FEE_INCONSISTENT => (500, "The exchange found a wire fee that was above the total transfer value (and thus could not have been charged)."), + EXCHANGE_PURSES_INVALID_WAIT_TARGET => (400, "The wait target of the URL was not in the set of expected values."), + EXCHANGE_PURSES_GET_INVALID_SIGNATURE_BY_EXCHANGE => (0, "The signature on the purse status returned by the exchange was invalid."), + EXCHANGE_REFUND_COIN_NOT_FOUND => (404, "The exchange knows literally nothing about the coin we were asked to refund. But without a transaction history, we cannot issue a refund. This is kind-of OK, the owner should just refresh it directly without executing the refund."), + EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT => (409, "We could not process the refund request as the coin's transaction history does not permit the requested refund because then refunds would exceed the deposit amount. The \"history\" in the response proves this."), + EXCHANGE_REFUND_DEPOSIT_NOT_FOUND => (404, "The exchange knows about the coin we were asked to refund, but not about the specific /deposit operation. Hence, we cannot issue a refund (as we do not know if this merchant public key is authorized to do a refund)."), + EXCHANGE_REFUND_MERCHANT_ALREADY_PAID => (410, "The exchange can no longer refund the customer/coin as the money was already transferred (paid out) to the merchant. (It should be past the refund deadline.)"), + EXCHANGE_REFUND_FEE_TOO_LOW => (400, "The refund fee specified for the request is lower than the refund fee charged by the exchange for the given denomination key of the refunded coin."), + EXCHANGE_REFUND_FEE_ABOVE_AMOUNT => (400, "The refunded amount is smaller than the refund fee, which would result in a negative refund."), + EXCHANGE_REFUND_MERCHANT_SIGNATURE_INVALID => (403, "The signature of the merchant is invalid."), + EXCHANGE_REFUND_MERCHANT_SIGNING_FAILED => (500, "Merchant backend failed to create the refund confirmation signature."), + EXCHANGE_REFUND_INVALID_SIGNATURE_BY_EXCHANGE => (0, "The signature returned by the exchange in a refund request was malformed."), + EXCHANGE_REFUND_INVALID_FAILURE_PROOF_BY_EXCHANGE => (0, "The failure proof returned by the exchange is incorrect."), + EXCHANGE_REFUND_INCONSISTENT_AMOUNT => (424, "Conflicting refund granted before with different amount but same refund transaction ID."), + EXCHANGE_RECOUP_SIGNATURE_INVALID => (403, "The given coin signature is invalid for the request."), + EXCHANGE_RECOUP_WITHDRAW_NOT_FOUND => (404, "The exchange could not find the corresponding withdraw operation. The request is denied."), + EXCHANGE_RECOUP_COIN_BALANCE_ZERO => (403, "The coin's remaining balance is zero. The request is denied."), + EXCHANGE_RECOUP_BLINDING_FAILED => (500, "The exchange failed to reproduce the coin's blinding."), + EXCHANGE_RECOUP_COIN_BALANCE_NEGATIVE => (500, "The coin's remaining balance is zero. The request is denied."), + EXCHANGE_RECOUP_NOT_ELIGIBLE => (404, "The coin's denomination has not been revoked yet."), + EXCHANGE_RECOUP_REFRESH_SIGNATURE_INVALID => (403, "The given coin signature is invalid for the request."), + EXCHANGE_RECOUP_REFRESH_MELT_NOT_FOUND => (404, "The exchange could not find the corresponding melt operation. The request is denied."), + EXCHANGE_RECOUP_REFRESH_BLINDING_FAILED => (500, "The exchange failed to reproduce the coin's blinding."), + EXCHANGE_RECOUP_REFRESH_NOT_ELIGIBLE => (404, "The coin's denomination has not been revoked yet."), + EXCHANGE_KEYS_TIMETRAVEL_FORBIDDEN => (403, "This exchange does not allow clients to request /keys for times other than the current (exchange) time."), + EXCHANGE_WIRE_SIGNATURE_INVALID => (0, "A signature in the server's response was malformed."), + EXCHANGE_WIRE_NO_ACCOUNTS_CONFIGURED => (500, "No bank accounts are enabled for the exchange. The administrator should enable-account using the taler-exchange-offline tool."), + EXCHANGE_WIRE_INVALID_PAYTO_CONFIGURED => (500, "The payto:// URI stored in the exchange database for its bank account is malformed."), + EXCHANGE_WIRE_FEES_NOT_CONFIGURED => (500, "No wire fees are configured for an enabled wire method of the exchange. The administrator must set the wire-fee using the taler-exchange-offline tool."), + EXCHANGE_RESERVES_PURSE_CREATE_CONFLICTING_META_DATA => (409, "This purse was previously created with different meta data."), + EXCHANGE_RESERVES_PURSE_MERGE_CONFLICTING_META_DATA => (409, "This purse was previously merged with different meta data."), + EXCHANGE_RESERVES_PURSE_CREATE_INSUFFICIENT_FUNDS => (409, "The reserve has insufficient funds to create another purse."), + EXCHANGE_RESERVES_PURSE_FEE_TOO_LOW => (400, "The purse fee specified for the request is lower than the purse fee charged by the exchange at this time."), + EXCHANGE_PURSE_DELETE_ALREADY_DECIDED => (409, "The payment request cannot be deleted anymore, as it either already completed or timed out."), + EXCHANGE_PURSE_DELETE_SIGNATURE_INVALID => (403, "The signature affirming the purse deletion is invalid."), + EXCHANGE_RESERVES_AGE_RESTRICTION_REQUIRED => (403, "Withdrawal from the reserve requires age restriction to be set."), + EXCHANGE_DENOMINATION_HELPER_UNAVAILABLE => (502, "The exchange failed to talk to the process responsible for its private denomination keys or the helpers had no denominations (properly) configured."), + EXCHANGE_DENOMINATION_HELPER_BUG => (500, "The response from the denomination key helper process was malformed."), + EXCHANGE_DENOMINATION_HELPER_TOO_EARLY => (400, "The helper refuses to sign with the key, because it is too early: the validity period has not yet started."), + EXCHANGE_PURSE_DEPOSIT_EXCHANGE_SIGNATURE_INVALID => (0, "The signature of the exchange on the reply was invalid."), + EXCHANGE_SIGNKEY_HELPER_UNAVAILABLE => (502, "The exchange failed to talk to the process responsible for its private signing keys."), + EXCHANGE_SIGNKEY_HELPER_BUG => (500, "The response from the online signing key helper process was malformed."), + EXCHANGE_SIGNKEY_HELPER_TOO_EARLY => (400, "The helper refuses to sign with the key, because it is too early: the validity period has not yet started."), + EXCHANGE_RESERVES_PURSE_EXPIRATION_BEFORE_NOW => (400, "The purse expiration time is in the past at the time of its creation."), + EXCHANGE_RESERVES_PURSE_EXPIRATION_IS_NEVER => (400, "The purse expiration time is set to never, which is not allowed."), + EXCHANGE_RESERVES_PURSE_MERGE_SIGNATURE_INVALID => (403, "The signature affirming the merge of the purse is invalid."), + EXCHANGE_RESERVES_RESERVE_MERGE_SIGNATURE_INVALID => (403, "The signature by the reserve affirming the merge is invalid."), + EXCHANGE_RESERVES_OPEN_BAD_SIGNATURE => (403, "The signature by the reserve affirming the open operation is invalid."), + EXCHANGE_RESERVES_CLOSE_BAD_SIGNATURE => (403, "The signature by the reserve affirming the close operation is invalid."), + EXCHANGE_RESERVES_ATTEST_BAD_SIGNATURE => (403, "The signature by the reserve affirming the attestion request is invalid."), + EXCHANGE_RESERVES_CLOSE_NO_TARGET_ACCOUNT => (409, "The exchange does not know an origin account to which the remaining reserve balance could be wired to, and the wallet failed to provide one."), + EXCHANGE_RESERVES_OPEN_INSUFFICIENT_FUNDS => (409, "The reserve balance is insufficient to pay for the open operation."), + EXCHANGE_MANAGEMENT_AUDITOR_NOT_FOUND => (404, "The auditor that was supposed to be disabled is unknown to this exchange."), + EXCHANGE_MANAGEMENT_AUDITOR_MORE_RECENT_PRESENT => (409, "The exchange has a more recently signed conflicting instruction and is thus refusing the current change (replay detected)."), + EXCHANGE_MANAGEMENT_AUDITOR_ADD_SIGNATURE_INVALID => (403, "The signature to add or enable the auditor does not validate."), + EXCHANGE_MANAGEMENT_AUDITOR_DEL_SIGNATURE_INVALID => (403, "The signature to disable the auditor does not validate."), + EXCHANGE_MANAGEMENT_DENOMINATION_REVOKE_SIGNATURE_INVALID => (403, "The signature to revoke the denomination does not validate."), + EXCHANGE_MANAGEMENT_SIGNKEY_REVOKE_SIGNATURE_INVALID => (403, "The signature to revoke the online signing key does not validate."), + EXCHANGE_MANAGEMENT_WIRE_MORE_RECENT_PRESENT => (409, "The exchange has a more recently signed conflicting instruction and is thus refusing the current change (replay detected)."), + EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_UNKNOWN => (404, "The signingkey specified is unknown to the exchange."), + EXCHANGE_MANAGEMENT_WIRE_DETAILS_SIGNATURE_INVALID => (403, "The signature to publish wire account does not validate."), + EXCHANGE_MANAGEMENT_WIRE_ADD_SIGNATURE_INVALID => (403, "The signature to add the wire account does not validate."), + EXCHANGE_MANAGEMENT_WIRE_DEL_SIGNATURE_INVALID => (403, "The signature to disable the wire account does not validate."), + EXCHANGE_MANAGEMENT_WIRE_NOT_FOUND => (404, "The wire account to be disabled is unknown to the exchange."), + EXCHANGE_MANAGEMENT_WIRE_FEE_SIGNATURE_INVALID => (403, "The signature to affirm wire fees does not validate."), + EXCHANGE_MANAGEMENT_WIRE_FEE_MISMATCH => (409, "The signature conflicts with a previous signature affirming different fees."), + EXCHANGE_MANAGEMENT_KEYS_DENOMKEY_ADD_SIGNATURE_INVALID => (403, "The signature affirming the denomination key is invalid."), + EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_ADD_SIGNATURE_INVALID => (403, "The signature affirming the signing key is invalid."), + EXCHANGE_MANAGEMENT_GLOBAL_FEE_MISMATCH => (409, "The signature conflicts with a previous signature affirming different fees."), + EXCHANGE_MANAGEMENT_GLOBAL_FEE_SIGNATURE_INVALID => (403, "The signature affirming the fee structure is invalid."), + EXCHANGE_MANAGEMENT_DRAIN_PROFITS_SIGNATURE_INVALID => (403, "The signature affirming the profit drain is invalid."), + EXCHANGE_AML_DECISION_ADD_SIGNATURE_INVALID => (403, "The signature affirming the AML decision is invalid."), + EXCHANGE_AML_DECISION_INVALID_OFFICER => (403, "The AML officer specified is not allowed to make AML decisions right now."), + EXCHANGE_AML_DECISION_MORE_RECENT_PRESENT => (409, "There is a more recent AML decision on file. The decision was rejected as timestamps of AML decisions must be monotonically increasing."), + EXCHANGE_AML_DECISION_UNKNOWN_CHECK => (400, "There AML decision would impose an AML check of a type that is not provided by any KYC provider known to the exchange."), + EXCHANGE_MANAGEMENT_UPDATE_AML_OFFICER_SIGNATURE_INVALID => (403, "The signature affirming the change in the AML officer status is invalid."), + EXCHANGE_MANAGEMENT_AML_OFFICERS_MORE_RECENT_PRESENT => (409, "A more recent decision about the AML officer status is known to the exchange."), + EXCHANGE_PURSE_CREATE_CONFLICTING_META_DATA => (409, "The purse was previously created with different meta data."), + EXCHANGE_PURSE_CREATE_CONFLICTING_CONTRACT_STORED => (409, "The purse was previously created with a different contract."), + EXCHANGE_PURSE_CREATE_COIN_SIGNATURE_INVALID => (403, "A coin signature for a deposit into the purse is invalid."), + EXCHANGE_PURSE_CREATE_EXPIRATION_BEFORE_NOW => (400, "The purse expiration time is in the past."), + EXCHANGE_PURSE_CREATE_EXPIRATION_IS_NEVER => (400, "The purse expiration time is \"never\"."), + EXCHANGE_PURSE_CREATE_SIGNATURE_INVALID => (403, "The purse signature over the purse meta data is invalid."), + EXCHANGE_PURSE_ECONTRACT_SIGNATURE_INVALID => (403, "The signature over the encrypted contract is invalid."), + EXCHANGE_PURSE_CREATE_EXCHANGE_SIGNATURE_INVALID => (0, "The signature from the exchange over the confirmation is invalid."), + EXCHANGE_PURSE_DEPOSIT_CONFLICTING_META_DATA => (409, "The coin was previously deposited with different meta data."), + EXCHANGE_PURSE_ECONTRACT_CONFLICTING_META_DATA => (409, "The encrypted contract was previously uploaded with different meta data."), + EXCHANGE_CREATE_PURSE_NEGATIVE_VALUE_AFTER_FEE => (400, "The deposited amount is less than the purse fee."), + EXCHANGE_PURSE_MERGE_INVALID_MERGE_SIGNATURE => (403, "The signature using the merge key is invalid."), + EXCHANGE_PURSE_MERGE_INVALID_RESERVE_SIGNATURE => (403, "The signature using the reserve key is invalid."), + EXCHANGE_PURSE_NOT_FULL => (409, "The targeted purse is not yet full and thus cannot be merged. Retrying the request later may succeed."), + EXCHANGE_PURSE_MERGE_EXCHANGE_SIGNATURE_INVALID => (0, "The signature from the exchange over the confirmation is invalid."), + EXCHANGE_MERGE_PURSE_PARTNER_UNKNOWN => (404, "The exchange of the target account is not a partner of this exchange."), + EXCHANGE_MANAGEMENT_ADD_PARTNER_SIGNATURE_INVALID => (403, "The signature affirming the new partner is invalid."), + EXCHANGE_MANAGEMENT_ADD_PARTNER_DATA_CONFLICT => (409, "Conflicting data for the partner already exists with the exchange."), + EXCHANGE_AUDITORS_AUDITOR_SIGNATURE_INVALID => (403, "The auditor signature over the denomination meta data is invalid."), + EXCHANGE_AUDITORS_AUDITOR_UNKNOWN => (412, "The auditor that was specified is unknown to this exchange."), + EXCHANGE_AUDITORS_AUDITOR_INACTIVE => (410, "The auditor that was specified is no longer used by this exchange."), + EXCHANGE_KYC_INFO_AUTHORIZATION_FAILED => (403, "The KYC info access token is not recognized. Hence the request was denied."), + EXCHANGE_KYC_RECURSIVE_RULE_DETECTED => (500, "The exchange got stuck in a long series of (likely recursive) KYC rules without user-inputs that did not result in a timely conclusion. This is a configuration failure. Please contact the administrator."), + EXCHANGE_KYC_AML_FORM_INCOMPLETE => (400, "The submitted KYC data lacks an attribute that is required by the KYC form. Please submit the complete form."), + EXCHANGE_KYC_GENERIC_AML_PROGRAM_GONE => (500, "The request requires an AML program which is no longer configured at the exchange. Contact the exchange operator to address the configuration issue."), + EXCHANGE_KYC_NOT_A_FORM => (400, "The given check is not of type 'form' and thus using this handler for form submission is incorrect."), + EXCHANGE_KYC_GENERIC_CHECK_GONE => (500, "The request requires a check which is no longer configured at the exchange. Contact the exchange operator to address the configuration issue."), + EXCHANGE_KYC_WALLET_SIGNATURE_INVALID => (403, "The signature affirming the wallet's KYC request was invalid."), + EXCHANGE_KYC_PROOF_BACKEND_INVALID_RESPONSE => (502, "The exchange received an unexpected malformed response from its KYC backend."), + EXCHANGE_KYC_PROOF_BACKEND_ERROR => (502, "The backend signaled an unexpected failure."), + EXCHANGE_KYC_PROOF_BACKEND_AUTHORIZATION_FAILED => (403, "The backend signaled an authorization failure."), + EXCHANGE_KYC_PROOF_REQUEST_UNKNOWN => (404, "The exchange is unaware of having made an the authorization request."), + EXCHANGE_KYC_CHECK_AUTHORIZATION_FAILED => (403, "The KYC authorization signature was invalid. Hence the request was denied."), + EXCHANGE_KYC_GENERIC_LOGIC_UNKNOWN => (404, "The request used a logic specifier that is not known to the exchange."), + EXCHANGE_KYC_GENERIC_LOGIC_GONE => (500, "The request requires a logic which is no longer configured at the exchange."), + EXCHANGE_KYC_GENERIC_LOGIC_BUG => (500, "The logic plugin had a bug in its interaction with the KYC provider."), + EXCHANGE_KYC_GENERIC_PROVIDER_ACCESS_REFUSED => (511, "The exchange could not process the request with its KYC provider because the provider refused access to the service. This indicates some configuration issue at the Taler exchange operator."), + EXCHANGE_KYC_GENERIC_PROVIDER_TIMEOUT => (504, "There was a timeout in the interaction between the exchange and the KYC provider. The most likely cause is some networking problem. Trying again later might succeed."), + EXCHANGE_KYC_GENERIC_PROVIDER_UNEXPECTED_REPLY => (502, "The KYC provider responded with a status that was completely unexpected by the KYC logic of the exchange."), + EXCHANGE_KYC_GENERIC_PROVIDER_RATE_LIMIT_EXCEEDED => (503, "The rate limit of the exchange at the KYC provider has been exceeded. Trying much later might work."), + EXCHANGE_KYC_WEBHOOK_UNAUTHORIZED => (401, "The request to the webhook lacked proper authorization or authentication data."), + EXCHANGE_KYC_CHECK_REQUEST_UNKNOWN => (404, "The exchange is unaware of the requested payto URI with respect to the KYC status."), + EXCHANGE_KYC_CHECK_AUTHORIZATION_KEY_UNKNOWN => (409, "The exchange has no account public key to check the KYC authorization signature against. Hence the request was denied. The user should do a wire transfer to the exchange with the KYC authorization key in the subject."), + EXCHANGE_KYC_FORM_ALREADY_UPLOADED => (409, "The form has been previously uploaded, and may only be filed once. The user should be redirected to their main KYC page and see if any other steps need to be taken."), + EXCHANGE_KYC_MEASURES_MALFORMED => (500, "The internal state of the exchange specifying KYC measures is malformed. Please contact technical support."), + EXCHANGE_KYC_MEASURE_INDEX_INVALID => (404, "The specified index does not refer to a valid KYC measure. Please check the URL."), + EXCHANGE_KYC_INVALID_LOGIC_TO_CHECK => (409, "The operation is not supported by the selected KYC logic. This is either caused by a configuration change or some invalid use of the API. Please contact technical support."), + EXCHANGE_KYC_AML_PROGRAM_FAILURE => (500, "The AML program failed. This is either caused by a configuration change or a bug. Please contact technical support."), + EXCHANGE_KYC_AML_PROGRAM_MALFORMED_RESULT => (500, "The AML program returned a malformed result. This is a bug. Please contact technical support."), + EXCHANGE_KYC_GENERIC_PROVIDER_INCOMPLETE_REPLY => (502, "The response from the KYC provider lacked required attributes. Please contact technical support."), + EXCHANGE_KYC_GENERIC_PROVIDER_INCOMPLETE_CONTEXT => (500, "The context of the KYC check lacked required fields. This is a bug. Please contact technical support."), + EXCHANGE_KYC_GENERIC_AML_LOGIC_BUG => (500, "The logic plugin had a bug in its AML processing. This is a bug. Please contact technical support."), + EXCHANGE_CONTRACTS_UNKNOWN => (404, "The exchange does not know a contract under the given contract public key."), + EXCHANGE_CONTRACTS_INVALID_CONTRACT_PUB => (400, "The URL does not encode a valid exchange public key in its path."), + EXCHANGE_CONTRACTS_DECRYPTION_FAILED => (0, "The returned encrypted contract did not decrypt."), + EXCHANGE_CONTRACTS_SIGNATURE_INVALID => (0, "The signature on the encrypted contract did not validate."), + EXCHANGE_CONTRACTS_DECODING_FAILED => (0, "The decrypted contract was malformed."), + EXCHANGE_PURSE_DEPOSIT_COIN_SIGNATURE_INVALID => (403, "A coin signature for a deposit into the purse is invalid."), + EXCHANGE_PURSE_DEPOSIT_DECIDED_ALREADY => (410, "It is too late to deposit coins into the purse."), + EXCHANGE_TOTP_KEY_INVALID => (0, "TOTP key is not valid."), + MERCHANT_GENERIC_INSTANCE_UNKNOWN => (404, "The backend could not find the merchant instance specified in the request."), + MERCHANT_GENERIC_HOLE_IN_WIRE_FEE_STRUCTURE => (0, "The start and end-times in the wire fee structure leave a hole. This is not allowed."), + MERCHANT_GENERIC_EXCHANGE_WIRE_REQUEST_FAILED => (502, "The merchant was unable to obtain a valid answer to /wire from the exchange."), + MERCHANT_GENERIC_CATEGORY_UNKNOWN => (404, "The product category is not known to the backend."), + MERCHANT_GENERIC_ORDER_UNKNOWN => (404, "The proposal is not known to the backend."), + MERCHANT_GENERIC_PRODUCT_UNKNOWN => (404, "The order provided to the backend could not be completed, because a product to be completed via inventory data is not actually in our inventory."), + MERCHANT_GENERIC_REWARD_ID_UNKNOWN => (404, "The reward ID is unknown. This could happen if the reward has expired."), + MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID => (500, "The contract obtained from the merchant backend was malformed."), + MERCHANT_GENERIC_CONTRACT_HASH_DOES_NOT_MATCH_ORDER => (403, "The order we found does not match the provided contract hash."), + MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE => (502, "The exchange failed to provide a valid response to the merchant's /keys request."), + MERCHANT_GENERIC_EXCHANGE_TIMEOUT => (504, "The exchange failed to respond to the merchant on time."), + MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE => (500, "The merchant failed to talk to the exchange."), + MERCHANT_GENERIC_EXCHANGE_REPLY_MALFORMED => (502, "The exchange returned a maformed response."), + MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS => (502, "The exchange returned an unexpected response status."), + MERCHANT_GENERIC_UNAUTHORIZED => (401, "The merchant refused the request due to lack of authorization."), + MERCHANT_GENERIC_INSTANCE_DELETED => (404, "The merchant instance specified in the request was deleted."), + MERCHANT_GENERIC_TRANSFER_UNKNOWN => (404, "The backend could not find the inbound wire transfer specified in the request."), + MERCHANT_GENERIC_TEMPLATE_UNKNOWN => (404, "The backend could not find the template(id) because it is not exist."), + MERCHANT_GENERIC_WEBHOOK_UNKNOWN => (404, "The backend could not find the webhook(id) because it is not exist."), + MERCHANT_GENERIC_PENDING_WEBHOOK_UNKNOWN => (404, "The backend could not find the webhook(serial) because it is not exist."), + MERCHANT_GENERIC_OTP_DEVICE_UNKNOWN => (404, "The backend could not find the OTP device(id) because it is not exist."), + MERCHANT_GENERIC_ACCOUNT_UNKNOWN => (404, "The account is not known to the backend."), + MERCHANT_GENERIC_H_WIRE_MALFORMED => (400, "The wire hash was malformed."), + MERCHANT_GENERIC_CURRENCY_MISMATCH => (409, "The currency specified in the operation does not work with the current state of the given resource."), + MERCHANT_GENERIC_EXCHANGE_UNTRUSTED => (400, "The exchange specified in the operation is not trusted by this exchange. The client should limit its operation to exchanges enabled by the merchant, or ask the merchant to enable additional exchanges in the configuration."), + MERCHANT_GET_ORDERS_EXCHANGE_TRACKING_FAILURE => (200, "The exchange failed to provide a valid answer to the tracking request, thus those details are not in the response."), + MERCHANT_GET_ORDERS_ID_EXCHANGE_REQUEST_FAILURE => (500, "The merchant backend failed to construct the request for tracking to the exchange, thus tracking details are not in the response."), + MERCHANT_GET_ORDERS_ID_EXCHANGE_LOOKUP_START_FAILURE => (500, "The merchant backend failed trying to contact the exchange for tracking details, thus those details are not in the response."), + MERCHANT_GET_ORDERS_ID_INVALID_TOKEN => (403, "The claim token used to authenticate the client is invalid for this order."), + MERCHANT_GET_ORDERS_ID_INVALID_CONTRACT_HASH => (403, "The contract terms hash used to authenticate the client is invalid for this order."), + MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_FUNDS => (409, "The exchange responded saying that funds were insufficient (for example, due to double-spending)."), + MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND => (400, "The denomination key used for payment is not listed among the denomination keys of the exchange."), + MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_AUDITOR_FAILURE => (400, "The denomination key used for payment is not audited by an auditor approved by the merchant."), + MERCHANT_POST_ORDERS_ID_PAY_AMOUNT_OVERFLOW => (500, "There was an integer overflow totaling up the amounts or deposit fees in the payment."), + MERCHANT_POST_ORDERS_ID_PAY_FEES_EXCEED_PAYMENT => (400, "The deposit fees exceed the total value of the payment."), + MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_DUE_TO_FEES => (400, "After considering deposit and wire fees, the payment is insufficient to satisfy the required amount for the contract. The client should revisit the logic used to calculate fees it must cover."), + MERCHANT_POST_ORDERS_ID_PAY_PAYMENT_INSUFFICIENT => (400, "Even if we do not consider deposit and wire fees, the payment is insufficient to satisfy the required amount for the contract."), + MERCHANT_POST_ORDERS_ID_PAY_COIN_SIGNATURE_INVALID => (403, "The signature over the contract of one of the coins was invalid."), + MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_LOOKUP_FAILED => (500, "When we tried to find information about the exchange to issue the deposit, we failed. This usually only happens if the merchant backend is somehow unable to get its own HTTP client logic to work."), + MERCHANT_POST_ORDERS_ID_PAY_REFUND_DEADLINE_PAST_WIRE_TRANSFER_DEADLINE => (500, "The refund deadline in the contract is after the transfer deadline."), + MERCHANT_POST_ORDERS_ID_PAY_ALREADY_PAID => (409, "The order was already paid (maybe by another wallet)."), + MERCHANT_POST_ORDERS_ID_PAY_OFFER_EXPIRED => (410, "The payment is too late, the offer has expired."), + MERCHANT_POST_ORDERS_ID_PAY_MERCHANT_FIELD_MISSING => (500, "The \"merchant\" field is missing in the proposal data. This is an internal error as the proposal is from the merchant's own database at this point."), + MERCHANT_POST_ORDERS_ID_PAY_WIRE_HASH_UNKNOWN => (500, "Failed to locate merchant's account information matching the wire hash given in the proposal."), + MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_DEPOSIT_EXPIRED => (410, "The deposit time for the denomination has expired."), + MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_WIRE_FEE_ADDITION_FAILED => (500, "The exchange of the deposited coin charges a wire fee that could not be added to the total (total amount too high)."), + MERCHANT_POST_ORDERS_ID_PAY_REFUNDED => (402, "The contract was not fully paid because of refunds. Note that clients MAY treat this as paid if, for example, contracts must be executed despite of refunds."), + MERCHANT_POST_ORDERS_ID_PAY_REFUNDS_EXCEED_PAYMENTS => (500, "According to our database, we have refunded more than we were paid (which should not be possible)."), + DEAD_QQQ_PAY_MERCHANT_POST_ORDERS_ID_ABORT_REFUND_REFUSED_PAYMENT_COMPLETE => (0, "Legacy stuff. Remove me with protocol v1."), + MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_FAILED => (502, "The payment failed at the exchange."), + MERCHANT_POST_ORDERS_ID_PAY_AGE_COMMITMENT_MISSING => (400, "The payment required a minimum age but one of the coins (of a denomination with support for age restriction) did not provide any age_commitment."), + MERCHANT_POST_ORDERS_ID_PAY_AGE_COMMITMENT_SIZE_MISMATCH => (400, "The payment required a minimum age but one of the coins provided an age_commitment that contained a wrong number of public keys compared to the number of age groups defined in the denomination of the coin."), + MERCHANT_POST_ORDERS_ID_PAY_AGE_VERIFICATION_FAILED => (400, "The payment required a minimum age but one of the coins provided a minimum_age_sig that couldn't be verified with the given age_commitment for that particular minimum age."), + MERCHANT_POST_ORDERS_ID_PAY_AGE_COMMITMENT_HASH_MISSING => (400, "The payment required no minimum age but one of the coins (of a denomination with support for age restriction) did not provide the required h_age_commitment."), + MERCHANT_POST_ORDERS_ID_PAY_WIRE_METHOD_UNSUPPORTED => (409, "The exchange does not support the selected bank account of the merchant. Likely the merchant had stale data on the bank accounts of the exchange and thus selected an inappropriate exchange when making the offer."), + MERCHANT_POST_ORDERS_ID_PAY_CHOICE_INDEX_MISSING => (400, "The payment requires the wallet to select a choice from the choices array and pass it in the 'choice_index' field of the request."), + MERCHANT_POST_ORDERS_ID_PAY_CHOICE_INDEX_OUT_OF_BOUNDS => (400, "The 'choice_index' field is invalid."), + MERCHANT_POST_ORDERS_ID_PAY_INPUT_TOKENS_MISMATCH => (400, "The provided 'tokens' array does not match with the required input tokens of the order."), + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_ISSUE_SIG_INVALID => (400, "Invalid token issue signature (blindly signed by merchant) for provided token."), + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_USE_SIG_INVALID => (400, "Invalid token use signature (EdDSA, signed by wallet) for provided token."), + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_COUNT_MISMATCH => (400, "The provided number of tokens does not match the required number."), + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_ENVELOPE_COUNT_MISMATCH => (400, "The provided number of token envelopes does not match the specified number."), + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_INVALID => (409, "Invalid token because it was already used, is expired or not yet valid."), + MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_TRANSACTION_LIMIT_VIOLATION => (403, "The payment violates a transaction limit configured at the given exchange. The wallet has a bug in that it failed to check exchange limits during coin selection. Please report the bug to your wallet developer."), + MERCHANT_POST_ORDERS_ID_PAID_CONTRACT_HASH_MISMATCH => (400, "The contract hash does not match the given order ID."), + MERCHANT_POST_ORDERS_ID_PAID_COIN_SIGNATURE_INVALID => (403, "The signature of the merchant is not valid for the given contract hash."), + MERCHANT_POST_TOKEN_FAMILY_CONFLICT => (409, "A token family with this ID but conflicting data exists."), + MERCHANT_PATCH_TOKEN_FAMILY_NOT_FOUND => (404, "The backend is unaware of a token family with the given ID."), + MERCHANT_POST_ORDERS_ID_ABORT_EXCHANGE_REFUND_FAILED => (500, "The merchant failed to send the exchange the refund request."), + MERCHANT_POST_ORDERS_ID_ABORT_EXCHANGE_LOOKUP_FAILED => (500, "The merchant failed to find the exchange to process the lookup."), + MERCHANT_POST_ORDERS_ID_ABORT_CONTRACT_NOT_FOUND => (404, "The merchant could not find the contract."), + MERCHANT_POST_ORDERS_ID_ABORT_REFUND_REFUSED_PAYMENT_COMPLETE => (412, "The payment was already completed and thus cannot be aborted anymore."), + MERCHANT_POST_ORDERS_ID_ABORT_CONTRACT_HASH_MISSMATCH => (403, "The hash provided by the wallet does not match the order."), + MERCHANT_POST_ORDERS_ID_ABORT_COINS_ARRAY_EMPTY => (400, "The array of coins cannot be empty."), + MERCHANT_EXCHANGE_TRANSFERS_AWAITING_KEYS => (202, "We are waiting for the exchange to provide us with key material before checking the wire transfer."), + MERCHANT_EXCHANGE_TRANSFERS_AWAITING_LIST => (202, "We are waiting for the exchange to provide us with the list of aggregated transactions."), + MERCHANT_EXCHANGE_TRANSFERS_FATAL_NO_EXCHANGE => (200, "The endpoint indicated in the wire transfer does not belong to a GNU Taler exchange."), + MERCHANT_EXCHANGE_TRANSFERS_FATAL_NOT_FOUND => (0, "The exchange indicated in the wire transfer claims to know nothing about the wire transfer."), + MERCHANT_EXCHANGE_TRANSFERS_RATE_LIMITED => (202, "The interaction with the exchange is delayed due to rate limiting."), + MERCHANT_EXCHANGE_TRANSFERS_TRANSIENT_FAILURE => (202, "We experienced a transient failure in our interaction with the exchange."), + MERCHANT_EXCHANGE_TRANSFERS_HARD_FAILURE => (200, "The response from the exchange was unacceptable and should be reviewed with an auditor."), + MERCHANT_POST_ORDERS_ID_CLAIM_NOT_FOUND => (404, "We could not claim the order because the backend is unaware of it."), + MERCHANT_POST_ORDERS_ID_CLAIM_ALREADY_CLAIMED => (409, "We could not claim the order because someone else claimed it first."), + MERCHANT_POST_ORDERS_ID_CLAIM_CLIENT_INTERNAL_FAILURE => (0, "The client-side experienced an internal failure."), + MERCHANT_POST_ORDERS_ID_REFUND_SIGNATURE_FAILED => (0, "The backend failed to sign the refund request."), + MERCHANT_REWARD_PICKUP_UNBLIND_FAILURE => (0, "The client failed to unblind the signature returned by the merchant."), + MERCHANT_REWARD_PICKUP_EXCHANGE_ERROR => (502, "The exchange returned a failure code for the withdraw operation."), + MERCHANT_REWARD_PICKUP_SUMMATION_FAILED => (500, "The merchant failed to add up the amounts to compute the pick up value."), + MERCHANT_REWARD_PICKUP_HAS_EXPIRED => (410, "The reward expired."), + MERCHANT_REWARD_PICKUP_AMOUNT_EXCEEDS_REWARD_REMAINING => (400, "The requested withdraw amount exceeds the amount remaining to be picked up."), + MERCHANT_REWARD_PICKUP_DENOMINATION_UNKNOWN => (409, "The merchant did not find the specified denomination key in the exchange's key set."), + MERCHANT_PRIVATE_POST_ORDERS_INSTANCE_CONFIGURATION_LACKS_WIRE => (404, "The merchant instance has no active bank accounts configured. However, at least one bank account must be available to create new orders."), + MERCHANT_PRIVATE_POST_ORDERS_NO_LOCALTIME => (500, "The proposal had no timestamp and the merchant backend failed to obtain the current local time."), + MERCHANT_PRIVATE_POST_ORDERS_PROPOSAL_PARSE_ERROR => (400, "The order provided to the backend could not be parsed; likely some required fields were missing or ill-formed."), + MERCHANT_PRIVATE_POST_ORDERS_ALREADY_EXISTS => (409, "A conflicting order (sharing the same order identifier) already exists at this merchant backend instance."), + MERCHANT_PRIVATE_POST_ORDERS_REFUND_AFTER_WIRE_DEADLINE => (400, "The order creation request is invalid because the given wire deadline is before the refund deadline."), + MERCHANT_PRIVATE_POST_ORDERS_DELIVERY_DATE_IN_PAST => (400, "The order creation request is invalid because the delivery date given is in the past."), + MERCHANT_PRIVATE_POST_ORDERS_WIRE_DEADLINE_IS_NEVER => (400, "The order creation request is invalid because a wire deadline of \"never\" is not allowed."), + MERCHANT_PRIVATE_POST_ORDERS_PAY_DEADLINE_IN_PAST => (400, "The order creation request is invalid because the given payment deadline is in the past."), + MERCHANT_PRIVATE_POST_ORDERS_REFUND_DEADLINE_IN_PAST => (400, "The order creation request is invalid because the given refund deadline is in the past."), + MERCHANT_PRIVATE_POST_ORDERS_NO_EXCHANGES_FOR_WIRE_METHOD => (409, "The backend does not trust any exchange that would allow funds to be wired to any bank account of this instance using the wire method specified with the order. Note that right now, we do not support the use of exchange bank accounts with mandatory currency conversion."), + MERCHANT_PRIVATE_PATCH_ORDERS_ID_FORGET_PATH_SYNTAX_INCORRECT => (400, "One of the paths to forget is malformed."), + MERCHANT_PRIVATE_PATCH_ORDERS_ID_FORGET_PATH_NOT_FORGETTABLE => (409, "One of the paths to forget was not marked as forgettable."), + MERCHANT_POST_ORDERS_ID_REFUND_EXCHANGE_TRANSACTION_LIMIT_VIOLATION => (451, "The refund amount would violate a refund transaction limit configured at the given exchange. Please find another way to refund the customer, and inquire with your legislator why they make strange banking regulations."), + MERCHANT_PRIVATE_POST_ORDERS_AMOUNT_EXCEEDS_LEGAL_LIMITS => (451, "The total order amount exceeds hard legal transaction limits from the available exchanges, thus a customer could never legally make this payment. You may try to increase your limits by passing legitimization checks with exchange operators. You could also inquire with your legislator why the limits are prohibitively low for your business."), + MERCHANT_PRIVATE_DELETE_ORDERS_AWAITING_PAYMENT => (409, "The order provided to the backend could not be deleted, our offer is still valid and awaiting payment. Deletion may work later after the offer has expired if it remains unpaid."), + MERCHANT_PRIVATE_DELETE_ORDERS_ALREADY_PAID => (409, "The order provided to the backend could not be deleted as the order was already paid."), + MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_INCONSISTENT_AMOUNT => (409, "The amount to be refunded is inconsistent: either is lower than the previous amount being awarded, or it exceeds the original price paid by the customer."), + MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_ORDER_UNPAID => (409, "Only paid orders can be refunded, and the frontend specified an unpaid order to issue a refund for."), + MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_NOT_ALLOWED_BY_CONTRACT => (403, "The refund delay was set to 0 and thus no refunds are ever allowed for this order."), + MERCHANT_PRIVATE_POST_ORDERS_TOKEN_FAMILY_SLUG_UNKNOWN => (404, "The token family slug provided in this order could not be found in the merchant database."), + MERCHANT_PRIVATE_POST_ORDERS_TOKEN_FAMILY_NOT_VALID => (409, "A token family referenced in this order is either expired or not valid yet."), + MERCHANT_PRIVATE_POST_TRANSFERS_EXCHANGE_UNKNOWN => (502, "The exchange says it does not know this transfer."), + MERCHANT_PRIVATE_POST_TRANSFERS_REQUEST_ERROR => (502, "We internally failed to execute the /track/transfer request."), + MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_TRANSFERS => (409, "The amount transferred differs between what was submitted and what the exchange claimed."), + MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_REPORTS => (409, "The exchange gave conflicting information about a coin which has been wire transferred."), + MERCHANT_PRIVATE_POST_TRANSFERS_BAD_WIRE_FEE => (502, "The exchange charged a different wire fee than what it originally advertised, and it is higher."), + MERCHANT_PRIVATE_POST_TRANSFERS_ACCOUNT_NOT_FOUND => (404, "We did not find the account that the transfer was made to."), + MERCHANT_PRIVATE_DELETE_TRANSFERS_ALREADY_CONFIRMED => (409, "The backend could not delete the transfer as the echange already replied to our inquiry about it and we have integrated the result."), + MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_SUBMISSION => (409, "The backend was previously informed about a wire transfer with the same ID but a different amount. Multiple wire transfers with the same ID are not allowed. If the new amount is correct, the old transfer should first be deleted."), + MERCHANT_EXCHANGE_TRANSFERS_CONFLICTING_TRANSFERS => (0, "The amount transferred differs between what was submitted and what the exchange claimed."), + MERCHANT_PRIVATE_POST_INSTANCES_ALREADY_EXISTS => (409, "The merchant backend cannot create an instance under the given identifier as one already exists. Use PATCH to modify the existing entry."), + MERCHANT_PRIVATE_POST_INSTANCES_BAD_AUTH => (400, "The merchant backend cannot create an instance because the authentication configuration field is malformed."), + MERCHANT_PRIVATE_POST_INSTANCE_AUTH_BAD_AUTH => (400, "The merchant backend cannot update an instance's authentication settings because the provided authentication settings are malformed."), + MERCHANT_PRIVATE_POST_INSTANCES_PURGE_REQUIRED => (409, "The merchant backend cannot create an instance under the given identifier, the previous one was deleted but must be purged first."), + MERCHANT_PRIVATE_PATCH_INSTANCES_PURGE_REQUIRED => (409, "The merchant backend cannot update an instance under the given identifier, the previous one was deleted but must be purged first."), + MERCHANT_PRIVATE_ACCOUNT_DELETE_UNKNOWN_ACCOUNT => (404, "The bank account referenced in the requested operation was not found."), + MERCHANT_PRIVATE_ACCOUNT_EXISTS => (409, "The bank account specified in the request already exists at the merchant."), + MERCHANT_PRIVATE_POST_PRODUCTS_CONFLICT_PRODUCT_EXISTS => (409, "The product ID exists."), + MERCHANT_PRIVATE_POST_CATEGORIES_CONFLICT_CATEGORY_EXISTS => (409, "A category with the same name exists already."), + MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_REDUCED => (409, "The update would have reduced the total amount of product lost, which is not allowed."), + MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_EXCEEDS_STOCKS => (400, "The update would have mean that more stocks were lost than what remains from total inventory after sales, which is not allowed."), + MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_STOCKED_REDUCED => (409, "The update would have reduced the total amount of product in stock, which is not allowed."), + MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_SOLD_REDUCED => (409, "The update would have reduced the total amount of product sold, which is not allowed."), + MERCHANT_PRIVATE_POST_PRODUCTS_LOCK_INSUFFICIENT_STOCKS => (410, "The lock request is for more products than we have left (unlocked) in stock."), + MERCHANT_PRIVATE_DELETE_PRODUCTS_CONFLICTING_LOCK => (409, "The deletion request is for a product that is locked."), + MERCHANT_PRIVATE_POST_RESERVES_UNSUPPORTED_WIRE_METHOD => (409, "The requested wire method is not supported by the exchange."), + MERCHANT_PRIVATE_POST_RESERVES_REWARDS_NOT_ALLOWED => (409, "The requested exchange does not allow rewards."), + MERCHANT_PRIVATE_DELETE_RESERVES_NO_SUCH_RESERVE => (404, "The reserve could not be deleted because it is unknown."), + MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_EXPIRED => (410, "The reserve that was used to fund the rewards has expired."), + MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_UNKNOWN => (503, "The reserve that was used to fund the rewards was not found in the DB."), + MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_INSUFFICIENT_FUNDS => (0, "The backend knows the instance that was supposed to support the reward, and it was configured for rewardping. However, the funds remaining are insufficient to cover the reward, and the merchant should top up the reserve."), + MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_NOT_FOUND => (503, "The backend failed to find a reserve needed to authorize the reward."), + MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE => (200, "The merchant backend encountered a failure in computing the deposit total."), + MERCHANT_PRIVATE_POST_TEMPLATES_CONFLICT_TEMPLATE_EXISTS => (409, "The template ID already exists."), + MERCHANT_PRIVATE_POST_OTP_DEVICES_CONFLICT_OTP_DEVICE_EXISTS => (409, "The OTP device ID already exists."), + MERCHANT_POST_USING_TEMPLATES_AMOUNT_CONFLICT_TEMPLATES_CONTRACT_AMOUNT => (409, "Amount given in the using template and in the template contract. There is a conflict."), + MERCHANT_POST_USING_TEMPLATES_SUMMARY_CONFLICT_TEMPLATES_CONTRACT_SUBJECT => (409, "Subject given in the using template and in the template contract. There is a conflict."), + MERCHANT_POST_USING_TEMPLATES_NO_AMOUNT => (409, "Amount not given in the using template and in the template contract. There is a conflict."), + MERCHANT_POST_USING_TEMPLATES_NO_SUMMARY => (409, "Subject not given in the using template and in the template contract. There is a conflict."), + MERCHANT_PRIVATE_POST_WEBHOOKS_CONFLICT_WEBHOOK_EXISTS => (409, "The webhook ID elready exists."), + MERCHANT_PRIVATE_POST_PENDING_WEBHOOKS_CONFLICT_PENDING_WEBHOOK_EXISTS => (409, "The webhook serial elready exists."), + AUDITOR_GENERIC_UNAUTHORIZED => (401, "The auditor refused the connection due to a lack of authorization."), + AUDITOR_GENERIC_METHOD_NOT_ALLOWED => (405, "This method is not allowed here."), + AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID => (403, "The signature from the exchange on the deposit confirmation is invalid."), + AUDITOR_EXCHANGE_SIGNING_KEY_REVOKED => (410, "The exchange key used for the signature on the deposit confirmation was revoked."), + AUDITOR_RESOURCE_NOT_FOUND => (404, "The requested resource could not be found."), + AUDITOR_URI_MISSING_PATH_COMPONENT => (400, "The URI is missing a path component."), + BANK_SAME_ACCOUNT => (400, "Wire transfer attempted with credit and debit party being the same bank account."), + BANK_UNALLOWED_DEBIT => (409, "Wire transfer impossible, due to financial limitation of the party that attempted the payment."), + BANK_NEGATIVE_NUMBER_AMOUNT => (400, "Negative numbers are not allowed (as value and/or fraction) to instantiate an amount object."), + BANK_NUMBER_TOO_BIG => (400, "A too big number was used (as value and/or fraction) to instantiate an amount object."), + BANK_UNKNOWN_ACCOUNT => (404, "The bank account referenced in the requested operation was not found."), + BANK_TRANSACTION_NOT_FOUND => (404, "The transaction referenced in the requested operation (typically a reject operation), was not found."), + BANK_BAD_FORMAT_AMOUNT => (400, "Bank received a malformed amount string."), + BANK_REJECT_NO_RIGHTS => (403, "The client does not own the account credited by the transaction which is to be rejected, so it has no rights do reject it."), + BANK_UNMANAGED_EXCEPTION => (500, "This error code is returned when no known exception types captured the exception."), + BANK_SOFT_EXCEPTION => (500, "This error code is used for all those exceptions that do not really need a specific error code to return to the client. Used for example when a client is trying to register with a unavailable username."), + BANK_TRANSFER_REQUEST_UID_REUSED => (409, "The request UID for a request to transfer funds has already been used, but with different details for the transfer."), + BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT => (409, "The withdrawal operation already has a reserve selected. The current request conflicts with the existing selection."), + BANK_DUPLICATE_RESERVE_PUB_SUBJECT => (409, "The wire transfer subject duplicates an existing reserve public key. But wire transfer subjects must be unique."), + BANK_ANCIENT_TRANSACTION_GONE => (410, "The client requested a transaction that is so far in the past, that it has been forgotten by the bank."), + BANK_ABORT_CONFIRM_CONFLICT => (409, "The client attempted to abort a transaction that was already confirmed."), + BANK_CONFIRM_ABORT_CONFLICT => (409, "The client attempted to confirm a transaction that was already aborted."), + BANK_REGISTER_CONFLICT => (409, "The client attempted to register an account with the same name."), + BANK_POST_WITHDRAWAL_OPERATION_REQUIRED => (400, "The client attempted to confirm a withdrawal operation before the wallet posted the required details."), + BANK_RESERVED_USERNAME_CONFLICT => (409, "The client tried to register a new account under a reserved username (like 'admin' for example)."), + BANK_REGISTER_USERNAME_REUSE => (409, "The client tried to register a new account with an username already in use."), + BANK_REGISTER_PAYTO_URI_REUSE => (409, "The client tried to register a new account with a payto:// URI already in use."), + BANK_ACCOUNT_BALANCE_NOT_ZERO => (409, "The client tried to delete an account with a non null balance."), + BANK_UNKNOWN_CREDITOR => (409, "The client tried to create a transaction or an operation that credit an unknown account."), + BANK_UNKNOWN_DEBTOR => (409, "The client tried to create a transaction or an operation that debit an unknown account."), + BANK_ACCOUNT_IS_EXCHANGE => (409, "The client tried to perform an action prohibited for exchange accounts."), + BANK_ACCOUNT_IS_NOT_EXCHANGE => (409, "The client tried to perform an action reserved for exchange accounts."), + BANK_BAD_CONVERSION => (409, "Received currency conversion is wrong."), + BANK_MISSING_TAN_INFO => (409, "The account referenced in this operation is missing tan info for the chosen channel."), + BANK_CONFIRM_INCOMPLETE => (409, "The client attempted to confirm a transaction with incomplete info."), + BANK_TAN_RATE_LIMITED => (429, "The request rate is too high. The server is refusing requests to guard against brute-force attacks."), + BANK_TAN_CHANNEL_NOT_SUPPORTED => (501, "This TAN channel is not supported."), + BANK_TAN_CHANNEL_SCRIPT_FAILED => (500, "Failed to send TAN using the helper script. Either script is not found, or script timeout, or script terminated with a non-successful result."), + BANK_TAN_CHALLENGE_FAILED => (403, "The client's response to the challenge was invalid."), + BANK_NON_ADMIN_PATCH_LEGAL_NAME => (409, "A non-admin user has tried to change their legal name."), + BANK_NON_ADMIN_PATCH_DEBT_LIMIT => (409, "A non-admin user has tried to change their debt limit."), + BANK_NON_ADMIN_PATCH_MISSING_OLD_PASSWORD => (409, "A non-admin user has tried to change their password whihout providing the current one."), + BANK_PATCH_BAD_OLD_PASSWORD => (409, "Provided old password does not match current password."), + BANK_PATCH_ADMIN_EXCHANGE => (409, "An admin user has tried to become an exchange."), + BANK_NON_ADMIN_PATCH_CASHOUT => (409, "A non-admin user has tried to change their cashout account."), + BANK_NON_ADMIN_PATCH_CONTACT => (409, "A non-admin user has tried to change their contact info."), + BANK_ADMIN_CREDITOR => (409, "The client tried to create a transaction that credit the admin account."), + BANK_CHALLENGE_NOT_FOUND => (404, "The referenced challenge was not found."), + BANK_TAN_CHALLENGE_EXPIRED => (409, "The referenced challenge has expired."), + BANK_NON_ADMIN_SET_TAN_CHANNEL => (409, "A non-admin user has tried to create an account with 2fa."), + BANK_NON_ADMIN_SET_MIN_CASHOUT => (409, "A non-admin user has tried to set their minimum cashout amount."), + BANK_CONVERSION_AMOUNT_TO_SMALL => (409, "Amount of currency conversion it less than the minimum allowed."), + BANK_AMOUNT_DIFFERS => (409, "Specified amount will not work for this withdrawal."), + BANK_AMOUNT_REQUIRED => (409, "The backend requires an amount to be specified."), + SYNC_ACCOUNT_UNKNOWN => (404, "The sync service failed find the account in its database."), + SYNC_BAD_IF_NONE_MATCH => (400, "The SHA-512 hash provided in the If-None-Match header is malformed."), + SYNC_BAD_IF_MATCH => (400, "The SHA-512 hash provided in the If-Match header is malformed or missing."), + SYNC_BAD_SYNC_SIGNATURE => (400, "The signature provided in the \"Sync-Signature\" header is malformed or missing."), + SYNC_INVALID_SIGNATURE => (403, "The signature provided in the \"Sync-Signature\" header does not match the account, old or new Etags."), + SYNC_MALFORMED_CONTENT_LENGTH => (400, "The \"Content-length\" field for the upload is not a number."), + SYNC_EXCESSIVE_CONTENT_LENGTH => (413, "The \"Content-length\" field for the upload is too big based on the server's terms of service."), + SYNC_OUT_OF_MEMORY_ON_CONTENT_LENGTH => (413, "The server is out of memory to handle the upload. Trying again later may succeed."), + SYNC_INVALID_UPLOAD => (400, "The uploaded data does not match the Etag."), + SYNC_PAYMENT_GENERIC_TIMEOUT => (408, "HTTP server experienced a timeout while awaiting promised payment."), + SYNC_PAYMENT_CREATE_BACKEND_ERROR => (500, "Sync could not setup the payment request with its own backend."), + SYNC_PREVIOUS_BACKUP_UNKNOWN => (404, "The sync service failed find the backup to be updated in its database."), + SYNC_MISSING_CONTENT_LENGTH => (400, "The \"Content-length\" field for the upload is missing."), + SYNC_GENERIC_BACKEND_ERROR => (502, "Sync had problems communicating with its payment backend."), + SYNC_GENERIC_BACKEND_TIMEOUT => (504, "Sync experienced a timeout communicating with its payment backend."), + WALLET_EXCHANGE_PROTOCOL_VERSION_INCOMPATIBLE => (501, "The wallet does not implement a version of the exchange protocol that is compatible with the protocol version of the exchange."), + WALLET_UNEXPECTED_EXCEPTION => (500, "The wallet encountered an unexpected exception. This is likely a bug in the wallet implementation."), + WALLET_RECEIVED_MALFORMED_RESPONSE => (0, "The wallet received a response from a server, but the response can't be parsed."), + WALLET_NETWORK_ERROR => (0, "The wallet tried to make a network request, but it received no response."), + WALLET_HTTP_REQUEST_THROTTLED => (0, "The wallet tried to make a network request, but it was throttled."), + WALLET_UNEXPECTED_REQUEST_ERROR => (0, "The wallet made a request to a service, but received an error response it does not know how to handle."), + WALLET_EXCHANGE_DENOMINATIONS_INSUFFICIENT => (0, "The denominations offered by the exchange are insufficient. Likely the exchange is badly configured or not maintained."), + WALLET_CORE_API_OPERATION_UNKNOWN => (0, "The wallet does not support the operation requested by a client."), + WALLET_INVALID_TALER_PAY_URI => (0, "The given taler://pay URI is invalid."), + WALLET_EXCHANGE_COIN_SIGNATURE_INVALID => (0, "The signature on a coin by the exchange's denomination key is invalid after unblinding it."), + WALLET_EXCHANGE_WITHDRAW_RESERVE_UNKNOWN_AT_EXCHANGE => (404, "The exchange does not know about the reserve (yet), and thus withdrawal can't progress."), + WALLET_CORE_NOT_AVAILABLE => (0, "The wallet core service is not available."), + WALLET_WITHDRAWAL_OPERATION_ABORTED_BY_BANK => (0, "The bank has aborted a withdrawal operation, and thus a withdrawal can't complete."), + WALLET_HTTP_REQUEST_GENERIC_TIMEOUT => (0, "An HTTP request made by the wallet timed out."), + WALLET_ORDER_ALREADY_CLAIMED => (0, "The order has already been claimed by another wallet."), + WALLET_WITHDRAWAL_GROUP_INCOMPLETE => (0, "A group of withdrawal operations (typically for the same reserve at the same exchange) has errors and will be tried again later."), + WALLET_REWARD_COIN_SIGNATURE_INVALID => (0, "The signature on a coin by the exchange's denomination key (obtained through the merchant via a reward) is invalid after unblinding it."), + WALLET_BANK_INTEGRATION_PROTOCOL_VERSION_INCOMPATIBLE => (0, "The wallet does not implement a version of the bank integration API that is compatible with the version offered by the bank."), + WALLET_CONTRACT_TERMS_BASE_URL_MISMATCH => (0, "The wallet processed a taler://pay URI, but the merchant base URL in the downloaded contract terms does not match the merchant base URL derived from the URI."), + WALLET_CONTRACT_TERMS_SIGNATURE_INVALID => (0, "The merchant's signature on the contract terms is invalid."), + WALLET_CONTRACT_TERMS_MALFORMED => (0, "The contract terms given by the merchant are malformed."), + WALLET_PENDING_OPERATION_FAILED => (0, "A pending operation failed, and thus the request can't be completed."), + WALLET_PAY_MERCHANT_SERVER_ERROR => (0, "A payment was attempted, but the merchant had an internal server error (5xx)."), + WALLET_CRYPTO_WORKER_ERROR => (0, "The crypto worker failed."), + WALLET_CRYPTO_WORKER_BAD_REQUEST => (0, "The crypto worker received a bad request."), + WALLET_WITHDRAWAL_KYC_REQUIRED => (0, "A KYC step is required before withdrawal can proceed."), + WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE => (0, "The wallet does not have sufficient balance to create a deposit group."), + WALLET_PEER_PUSH_PAYMENT_INSUFFICIENT_BALANCE => (0, "The wallet does not have sufficient balance to create a peer push payment."), + WALLET_PEER_PULL_PAYMENT_INSUFFICIENT_BALANCE => (0, "The wallet does not have sufficient balance to pay for an invoice."), + WALLET_REFRESH_GROUP_INCOMPLETE => (0, "A group of refresh operations has errors and will be tried again later."), + WALLET_EXCHANGE_BASE_URL_MISMATCH => (0, "The exchange's self-reported base URL does not match the one that the wallet is using."), + WALLET_ORDER_ALREADY_PAID => (0, "The order has already been paid by another wallet."), + WALLET_EXCHANGE_UNAVAILABLE => (0, "An exchange that is required for some request is currently not available."), + WALLET_EXCHANGE_ENTRY_USED => (0, "An exchange entry is still used by the exchange, thus it can't be deleted without purging."), + WALLET_DB_UNAVAILABLE => (0, "The wallet database is unavailable and the wallet thus is not operational."), + WALLET_TALER_URI_MALFORMED => (0, "A taler:// URI is malformed and can't be parsed."), + WALLET_CORE_REQUEST_CANCELLED => (0, "A wallet-core request was cancelled and thus can't provide a response."), + WALLET_EXCHANGE_TOS_NOT_ACCEPTED => (0, "A wallet-core request failed because the user needs to first accept the exchange's terms of service."), + WALLET_EXCHANGE_ENTRY_UPDATE_CONFLICT => (0, "An exchange entry could not be updated, as the exchange's new details conflict with the new details."), + WALLET_EXCHANGE_ENTRY_OUTDATED => (0, "The wallet's information about the exchange is outdated."), + WALLET_PAY_MERCHANT_KYC_MISSING => (0, "The merchant needs to do KYC first, the payment could not be completed."), + WALLET_PEER_PULL_DEBIT_PURSE_GONE => (0, "A peer-pull-debit transaction was aborted because the exchange reported the purse as gone."), + WALLET_TRANSACTION_ABORTED_BY_USER => (0, "A transaction was aborted on explicit request by the user."), + WALLET_TRANSACTION_ABANDONED_BY_USER => (0, "A transaction was abandoned on explicit request by the user."), + ANASTASIS_GENERIC_BACKEND_TIMEOUT => (504, "We encountered a timeout with our payment backend."), + ANASTASIS_GENERIC_INVALID_PAYMENT_REQUEST => (0, "The backend requested payment, but the request is malformed."), + ANASTASIS_GENERIC_BACKEND_ERROR => (502, "The backend got an unexpected reply from the payment processor."), + ANASTASIS_GENERIC_MISSING_CONTENT_LENGTH => (400, "The \"Content-length\" field for the upload is missing."), + ANASTASIS_GENERIC_MALFORMED_CONTENT_LENGTH => (400, "The \"Content-length\" field for the upload is malformed."), + ANASTASIS_GENERIC_ORDER_CREATE_BACKEND_ERROR => (502, "The backend failed to setup an order with the payment processor."), + ANASTASIS_GENERIC_PAYMENT_CHECK_UNAUTHORIZED => (500, "The backend was not authorized to check for payment with the payment processor."), + ANASTASIS_GENERIC_PAYMENT_CHECK_START_FAILED => (500, "The backend could not check payment status with the payment processor."), + ANASTASIS_GENERIC_PROVIDER_UNREACHABLE => (0, "The Anastasis provider could not be reached."), + ANASTASIS_PAYMENT_GENERIC_TIMEOUT => (408, "HTTP server experienced a timeout while awaiting promised payment."), + ANASTASIS_TRUTH_UNKNOWN => (404, "The key share is unknown to the provider."), + ANASTASIS_TRUTH_AUTHORIZATION_METHOD_NO_LONGER_SUPPORTED => (500, "The authorization method used for the key share is no longer supported by the provider."), + ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED => (403, "The client needs to respond to the challenge."), + ANASTASIS_TRUTH_CHALLENGE_FAILED => (403, "The client's response to the challenge was invalid."), + ANASTASIS_TRUTH_CHALLENGE_UNKNOWN => (404, "The backend is not aware of having issued the provided challenge code. Either this is the wrong code, or it has expired."), + ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED => (500, "The backend failed to initiate the authorization process."), + ANASTASIS_TRUTH_KEY_SHARE_GONE => (404, "The authorization succeeded, but the key share is no longer available."), + ANASTASIS_TRUTH_ORDER_DISAPPEARED => (502, "The backend forgot the order we asked the client to pay for"), + ANASTASIS_TRUTH_BACKEND_EXCHANGE_BAD => (502, "The backend itself reported a bad exchange interaction."), + ANASTASIS_TRUTH_UNEXPECTED_PAYMENT_STATUS => (500, "The backend reported a payment status we did not expect."), + ANASTASIS_TRUTH_PAYMENT_CREATE_BACKEND_ERROR => (502, "The backend failed to setup the order for payment."), + ANASTASIS_TRUTH_DECRYPTION_FAILED => (400, "The decryption of the key share failed with the provided key."), + ANASTASIS_TRUTH_RATE_LIMITED => (429, "The request rate is too high. The server is refusing requests to guard against brute-force attacks."), + ANASTASIS_TRUTH_CHALLENGE_WRONG_METHOD => (400, "A request to issue a challenge is not valid for this authentication method."), + ANASTASIS_TRUTH_UPLOAD_UUID_EXISTS => (409, "The backend failed to store the key share because the UUID is already in use."), + ANASTASIS_TRUTH_UPLOAD_METHOD_NOT_SUPPORTED => (400, "The backend failed to store the key share because the authorization method is not supported."), + ANASTASIS_SMS_PHONE_INVALID => (409, "The provided phone number is not an acceptable number."), + ANASTASIS_SMS_HELPER_EXEC_FAILED => (500, "Failed to run the SMS transmission helper process."), + ANASTASIS_SMS_HELPER_COMMAND_FAILED => (500, "Provider failed to send SMS. Helper terminated with a non-successful result."), + ANASTASIS_EMAIL_INVALID => (409, "The provided email address is not an acceptable address."), + ANASTASIS_EMAIL_HELPER_EXEC_FAILED => (500, "Failed to run the E-mail transmission helper process."), + ANASTASIS_EMAIL_HELPER_COMMAND_FAILED => (500, "Provider failed to send E-mail. Helper terminated with a non-successful result."), + ANASTASIS_POST_INVALID => (409, "The provided postal address is not an acceptable address."), + ANASTASIS_POST_HELPER_EXEC_FAILED => (500, "Failed to run the mail transmission helper process."), + ANASTASIS_POST_HELPER_COMMAND_FAILED => (500, "Provider failed to send mail. Helper terminated with a non-successful result."), + ANASTASIS_IBAN_INVALID => (409, "The provided IBAN address is not an acceptable IBAN."), + ANASTASIS_IBAN_MISSING_TRANSFER => (403, "The provider has not yet received the IBAN wire transfer authorizing the disclosure of the key share."), + ANASTASIS_TOTP_KEY_MISSING => (409, "The backend did not find a TOTP key in the data provided."), + ANASTASIS_TOTP_KEY_INVALID => (409, "The key provided does not satisfy the format restrictions for an Anastasis TOTP key."), + ANASTASIS_POLICY_BAD_IF_NONE_MATCH => (400, "The given if-none-match header is malformed."), + ANASTASIS_POLICY_OUT_OF_MEMORY_ON_CONTENT_LENGTH => (413, "The server is out of memory to handle the upload. Trying again later may succeed."), + ANASTASIS_POLICY_BAD_SIGNATURE => (400, "The signature provided in the \"Anastasis-Policy-Signature\" header is malformed or missing."), + ANASTASIS_POLICY_BAD_IF_MATCH => (400, "The given if-match header is malformed."), + ANASTASIS_POLICY_INVALID_UPLOAD => (400, "The uploaded data does not match the Etag."), + ANASTASIS_POLICY_NOT_FOUND => (404, "The provider is unaware of the requested policy."), + ANASTASIS_REDUCER_ACTION_INVALID => (0, "The given action is invalid for the current state of the reducer."), + ANASTASIS_REDUCER_STATE_INVALID => (0, "The given state of the reducer is invalid."), + ANASTASIS_REDUCER_INPUT_INVALID => (0, "The given input to the reducer is invalid."), + ANASTASIS_REDUCER_AUTHENTICATION_METHOD_NOT_SUPPORTED => (0, "The selected authentication method does not work for the Anastasis provider."), + ANASTASIS_REDUCER_INPUT_INVALID_FOR_STATE => (0, "The given input and action do not work for the current state."), + ANASTASIS_REDUCER_BACKEND_FAILURE => (0, "We experienced an unexpected failure interacting with the backend."), + ANASTASIS_REDUCER_RESOURCE_MALFORMED => (0, "The contents of a resource file did not match our expectations."), + ANASTASIS_REDUCER_RESOURCE_MISSING => (0, "A required resource file is missing."), + ANASTASIS_REDUCER_INPUT_REGEX_FAILED => (0, "An input did not match the regular expression."), + ANASTASIS_REDUCER_INPUT_VALIDATION_FAILED => (0, "An input did not match the custom validation logic."), + ANASTASIS_REDUCER_POLICY_LOOKUP_FAILED => (0, "Our attempts to download the recovery document failed with all providers. Most likely the personal information you entered differs from the information you provided during the backup process and you should go back to the previous step. Alternatively, if you used a backup provider that is unknown to this application, you should add that provider manually."), + ANASTASIS_REDUCER_BACKUP_PROVIDER_FAILED => (0, "Anastasis provider reported a fatal failure."), + ANASTASIS_REDUCER_PROVIDER_CONFIG_FAILED => (0, "Anastasis provider failed to respond to the configuration request."), + ANASTASIS_REDUCER_POLICY_MALFORMED => (0, "The policy we downloaded is malformed. Must have been a client error while creating the backup."), + ANASTASIS_REDUCER_NETWORK_FAILED => (0, "We failed to obtain the policy, likely due to a network issue."), + ANASTASIS_REDUCER_SECRET_MALFORMED => (0, "The recovered secret did not match the required syntax."), + ANASTASIS_REDUCER_CHALLENGE_DATA_TOO_BIG => (0, "The challenge data provided is too large for the available providers."), + ANASTASIS_REDUCER_SECRET_TOO_BIG => (0, "The provided core secret is too large for some of the providers."), + ANASTASIS_REDUCER_PROVIDER_INVALID_CONFIG => (0, "The provider returned in invalid configuration."), + ANASTASIS_REDUCER_INTERNAL_ERROR => (0, "The reducer encountered an internal error, likely a bug that needs to be reported."), + ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED => (0, "The reducer already synchronized with all providers."), + DONAU_GENERIC_KEYS_MISSING => (503, "The Donau failed to perform the operation as it could not find the private keys. This is a problem with the Donau setup, not with the client's request."), + DONAU_CHARITY_SIGNATURE_INVALID => (403, "The signature of the charity key is not valid."), + DONAU_CHARITY_NOT_FOUND => (404, "The charity is unknown."), + DONAU_EXCEEDING_DONATION_LIMIT => (400, "The donation amount specified in the request exceeds the limit of the charity."), + DONAU_GENERIC_DONATION_UNIT_UNKNOWN => (404, "The Donau is not aware of the donation unit requested for the operation."), + DONAU_DONATION_UNIT_HELPER_UNAVAILABLE => (502, "The Donau failed to talk to the process responsible for its private donation unit keys or the helpers had no donation units (properly) configured."), + DONAU_SIGNKEY_HELPER_UNAVAILABLE => (502, "The Donau failed to talk to the process responsible for its private signing keys."), + DONAU_SIGNKEY_HELPER_BUG => (500, "The response from the online signing key helper process was malformed."), + DONAU_GENERIC_WRONG_NUMBER_OF_SEGMENTS => (404, "The number of segments included in the URI does not match the number of segments expected by the endpoint."), + DONAU_DONATION_RECEIPT_SIGNATURE_INVALID => (403, "The signature of the donation receipt is not valid."), + DONAU_DONOR_IDENTIFIER_NONCE_REUSE => (409, "The client re-used a unique donor identifier nonce, which is not allowed."), + LIBEUFIN_NEXUS_GENERIC_ERROR => (0, "A generic error happened in the LibEuFin nexus. See the enclose details JSON for more information."), + LIBEUFIN_NEXUS_UNCAUGHT_EXCEPTION => (500, "An uncaught exception happened in the LibEuFin nexus service."), + LIBEUFIN_SANDBOX_GENERIC_ERROR => (0, "A generic error happened in the LibEuFin sandbox. See the enclose details JSON for more information."), + LIBEUFIN_SANDBOX_UNCAUGHT_EXCEPTION => (500, "An uncaught exception happened in the LibEuFin sandbox service."), + TALDIR_METHOD_NOT_SUPPORTED => (404, "This validation method is not supported by the service."), + TALDIR_REGISTER_RATE_LIMITED => (429, "Number of allowed attempts for initiating a challenge exceeded."), + CHALLENGER_GENERIC_CLIENT_UNKNOWN => (404, "The client is unknown or unauthorized."), + CHALLENGER_GENERIC_CLIENT_FORBIDDEN_BAD_REDIRECT_URI => (403, "The client is not authorized to use the given redirect URI."), + CHALLENGER_HELPER_EXEC_FAILED => (500, "The service failed to execute its helper process to send the challenge."), + CHALLENGER_GRANT_UNKNOWN => (404, "The grant is unknown to the service (it could also have expired)."), + CHALLENGER_CLIENT_FORBIDDEN_BAD_CODE => (403, "The code given is not even well-formed."), + CHALLENGER_GENERIC_VALIDATION_UNKNOWN => (404, "The service is not aware of the referenced validation process."), + CHALLENGER_CLIENT_FORBIDDEN_INVALID_CODE => (403, "The code given is not valid."), + CHALLENGER_TOO_MANY_ATTEMPTS => (429, "Too many attempts have been made, validation is temporarily disabled for this address."), + CHALLENGER_INVALID_PIN => (403, "The PIN code provided is incorrect."), + CHALLENGER_MISSING_ADDRESS => (409, "The token cannot be valid as no address was ever provided by the client."), + END => (0, "End of error code range."), + } + } +} diff --git a/taler-common/src/lib.rs b/taler-common/src/lib.rs @@ -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 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/> +*/ + +pub mod amount; +pub mod api_common; +pub mod api_params; +pub mod api_wire; +pub mod error_code; +pub mod config { + // TODO +} +pub mod payto { + // TODO +} diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "test-utils" +version = "0.1.0" +edition = "2021" + +[dependencies] +axum-test = "16.2" +axum.workspace = true +tokio.workspace = true +serde_json.workspace = true +serde.workspace = true +taler-common = { path = "../taler-common" } diff --git a/test-utils/src/helpers.rs b/test-utils/src/helpers.rs @@ -0,0 +1,99 @@ +/* + 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 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/> +*/ + +use axum::http::StatusCode; +use axum_test::TestResponse; +use serde::de::DeserializeOwned; +use serde_json::Value; +use taler_common::{api_common::ErrorDetail, error_code::ErrorCode}; + +pub trait TestResponseHelper { + fn json_parse<T: DeserializeOwned>(&self) -> T; + fn assert_ok_json<T: DeserializeOwned>(&self) -> T; + fn assert_ok(&self); + fn assert_no_content(&self); + fn assert_error(&self, error_code: ErrorCode); +} + +#[track_caller] +pub fn assert_status(resp: &TestResponse, status: StatusCode) { + if resp.status_code() != status { + let body = resp.as_bytes(); + if resp.status_code().is_success() || body.is_empty() { + panic!( + "{} {} expected {status} got {}", + resp.request_method(), + resp.request_url(), + resp.status_code() + ); + } else { + let err: ErrorDetail = resp.json_parse(); + let description = err.hint.unwrap_or_default(); + panic!( + "{} {} expected {status} got {}: {} {description}", + resp.request_method(), + resp.request_url(), + resp.status_code(), + err.code + ); + } + } +} + +impl TestResponseHelper for TestResponse { + #[track_caller] + fn assert_ok_json<T: DeserializeOwned>(&self) -> T { + self.assert_ok(); + self.json_parse() + } + #[track_caller] + fn assert_ok(&self) { + assert_status(self, StatusCode::OK); + } + #[track_caller] + fn assert_no_content(&self) { + assert_status(self, StatusCode::NO_CONTENT); + } + + #[track_caller] + fn assert_error(&self, error_code: ErrorCode) { + let (status_code, _) = error_code.metadata(); + assert_status(self, StatusCode::from_u16(status_code).unwrap()); + let err: ErrorDetail = self.json_parse(); + assert_eq!(error_code as u32, err.code); + } + #[track_caller] + fn json_parse<T: DeserializeOwned>(&self) -> T { + match serde_json::from_slice(self.as_bytes()) { + Ok(body) => body, + Err(err) => match serde_json::from_slice::<Value>(self.as_bytes()) { + Ok(raw) => panic!( + "{} {} {} invalid JSON schema: {err}\n{raw}", + self.request_method(), + self.request_url(), + self.status_code() + ), + Err(err) => panic!( + "{} {} {} invalid JSON body: {err}\n{}", + self.request_method(), + self.request_url(), + self.status_code(), + String::from_utf8_lossy(self.as_bytes()) + ), + }, + } + } +} diff --git a/test-utils/src/json.rs b/test-utils/src/json.rs @@ -0,0 +1,42 @@ +/* + 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 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/> +*/ + +use serde_json::Value; + +pub fn merge(a: &mut Value, b: Value) { + match (a, b) { + (a @ &mut Value::Object(_), Value::Object(b)) => { + let a = a.as_object_mut().unwrap(); + for (k, v) in b { + merge(a.entry(k).or_insert(Value::Null), v); + } + } + (a, b) => *a = b, + } +} + +#[macro_export] +macro_rules! json { + ($object:ident + $($json:tt)+) => { + { + let change = json!($($json)+); + let mut original = $object.clone(); + test_utils::json::merge(&mut original, change); + original + } + }; + ($($json:tt)+) => { serde_json::json!($($json)+) }; +} diff --git a/test-utils/src/lib.rs b/test-utils/src/lib.rs @@ -0,0 +1,20 @@ +/* + 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 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/> +*/ + +pub use axum_test; +pub mod helpers; +pub mod json; +pub mod routine; diff --git a/test-utils/src/routine.rs b/test-utils/src/routine.rs @@ -0,0 +1,243 @@ +/* + 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 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/> +*/ + +use std::{ + borrow::Cow, + fmt::Debug, + future::Future, + str::FromStr, + time::{Duration, Instant}, +}; + +use axum::{extract::Query, http::Uri}; +use axum_test::{TestResponse, TestServer}; +use serde::de::DeserializeOwned; +use taler_common::api_params::PageParams; +use tokio::time::sleep; + +use crate::helpers::TestResponseHelper; + +pub async fn routine_pagination<'a, T: DeserializeOwned, F: Future<Output = ()>>( + server: &'a TestServer, + url: &str, + ids: fn(T) -> Vec<i64>, + register: fn(&'a TestServer, usize) -> F, +) { + // Check history is following specs + let assert_history = |args: Cow<'static, str>, size: usize| async move { + let resp = server.get(&format!("{url}?{args}")).await; + assert_history_ids(resp, ids, size) + }; + // Get latest registered id + let latest_id = || async move { assert_history("limit=-1".into(), 1).await[0] }; + + for i in 0..20 { + register(server, i).await; + } + + let id = latest_id().await; + + // default + assert_history("".into(), 20).await; + + // forward range + assert_history("limit=10".into(), 10).await; + assert_history("limit=10&offset=4".into(), 10).await; + + // backward range + assert_history("limit=-10".into(), 10).await; + assert_history(format!("limit=-10&{}", id - 4).into(), 10).await; +} + +pub async fn assert_time<R: Debug>(range: std::ops::Range<u128>, task: impl Future<Output = R>) { + let start = Instant::now(); + task.await; + let elapsed = start.elapsed().as_millis(); + if !range.contains(&elapsed) { + panic!("Expected to last {range:?} got {elapsed:?}") + } +} + +pub async fn routine_history< + 'a, + T: DeserializeOwned, + FR: Future<Output = ()>, + FI: Future<Output = ()>, +>( + server: &'a TestServer, + url: &str, + ids: fn(T) -> Vec<i64>, + nb_register: usize, + register: fn(&'a TestServer, usize) -> FR, + nb_ignore: usize, + ignore: fn(&'a TestServer, usize) -> FI, +) { + // Check history is following specs + let assert_history = |args: String, size: usize| async move { + let resp = server.get(&format!("{url}?{args}")).await; + assert_history_ids(resp, ids, size) + }; + // Get latest registered id + let latest_id = || async { assert_history(format!("limit=-1"), 1).await[0] }; + + // Check error when no transactions + assert_history(format!("limit=7"), 0).await; + + let mut register_iter = (0..nb_register).peekable(); + let mut ignore_iter = (0..nb_ignore).peekable(); + while register_iter.peek().is_some() || ignore_iter.peek().is_some() { + if let Some(idx) = register_iter.next() { + register(server, idx).await + } + if let Some(idx) = ignore_iter.next() { + ignore(server, idx).await + } + } + let nb_total = nb_register + nb_ignore; + + // Check ignored + assert_history(format!("limit={nb_total}"), nb_register).await; + // Check skip ignored + assert_history(format!("limit={nb_register}"), nb_register).await; + + // Check no polling when we cannot have more transactions + assert_time( + 0..100, + assert_history( + format!("limit=-{}&timeout_ms=1000", nb_register + 1), + nb_register, + ), + ) + .await; + // Check no polling when already find transactions even if less than delta + assert_time( + 0..100, + assert_history( + format!("limit={}&timeout_ms=1000", nb_register + 1), + nb_register, + ), + ) + .await; + + // Check polling + let id = latest_id().await; + tokio::join!( + // Check polling succeed + assert_time( + 100..200, + assert_history(format!("limit=2&offset={id}&timeout_ms=1000"), 1) + ), + assert_time( + 200..300, + assert_history( + format!( + "limit=1&offset={}&timeout_ms=200", + id as usize + nb_total * 3 + ), + 0 + ) + ), + async { + sleep(Duration::from_millis(100)).await; + register(server, 0).await + } + ); + + // Test triggers + for i in 0..nb_register { + let id = latest_id().await; + tokio::join!( + // Check polling succeed + assert_time( + 100..200, + assert_history(format!("limit=7&offset={id}&timeout_ms=1000"), 1) + ), + async { + sleep(Duration::from_millis(100)).await; + register(server, i).await + } + ); + } + + // Test doesn't trigger + let id = latest_id().await; + tokio::join!( + // Check polling succeed + assert_time( + 200..300, + assert_history(format!("limit=7&offset={id}&timeout_ms=200"), 0) + ), + async { + sleep(Duration::from_millis(100)).await; + for i in 0..nb_ignore { + ignore(server, i).await + } + } + ); + + routine_pagination(server, url, ids, register).await; +} + +#[track_caller] +fn assert_history_ids<T: DeserializeOwned>( + resp: TestResponse, + ids: impl Fn(T) -> Vec<i64>, + size: usize, +) -> Vec<i64> { + if size == 0 { + resp.assert_no_content(); + return vec![]; + } + let body = resp.assert_ok_json::<T>(); + let history: Vec<_> = ids(body); + let Query(raw) = + <Query<PageParams>>::try_from_uri(&Uri::from_str(resp.request_url().as_str()).unwrap()) + .unwrap(); + let params = raw.check(1024).unwrap(); + + // testing the size is like expected + assert_eq!(size, history.len(), "bad history length: {history:?}"); + if params.limit < 0 { + // testing that the first id is at most the 'offset' query param. + assert!( + params + .offset + .map(|offset| history[0] <= offset) + .unwrap_or(true), + "bad history offset: {params:?} {history:?}" + ); + // testing that the id decreases. + assert!( + history.as_slice().is_sorted_by(|a, b| a > b), + "bad history order: {history:?}" + ) + } else { + // testing that the first id is at least the 'offset' query param. + assert!( + params + .offset + .map(|offset| history[0] >= offset) + .unwrap_or(true), + "bad history offset: {params:?} {history:?}" + ); + // testing that the id increases. + assert!( + history.as_slice().is_sorted(), + "bad history order: {history:?}" + ) + } + history +}