瀏覽代碼

Working on UTXO model

Cesar Rodas 1 年之前
當前提交
a92727113a

+ 1751 - 0
utxo/Cargo.lock

@@ -0,0 +1,1751 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "addr2line"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
+dependencies = [
+ "gimli",
+]
+
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
+[[package]]
+name = "ahash"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
+dependencies = [
+ "cfg-if",
+ "getrandom",
+ "once_cell",
+ "version_check",
+]
+
+[[package]]
+name = "allocator-api2"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
+
+[[package]]
+name = "async-trait"
+version = "0.1.73"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "atoi"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+
+[[package]]
+name = "backtrace"
+version = "0.3.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
+dependencies = [
+ "addr2line",
+ "cc",
+ "cfg-if",
+ "libc",
+ "miniz_oxide",
+ "object",
+ "rustc-demangle",
+]
+
+[[package]]
+name = "base64"
+version = "0.21.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
+
+[[package]]
+name = "base64ct"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
+
+[[package]]
+name = "bincode"
+version = "1.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "bitflags"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
+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 = "byteorder"
+version = "1.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
+
+[[package]]
+name = "bytes"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
+
+[[package]]
+name = "cc"
+version = "1.0.83"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "const-oid"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f"
+
+[[package]]
+name = "core-foundation"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
+
+[[package]]
+name = "cpufeatures"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crc"
+version = "3.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe"
+dependencies = [
+ "crc-catalog",
+]
+
+[[package]]
+name = "crc-catalog"
+version = "2.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484"
+
+[[package]]
+name = "crossbeam-queue"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
+dependencies = [
+ "cfg-if",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
+dependencies = [
+ "cfg-if",
+]
+
+[[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 = "der"
+version = "0.7.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c"
+dependencies = [
+ "const-oid",
+ "pem-rfc7468",
+ "zeroize",
+]
+
+[[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 = "dotenvy"
+version = "0.15.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
+
+[[package]]
+name = "either"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
+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.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
+dependencies = [
+ "errno-dragonfly",
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "errno-dragonfly"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
+dependencies = [
+ "cc",
+ "libc",
+]
+
+[[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",
+]
+
+[[package]]
+name = "event-listener"
+version = "2.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
+
+[[package]]
+name = "fastrand"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
+
+[[package]]
+name = "finl_unicode"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6"
+
+[[package]]
+name = "flume"
+version = "0.10.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577"
+dependencies = [
+ "futures-core",
+ "futures-sink",
+ "pin-project",
+ "spin 0.9.8",
+]
+
+[[package]]
+name = "foreign-types"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
+dependencies = [
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+
+[[package]]
+name = "form_urlencoded"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652"
+dependencies = [
+ "percent-encoding",
+]
+
+[[package]]
+name = "futures"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-executor",
+ "futures-io",
+ "futures-sink",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
+name = "futures-channel"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
+dependencies = [
+ "futures-core",
+ "futures-sink",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
+
+[[package]]
+name = "futures-executor"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
+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.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
+
+[[package]]
+name = "futures-macro"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "futures-sink"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
+
+[[package]]
+name = "futures-task"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
+
+[[package]]
+name = "futures-util"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-io",
+ "futures-macro",
+ "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.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "gimli"
+version = "0.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
+
+[[package]]
+name = "hashbrown"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
+dependencies = [
+ "ahash",
+ "allocator-api2",
+]
+
+[[package]]
+name = "hashlink"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7"
+dependencies = [
+ "hashbrown",
+]
+
+[[package]]
+name = "heck"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
+dependencies = [
+ "unicode-segmentation",
+]
+
+[[package]]
+name = "hermit-abi"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
+
+[[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.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437"
+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.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "idna"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c"
+dependencies = [
+ "unicode-bidi",
+ "unicode-normalization",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
+dependencies = [
+ "equivalent",
+ "hashbrown",
+]
+
+[[package]]
+name = "itertools"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+dependencies = [
+ "spin 0.5.2",
+]
+
+[[package]]
+name = "ledger-utxo"
+version = "0.1.0"
+dependencies = [
+ "async-trait",
+ "bincode",
+ "futures",
+ "hex",
+ "serde",
+ "sha2",
+ "sqlx",
+ "strum",
+ "strum_macros",
+ "thiserror",
+ "tokio",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.147"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
+
+[[package]]
+name = "libm"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
+
+[[package]]
+name = "libsqlite3-sys"
+version = "0.26.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326"
+dependencies = [
+ "cc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
+
+[[package]]
+name = "lock_api"
+version = "0.4.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
+
+[[package]]
+name = "md-5"
+version = "0.10.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca"
+dependencies = [
+ "digest",
+]
+
+[[package]]
+name = "memchr"
+version = "2.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
+
+[[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.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "mio"
+version = "0.8.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
+dependencies = [
+ "libc",
+ "wasi",
+ "windows-sys",
+]
+
+[[package]]
+name = "native-tls"
+version = "0.2.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
+dependencies = [
+ "lazy_static",
+ "libc",
+ "log",
+ "openssl",
+ "openssl-probe",
+ "openssl-sys",
+ "schannel",
+ "security-framework",
+ "security-framework-sys",
+ "tempfile",
+]
+
+[[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 = "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-integer"
+version = "0.1.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
+dependencies = [
+ "autocfg",
+ "num-traits",
+]
+
+[[package]]
+name = "num-iter"
+version = "0.1.43"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
+dependencies = [
+ "autocfg",
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2"
+dependencies = [
+ "autocfg",
+ "libm",
+]
+
+[[package]]
+name = "num_cpus"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
+dependencies = [
+ "hermit-abi",
+ "libc",
+]
+
+[[package]]
+name = "object"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
+
+[[package]]
+name = "openssl"
+version = "0.10.57"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c"
+dependencies = [
+ "bitflags 2.4.0",
+ "cfg-if",
+ "foreign-types",
+ "libc",
+ "once_cell",
+ "openssl-macros",
+ "openssl-sys",
+]
+
+[[package]]
+name = "openssl-macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "openssl-probe"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
+
+[[package]]
+name = "openssl-sys"
+version = "0.9.93"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "parking_lot"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-targets",
+]
+
+[[package]]
+name = "paste"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
+
+[[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.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
+
+[[package]]
+name = "pin-project"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
+
+[[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.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.66"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
+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.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
+dependencies = [
+ "bitflags 1.3.2",
+]
+
+[[package]]
+name = "rsa"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8"
+dependencies = [
+ "byteorder",
+ "const-oid",
+ "digest",
+ "num-bigint-dig",
+ "num-integer",
+ "num-iter",
+ "num-traits",
+ "pkcs1",
+ "pkcs8",
+ "rand_core",
+ "signature",
+ "spki",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustc-demangle"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
+
+[[package]]
+name = "rustix"
+version = "0.38.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453"
+dependencies = [
+ "bitflags 2.4.0",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
+
+[[package]]
+name = "ryu"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
+
+[[package]]
+name = "schannel"
+version = "0.1.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "security-framework"
+version = "2.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "core-foundation-sys",
+ "libc",
+ "security-framework-sys",
+]
+
+[[package]]
+name = "security-framework-sys"
+version = "2.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.188"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.188"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.105"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "sha1"
+version = "0.10.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
+[[package]]
+name = "sha2"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
+[[package]]
+name = "signal-hook-registry"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "signature"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500"
+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.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
+
+[[package]]
+name = "socket2"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877"
+dependencies = [
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "spin"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
+
+[[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.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a"
+dependencies = [
+ "base64ct",
+ "der",
+]
+
+[[package]]
+name = "sqlformat"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b7b278788e7be4d0d29c0f39497a0eef3fba6bbc8e70d8bf7fde46edeaa9e85"
+dependencies = [
+ "itertools",
+ "nom",
+ "unicode_categories",
+]
+
+[[package]]
+name = "sqlx"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e58421b6bc416714d5115a2ca953718f6c621a51b68e4f4922aea5a4391a721"
+dependencies = [
+ "sqlx-core",
+ "sqlx-macros",
+ "sqlx-mysql",
+ "sqlx-postgres",
+ "sqlx-sqlite",
+]
+
+[[package]]
+name = "sqlx-core"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd4cef4251aabbae751a3710927945901ee1d97ee96d757f6880ebb9a79bfd53"
+dependencies = [
+ "ahash",
+ "atoi",
+ "byteorder",
+ "bytes",
+ "crc",
+ "crossbeam-queue",
+ "dotenvy",
+ "either",
+ "event-listener",
+ "futures-channel",
+ "futures-core",
+ "futures-intrusive",
+ "futures-io",
+ "futures-util",
+ "hashlink",
+ "hex",
+ "indexmap",
+ "log",
+ "memchr",
+ "native-tls",
+ "once_cell",
+ "paste",
+ "percent-encoding",
+ "serde",
+ "serde_json",
+ "sha2",
+ "smallvec",
+ "sqlformat",
+ "thiserror",
+ "tokio",
+ "tokio-stream",
+ "tracing",
+ "url",
+]
+
+[[package]]
+name = "sqlx-macros"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "208e3165167afd7f3881b16c1ef3f2af69fa75980897aac8874a0696516d12c2"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "sqlx-core",
+ "sqlx-macros-core",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "sqlx-macros-core"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a4a8336d278c62231d87f24e8a7a74898156e34c1c18942857be2acb29c7dfc"
+dependencies = [
+ "dotenvy",
+ "either",
+ "heck",
+ "hex",
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "serde_json",
+ "sha2",
+ "sqlx-core",
+ "sqlx-mysql",
+ "sqlx-sqlite",
+ "syn 1.0.109",
+ "tempfile",
+ "tokio",
+ "url",
+]
+
+[[package]]
+name = "sqlx-mysql"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ca69bf415b93b60b80dc8fda3cb4ef52b2336614d8da2de5456cc942a110482"
+dependencies = [
+ "atoi",
+ "base64",
+ "bitflags 2.4.0",
+ "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",
+ "tracing",
+ "whoami",
+]
+
+[[package]]
+name = "sqlx-postgres"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0db2df1b8731c3651e204629dd55e52adbae0462fa1bdcbed56a2302c18181e"
+dependencies = [
+ "atoi",
+ "base64",
+ "bitflags 2.4.0",
+ "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",
+ "sha1",
+ "sha2",
+ "smallvec",
+ "sqlx-core",
+ "stringprep",
+ "thiserror",
+ "tracing",
+ "whoami",
+]
+
+[[package]]
+name = "sqlx-sqlite"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be4c21bf34c7cae5b283efb3ac1bcc7670df7561124dc2f8bdc0b59be40f79a2"
+dependencies = [
+ "atoi",
+ "flume",
+ "futures-channel",
+ "futures-core",
+ "futures-executor",
+ "futures-intrusive",
+ "futures-util",
+ "libsqlite3-sys",
+ "log",
+ "percent-encoding",
+ "serde",
+ "sqlx-core",
+ "tracing",
+ "url",
+]
+
+[[package]]
+name = "stringprep"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6"
+dependencies = [
+ "finl_unicode",
+ "unicode-bidi",
+ "unicode-normalization",
+]
+
+[[package]]
+name = "strum"
+version = "0.25.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
+
+[[package]]
+name = "strum_macros"
+version = "0.25.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "subtle"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
+
+[[package]]
+name = "syn"
+version = "1.0.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
+dependencies = [
+ "cfg-if",
+ "fastrand",
+ "redox_syscall",
+ "rustix",
+ "windows-sys",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.48"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.48"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "tinyvec"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
+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.32.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9"
+dependencies = [
+ "backtrace",
+ "bytes",
+ "libc",
+ "mio",
+ "num_cpus",
+ "parking_lot",
+ "pin-project-lite",
+ "signal-hook-registry",
+ "socket2",
+ "tokio-macros",
+ "windows-sys",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tracing"
+version = "0.1.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
+dependencies = [
+ "cfg-if",
+ "log",
+ "pin-project-lite",
+ "tracing-attributes",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-attributes"
+version = "0.1.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "typenum"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
+
+[[package]]
+name = "unicode-bidi"
+version = "0.3.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
+
+[[package]]
+name = "unicode-normalization"
+version = "0.1.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
+dependencies = [
+ "tinyvec",
+]
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
+
+[[package]]
+name = "unicode_categories"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
+
+[[package]]
+name = "url"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5"
+dependencies = [
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
+]
+
+[[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.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+
+[[package]]
+name = "wasi"
+version = "0.11.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+
+[[package]]
+name = "whoami"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50"
+
+[[package]]
+name = "windows-sys"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[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_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[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_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[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_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+
+[[package]]
+name = "zeroize"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"

+ 25 - 0
utxo/Cargo.toml

@@ -0,0 +1,25 @@
+[package]
+name = "ledger-utxo"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+[dependencies]
+async-trait = "0.1.73"
+bincode = { version = "1.3.3", features = ["i128"] }
+futures = "0.3.28"
+hex = "0.4.3"
+serde = { version = "1.0.188", features = ["derive"] }
+sha2 = "0.10.7"
+sqlx = { version = "0.7.1", features = ["runtime-tokio", "tls-native-tls", "sqlite"] }
+strum = "0.25.0"
+strum_macros = "0.25.2"
+thiserror = "1.0.48"
+tokio = { version = "1.32.0", features = ["full"] }
+
+[dev-dependencies]
+sqlx = { version = "0.7.1", features = ["sqlite"] }
+
+[features]
+default = []
+sqlite = ["sqlx/sqlite"]

+ 24 - 0
utxo/src/account_id.rs

@@ -0,0 +1,24 @@
+use std::fmt::Display;
+
+use serde::Serialize;
+
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize)]
+pub struct AccountId(pub [u8; 32]);
+
+impl AccountId {
+    pub fn new() -> Self {
+        Self([0; 32])
+    }
+}
+
+impl Display for AccountId {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        write!(f, "{}", hex::encode(self.0))
+    }
+}
+
+impl AsRef<[u8]> for AccountId {
+    fn as_ref(&self) -> &[u8] {
+        &self.0
+    }
+}

+ 42 - 0
utxo/src/amount.rs

@@ -0,0 +1,42 @@
+use crate::Asset;
+use serde::Serialize;
+
+pub type AmountCents = i128;
+
+/// Amount
+///
+/// The cents are stored in their lowest denomination, or their "cents".  For
+/// instance a Bitcoin would be represented with a `precision` of 8, or dollars
+/// in a 2 or 3.
+///
+/// For instance, if the dollar Asset has a `precision` of `2`, an `cents` of
+/// 1255 will represent `12.55 USD`.
+///
+/// Amount will abstract all the math operations that can be performed with the
+/// amounts, guarding that the `Asset` are the same before performing any
+/// operation.
+///
+///
+/// The `cents` and `Asset.id` must be used to store amounts in the storge
+/// layer. Float or string representations should be used to display
+#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize)]
+pub struct Amount {
+    asset: Asset,
+    cents: AmountCents,
+}
+
+impl Amount {
+    pub fn new(asset: Asset, cents: AmountCents) -> Self {
+        Self { asset, cents }
+    }
+
+    #[inline]
+    pub fn asset(&self) -> &Asset {
+        &self.asset
+    }
+
+    #[inline]
+    pub fn cents(&self) -> AmountCents {
+        self.cents
+    }
+}

+ 24 - 0
utxo/src/asset.rs

@@ -0,0 +1,24 @@
+use serde::{Deserialize, Serialize};
+use std::fmt::Display;
+
+pub type AssetId = u32;
+
+/// An asset
+///
+/// The asset definition is just a u32 number, which is meaningless for the
+/// code, as long as each asset has an unique id.
+///
+/// The asset struct also has a precision, which is a u8 number (from 0-255)
+/// which is used by amount when converting the inner_amount to a human readable
+/// format.
+#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
+pub struct Asset {
+    pub id: AssetId,
+    precision: u8,
+}
+
+impl Display for Asset {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        write!(f, "{}", self.id)
+    }
+}

+ 43 - 0
utxo/src/asset_manager.rs

@@ -0,0 +1,43 @@
+use crate::{amount::AmountCents, asset::AssetId, Amount, Asset, Error};
+use std::{collections::HashMap, sync::Arc};
+
+#[derive(Clone, Debug, Eq, PartialEq)]
+pub struct AssetManager {
+    assets: HashMap<AssetId, AssetDefinition>,
+}
+
+#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize)]
+pub struct AssetDefinition {
+    #[serde(flatten)]
+    asset: Asset,
+    name: Arc<str>,
+}
+
+impl AssetManager {
+    pub fn new(assets: Vec<AssetDefinition>) -> Self {
+        Self {
+            assets: assets
+                .into_iter()
+                .map(|asset| (asset.asset.id, asset))
+                .collect(),
+        }
+    }
+
+    pub fn asset(&self, id: AssetId) -> Result<Asset, Error> {
+        self.assets
+            .get(&id)
+            .map(|asset| asset.asset)
+            .ok_or(Error::AssetNotFound(id))
+    }
+
+    pub fn asset_name(&self, asset: &Asset) -> Result<Arc<str>, Error> {
+        self.assets
+            .get(&asset.id)
+            .map(|asset| asset.name.clone())
+            .ok_or(Error::AssetNotFound(asset.id))
+    }
+
+    pub fn amount(&self, id: AssetId, cents: AmountCents) -> Result<Amount, Error> {
+        self.asset(id).map(|asset| Amount::new(asset, cents))
+    }
+}

+ 16 - 0
utxo/src/error.rs

@@ -0,0 +1,16 @@
+use crate::{asset::AssetId, storage, transaction, AccountId};
+
+#[derive(thiserror::Error, Debug)]
+pub enum Error {
+    #[error("Transaction: {0}")]
+    Transaction(#[from] transaction::Error),
+
+    #[error("Storage: {0}")]
+    Storage(#[from] storage::Error),
+
+    #[error("Asset {0} is not defined")]
+    AssetNotFound(AssetId),
+
+    #[error("Not enough funds (asset {1}) for account {0}")]
+    InsufficientBalance(AccountId, AssetId),
+}

+ 116 - 0
utxo/src/ledger.rs

@@ -0,0 +1,116 @@
+use crate::{
+    amount::AmountCents, storage, AccountId, Amount, AssetManager, Batch, Error, PaymentId,
+    Storage, Transaction,
+};
+use futures::TryStreamExt;
+use std::{collections::HashMap, sync::Arc};
+
+#[derive(Clone, Debug)]
+pub struct Ledger<B, I, S>
+where
+    B: Batch,
+    I: TryStreamExt<Ok = (PaymentId, AmountCents), Error = storage::Error> + Unpin,
+    S: Storage<B, I>,
+{
+    storage: Arc<S>,
+    asset_manager: Arc<AssetManager>,
+    _phantom_batch: std::marker::PhantomData<B>,
+    _phantom_iterator: std::marker::PhantomData<I>,
+}
+
+impl<B, I, S> Ledger<B, I, S>
+where
+    B: Batch,
+    I: TryStreamExt<Ok = (PaymentId, AmountCents), Error = storage::Error> + Unpin,
+    S: Storage<B, I>,
+{
+    pub fn new(storage: S, asset_manager: AssetManager) -> Self {
+        Self {
+            storage: Arc::new(storage),
+            asset_manager: Arc::new(asset_manager),
+            _phantom_batch: std::marker::PhantomData,
+            _phantom_iterator: std::marker::PhantomData,
+        }
+    }
+
+    pub async fn get_balance(&self, account: AccountId) -> Result<Vec<Amount>, Error> {
+        self.storage
+            .get_balance(account)
+            .await?
+            .into_iter()
+            .map(|(asset, cents)| self.asset_manager.amount(asset, cents))
+            .collect::<Result<Vec<_>, _>>()
+    }
+
+    async fn normalize_payments_to_spend(
+        &self,
+        payments: Vec<(AccountId, Amount)>,
+    ) -> Result<Vec<(AccountId, Amount)>, Error> {
+        let mut to_spend = HashMap::new();
+        let mut balances = HashMap::new();
+        for (account_id, amount) in payments.into_iter() {
+            if balances.get(&account_id).is_none() {
+                balances.insert(account_id, self.get_balance(account_id).await?);
+            }
+            let id = (account_id, *amount.asset());
+            if let Some(value) = to_spend.get_mut(&id) {
+                *value += amount.cents();
+            } else {
+                to_spend.insert(id, amount.cents());
+            }
+        }
+
+        for ((account, asset), mut to_spend_cents) in to_spend.into_iter() {
+            let mut payment_ids: Vec<PaymentId> = vec![];
+            let mut iterator = self.storage.get_unspend_payments(account, asset.id).await?;
+            while let Some((payment_id, cents)) = iterator.try_next().await? {
+                payment_ids.push(payment_id);
+                to_spend_cents -= cents;
+                if to_spend_cents < 0 {
+                    // We have enough payment_id to to cover the to_spend_cents
+                    // Any negative number will be the return to the account
+                    break;
+                }
+            }
+        }
+
+        /*
+               to_spend
+                   .into_iter()
+                   .map(|((account_id, asset), cents)| (account_id, Amount::new(asset, cents)))
+                   .collect::<Vec<_>>()
+                   .into_iter()
+                   .map(|(id, to_debit)| {
+                       balances
+                           .get(&id)
+                           .ok_or_else(|| Error::InsufficientBalance(id, to_debit.asset().id))
+                           .map(|balances| {
+                               if let Some(available) = balances
+                                   .iter()
+                                   .find(|asset| asset.asset() == to_debit.asset())
+                                   .map(|amount| amount.cents())
+                               {
+                                   if to_debit.cents() > available {
+                                       Err(Error::InsufficientBalance(id, to_debit.asset().id))
+                                   } else {
+                                       Ok((id, to_debit))
+                                   }
+                               } else {
+                                   Err(Error::InsufficientBalance(id, to_debit.asset().id))
+                               }
+                           })
+                   })
+                   .collect::<Result<Result<Vec<_>, _>, _>>()?
+        */
+        todo!()
+    }
+
+    pub async fn new_transaction<'a>(
+        &self,
+        from: Vec<(AccountId, Amount)>,
+        to: Vec<(AccountId, Amount)>,
+    ) -> Result<Transaction<'a, B, I, S>, Error> {
+        let from = self.normalize_payments_to_spend(from).await?;
+        todo!()
+    }
+}

+ 25 - 0
utxo/src/lib.rs

@@ -0,0 +1,25 @@
+mod account_id;
+mod amount;
+mod asset;
+mod asset_manager;
+mod error;
+mod ledger;
+mod payment;
+#[cfg(any(feature = "sqlite", test))]
+mod sqlite;
+mod status;
+mod storage;
+mod transaction;
+
+pub use self::{
+    account_id::AccountId,
+    amount::Amount,
+    asset::Asset,
+    asset_manager::AssetManager,
+    error::Error,
+    ledger::Ledger,
+    payment::{Payment, PaymentId},
+    status::Status,
+    storage::{Batch, Storage},
+    transaction::Transaction,
+};

+ 23 - 0
utxo/src/payment.rs

@@ -0,0 +1,23 @@
+use crate::{AccountId, Amount};
+use serde::Serialize;
+
+#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize)]
+pub struct PaymentId {
+    pub transaction: AccountId,
+    pub position: usize,
+}
+
+impl ToString for PaymentId {
+    fn to_string(&self) -> String {
+        format!("{}:{}", hex::encode(self.transaction), self.position)
+    }
+}
+
+#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
+pub struct Payment {
+    pub id: PaymentId,
+    pub to: AccountId,
+    pub amount: Amount,
+    #[serde(skip)]
+    pub spent_by: Option<AccountId>,
+}

+ 81 - 0
utxo/src/sqlite/mod.rs

@@ -0,0 +1,81 @@
+use std::marker::PhantomData;
+
+use crate::{
+    storage::{self, Error},
+    AccountId, Payment, PaymentId,
+};
+use sqlx::{Sqlite, Transaction as SqlxTransaction};
+
+pub struct Batch<'a> {
+    inner: SqlxTransaction<'a, Sqlite>,
+    x: PhantomData<&'a ()>,
+}
+
+#[async_trait::async_trait]
+impl<'a> storage::Batch for Batch<'a> {
+    async fn spend_payment(
+        &mut self,
+        payment_id: PaymentId,
+        transaction_id: AccountId,
+    ) -> Result<(), Error> {
+        let result = sqlx::query(
+            r#"
+                UPDATE payments SET spent_by = ?
+                WHERE transaction_id = ? AND position_id = ? AND spent_by IS NULL
+            "#,
+        )
+        .bind(transaction_id.to_string())
+        .bind(payment_id.transaction.to_string())
+        .bind(payment_id.position.to_string())
+        .execute(&mut *self.inner)
+        .await
+        .map_err(|e| Error::Storage(e.to_string()))?;
+        if result.rows_affected() == 1 {
+            Ok(())
+        } else {
+            Err(Error::NoUpdate)
+        }
+    }
+
+    async fn rollback(self) -> Result<(), Error> {
+        self.inner
+            .rollback()
+            .await
+            .map_err(|e| Error::Storage(e.to_string()))
+    }
+
+    async fn commit(self) -> Result<(), Error> {
+        self.inner
+            .commit()
+            .await
+            .map_err(|e| Error::Storage(e.to_string()))
+    }
+
+    async fn store_new_payments(&mut self, payments: &[Payment]) -> Result<(), Error> {
+        for payment in payments.iter() {
+            sqlx::query(
+                r#"
+                INSERT INTO payments(transaction_id, position_id, to, amount, asset, spent_by)
+                VALUES (?, ?, ?, ?, ?, ?)
+            "#,
+            )
+            .bind(payment.id.transaction.to_string())
+            .bind(payment.id.position.to_string())
+            .bind(payment.to.to_string())
+            .bind(payment.amount.cents().to_string())
+            .bind(payment.amount.asset().id)
+            .bind(payment.spent_by.map(|id| id.to_string()))
+            .execute(&mut *self.inner)
+            .await
+            .map_err(|e| Error::Storage(e.to_string()))?;
+        }
+        Ok(())
+    }
+
+    async fn store_transaction(&mut self) -> Result<(), Error> {
+        todo!()
+    }
+}
+
+#[cfg(test)]
+mod test {}

+ 120 - 0
utxo/src/status.rs

@@ -0,0 +1,120 @@
+use strum_macros::Display;
+
+/// Transaction status
+#[derive(Clone, Eq, PartialEq, Debug, Display)]
+pub enum Status {
+    /// Pending status
+    ///
+    /// A transaction has been created. At this status the transaction can be
+    /// Cancelled.
+    /// From Processing it can be moved to Settled or Failed.
+    Pending,
+    /// Processing
+    ///
+    /// The transaction leaves the Pending status and it cannot longer be
+    /// Cancelled by an external event.
+    Processing,
+    /// Cancelled.
+    ///
+    /// The transaction has been Cancelled, the funds that were burned are
+    /// released and can be used again.
+    Cancelled,
+    /// Settled
+    ///
+    /// The transaction is settled, the inputs used to create the transaction
+    /// are forever burned.
+    Settled,
+    /// Failed
+    ///
+    /// The transaction has failed, the inputs used to create the transaction
+    /// are released and can be used again.
+    Failed,
+}
+
+impl Default for Status {
+    fn default() -> Self {
+        Self::Pending
+    }
+}
+
+impl Status {
+    /// Checks if the current status can transition to the new state.
+    pub fn can_transition_to(&self, new_status: &Status) -> bool {
+        if self == new_status {
+            false
+        } else {
+            match self {
+                Self::Pending => true,
+                Self::Processing => {
+                    matches!(new_status, Self::Cancelled | Self::Settled | Self::Failed)
+                }
+                _ => false,
+            }
+        }
+    }
+
+    /// Checks if the transaction status is finalized
+    pub fn is_finalized(&self) -> bool {
+        matches!(self, Self::Cancelled | Self::Settled | Self::Failed)
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use super::*;
+
+    #[test]
+    fn pending() {
+        let status = Status::Pending;
+        assert!(!status.can_transition_to(&Status::Pending));
+        assert!(status.can_transition_to(&Status::Processing));
+        assert!(status.can_transition_to(&Status::Cancelled));
+        assert!(status.can_transition_to(&Status::Settled));
+        assert!(status.can_transition_to(&Status::Failed));
+        assert!(!status.is_finalized());
+    }
+
+    #[test]
+    fn processing() {
+        let status = Status::Processing;
+        assert!(!status.can_transition_to(&Status::Pending));
+        assert!(!status.can_transition_to(&Status::Processing));
+        assert!(status.can_transition_to(&Status::Cancelled));
+        assert!(status.can_transition_to(&Status::Settled));
+        assert!(status.can_transition_to(&Status::Failed));
+        assert!(!status.is_finalized());
+    }
+
+    #[test]
+    fn cancelled() {
+        let status = Status::Cancelled;
+        assert!(!status.can_transition_to(&Status::Pending));
+        assert!(!status.can_transition_to(&Status::Processing));
+        assert!(!status.can_transition_to(&Status::Cancelled));
+        assert!(!status.can_transition_to(&Status::Settled));
+        assert!(!status.can_transition_to(&Status::Failed));
+        assert!(status.is_finalized());
+    }
+
+    #[test]
+    fn settled() {
+        let status = Status::Settled;
+        assert!(!status.can_transition_to(&Status::Pending));
+        assert!(!status.can_transition_to(&Status::Processing));
+        assert!(!status.can_transition_to(&Status::Cancelled));
+        assert!(!status.can_transition_to(&Status::Settled));
+        assert!(!status.can_transition_to(&Status::Failed));
+        assert!(status.is_finalized());
+    }
+
+    #[test]
+    fn failed() {
+        let status = Status::Failed;
+        assert!(!status.can_transition_to(&Status::Pending));
+        assert!(!status.can_transition_to(&Status::Processing));
+        assert!(!status.can_transition_to(&Status::Cancelled));
+        assert!(!status.can_transition_to(&Status::Settled));
+        assert!(!status.can_transition_to(&Status::Failed));
+        assert!(status.is_finalized());
+    }
+}

+ 43 - 0
utxo/src/storage.rs

@@ -0,0 +1,43 @@
+use crate::{amount::AmountCents, asset::AssetId, AccountId, Payment, PaymentId};
+use futures::TryStreamExt;
+
+#[derive(thiserror::Error, Debug)]
+pub enum Error {
+    #[error("Storage error: {0}")]
+    Storage(String),
+
+    #[error("No storage update when expecting")]
+    NoUpdate,
+}
+
+#[async_trait::async_trait]
+pub trait Batch {
+    async fn spend_payment(
+        &mut self,
+        payment_id: PaymentId,
+        transaction_id: AccountId,
+    ) -> Result<(), Error>;
+
+    async fn rollback(self) -> Result<(), Error>;
+
+    async fn commit(self) -> Result<(), Error>;
+
+    async fn store_new_payments(&mut self, outputs: &[Payment]) -> Result<(), Error>;
+
+    async fn store_transaction(&mut self) -> Result<(), Error>;
+}
+
+#[async_trait::async_trait]
+pub trait Storage<B, I>
+where
+    B: Batch,
+    I: TryStreamExt<Ok = (PaymentId, AmountCents), Error = Error> + Unpin,
+{
+    async fn get_payment(&self, id: PaymentId) -> Result<Payment, Error>;
+
+    async fn begin(&self) -> Result<B, Error>;
+
+    async fn get_balance(&self, account: AccountId) -> Result<Vec<(AssetId, AmountCents)>, Error>;
+
+    async fn get_unspend_payments(&self, account: AccountId, asset: AssetId) -> Result<I, Error>;
+}

+ 33 - 0
utxo/src/transaction/error.rs

@@ -0,0 +1,33 @@
+use crate::{amount::AmountCents, storage, Asset, Status};
+
+#[derive(thiserror::Error, Debug)]
+pub enum Error {
+    #[error("Payment {0} is already spent")]
+    SpentPayment(usize),
+
+    #[error(
+        "Payment {0} is not a valid amount. Spending {1} and issuing {2}. Both amounts must match"
+    )]
+    InvalidAmount(Asset, AmountCents, AmountCents),
+
+    #[error("Missing input payment for asset {0}")]
+    MissingSpendingAsset(Asset),
+
+    #[error("Missing output payment for asset {0}")]
+    MissingPaymentAsset(Asset),
+
+    #[error("Transaction updates are not allowed")]
+    TransactionUpdatesNotAllowed,
+
+    #[error("Mismatch between spend and create payment assets")]
+    MismatchSpendingPayingAssets,
+
+    #[error("Status transition from {0} to {1} is not allowed")]
+    StatusTransitionNotAllowed(Status, Status),
+
+    #[error("Storage: {0}")]
+    Storage(#[from] storage::Error),
+
+    #[error("Overflow")]
+    Overflow,
+}

+ 182 - 0
utxo/src/transaction/mod.rs

@@ -0,0 +1,182 @@
+use crate::{
+    amount::AmountCents, storage, AccountId, Asset, Batch, Payment, PaymentId, Status, Storage,
+};
+use futures::{future::join_all, TryStreamExt};
+use sha2::{Digest, Sha256};
+use std::collections::HashMap;
+
+mod error;
+
+pub use error::Error;
+
+/// Transactions
+///
+/// Transactions are the core components of the ledger. The transactions are a
+/// list of unspent payments that are about to be spend, to create a new set of
+/// Payments, that can be spend in the future. This model is heavily inspired in
+/// Bitcoin's UTXO model. The terms in this context are payments, spend and
+/// create instead of unspent transactions, input and output.
+///
+/// This simple architecture allows to track accounts pretty efficiently,
+/// because all that matters are unspent payments owned by a given account.
+/// Every spent payment is stored for historical reasons but it is not relevant
+/// for any calculations regarding available funds.
+///
+/// The transaction has a few rules, for instance the sum of spend Payments
+/// should be the same as create Payments, for each easy. There is no 'fee'
+/// concept, so any mismatch in any direction will error the constructor.
+///
+/// Transactions are immutable after they are finalized, and the payments can
+/// only be re-usable if the transaction failed or was cancelled. Once the
+/// transaction settles the spent payments are forever spent. Any rollback
+/// should be a new transaction, initiated by a higher layer.
+///
+/// The spent payments are unavailable until the transaction is finalized,
+/// either as settled, cancelled or failed. A higher layer should split any
+/// available payment to be spend into a new transaction, and then finalize the
+/// transaction, and reserve only the exact amount to be spent, otherwise
+/// unrelated funds will be held unspendable until the transaction is finalized.
+#[derive(Debug, Clone)]
+pub struct Transaction<'a, B, I, S>
+where
+    B: Batch,
+    I: TryStreamExt<Ok = (PaymentId, AmountCents), Error = storage::Error> + Unpin,
+    S: Storage<B, I>,
+{
+    storage: &'a S,
+    id: Option<AccountId>,
+    spend: Vec<Payment>,
+    create: Vec<Payment>,
+    status: Status,
+    _phantom_batch: std::marker::PhantomData<B>,
+    _phantom_iterator: std::marker::PhantomData<I>,
+}
+
+impl<'a, B, I, S> Transaction<'a, B, I, S>
+where
+    B: Batch,
+    I: TryStreamExt<Ok = (PaymentId, AmountCents), Error = storage::Error> + Unpin,
+    S: Storage<B, I>,
+{
+    pub async fn new(
+        storage: &'a S,
+        input_ids: Vec<PaymentId>,
+    ) -> Result<Transaction<'a, B, I, S>, Error> {
+        let futures = input_ids
+            .into_iter()
+            .map(|id| storage.get_payment(id))
+            .collect::<Vec<_>>();
+        let spend = join_all(futures)
+            .await
+            .into_iter()
+            .collect::<Result<Vec<Payment>, _>>()?;
+        for (i, input) in spend.iter().enumerate() {
+            if input.spent_by.is_some() {
+                return Err(Error::SpentPayment(i));
+            }
+        }
+
+        Ok(Self {
+            storage,
+            id: None,
+            spend,
+            status: Status::default(),
+            create: Vec::new(),
+            _phantom_batch: std::marker::PhantomData,
+            _phantom_iterator: std::marker::PhantomData,
+        })
+    }
+
+    pub fn change_status(&mut self, new_status: Status) -> Result<(), Error> {
+        if self.status.can_transition_to(&new_status) {
+            self.status = new_status;
+            Ok(())
+        } else {
+            Err(Error::StatusTransitionNotAllowed(
+                self.status.clone(),
+                new_status,
+            ))
+        }
+    }
+
+    fn validate(&mut self) -> Result<(), Error> {
+        let mut sha256 = Sha256::new();
+        let mut debit = HashMap::<Asset, AmountCents>::new();
+        let mut credit = HashMap::<Asset, AmountCents>::new();
+
+        for (i, input) in self.spend.iter().enumerate() {
+            if input.spent_by.is_some() {
+                return Err(Error::SpentPayment(i));
+            }
+            if let Some(value) = debit.get_mut(input.amount.asset()) {
+                *value = input
+                    .amount
+                    .cents()
+                    .checked_add(*value)
+                    .ok_or(Error::Overflow)?;
+            } else {
+                debit.insert(*input.amount.asset(), input.amount.cents());
+            }
+            let bytes: Vec<u8> = bincode::serialize(&input).unwrap();
+            sha256.update(&bytes);
+        }
+
+        for (i, output) in self.create.iter().enumerate() {
+            if output.spent_by.is_some() {
+                return Err(Error::SpentPayment(i));
+            }
+            if let Some(value) = credit.get_mut(output.amount.asset()) {
+                *value = output
+                    .amount
+                    .cents()
+                    .checked_add(*value)
+                    .ok_or(Error::Overflow)?;
+            } else {
+                credit.insert(*output.amount.asset(), output.amount.cents());
+            }
+            let bytes: Vec<u8> = bincode::serialize(&output).unwrap();
+            sha256.update(&bytes);
+        }
+
+        for (asset, credit_amount) in credit.into_iter() {
+            if let Some(debit_amount) = debit.remove(&asset) {
+                if debit_amount != credit_amount {
+                    return Err(Error::InvalidAmount(asset, debit_amount, credit_amount));
+                }
+            } else {
+                return Err(Error::MissingSpendingAsset(asset));
+            }
+        }
+
+        if let Some((asset, _)) = debit.into_iter().next() {
+            return Err(Error::MissingPaymentAsset(asset));
+        }
+
+        self.id = Some(AccountId(sha256.finalize().into()));
+        Ok(())
+    }
+
+    pub fn spent(&self) -> &[Payment] {
+        &self.spend
+    }
+
+    pub fn created(&self) -> &[Payment] {
+        &self.create
+    }
+
+    pub async fn persist(mut self) -> Result<Transaction<'a, B, I, S>, Error> {
+        if self.status.is_finalized() {
+            return Err(Error::TransactionUpdatesNotAllowed);
+        }
+        self.validate()?;
+        let mut batch = self.storage.begin().await?;
+        batch.store_new_payments(&self.create).await?;
+        let id = self.id.as_ref().unwrap();
+        for input in self.spend.iter_mut() {
+            batch.spend_payment(input.id, *id).await?;
+            input.spent_by = Some(*id);
+        }
+        batch.commit().await?;
+        Ok(self)
+    }
+}