From fd17ca77235d287b31aa94c7f40f62c04189cf3f Mon Sep 17 00:00:00 2001 From: "S. Santos" Date: Tue, 10 Dec 2024 09:57:17 -0300 Subject: [PATCH] Add NIP 100 support --- Cargo.lock | 916 ++++++++++++++++++++++--- clients/apps/rust/Cargo.toml | 2 +- clients/apps/rust/rust-toolchain.toml | 2 +- clients/libs/rust/Cargo.toml | 2 +- clients/libs/rust/rust-toolchain.toml | 2 +- clients/tests/rust/rust-toolchain.toml | 2 +- lib/Cargo.toml | 2 +- lib/rust-toolchain.toml | 2 +- server/Cargo.toml | 1 + server/Settings.toml | 13 + server/rust-toolchain.toml | 2 +- server/src/main.rs | 92 ++- server/src/server_config.rs | 53 +- token-server/rust-toolchain.toml | 2 +- wasm/Cargo.toml | 2 +- wasm/rust-toolchain.toml | 2 +- 16 files changed, 970 insertions(+), 127 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe672c0f..ea887f5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,6 +166,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + [[package]] name = "askama" version = "0.12.1" @@ -240,6 +246,37 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "async-utility" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a349201d80b4aa18d17a34a182bdd7f8ddf845e9e57d2ea130a12e10ef1e3a47" +dependencies = [ + "futures-util", + "gloo-timers", + "tokio", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-wsocket" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d50cb541e6d09e119e717c64c46ed33f49be7fa592fa805d56c11d6a7ff093c" +dependencies = [ + "async-utility", + "futures", + "futures-util", + "js-sys", + "tokio", + "tokio-rustls", + "tokio-socks", + "tokio-tungstenite", + "url", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "atoi" version = "2.0.0" @@ -264,6 +301,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "atomic-destructor" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d919cb60ba95c87ba42777e9e246c4e8d658057299b437b7512531ce0a09a23" +dependencies = [ + "tracing", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -285,6 +331,16 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base58ck" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c8d66485a3a2ea485c1913c4572ce0256067a5377ac8c75c4960e1cda98605f" +dependencies = [ + "bitcoin-internals", + "bitcoin_hashes 0.14.0", +] + [[package]] name = "base64" version = "0.13.1" @@ -324,6 +380,12 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + [[package]] name = "binascii" version = "0.1.4" @@ -341,12 +403,11 @@ dependencies = [ [[package]] name = "bip39" -version = "1.2.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b9e657de8ff1c3488a4ab77cb51d604eab53415ce34f0bc800f2eac9b13c28" +checksum = "33415e24172c1b7d6066f6d999545375ab8e1d95421d6784bdfff9496f292387" dependencies = [ - "bitcoin_hashes 0.11.0", - "rand_core 0.4.2", + "bitcoin_hashes 0.12.0", "serde", "unicode-normalization", ] @@ -358,15 +419,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e99ff7289b20a7385f66a0feda78af2fc119d28fb56aea8886a9cd0a4abdd75" dependencies = [ "base64 0.13.1", - "bech32", + "bech32 0.9.1", "bitcoin-private", "bitcoin_hashes 0.12.0", "bitcoinconsensus", "hex_lit", - "secp256k1", + "secp256k1 0.27.0", "serde", ] +[[package]] +name = "bitcoin" +version = "0.32.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6bc65742dea50536e35ad42492b234c27904a27f0abdcbce605015cb4ea026" +dependencies = [ + "base58ck", + "bech32 0.11.0", + "bitcoin-internals", + "bitcoin-io", + "bitcoin-units", + "bitcoin_hashes 0.14.0", + "hex-conservative", + "hex_lit", + "secp256k1 0.29.1", + "serde", +] + +[[package]] +name = "bitcoin-internals" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bdbe14aa07b06e6cfeffc529a1f099e5fbe249524f8125358604df99a4bed2" +dependencies = [ + "serde", +] + +[[package]] +name = "bitcoin-io" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf" + [[package]] name = "bitcoin-private" version = "0.1.0" @@ -374,10 +468,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" [[package]] -name = "bitcoin_hashes" -version = "0.11.0" +name = "bitcoin-units" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" +checksum = "5285c8bcaa25876d07f37e3d30c303f2609179716e11d688f51e8f1fe70063e2" +dependencies = [ + "bitcoin-internals", + "serde", +] [[package]] name = "bitcoin_hashes" @@ -389,6 +487,17 @@ dependencies = [ "serde", ] +[[package]] +name = "bitcoin_hashes" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16" +dependencies = [ + "bitcoin-io", + "hex-conservative", + "serde", +] + [[package]] name = "bitcoinconsensus" version = "0.20.2-0.5.0" @@ -423,6 +532,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-padding" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -479,6 +597,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.1.15" @@ -494,6 +621,30 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + [[package]] name = "chrono" version = "0.4.38" @@ -516,6 +667,7 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", + "zeroize", ] [[package]] @@ -563,9 +715,9 @@ name = "client-rust" version = "0.1.0" dependencies = [ "anyhow", - "bech32", + "bech32 0.9.1", "bip39", - "bitcoin", + "bitcoin 0.30.1", "chrono", "clap", "config", @@ -686,9 +838,9 @@ checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" [[package]] name = "critical-section" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" [[package]] name = "crossbeam-queue" @@ -722,6 +874,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "rand_core", "typenum", ] @@ -734,6 +887,12 @@ dependencies = [ "cipher", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "der" version = "0.7.8" @@ -808,6 +967,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "dlv-list" version = "0.3.0" @@ -838,7 +1008,7 @@ dependencies = [ "libsecp256k1", "once_cell", "parking_lot", - "rand_core 0.6.4", + "rand_core", "sha2", "typenum", "wasm-bindgen", @@ -859,7 +1029,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bc133f1c8d829d254f013f946653cbeb2b08674b960146361d1e9b67733ad19" dependencies = [ - "bitcoin", + "bitcoin 0.30.1", "bitcoin-private", "byteorder", "libc", @@ -985,6 +1155,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1002,9 +1178,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1163,6 +1339,18 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "goblin" version = "0.8.0" @@ -1185,7 +1373,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.9", "indexmap 1.9.3", "slab", "tokio", @@ -1212,6 +1400,17 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + [[package]] name = "hashlink" version = "0.9.1" @@ -1245,6 +1444,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-conservative" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd" +dependencies = [ + "arrayvec", +] + [[package]] name = "hex_lit" version = "0.1.1" @@ -1289,6 +1497,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -1296,7 +1515,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.9", "pin-project-lite", ] @@ -1329,7 +1548,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.9", "http-body", "httparse", "httpdate", @@ -1378,15 +1597,143 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "idna" -version = "0.2.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de910d521f7cc3135c4de8db1cb910e0b5ed1dc6f57c381cd07e8e661ce10094" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -1422,9 +1769,22 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ + "block-padding", "generic-array", ] +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "ipnet" version = "2.8.0" @@ -1494,9 +1854,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "libm" @@ -1572,6 +1932,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "lock_api" version = "0.4.10" @@ -1603,6 +1969,15 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "lru" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +dependencies = [ + "hashbrown 0.15.2", +] + [[package]] name = "matchers" version = "0.1.0" @@ -1612,18 +1987,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "md-5" version = "0.10.6" @@ -1644,13 +2007,14 @@ checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" name = "mercury-server" version = "0.2.1" dependencies = [ - "bitcoin", + "bitcoin 0.30.1", "chrono", "config", "env_logger", "hex", "log", "mercurylib", + "nostr-sdk", "rand", "reqwest", "rocket", @@ -1685,9 +2049,9 @@ dependencies = [ name = "mercurylib" version = "0.1.0" dependencies = [ - "bech32", + "bech32 0.9.1", "bip39", - "bitcoin", + "bitcoin 0.30.1", "ecies", "hex", "secp256k1-zkp", @@ -1702,9 +2066,9 @@ name = "mercuryrustlib" version = "0.1.0" dependencies = [ "anyhow", - "bech32", + "bech32 0.9.1", "bip39", - "bitcoin", + "bitcoin 0.30.1", "chrono", "clap", "config", @@ -1755,13 +2119,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1773,7 +2137,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http", + "http 0.2.9", "httparse", "log", "memchr", @@ -1802,6 +2166,18 @@ dependencies = [ "tempfile", ] +[[package]] +name = "negentropy" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e664971378a3987224f7a0e10059782035e89899ae403718ee07de85bec42afe" + +[[package]] +name = "negentropy" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a88da9dd148bbcdce323dd6ac47d369b4769d4a3b78c6c52389b9269f77932" + [[package]] name = "nom" version = "7.1.3" @@ -1812,6 +2188,81 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nostr" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aad4b767bbed24ac5eb4465bfb83bc1210522eb99d67cf4e547ec2ec7e47786" +dependencies = [ + "async-trait", + "base64 0.22.1", + "bech32 0.11.0", + "bip39", + "bitcoin 0.32.5", + "cbc", + "chacha20", + "chacha20poly1305", + "getrandom", + "instant", + "negentropy 0.3.1", + "negentropy 0.4.3", + "once_cell", + "scrypt", + "serde", + "serde_json", + "unicode-normalization", + "url", +] + +[[package]] +name = "nostr-database" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23696338d51e45cd44e061823847f4b0d1d362eca80d5033facf9c184149f72f" +dependencies = [ + "async-trait", + "lru", + "nostr", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "nostr-relay-pool" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15fcc6e3f0ca54d0fc779009bc5f2684cea9147be3b6aa68a7d301ea590f95f5" +dependencies = [ + "async-utility", + "async-wsocket", + "atomic-destructor", + "negentropy 0.3.1", + "negentropy 0.4.3", + "nostr", + "nostr-database", + "thiserror", + "tokio", + "tokio-stream", + "tracing", +] + +[[package]] +name = "nostr-sdk" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "491221fc89b1aa189a0de640127127d68b4e7c5c1d44371b04d9a6d10694b5af" +dependencies = [ + "async-utility", + "atomic-destructor", + "nostr", + "nostr-database", + "nostr-relay-pool", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -1835,7 +2286,7 @@ dependencies = [ "num-iter", "num-traits", "rand", - "smallvec 1.11.1", + "smallvec", "zeroize", ] @@ -1897,9 +2348,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" dependencies = [ "critical-section", "portable-atomic", @@ -2002,10 +2453,21 @@ dependencies = [ "cfg-if", "libc", "redox_syscall", - "smallvec 1.11.1", + "smallvec", "windows-targets 0.48.5", ] +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + [[package]] name = "paste" version = "1.0.14" @@ -2018,6 +2480,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", + "hmac", +] + [[package]] name = "pear" version = "0.2.7" @@ -2052,9 +2524,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" @@ -2146,6 +2618,17 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + [[package]] name = "polyval" version = "0.6.1" @@ -2160,9 +2643,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "powerfmt" @@ -2215,7 +2698,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -2225,15 +2708,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.4" @@ -2328,7 +2805,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.9", "http-body", "hyper", "hyper-tls", @@ -2448,7 +2925,7 @@ dependencies = [ "cookie", "either", "futures", - "http", + "http 0.2.9", "hyper", "indexmap 2.0.2", "log", @@ -2458,7 +2935,7 @@ dependencies = [ "pin-project-lite", "ref-cast", "serde", - "smallvec 1.11.1", + "smallvec", "stable-pattern", "state", "time", @@ -2492,7 +2969,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8", - "rand_core 0.6.4", + "rand_core", "signature", "spki", "subtle", @@ -2557,14 +3034,14 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "once_cell", "ring 0.17.3", "rustls-pki-types", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] @@ -2581,9 +3058,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" @@ -2597,9 +3074,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring 0.17.3", "rustls-pki-types", @@ -2618,6 +3095,15 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + [[package]] name = "schannel" version = "0.1.22" @@ -2685,6 +3171,18 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "scrypt" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" +dependencies = [ + "password-hash", + "pbkdf2", + "salsa20", + "sha2", +] + [[package]] name = "sct" version = "0.7.0" @@ -2703,7 +3201,19 @@ checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" dependencies = [ "bitcoin_hashes 0.12.0", "rand", - "secp256k1-sys", + "secp256k1-sys 0.8.1", + "serde", +] + +[[package]] +name = "secp256k1" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +dependencies = [ + "bitcoin_hashes 0.12.0", + "rand", + "secp256k1-sys 0.10.1", "serde", ] @@ -2716,6 +3226,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" +dependencies = [ + "cc", +] + [[package]] name = "secp256k1-zkp" version = "0.9.2" @@ -2723,7 +3242,7 @@ source = "git+https://github.com/ssantos21/rust-secp256k1-zkp.git?branch=blinded dependencies = [ "bitcoin-private", "rand", - "secp256k1", + "secp256k1 0.27.0", "secp256k1-zkp-sys", ] @@ -2733,7 +3252,7 @@ version = "0.8.1" source = "git+https://github.com/ssantos21/rust-secp256k1-zkp.git?branch=blinded-musig-scheme#e03de85e3c74e58249bb3bb43e8642e5e744cfa0" dependencies = [ "cc", - "secp256k1-sys", + "secp256k1-sys 0.8.1", ] [[package]] @@ -2816,6 +3335,7 @@ version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ + "indexmap 2.0.2", "itoa", "ryu", "serde", @@ -2895,7 +3415,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.7", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -2915,18 +3435,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "0.6.14" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "smallvec" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" dependencies = [ "serde", ] @@ -2949,12 +3460,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -3034,12 +3545,12 @@ dependencies = [ "once_cell", "paste", "percent-encoding", - "rustls 0.23.12", + "rustls 0.23.19", "rustls-pemfile", "serde", "serde_json", "sha2", - "smallvec 1.11.1", + "smallvec", "sqlformat", "thiserror", "time", @@ -3125,7 +3636,7 @@ dependencies = [ "serde", "sha1", "sha2", - "smallvec 1.11.1", + "smallvec", "sqlx-core", "stringprep", "thiserror", @@ -3166,7 +3677,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "smallvec 1.11.1", + "smallvec", "sqlx-core", "stringprep", "thiserror", @@ -3211,6 +3722,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "state" version = "0.6.0" @@ -3271,6 +3788,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -3377,6 +3905,31 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "token-server" version = "0.1.1" @@ -3395,28 +3948,27 @@ dependencies = [ [[package]] name = "tokio" -version = "1.33.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.4", + "socket2 0.5.8", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -3433,6 +3985,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +dependencies = [ + "rustls 0.23.19", + "tokio", +] + [[package]] name = "tokio-socks" version = "0.5.1" @@ -3456,6 +4018,22 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" +dependencies = [ + "futures-util", + "log", + "rustls 0.23.19", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tungstenite", + "webpki-roots 0.26.3", +] + [[package]] name = "tokio-util" version = "0.7.9" @@ -3575,7 +4153,7 @@ dependencies = [ "once_cell", "regex", "sharded-slab", - "smallvec 1.11.1", + "smallvec", "thread_local", "tracing", "tracing-core", @@ -3588,6 +4166,26 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "tungstenite" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.2.0", + "httparse", + "log", + "rand", + "rustls 0.23.19", + "rustls-pki-types", + "sha1", + "thiserror", + "utf-8", +] + [[package]] name = "typenum" version = "1.17.0" @@ -3648,11 +4246,11 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-normalization" -version = "0.1.9" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c8070a9942f5e7cfccd93f490fdebd230ee3c3c9f107cb25bad5351ef671cf" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ - "smallvec 0.6.14", + "tinyvec", ] [[package]] @@ -3818,15 +4416,34 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.3.0" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22fe195a4f217c25b25cb5058ced57059824a678474874038dc88d211bf508d3" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.1" @@ -4232,6 +4849,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "yaml-rust" version = "0.4.5" @@ -4250,6 +4879,30 @@ dependencies = [ "is-terminal", ] +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -4270,8 +4923,51 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] diff --git a/clients/apps/rust/Cargo.toml b/clients/apps/rust/Cargo.toml index 1113f7a7..3142a8d6 100644 --- a/clients/apps/rust/Cargo.toml +++ b/clients/apps/rust/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0" bech32 = { version = "0.9.1", default-features = false } bitcoin = { version = "0.30.1", features = ["serde", "base64", "rand-std", "std", "bitcoinconsensus"], default-features = false } -bip39 = "1.2.0" +bip39 = "2.0" clap = { version = "4.2.5", features = ["derive"]} chrono = "0.4.31" config = "0.13.1" diff --git a/clients/apps/rust/rust-toolchain.toml b/clients/apps/rust/rust-toolchain.toml index a56a283d..0193dee3 100644 --- a/clients/apps/rust/rust-toolchain.toml +++ b/clients/apps/rust/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.1" +channel = "1.83.0" diff --git a/clients/libs/rust/Cargo.toml b/clients/libs/rust/Cargo.toml index c502f3e9..43341475 100644 --- a/clients/libs/rust/Cargo.toml +++ b/clients/libs/rust/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0" bech32 = { version = "0.9.1", default-features = false } bitcoin = { version = "0.30.1", features = ["serde", "base64", "rand-std", "std", "bitcoinconsensus"], default-features = false } -bip39 = "1.2.0" +bip39 = "2.0" clap = { version = "4.2.5", features = ["derive"]} chrono = "0.4.31" config = "0.13.1" diff --git a/clients/libs/rust/rust-toolchain.toml b/clients/libs/rust/rust-toolchain.toml index a56a283d..0193dee3 100644 --- a/clients/libs/rust/rust-toolchain.toml +++ b/clients/libs/rust/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.1" +channel = "1.83.0" diff --git a/clients/tests/rust/rust-toolchain.toml b/clients/tests/rust/rust-toolchain.toml index a56a283d..0193dee3 100644 --- a/clients/tests/rust/rust-toolchain.toml +++ b/clients/tests/rust/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.1" +channel = "1.83.0" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 60d39cae..c6c1aa70 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -14,7 +14,7 @@ required-features = ["bindings"] [dependencies] bitcoin = { version = "0.30.1", features = ["serde", "base64", "rand-std", "std"], default-features = false } -bip39 = "1.2.0" +bip39 = "2.0" bech32 = { version = "0.9.1", default-features = false } ecies = {version = "0.2.7", default-features = false, features = ["pure"]} hex = "0.4.3" diff --git a/lib/rust-toolchain.toml b/lib/rust-toolchain.toml index a56a283d..0193dee3 100644 --- a/lib/rust-toolchain.toml +++ b/lib/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.1" +channel = "1.83.0" diff --git a/server/Cargo.toml b/server/Cargo.toml index c8c0a3f2..4e6e6e52 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -24,3 +24,4 @@ chrono = "0.4.31" sha2 = "0.10.8" log = "0.4.22" env_logger = "0.11.5" +nostr-sdk = "0.37.0" diff --git a/server/Settings.toml b/server/Settings.toml index 96d89dca..739b3743 100644 --- a/server/Settings.toml +++ b/server/Settings.toml @@ -8,6 +8,18 @@ db_host = "localhost" db_port = 5432 db_name = "mercury" +[nostr_info] +relay_server = "wss://relay.damus.io/" +relay_interval = 15 +nostr_privkey = "nsec17e0nvplcze4k7q9nazrw0k3aracwhg6vmuareewjp83ta89njw5spjcgzs" +server_url = "http://mercury_server.xyz" +location = "UK" +active = true +onchain_payments = false +ln_payments = true +fee = 0.0001 +unit = "BTC" + [[enclaves]] url = "http://0.0.0.0:18080" allow_deposit = true @@ -29,3 +41,4 @@ url = "http://0.0.0.0:18080" allow_deposit = true # env var: ENCLAVES='[{"url": "http://0.0.0.0:18080", "allow_deposit": true}, {"url": "http://0.0.0.0:18080", "allow_deposit": false}]' +# env var: NOSTR_INFO='{"relay_server": "wss://relay.damus.io/", "relay_interval": 10, "nostr_privkey": "nsec17e0nvplcze4k7q9nazrw0k3aracwhg6vmuareewjp83ta89njw5spjcgzs"}' diff --git a/server/rust-toolchain.toml b/server/rust-toolchain.toml index a56a283d..0193dee3 100644 --- a/server/rust-toolchain.toml +++ b/server/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.1" +channel = "1.83.0" diff --git a/server/src/main.rs b/server/src/main.rs index 90a4277c..84a976af 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -5,9 +5,11 @@ mod database; #[macro_use] extern crate rocket; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; + use endpoints::utils; -use rocket::{serde::json::{Value, json}, Request, Response}; -use rocket::fairing::{Fairing, Info, Kind}; +use rocket::{serde::json::{json, Value}, tokio::{self, time::interval}, Request, Response}; +use rocket::fairing::{Fairing, Info}; use rocket::http::Header; use server::StateChainEntity; @@ -34,12 +36,70 @@ fn not_found(req: &Request) -> Value { json!(message) } +async fn broadcast_nip_100(nostr_info: &server_config::NostrInfo, published_at: u64, timelock: u32) -> Result<(), Box> { + + let relay_server = &nostr_info.relay_server; + let nostr_privkey = &nostr_info.nostr_privkey; + let server_url = &nostr_info.server_url; + let location = &nostr_info.location; + let status = &nostr_info.active; + let onchain_payments = &nostr_info.onchain_payments.to_string(); + let ln_payments = &nostr_info.ln_payments.to_string(); + let fee = &nostr_info.fee.to_string(); + let unit = &nostr_info.unit; + + let sec_key = nostr_sdk::Keys::parse(nostr_privkey)?; + + let content = "Mercury server descritpion"; + let mut tags = vec![ + nostr_sdk::Tag::custom(nostr_sdk::TagKind::Custom("url".into()), [server_url]), + nostr_sdk::Tag::custom(nostr_sdk::TagKind::Custom("published_at".into()), [published_at.to_string()]), + nostr_sdk::Tag::custom(nostr_sdk::TagKind::Custom("timelock".into()), [timelock.to_string()]), + ]; + + if location.is_some() { + tags.push(nostr_sdk::Tag::custom(nostr_sdk::TagKind::Custom("location".into()), [location.as_ref().unwrap()])); + } + + tags.push(nostr_sdk::Tag::custom(nostr_sdk::TagKind::Custom("fee".into()), [fee, unit, ln_payments, onchain_payments])); + + if status.is_some() { + let status_desc = if status.unwrap() { "active" } else { "offline" }; + tags.push(nostr_sdk::Tag::custom(nostr_sdk::TagKind::Custom("status".into()), [status_desc])); + } + + let client = nostr_sdk::Client::new(sec_key.clone()); + + client.add_relay(relay_server).await?; + + client.connect().await; + + let created_at = nostr_sdk::Timestamp::now(); + + let event = nostr_sdk::EventBuilder::new( + nostr_sdk::Kind::Custom(39101), + content.to_string(), + ) + .tags(tags) + .custom_created_at(created_at) + .sign_with_keys(&sec_key)?; + + /* println!("Event as JSON:"); + println!("{}", serde_json::to_string_pretty(&event)?); */ + + + client.send_event(event).await?; + + Ok(()) + +} + #[rocket::main] async fn main() { env_logger::init(); - server_config::ServerConfig::load(); + let config = server_config::ServerConfig::load(); let statechain_entity = StateChainEntity::new().await; @@ -48,6 +108,30 @@ async fn main() { .await .unwrap(); + if config.nostr_info.is_some() { + let nostr_info = config.nostr_info.unwrap(); + + let interval_seconds = nostr_info.relay_interval as u64; + + tokio::spawn(async move { + let mut ticker = interval(Duration::from_secs(interval_seconds)); + + let start = SystemTime::now(); + let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap(); + let published_at = since_the_epoch.as_secs(); + + let timelock = config.lockheight_init; + + loop { + ticker.tick().await; + broadcast_nip_100(&nostr_info, published_at, timelock).await.unwrap(); + } + }); + } else { + println!("No Nostr info found in config file"); + } + + let _ = rocket::build() .mount("/", routes![ endpoints::deposit::post_deposit, @@ -95,7 +179,7 @@ impl Fairing for Cors { fn info(&self) -> Info { Info { name: "Cross-Origin-Resource-Sharing Fairing", - kind: Kind::Response, + kind: rocket::fairing::Kind::Response, } } diff --git a/server/src/server_config.rs b/server/src/server_config.rs index a210d65e..a91bdac4 100644 --- a/server/src/server_config.rs +++ b/server/src/server_config.rs @@ -9,6 +9,30 @@ pub struct Enclave { pub allow_deposit: bool, } +#[derive(Debug, Serialize, Deserialize)] +pub struct NostrInfo { + /// Nostr Relay server + pub relay_server: String, + /// Relay interval + pub relay_interval: u32, + /// Nostr private key + pub nostr_privkey: String, + /// Sever url + pub server_url: String, + /// Optional server location + pub location: Option, + /// Optional server status + pub active: Option, + /// Accepts onchain payments + pub onchain_payments: bool, + /// Accepts LN payments + pub ln_payments: bool, + /// Fee charged by the server + pub fee: f64, + /// Fee currency unit + pub unit: String, +} + /// Config struct storing all StataChain Entity config #[derive(Debug, Serialize, Deserialize)] pub struct ServerConfig { @@ -32,6 +56,9 @@ pub struct ServerConfig { pub db_port: u16, /// Database name pub db_name: String, + /// Nostr info + pub nostr_info: Option, + } impl Default for ServerConfig { @@ -56,11 +83,12 @@ impl Default for ServerConfig { db_host: String::from("db_server"), db_port: 5432, db_name: String::from("mercury"), + nostr_info: None, } } } -impl From for ServerConfig { +/* impl From for ServerConfig { fn from(config: ConfigRs) -> Self { ServerConfig { network: config.get::("network").unwrap_or_else(|_| String::new()), @@ -75,7 +103,7 @@ impl From for ServerConfig { db_name: config.get::("db_name").unwrap_or_else(|_| String::new()), } } -} +} */ impl ServerConfig { pub fn load() -> Self { @@ -111,6 +139,26 @@ impl ServerConfig { settings.get::>(key).unwrap() }; + let get_env_or_config_nostr_info = |key: &str, env_var: &str| -> Option { + + let env_nostr_info = env::var(env_var); + + + if env_nostr_info.is_ok() { + + let res = serde_json::from_str::(&env_nostr_info.unwrap()).unwrap(); + return Some(res) + } + + let res = settings.get::(key); + + if res.is_ok() { + return Some(res.unwrap()) + } else { + return None + } + }; + ServerConfig { network: get_env_or_config("network", "BITCOIN_NETWORK"), lockheight_init: get_env_or_config("lockheight_init", "LOCKHEIGHT_INIT").parse::().unwrap(), @@ -122,6 +170,7 @@ impl ServerConfig { db_host: get_env_or_config("db_host", "DB_HOST"), db_port: get_env_or_config("db_port", "DB_PORT").parse::().unwrap(), db_name: get_env_or_config("db_name", "DB_NAME"), + nostr_info: get_env_or_config_nostr_info("nostr_info", "NOSTR_INFO"), } } diff --git a/token-server/rust-toolchain.toml b/token-server/rust-toolchain.toml index a56a283d..0193dee3 100644 --- a/token-server/rust-toolchain.toml +++ b/token-server/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.1" +channel = "1.83.0" diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 806d0933..e285190b 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -17,7 +17,7 @@ js-sys = "0.3.64" wasm-bindgen-futures = "0.4.37" serde = { version = "1.0", features = ["derive"] } serde-wasm-bindgen = "0.4" -bip39 = "1.2.0" +bip39 = "2.0" rand = "0.8" mercurylib = { path = "../lib" } diff --git a/wasm/rust-toolchain.toml b/wasm/rust-toolchain.toml index a56a283d..0193dee3 100644 --- a/wasm/rust-toolchain.toml +++ b/wasm/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.1" +channel = "1.83.0"