From 8bf93e8dfd92b7dcbe19b0c8a29c336fbb1de23f Mon Sep 17 00:00:00 2001 From: elsirion Date: Sun, 26 Nov 2023 17:35:26 +0100 Subject: [PATCH] chore: upgrade to Fedimint 0.2.0-rc2 --- Cargo.lock | 615 +++++++++++++++++++++++++---------- Cargo.toml | 13 +- src/client.rs | 115 ++++--- src/components/qrcode.rs | 2 +- src/components/receive.rs | 1 - src/components/receive_ln.rs | 1 - src/components/send.rs | 1 - src/components/tx_list.rs | 2 +- src/db.rs | 76 ++--- 9 files changed, 560 insertions(+), 266 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7043513..b5aeebf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # 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" @@ -41,7 +50,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df752953c49ce90719c7bf1fc587bc8227aed04732ea0c0f85e5397d7fdbd1a1" dependencies = [ "include_dir", - "itertools", + "itertools 0.10.5", "proc-macro-error", "proc-macro2", "quote", @@ -59,6 +68,12 @@ dependencies = [ "password-hash", ] +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "async-lock" version = "2.7.0" @@ -103,9 +118,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", @@ -146,6 +161,21 @@ 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.13.1" @@ -210,11 +240,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3" dependencies = [ "bech32", - "bitcoin_hashes", - "secp256k1", + "bitcoin_hashes 0.11.0", + "secp256k1 0.24.3", "serde", ] +[[package]] +name = "bitcoin" +version = "0.30.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1945a5048598e4189e239d3f809b19bdad4845c4b2ba400d304d2dcf26d2c462" +dependencies = [ + "bech32", + "bitcoin-private", + "bitcoin_hashes 0.12.0", + "hex_lit", + "secp256k1 0.27.0", +] + +[[package]] +name = "bitcoin-private" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" + [[package]] name = "bitcoin_hashes" version = "0.11.0" @@ -224,6 +273,15 @@ dependencies = [ "serde", ] +[[package]] +name = "bitcoin_hashes" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d7066118b13d4b20b23645932dfb3a81ce7e29f95726c2036fa33cd7b092501" +dependencies = [ + "bitcoin-private", +] + [[package]] name = "bitcoincore-rpc" version = "0.16.0" @@ -243,7 +301,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c231bea28e314879c5aef240f6052e8a72a369e3c9f9b20d9bfbb33ad18029b2" dependencies = [ - "bitcoin", + "bitcoin 0.29.2", "serde", "serde_json", ] @@ -313,6 +371,12 @@ version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + [[package]] name = "bytemuck" version = "1.13.1" @@ -339,9 +403,12 @@ checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -584,7 +651,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e11244e7fd8b0beee0a3c62137c4bd9f756fe2c492ccf93171f81467b59200" dependencies = [ - "bitcoin", + "bitcoin 0.29.2", "log", "reqwest", "serde", @@ -607,25 +674,27 @@ dependencies = [ [[package]] name = "fedimint-aead" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cd7227f11ad59bca3da4d4db9b769e578a4cb54c21e03f11bfaf49604240d59" dependencies = [ "anyhow", "argon2", "hex", "rand", - "ring", + "ring 0.17.5", ] [[package]] name = "fedimint-bitcoind" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "087dd16ce89d0c6b746533d4897b5b37e6b7f88f23717031d07b043ddb295509" dependencies = [ "anyhow", "async-trait", - "bitcoin", - "bitcoin_hashes", + "bitcoin 0.29.2", + "bitcoin_hashes 0.11.0", "bitcoincore-rpc", "esplora-client", "fedimint-core", @@ -639,29 +708,31 @@ dependencies = [ [[package]] name = "fedimint-build" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882d08a4da0c169be54f4d919bfc373fc329284e351e7e67f9bff15863daf9c2" [[package]] name = "fedimint-client" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0841e99d88499bb75cf96ff89c426170ce2f2017aba920c0237398119fa8ad45" dependencies = [ "anyhow", "aquamarine", "async-stream", "async-trait", - "bitcoin", - "bitcoin_hashes", + "bitcoin 0.29.2", + "bitcoin_hashes 0.11.0", "fedimint-aead", "fedimint-build", "fedimint-core", "fedimint-derive-secret", "fedimint-logging", "futures", - "itertools", + "itertools 0.10.5", "rand", - "ring", + "ring 0.17.5", "secp256k1-zkp", "serde", "serde_json", @@ -674,26 +745,31 @@ dependencies = [ [[package]] name = "fedimint-core" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d1843a1f8b6acc703f4d5c1be225f2d4efca4b6658544a8af25b5a357d47677" dependencies = [ "anyhow", "async-lock", "async-recursion", "async-trait", + "backtrace", "bech32", "bincode", - "bitcoin", - "bitcoin_hashes", + "bitcoin 0.29.2", + "bitcoin 0.30.2", + "bitcoin_hashes 0.11.0", "bitvec", "erased-serde", "fedimint-derive", "fedimint-logging", + "fedimint-tbs", + "fedimint-threshold-crypto", "futures", "getrandom", "gloo-timers", "hex", - "itertools", + "itertools 0.10.5", "js-sys", "jsonrpsee-core", "jsonrpsee-types", @@ -703,6 +779,7 @@ dependencies = [ "lightning-invoice", "macro_rules_attribute", "miniscript", + "parity-scale-codec", "rand", "secp256k1-zkp", "serde", @@ -710,9 +787,7 @@ dependencies = [ "sha3", "strum", "strum_macros", - "tbs", "thiserror", - "threshold_crypto", "tokio", "tokio-rustls 0.23.4", "tracing", @@ -722,10 +797,11 @@ dependencies = [ [[package]] name = "fedimint-derive" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c24826f699aa32cabd3e5aada21deedb91ae20c8d94b16d95fdea787b4c5895d" dependencies = [ - "heck", + "itertools 0.11.0", "proc-macro2", "quote", "syn 1.0.109", @@ -733,15 +809,25 @@ dependencies = [ [[package]] name = "fedimint-derive-secret" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a42324f125badf4930bb04a954e707ebb13f10570e79b5db1675ec19589786" dependencies = [ "anyhow", "fedimint-core", - "hkdf", - "ring", + "fedimint-hkdf", + "fedimint-tbs", + "ring 0.17.5", "secp256k1-zkp", - "tbs", +] + +[[package]] +name = "fedimint-hkdf" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b334a9b5288034f8f50fd8240b8cbd905e4f4e893a30e752e81ae37078055218" +dependencies = [ + "bitcoin_hashes 0.11.0", ] [[package]] @@ -766,6 +852,7 @@ dependencies = [ "leptos_meta", "lightning-invoice", "qrcode-generator", + "rand", "serde", "thiserror", "tokio", @@ -779,72 +866,74 @@ dependencies = [ [[package]] name = "fedimint-ln-client" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cf5cb2a5860093def85c6765a6e566ec67b59c0fe3a1b36bc0611faaa60339a" dependencies = [ "anyhow", "aquamarine", "async-stream", "async-trait", "bincode", - "bitcoin", - "bitcoin_hashes", + "bitcoin 0.29.2", + "bitcoin_hashes 0.11.0", "erased-serde", "fedimint-client", "fedimint-core", "fedimint-ln-common", + "fedimint-threshold-crypto", "futures", - "itertools", - "lightning", + "itertools 0.10.5", "lightning-invoice", "rand", "reqwest", - "secp256k1", + "secp256k1 0.24.3", "secp256k1-zkp", "serde", "serde_json", "strum", "strum_macros", "thiserror", - "threshold_crypto", + "tokio", "tracing", "url", ] [[package]] name = "fedimint-ln-common" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9603f53afb9bb2bf601831b917c3c3a5f8eaac7087d29586d2dbc0d2446a6ea6" dependencies = [ "anyhow", "aquamarine", "async-trait", - "bincode", - "bitcoin", - "bitcoin_hashes", + "bitcoin 0.29.2", + "bitcoin_hashes 0.11.0", "erased-serde", "fedimint-client", "fedimint-core", + "fedimint-threshold-crypto", "futures", - "itertools", - "lightning", + "itertools 0.10.5", "lightning-invoice", "rand", - "secp256k1", + "secp256k1 0.24.3", "serde", + "serde-big-array", "serde_json", "strum", "strum_macros", "thiserror", - "threshold_crypto", "tracing", "url", ] [[package]] name = "fedimint-logging" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11bcdb097ef939b4c700757b91234563909bdafdf5b91046b7e115f774026010" dependencies = [ "anyhow", "tracing-subscriber", @@ -852,8 +941,9 @@ dependencies = [ [[package]] name = "fedimint-mint-client" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbadc42631bd2cdeebbabcda184140a8eecfd0abc7ce6655e597cf1349009f2f" dependencies = [ "anyhow", "aquamarine", @@ -861,65 +951,104 @@ dependencies = [ "async-trait", "base64 0.20.0", "bincode", - "bitcoin_hashes", + "bitcoin_hashes 0.11.0", "erased-serde", "fedimint-client", "fedimint-core", "fedimint-derive-secret", "fedimint-logging", "fedimint-mint-common", + "fedimint-tbs", + "fedimint-threshold-crypto", "futures", - "itertools", + "itertools 0.10.5", "rand", - "secp256k1", + "secp256k1 0.24.3", "secp256k1-zkp", "serde", "serde-big-array", "serde_json", "strum", "strum_macros", - "tbs", "thiserror", - "threshold_crypto", "tokio", "tracing", ] [[package]] name = "fedimint-mint-common" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc8abd967d023c8c1d6cf10eb3711419ed67b7ae1387a4fa293855557d95cc44" dependencies = [ "anyhow", "async-trait", "bincode", - "bitcoin_hashes", + "bitcoin_hashes 0.11.0", "fedimint-core", + "fedimint-tbs", + "fedimint-threshold-crypto", "futures", - "impl-tools", - "itertools", + "itertools 0.10.5", "rand", - "secp256k1", + "secp256k1 0.24.3", "secp256k1-zkp", "serde", "strum", "strum_macros", - "tbs", "thiserror", - "threshold_crypto", "tracing", ] [[package]] -name = "fedimint-wallet-client" +name = "fedimint-tbs" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf6130946f3299f63041a89284de7a1d6a4823c42db168a27f49589d66840e5" +dependencies = [ + "bitcoin_hashes 0.11.0", + "bls12_381", + "ff", + "group", + "rand", + "rand_chacha", + "serde", + "sha3", +] + +[[package]] +name = "fedimint-threshold-crypto" version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd2930eda59c029045497a7ef03799d01eaba6091a03713bef5366bd79aab423" +dependencies = [ + "bls12_381", + "byteorder", + "ff", + "group", + "hex_fmt", + "log", + "pairing", + "rand", + "rand_chacha", + "serde", + "subtle", + "thiserror", + "tiny-keccak", + "zeroize", +] + +[[package]] +name = "fedimint-wallet-client" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9b25b3afb3a87a201f99ebcc937d8a3be0124606f135c8ef92e0204f4dec048" dependencies = [ "anyhow", "aquamarine", "async-stream", "async-trait", - "bitcoin", + "bitcoin 0.29.2", "erased-serde", "fedimint-bitcoind", "fedimint-client", @@ -929,8 +1058,9 @@ dependencies = [ "impl-tools", "miniscript", "rand", - "secp256k1", + "secp256k1 0.24.3", "serde", + "serde_json", "strum", "strum_macros", "thiserror", @@ -942,19 +1072,20 @@ dependencies = [ [[package]] name = "fedimint-wallet-common" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" +version = "0.2.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c14b5a6f45cb531d41c0bc59f294f13790cb4db4ed0f11fcc0a4b856cee76b" dependencies = [ "anyhow", "async-trait", - "bitcoin", + "bitcoin 0.29.2", "erased-serde", "fedimint-core", "futures", "impl-tools", "miniscript", "rand", - "secp256k1", + "secp256k1 0.24.3", "serde", "strum", "strum_macros", @@ -1128,6 +1259,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + [[package]] name = "gloo-net" version = "0.2.6" @@ -1148,6 +1285,27 @@ dependencies = [ "web-sys", ] +[[package]] +name = "gloo-net" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ac9e8288ae2c632fa9f8657ac70bfe38a1530f345282d7ba66a1f70b72b7dc4" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils 0.2.0", + "http", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "gloo-storage" version = "0.3.0" @@ -1283,12 +1441,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" [[package]] -name = "hkdf" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" -dependencies = [ - "bitcoin_hashes", -] +name = "hex_lit" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd" [[package]] name = "html-escape" @@ -1467,6 +1623,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "include_dir" version = "0.7.3" @@ -1533,6 +1700,15 @@ dependencies = [ "either", ] +[[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.6" @@ -1573,13 +1749,13 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.18.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11aa5766d5c430b89cb26a99b88f3245eb91534be8126102cea9e45ee3891b22" +checksum = "b5b005c793122d03217da09af68ba9383363caa950b90d3436106df8cabce935" dependencies = [ "futures-channel", "futures-util", - "gloo-net", + "gloo-net 0.4.0", "http", "jsonrpsee-core", "pin-project", @@ -1589,14 +1765,15 @@ dependencies = [ "tokio-rustls 0.24.1", "tokio-util", "tracing", - "webpki-roots 0.23.1", + "url", + "webpki-roots 0.25.3", ] [[package]] name = "jsonrpsee-core" -version = "0.18.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c6832a55f662b5a6ecc844db24b8b9c387453f923de863062c60ce33d62b81" +checksum = "da2327ba8df2fdbd5e897e2b5ed25ce7f299d345b9736b6828814c3dbd1fd47b" dependencies = [ "anyhow", "async-lock", @@ -1610,16 +1787,15 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tokio-stream", "tracing", "wasm-bindgen-futures", ] [[package]] name = "jsonrpsee-types" -version = "0.18.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5bf6c75ce2a4217421154adfc65a24d2b46e77286e59bba5d9fa6544ccc8f4" +checksum = "5be0be325642e850ed0bdff426674d2e66b2b7117c9be23a7caef68a2902b7d9" dependencies = [ "anyhow", "beef", @@ -1631,9 +1807,9 @@ dependencies = [ [[package]] name = "jsonrpsee-wasm-client" -version = "0.18.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34e6ea7c6d862e60f8baebd946c037b70c6808a4e4e31e792a4029184e3ce13a" +checksum = "7c7cbb3447cf14fd4d2f407c3cc96e6c9634d5440aa1fbed868a31f3c02b27f0" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -1642,14 +1818,15 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.18.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64b2589680ba1ad7863f279cd2d5083c1dc0a7c0ea959d22924553050f8ab9f" +checksum = "bca9cb3933ccae417eb6b08c3448eb1cb46e39834e5b503e395e5e5bd08546c0" dependencies = [ "http", "jsonrpsee-client-transport", "jsonrpsee-core", "jsonrpsee-types", + "url", ] [[package]] @@ -1723,7 +1900,7 @@ dependencies = [ "getrandom", "html-escape", "indexmap 2.0.0", - "itertools", + "itertools 0.10.5", "js-sys", "leptos_reactive", "once_cell", @@ -1778,7 +1955,7 @@ dependencies = [ "cfg-if", "convert_case", "html-escape", - "itertools", + "itertools 0.10.5", "leptos_hot_reload", "prettyplease", "proc-macro-error", @@ -1847,30 +2024,31 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.146" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "lightning" -version = "0.0.113" +version = "0.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087add70f81d2fdc6d4409bc0cef69e11ad366ef1d0068550159bd22b3ac8664" +checksum = "d52cec5fa9382154fe9671e8df93095b800c7d77abc66e2a5ef839d672521c5e" dependencies = [ - "bitcoin", + "bitcoin 0.29.2", ] [[package]] name = "lightning-invoice" -version = "0.21.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9680857590c3529cf8c7d32b04501f215f2bf1e029fdfa22f4112f66c1741e4" +checksum = "3eb24878b0f4ef75f020976c886d9ad1503867802329cc963e0ab4623ea3b25c" dependencies = [ "bech32", - "bitcoin_hashes", + "bitcoin 0.29.2", + "bitcoin_hashes 0.11.0", "lightning", "num-traits", - "secp256k1", + "secp256k1 0.24.3", "serde", ] @@ -1945,7 +2123,7 @@ version = "9.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5b106477a0709e2da253e5559ba4ab20a272f8577f1eefff72f3a905b5d35f5" dependencies = [ - "bitcoin", + "bitcoin 0.29.2", "serde", ] @@ -2041,6 +2219,15 @@ dependencies = [ "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" @@ -2084,6 +2271,32 @@ dependencies = [ "group", ] +[[package]] +name = "parity-scale-codec" +version = "3.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -2241,6 +2454,16 @@ dependencies = [ "syn 2.0.28", ] +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -2317,9 +2540,9 @@ checksum = "4339fc7a1021c9c1621d87f5e3505f2805c8c105420ba2f2a4df86814590c142" [[package]] name = "quote" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -2461,12 +2684,25 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", - "web-sys", + "spin 0.5.2", + "untrusted 0.7.1", "winapi", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys", +] + [[package]] name = "ron" version = "0.7.1" @@ -2502,6 +2738,12 @@ dependencies = [ "ordered-multimap", ] +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -2515,7 +2757,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", - "ring", + "ring 0.16.20", "sct", "webpki", ] @@ -2527,7 +2769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e32ca28af694bc1bbf399c33a516dbdf1c90090b8ab23c2bc24f834aa2247f5f" dependencies = [ "log", - "ring", + "ring 0.16.20", "rustls-webpki", "sct", ] @@ -2547,8 +2789,8 @@ version = "0.100.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -2584,8 +2826,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -2594,12 +2836,22 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ - "bitcoin_hashes", + "bitcoin_hashes 0.11.0", "rand", - "secp256k1-sys", + "secp256k1-sys 0.6.1", "serde", ] +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "bitcoin_hashes 0.12.0", + "secp256k1-sys 0.8.1", +] + [[package]] name = "secp256k1-sys" version = "0.6.1" @@ -2609,13 +2861,22 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + [[package]] name = "secp256k1-zkp" version = "0.7.0" source = "git+https://github.com/dpc/rust-secp256k1-zkp/?branch=sanket-pr#f29b1b8c442d4b8a42547ce36d3987aaedf94224" dependencies = [ "rand", - "secp256k1", + "secp256k1 0.24.3", "secp256k1-zkp-sys", "serde", ] @@ -2626,7 +2887,7 @@ version = "0.7.0" source = "git+https://github.com/dpc/rust-secp256k1-zkp/?branch=sanket-pr#f29b1b8c442d4b8a42547ce36d3987aaedf94224" dependencies = [ "cc", - "secp256k1-sys", + "secp256k1-sys 0.6.1", ] [[package]] @@ -2643,9 +2904,9 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -2672,9 +2933,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -2683,9 +2944,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.97" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf3bf93142acad5821c99197022e170842cdbc1c30482b98750c688c640842a" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2723,7 +2984,7 @@ checksum = "644216cf54c944da2d7fc7a75337a35dc39de19130be3fd88fd58674719a1b5b" dependencies = [ "ciborium", "const_format", - "gloo-net", + "gloo-net 0.2.6", "js-sys", "lazy_static", "once_cell", @@ -2878,6 +3139,12 @@ 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" + [[package]] name = "strum" version = "0.24.1" @@ -2943,21 +3210,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "tbs" -version = "0.1.0" -source = "git+https://github.com/fedimint/fedimint?tag=v0.1.1#1bb1b7bcb38b478b32045d0a864131c144758539" -dependencies = [ - "bitcoin_hashes", - "bls12_381", - "ff", - "group", - "rand", - "rand_chacha", - "serde", - "sha3", -] - [[package]] name = "thiserror" version = "1.0.40" @@ -2988,27 +3240,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "threshold_crypto" -version = "0.4.0" -source = "git+https://github.com/fedimint/threshold_crypto#9b0eeec8f23f41a385174c0d84290cbf8d88a656" -dependencies = [ - "bls12_381", - "byteorder", - "ff", - "group", - "hex_fmt", - "log", - "pairing", - "rand", - "rand_chacha", - "serde", - "subtle", - "thiserror", - "tiny-keccak", - "zeroize", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -3049,6 +3280,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", + "tracing", "windows-sys", ] @@ -3131,6 +3363,23 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.0.0", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -3278,6 +3527,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.4.0" @@ -3466,8 +3721,8 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -3481,12 +3736,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.23.1" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki", -] +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] name = "winapi" @@ -3585,6 +3837,15 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "winnow" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.10.1" diff --git a/Cargo.toml b/Cargo.toml index 763eaea..6f31e84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,18 +12,18 @@ opt-level = 'z' async-trait = "0.1.68" anyhow = "1.0.71" base64 = "0.21.3" -fedimint-client = { git = "https://github.com/fedimint/fedimint", tag = "v0.1.1" } -fedimint-core = { git = "https://github.com/fedimint/fedimint", tag = "v0.1.1" } -fedimint-wallet-client = { git = "https://github.com/fedimint/fedimint", tag = "v0.1.1" } -fedimint-mint-client = { git = "https://github.com/fedimint/fedimint", tag = "v0.1.1" } -fedimint-ln-client = { git = "https://github.com/fedimint/fedimint", tag = "v0.1.1" } +fedimint-client = "0.2.0-rc2" +fedimint-core = "0.2.0-rc2" +fedimint-wallet-client = "0.2.0-rc2" +fedimint-mint-client = "0.2.0-rc2" +fedimint-ln-client = "0.2.0-rc2" futures = "0.3.28" hex = "0.4.3" leptos = { version = "0.4.8", features = ["csr"] } leptos-qr-scanner = { git = "https://github.com/elsirion/leptos-qr-scanner", rev = "75e976e99d9c1ed64921081a23f7da823d2a0b6d" } leptos_icons = { version = "0.0.15", features = ["macros", "BsLightningCharge", "FaCoinsSolid"] } leptos_meta = { version = "0.4.8", features = ["csr"] } -lightning-invoice = { version = "0.21.0", features = [ "serde" ] } +lightning-invoice = { version = "0.26.0", features = [ "serde" ] } qrcode-generator = "4.1.8" console_error_panic_hook = "0.1.7" @@ -40,6 +40,7 @@ wasm-bindgen = "0.2.87" wasm-bindgen-futures = "0.4.37" web-sys = { version = "0.3.65", features = [ "Navigator", "Window", "ServiceWorkerContainer" ] } gloo-storage = "0.3.0" +rand = "0.8.5" [patch.crates-io] secp256k1-zkp = { git = "https://github.com/dpc/rust-secp256k1-zkp/", branch = "sanket-pr" } diff --git a/src/client.rs b/src/client.rs index 8cbdffb..d1bba19 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,26 +1,26 @@ use crate::db::PersistentMemDb; -use anyhow; -use fedimint_client::secret::PlainRootSecretStrategy; -use fedimint_client::sm::OperationId; -use fedimint_client::Client; +use fedimint_client::secret::{PlainRootSecretStrategy, RootSecretStrategy}; +use fedimint_core::core::OperationId; +use fedimint_client::{Client, FederationInfo}; use fedimint_core::api::InviteCode; -use fedimint_core::db::IDatabase; +use fedimint_core::db::{IRawDatabase}; use fedimint_core::task::spawn; use fedimint_core::util::BoxStream; use fedimint_core::Amount; -use fedimint_ln_client::{LightningClientExt, LightningClientGen, LightningMeta}; -use fedimint_mint_client::{MintClientExt, OOBNotes}; -use fedimint_mint_client::{MintClientGen, MintMeta, MintMetaVariants}; -use fedimint_wallet_client::WalletClientGen; +use fedimint_ln_client::{LightningClientInit, LightningClientModule, LightningOperationMeta, LightningOperationMetaPay, LightningOperationMetaVariant}; +use fedimint_wallet_client::WalletClientInit; use futures::StreamExt; use leptos::warn; -use lightning_invoice::{Invoice, InvoiceDescription}; +use lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription}; use serde::{Deserialize, Serialize}; use std::fmt::{Debug, Formatter}; use std::str::FromStr; use std::time::SystemTime; +use fedimint_mint_client::{MintClientInit, MintClientModule, MintOperationMeta, MintOperationMetaVariants, OOBNotes}; use thiserror::Error as ThisError; use tokio::sync::{mpsc, oneshot, watch}; +use fedimint_core::db::IDatabaseTransactionOpsCore; +use rand::thread_rng; use tracing::{debug, info}; #[derive(Debug, Clone)] @@ -157,13 +157,30 @@ async fn run_client(mut rpc: mpsc::Receiver) { }; let mut client_builder = fedimint_client::Client::builder(); - client_builder.with_module(WalletClientGen(None)); - client_builder.with_module(MintClientGen); - client_builder.with_module(LightningClientGen); - client_builder.with_database(wallet_db.clone()); + client_builder.with_database(wallet_db.clone().into()); + + let client_secret = match client_builder + .load_decodable_client_secret::<[u8; 64]>() + .await + { + Ok(secret) => secret, + Err(_) => { + info!("Generating secret and writing to client storage"); + let secret = PlainRootSecretStrategy::random(&mut thread_rng()); + client_builder + .store_encodable_client_secret(secret) + .await + .expect("Failed to store client secret"); + secret + } + }; + + client_builder.with_module(WalletClientInit(None)); + client_builder.with_module(MintClientInit); + client_builder.with_module(LightningClientInit); client_builder.with_primary_module(1); - client_builder.with_invite_code(invite_code); - let client_res = client_builder.build::().await; + client_builder.with_federation_info(FederationInfo::from_invite_code(invite_code).await.unwrap()); + let client_res = client_builder.build(PlainRootSecretStrategy::to_root_secret(&client_secret)).await; match client_res { Ok(client) => { @@ -183,13 +200,30 @@ async fn run_client(mut rpc: mpsc::Receiver) { } else { // TODO: dedup let mut client_builder = fedimint_client::Client::builder(); - client_builder.with_module(WalletClientGen(None)); - client_builder.with_module(MintClientGen); - client_builder.with_module(LightningClientGen); - client_builder.with_database(wallet_db); + client_builder.with_database(wallet_db.into()); + + let client_secret = match client_builder + .load_decodable_client_secret::<[u8; 64]>() + .await + { + Ok(secret) => secret, + Err(_) => { + info!("Generating secret and writing to client storage"); + let secret = PlainRootSecretStrategy::random(&mut thread_rng()); + client_builder + .store_encodable_client_secret(secret) + .await + .expect("Failed to store client secret"); + secret + } + }; + + client_builder.with_module(WalletClientInit(None)); + client_builder.with_module(MintClientInit); + client_builder.with_module(LightningClientInit); client_builder.with_primary_module(1); client_builder - .build::() + .build(PlainRootSecretStrategy::to_root_secret(&client_secret)) .await .unwrap() }; @@ -222,7 +256,7 @@ async fn run_client(mut rpc: mpsc::Receiver) { info!("Receiving notes: \"{notes}\""); let notes: OOBNotes = notes.parse()?; let amount = notes.total_amount(); - client.reissue_external_notes(notes, ()).await?; + client.get_first_module::().reissue_external_notes(notes, ()).await?; Ok(RpcResponse::Receive(amount)) } let _ = response_sender @@ -230,7 +264,7 @@ async fn run_client(mut rpc: mpsc::Receiver) { .map_err(|_| warn!("RPC receiver dropped before response was sent")); } RpcRequest::LnSend(invoice) => { - let invoice = match Invoice::from_str(&invoice) { + let invoice = match Bolt11Invoice::from_str(&invoice) { Ok(invoice) => invoice, Err(e) => { let _ = response_sender @@ -243,7 +277,8 @@ async fn run_client(mut rpc: mpsc::Receiver) { let _ = response_sender .send( client - .pay_bolt11_invoice(invoice) + .get_first_module::() + .pay_bolt11_invoice(invoice, ()) .await .map(|_| RpcResponse::LnSend), ) @@ -253,8 +288,8 @@ async fn run_client(mut rpc: mpsc::Receiver) { amount, description, } => { - let (operation_id, invoice) = match client - .create_bolt11_invoice(amount, description, None) + let (operation_id, invoice) = match client.get_first_module::() + .create_bolt11_invoice(amount, description, None, ()) .await { Ok(res) => res, @@ -267,12 +302,12 @@ async fn run_client(mut rpc: mpsc::Receiver) { }; let (await_paid_sender, await_paid_receiver) = watch::channel(false); - let mut subscription = client + let mut subscription = client.get_first_module::() .subscribe_ln_receive(operation_id) .await .expect("subscribing to a just created operation can't fail") .into_stream(); - spawn(async move { + spawn("waiting for invoice being paid", async move { while let Some(state) = subscription.next().await { if state == fedimint_ln_client::LnReceiveState::Funded { let _ = await_paid_sender.send(true); @@ -294,44 +329,44 @@ async fn run_client(mut rpc: mpsc::Receiver) { .await .into_iter() .map(|(key, op_log)| { - let (amount_msat, description) = match op_log.operation_type() { + let (amount_msat, description) = match op_log.operation_module_kind() { "mint" => { - let meta = op_log.meta::(); + let meta = op_log.meta::(); match meta.variant { - MintMetaVariants::Reissuance { .. } => { + MintOperationMetaVariants::Reissuance { .. } => { (meta.amount.msats as i64, None) } - MintMetaVariants::SpendOOB { .. } => { + MintOperationMetaVariants::SpendOOB { .. } => { (-(meta.amount.msats as i64), None) } } } - "ln" => match op_log.meta::() { - LightningMeta::Receive { invoice, .. } => { + "ln" => match op_log.meta::().variant { + LightningOperationMetaVariant::Receive { invoice, .. } => { let amount = invoice .amount_milli_satoshis() .expect("We don't create 0 amount invoices") as i64; let description = match invoice.description() { - InvoiceDescription::Direct(description) => { + Bolt11InvoiceDescription::Direct(description) => { Some(description.to_string()) } - InvoiceDescription::Hash(_) => None, + Bolt11InvoiceDescription::Hash(_) => None, }; (amount, description) } - LightningMeta::Pay { invoice, .. } => { + LightningOperationMetaVariant::Pay(LightningOperationMetaPay {invoice, ..}) => { // TODO: add fee let amount = -(invoice .amount_milli_satoshis() .expect("Can't pay 0 amount invoices") as i64); let description = match invoice.description() { - InvoiceDescription::Direct(description) => { + Bolt11InvoiceDescription::Direct(description) => { Some(description.to_string()) } - InvoiceDescription::Hash(_) => None, + Bolt11InvoiceDescription::Hash(_) => None, }; (amount, description) @@ -343,7 +378,7 @@ async fn run_client(mut rpc: mpsc::Receiver) { Transaction { timestamp: key.creation_time, operation_id: key.operation_id, - operation_kind: op_log.operation_type().to_owned(), + operation_kind: op_log.operation_module_kind().to_owned(), amount_msat, description, } diff --git a/src/components/qrcode.rs b/src/components/qrcode.rs index 0374f71..77e6453 100644 --- a/src/components/qrcode.rs +++ b/src/components/qrcode.rs @@ -10,7 +10,7 @@ pub fn QrCode( let qr_image_size = qr_image_size.unwrap_or(1024); let qr_data_url = move || { let png_bytes = qrcode_generator::to_png_to_vec_from_str( - &data.get(), + data.get(), qrcode_generator::QrCodeEcc::Medium, qr_image_size, ) diff --git a/src/components/receive.rs b/src/components/receive.rs index 734046d..b517bb3 100644 --- a/src/components/receive.rs +++ b/src/components/receive.rs @@ -10,7 +10,6 @@ use crate::context::ClientContext; pub fn Receive(cx: Scope) -> impl IntoView { let ClientContext { client, .. } = expect_context::(cx); - let client = client.clone(); let submit_action = create_action(cx, move |invoice: &String| { let invoice = invoice.clone(); async move { client.get_value().receive(invoice).await } diff --git a/src/components/receive_ln.rs b/src/components/receive_ln.rs index 27093ab..bc4179c 100644 --- a/src/components/receive_ln.rs +++ b/src/components/receive_ln.rs @@ -12,7 +12,6 @@ use leptos::*; pub fn ReceiveLn(cx: Scope) -> impl IntoView { let ClientContext { client, .. } = expect_context::(cx); - let client = client.clone(); let submit_action = create_action(cx, move |(amount_msat, description): &(u64, String)| { let description = description.clone(); let amount_msat = *amount_msat; diff --git a/src/components/send.rs b/src/components/send.rs index cab7737..ac322d2 100644 --- a/src/components/send.rs +++ b/src/components/send.rs @@ -10,7 +10,6 @@ use crate::context::ClientContext; pub fn Send(cx: Scope) -> impl IntoView { let ClientContext { client, .. } = expect_context::(cx); - let client = client.clone(); let submit_action = create_action(cx, move |invoice: &String| { let invoice = invoice.clone(); async move { client.get_value().ln_send(invoice).await } diff --git a/src/components/tx_list.rs b/src/components/tx_list.rs index bdba707..6911b34 100644 --- a/src/components/tx_list.rs +++ b/src/components/tx_list.rs @@ -11,7 +11,7 @@ use crate::context::ClientContext; #[component] pub fn TxList(cx: Scope, update_signal: F) -> impl IntoView where - F: Fn() -> () + Copy + 'static, + F: Fn() + Copy + 'static, { let ClientContext { client, .. } = expect_context::(cx); diff --git a/src/db.rs b/src/db.rs index 52e23c1..8a3a862 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,7 +1,7 @@ use anyhow::Result; -use fedimint_core::db::mem_impl::MemDatabase; -use fedimint_core::db::IDatabaseTransactionOps; -use fedimint_core::db::{IDatabase, ISingleUseDatabaseTransaction, PrefixStream}; +use fedimint_core::db::mem_impl::{MemDatabase, MemTransaction}; +use fedimint_core::db::{IDatabaseTransactionOps, IDatabaseTransactionOpsCore, IRawDatabase, IRawDatabaseTransaction}; +use fedimint_core::db::{PrefixStream}; use fedimint_core::module::__reexports::serde_json; use fedimint_core::{apply, async_trait_maybe_send}; use std::collections::BTreeMap; @@ -44,51 +44,27 @@ impl PersistentMemDb { pub fn list_dbs() -> Vec { gloo_storage::LocalStorage::get_all::>() .unwrap() - .into_iter() - .map(|(key, _)| key) + .into_keys() .collect() } } #[apply(async_trait_maybe_send!)] -impl IDatabase for PersistentMemDb { - async fn begin_transaction<'a>(&'a self) -> Box> { - Box::new(PersistentMemDbTransaction( +impl IRawDatabase for PersistentMemDb { + type Transaction<'a> = PersistentMemDbTransaction<'a>; + + async fn begin_transaction<'a>(&'a self) -> PersistentMemDbTransaction<'a> { + PersistentMemDbTransaction( self.0.begin_transaction().await, self.1.clone(), - )) + ) } } -pub struct PersistentMemDbTransaction<'a>(Box>, String); - -#[apply(async_trait_maybe_send!)] -impl<'a> ISingleUseDatabaseTransaction<'a> for PersistentMemDbTransaction<'a> { - async fn commit_tx(&mut self) -> Result<()> { - let dump = self - .0 - .raw_find_by_prefix(&[]) - .await - .expect("Dumping DB failed") - .collect::, Vec)>>() - .await; - self.0.commit_tx().await?; - - info!("Writing DB dump of {} kv pairs", dump.len()); - - // FIXME: more compact format - gloo_storage::LocalStorage::set(&self.1, dump).expect("Could not store DB"); - - Ok(()) - } - - fn add_notification_key(&mut self, key: &[u8]) -> Result<()> { - self.0.add_notification_key(key) - } -} +pub struct PersistentMemDbTransaction<'a>(MemTransaction<'a>, String); #[apply(async_trait_maybe_send!)] -impl<'a> IDatabaseTransactionOps<'a> for PersistentMemDbTransaction<'a> { +impl<'a> IDatabaseTransactionOpsCore for PersistentMemDbTransaction<'a> { async fn raw_insert_bytes( &mut self, key: &[u8], @@ -121,12 +97,36 @@ impl<'a> IDatabaseTransactionOps<'a> for PersistentMemDbTransaction<'a> { async fn raw_remove_by_prefix(&mut self, key_prefix: &[u8]) -> Result<()> { self.0.raw_remove_by_prefix(key_prefix).await } +} + +#[apply(async_trait_maybe_send!)] +impl<'a> IDatabaseTransactionOps for PersistentMemDbTransaction<'a> { + async fn set_tx_savepoint(&mut self) -> anyhow::Result<()> { + self.0.set_tx_savepoint().await + } async fn rollback_tx_to_savepoint(&mut self) -> anyhow::Result<()> { self.0.rollback_tx_to_savepoint().await } +} - async fn set_tx_savepoint(&mut self) -> anyhow::Result<()> { - self.0.set_tx_savepoint().await +#[apply(async_trait_maybe_send!)] +impl<'a> IRawDatabaseTransaction for PersistentMemDbTransaction<'a> { + async fn commit_tx(mut self) -> Result<()> { + let dump = self + .0 + .raw_find_by_prefix(&[]) + .await + .expect("Dumping DB failed") + .collect::, Vec)>>() + .await; + self.0.commit_tx().await?; + + info!("Writing DB dump of {} kv pairs", dump.len()); + + // FIXME: more compact format + gloo_storage::LocalStorage::set(&self.1, dump).expect("Could not store DB"); + + Ok(()) } }