diff --git a/.env-sample b/.env-sample deleted file mode 100644 index 9a903faa..00000000 --- a/.env-sample +++ /dev/null @@ -1,34 +0,0 @@ -## Nostr ## -# Mostro private key in nsec format -NSEC_PRIVKEY='nsec1...' -# Comma-separated list of relays -RELAYS='wss://nostr.massmux.com,wss://relay.nostr.vision,wss://nostr.zebedee.cloud,wss://nostr.slothy.win,wss://nostr.rewardsbunny.com,wss://nostr.supremestack.xyz,wss://nostr.shawnyeager.net,wss://relay.nostrmoto.xyz,wss://nostr.roundrockbitcoiners.com' - -DATABASE_URL='sqlite://mostro.db' - -## Lightning ## -# Path to tls.cert file -LND_CERT_FILE='/home/user/.polar/networks/1/volumes/lnd/alice/tls.cert' -# Path to macaroon file -LND_MACAROON_FILE='/home/user/.polar/networks/1/volumes/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon' -LND_GRPC_PORT='10001' -LND_GRPC_HOST='localhost' -# lightning invoice expiration time in seconds -INVOICE_EXPIRATION_WINDOW=3600 -# Hold invoice cltv delta (expiration time in blocks) -HOLD_INVOICE_CLTV_DELTA=144 - -## Mostro ## -# Minimum amount for a payment in satoshis -MIN_PAYMENT_AMT=100 - -# Expiration order hours -EXP_HOURS=24 -# Expiration of pending orders -EXP_SECONDS=900 -# Max routing fee that we want to pay to the network, 0.001 = 0.1% -MAX_ROUTING_FEE=0.001 -# Mostro Fee -FEE=0.006 -# Max order amount (sats) -MAX_ORDER_AMOUNT=10000 \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f960c759..2b5b573f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,6 +17,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Install Protoc + uses: arduino/setup-protoc@v3 + - uses: actions/checkout@v3 - name: Run tests diff --git a/Cargo.lock b/Cargo.lock index 7f41b290..bd20c372 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" @@ -151,9 +151,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "arrayvec" @@ -253,17 +253,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.2.0" @@ -272,9 +261,9 @@ checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "axum" -version = "0.5.17" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acee9fd5073ab6b045a275b3e709c163dd36c90685219cb21804a147b58dba43" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", @@ -290,20 +279,19 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", + "rustversion", "serde", "sync_wrapper", - "tokio", "tower", - "tower-http", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.2.9" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e5939e02c56fecd5c017c37df4238c0a839fa76b7f97acdd7efb804fd181cc" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", "bytes", @@ -311,6 +299,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "mime", + "rustversion", "tower-layer", "tower-service", ] @@ -340,12 +329,6 @@ dependencies = [ "bitcoin_hashes 0.14.0", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -393,19 +376,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "bitcoin" -version = "0.30.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1945a5048598e4189e239d3f809b19bdad4845c4b2ba400d304d2dcf26d2c462" -dependencies = [ - "bech32 0.9.1", - "bitcoin-private", - "bitcoin_hashes 0.12.0", - "hex_lit", - "secp256k1 0.27.0", -] - [[package]] name = "bitcoin" version = "0.31.2" @@ -463,12 +433,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56" -[[package]] -name = "bitcoin-private" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" - [[package]] name = "bitcoin-units" version = "0.1.2" @@ -485,15 +449,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" -[[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 = "bitcoin_hashes" version = "0.13.0" @@ -672,9 +627,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" dependencies = [ "clap_builder", "clap_derive", @@ -682,9 +637,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" dependencies = [ "anstream", "anstyle", @@ -694,9 +649,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -710,15 +665,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - [[package]] name = "colorchoice" version = "1.0.0" @@ -961,19 +907,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1008,6 +941,26 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +[[package]] +name = "fedimint-tonic-lnd" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df03ca33b5116de3051c1e233fe341e23b04c4913c7b16042497924559bc2a2e" +dependencies = [ + "hex", + "http-body 0.4.6", + "hyper 0.14.28", + "hyper-rustls 0.24.2", + "prost", + "rustls 0.21.10", + "rustls-pemfile 1.0.4", + "tokio", + "tokio-stream", + "tonic", + "tonic-build", + "tower", +] + [[package]] name = "finl_unicode" version = "1.2.0" @@ -1306,15 +1259,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -1357,15 +1301,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "0.2.12" @@ -1422,12 +1357,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "http-range-header" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" - [[package]] name = "httparse" version = "1.8.0" @@ -1440,15 +1369,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hyper" version = "0.14.28" @@ -1494,21 +1414,17 @@ dependencies = [ ] [[package]] -name = "hyper-openssl" -version = "0.9.2" +name = "hyper-rustls" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ee5d7a8f718585d1c3c61dfde28ef5b0bb14734b4db13f5ada856cdc6c612b" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ + "futures-util", "http 0.2.12", "hyper 0.14.28", - "linked_hash_set", - "once_cell", - "openssl", - "openssl-sys", - "parking_lot 0.12.1", + "rustls 0.21.10", "tokio", - "tokio-openssl", - "tower-layer", + "tokio-rustls 0.24.1", ] [[package]] @@ -1657,15 +1573,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.1" @@ -1734,25 +1641,25 @@ dependencies = [ ] [[package]] -name = "lightning" -version = "0.0.123" +name = "lightning-invoice" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd92d4aa159374be430c7590e169b4a6c0fb79018f5bc4ea1bffde536384db3" +checksum = "90ab9f6ea77e20e3129235e62a2e6bd64ed932363df104e864ee65ccffb54a8f" dependencies = [ - "bitcoin 0.30.2", - "hex-conservative 0.1.1", + "bech32 0.9.1", + "bitcoin 0.32.2", + "lightning-types", ] [[package]] -name = "lightning-invoice" -version = "0.31.0" +name = "lightning-types" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d07d01cf197bf2184b929b7dc94aa70d935aac6df896c256a3a9475b7e9d40" +checksum = "1083b8d9137000edf3bfcb1ff011c0d25e0cdd2feb98cc21d6765e64a494148f" dependencies = [ "bech32 0.9.1", - "bitcoin 0.30.2", - "lightning", - "secp256k1 0.27.0", + "bitcoin 0.32.2", + "hex-conservative 0.2.1", ] [[package]] @@ -1761,15 +1668,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linked_hash_set" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -1844,9 +1742,9 @@ dependencies = [ [[package]] name = "matchit" -version = "0.5.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "md2" @@ -1906,13 +1804,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1924,6 +1823,7 @@ dependencies = [ "clap", "config", "easy-hasher", + "fedimint-tonic-lnd", "lightning-invoice", "lnurl-rs", "mostro-core", @@ -1936,7 +1836,6 @@ dependencies = [ "sqlx", "sqlx-crud", "tokio", - "tonic_openssl_lnd", "tracing", "tracing-subscriber", "uuid", @@ -1944,9 +1843,9 @@ dependencies = [ [[package]] name = "mostro-core" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb872aba1146e74329e70a689f78a5b4722368d5e400c429cc4b380222eca96" +checksum = "389a75ea2e08eeeb37b54156559d0e988cfe23d365310a2253cf428008bb4271" dependencies = [ "anyhow", "chrono", @@ -2123,16 +2022,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.9", - "libc", -] - [[package]] name = "nwc" version = "0.32.0" @@ -2158,9 +2047,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" [[package]] name = "opaque-debug" @@ -2176,9 +2065,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ "bitflags 2.5.0", "cfg-if", @@ -2217,9 +2106,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.102" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", @@ -2378,9 +2267,9 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", "indexmap 2.2.6", @@ -2451,24 +2340,14 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "pretty_env_logger" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" -dependencies = [ - "env_logger", - "log", -] - [[package]] name = "prettyplease" -version = "0.1.25" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 1.0.109", + "syn 2.0.57", ] [[package]] @@ -2482,9 +2361,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.10.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71adf41db68aa0daaefc69bb30bcd68ded9b9abaad5d1fbb6304c4fb390e083e" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", "prost-derive", @@ -2492,55 +2371,47 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.10.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae5a4388762d5815a9fc0dea33c56b021cdc8dde0c55e0c9ca57197254b0cab" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", - "cfg-if", - "cmake", - "heck 0.4.1", - "itertools 0.10.5", - "lazy_static", + "heck 0.5.0", + "itertools", "log", "multimap", + "once_cell", "petgraph", + "prettyplease", "prost", "prost-types", "regex", + "syn 2.0.57", "tempfile", - "which", ] [[package]] name = "prost-derive" -version = "0.10.1" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b670f45da57fb8542ebdbb6105a925fe571b67f9e7ed9f47a06a84e72b4e7cc" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.57", ] [[package]] name = "prost-types" -version = "0.10.1" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d0a014229361011dc8e69c8a1ec6c2e8d0f2af7c91e3ea3f5b2170298461e68" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "bytes", "prost", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" version = "1.0.35" @@ -2658,7 +2529,7 @@ dependencies = [ "http-body 1.0.0", "http-body-util", "hyper 1.2.0", - "hyper-rustls", + "hyper-rustls 0.26.0", "hyper-tls", "hyper-util", "ipnet", @@ -2868,6 +2739,12 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + [[package]] name = "ryu" version = "1.0.17" @@ -2920,16 +2797,6 @@ dependencies = [ "untrusted 0.9.0", ] -[[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" version = "0.28.2" @@ -2954,15 +2821,6 @@ dependencies = [ "serde", ] -[[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-sys" version = "0.9.2" @@ -3018,18 +2876,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -3038,12 +2896,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "indexmap 2.2.6", "itoa", + "memchr", "ryu", "serde", ] @@ -3206,7 +3065,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" dependencies = [ - "itertools 0.12.1", + "itertools", "nom", "unicode_categories", ] @@ -3411,15 +3270,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.58" @@ -3476,21 +3326,20 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -3505,9 +3354,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -3525,26 +3374,24 @@ dependencies = [ ] [[package]] -name = "tokio-openssl" -version = "0.6.4" +name = "tokio-rustls" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ffab79df67727f6acf57f1ff743091873c24c579b1e2ce4d8f53e47ded4d63d" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ - "futures-util", - "openssl", - "openssl-sys", + "rustls 0.20.9", "tokio", + "webpki", ] [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.20.9", + "rustls 0.21.10", "tokio", - "webpki", ] [[package]] @@ -3658,17 +3505,15 @@ dependencies = [ [[package]] name = "tonic" -version = "0.7.2" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be9d60db39854b30b835107500cf0aca0b0d14d6e1c3de124217c23a29c2ddb" +checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.13.1", + "base64 0.21.7", "bytes", - "futures-core", - "futures-util", "h2 0.3.25", "http 0.2.12", "http-body 0.4.6", @@ -3677,62 +3522,28 @@ dependencies = [ "percent-encoding", "pin-project", "prost", - "prost-derive", + "rustls 0.21.10", + "rustls-pemfile 1.0.4", "tokio", + "tokio-rustls 0.24.1", "tokio-stream", - "tokio-util", "tower", "tower-layer", "tower-service", "tracing", - "tracing-futures", ] [[package]] name = "tonic-build" -version = "0.7.2" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9263bf4c9bfaae7317c1c2faf7f18491d2fe476f70c414b73bf5d445b00ffa1" +checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889" dependencies = [ "prettyplease", "proc-macro2", "prost-build", "quote", - "syn 1.0.109", -] - -[[package]] -name = "tonic-openssl" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc64bfb2812f4311055de425e65745229551438db6add3815b489770da3b906d" -dependencies = [ - "async-stream", - "futures", - "openssl", - "tokio", - "tokio-openssl", - "tonic", -] - -[[package]] -name = "tonic_openssl_lnd" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e12d23e1ec801d3713db19b64e1f46e4c7df5f4eb0f75da0208f8a4cd8fa34a" -dependencies = [ - "hex", - "hyper 0.14.28", - "hyper-openssl", - "openssl", - "pretty_env_logger", - "prost", - "tokio", - "tokio-stream", - "tonic", - "tonic-build", - "tonic-openssl", - "tower", + "syn 2.0.57", ] [[package]] @@ -3755,25 +3566,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-http" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" -dependencies = [ - "bitflags 1.3.2", - "bytes", - "futures-core", - "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "http-range-header", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-layer" version = "0.3.2" @@ -3819,16 +3611,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "tracing-log" version = "0.2.0" @@ -4178,18 +3960,6 @@ dependencies = [ "rustls-pki-types", ] -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "winapi" version = "0.3.9" @@ -4206,15 +3976,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 7209c7a8..79a74d7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,13 +13,13 @@ name = "mostrod" path = "src/main.rs" [dependencies] -anyhow = "1.0.81" +anyhow = "1.0.89" chrono = "0.4.35" easy-hasher = "2.2.1" -lightning-invoice = "0.31.0" +lightning-invoice = { version = "0.32.0", features = ["std"] } nostr-sdk = "0.32.0" -serde = { version = "1.0.197" } -serde_json = "1.0.114" +serde = { version = "1.0.210" } +serde_json = "1.0.128" sqlx = { version = "0.6.2", features = [ "runtime-tokio-rustls", "sqlite", @@ -29,8 +29,8 @@ sqlx = { version = "0.6.2", features = [ "offline", ] } sqlx-crud = { version = "0.4.0", features = ["runtime-tokio-rustls"] } -tokio = { version = "1.36.0", features = ["full"] } -tonic_openssl_lnd = "0.2.0" +tokio = { version = "1.40.0", features = ["full"] } +fedimint-tonic-lnd = "0.2.0" uuid = { version = "1.8.0", features = [ "v4", "fast-rng", @@ -38,11 +38,11 @@ uuid = { version = "1.8.0", features = [ "serde", ] } reqwest = { version = "0.12.1", features = ["json"] } -mostro-core = { version = "0.6.7", features = ["sqlx"] } +mostro-core = { version = "0.6.8", features = ["sqlx"] } tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } config = "0.14.0" -clap = { version = "4.5.3", features = ["derive"] } +clap = { version = "4.5.19", features = ["derive"] } lnurl-rs = "0.8.0" -openssl = { version = "0.10", features = ["vendored"] } -once_cell = "1.19.0" +openssl = { version = "0.10.66", features = ["vendored"] } +once_cell = "1.20.2" diff --git a/INSTALL.md b/INSTALL.md index 8cc33042..b5dab523 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -104,8 +104,7 @@ Here some parameters you might want to change: - **lnd_cert_file**: path to tls.cert file - **lnd_macaroon_file**: path to macaroon file -- **lnd_grpc_port**: lnd gRPC port -- **lnd_grpc_host**: lnd gRPC host +- **lnd_grpc_host**: lnd gRPC host and port - **nsec_privkey** : Your mostro private key - **relays** : List of relays you want to connect to diff --git a/README.md b/README.md index fe442bdb..11bdce6a 100644 --- a/README.md +++ b/README.md @@ -82,9 +82,7 @@ _lnd_cert_file:_ LND node TLS certificate file path. _lnd_macaroon_file:_ Macaroon file path, the macaroon file contains permission for doing actions on the lnd node. -_lnd_grpc_host:_ IP address or domain name from the LND node, example: `127.0.0.1`. - -_lnd_grpc_port:_ LND node port to connect, example: `10009`. +_lnd_grpc_host:_ IP address or domain name from the LND node and port, example: `https://127.0.0.1:10009`. ### Database diff --git a/docker/settings.docker.toml b/docker/settings.docker.toml index 71c73417..51858b33 100644 --- a/docker/settings.docker.toml +++ b/docker/settings.docker.toml @@ -3,8 +3,8 @@ lnd_cert_file = '/lnd/alice/tls.cert' # path to macaroon file lnd_macaroon_file = '/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon' -lnd_grpc_port = 10001 -lnd_grpc_host = '127.0.0.1' +# lnd grpc host and port +lnd_grpc_host = 'https://127.0.0.1:10001' # lightning invoices sent by the buyer to Mostro should have at least # this expiration time in seconds invoice_expiration_window = 3600 diff --git a/settings.tpl.toml b/settings.tpl.toml index 1b3591a0..361445b5 100644 --- a/settings.tpl.toml +++ b/settings.tpl.toml @@ -3,8 +3,8 @@ lnd_cert_file = '/home/user/.polar/networks/1/volumes/lnd/alice/tls.cert' # path to macaroon file lnd_macaroon_file = '/home/user/.polar/networks/1/volumes/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon' -lnd_grpc_port = 10001 -lnd_grpc_host = '127.0.0.1' +# lnd grpc host and port +lnd_grpc_host = 'https://127.0.0.1:10001' # lightning invoices sent by the buyer to Mostro should have at least # this expiration time in seconds invoice_expiration_window = 3600 diff --git a/src/app/release.rs b/src/app/release.rs index 527679a2..562d2325 100644 --- a/src/app/release.rs +++ b/src/app/release.rs @@ -9,6 +9,7 @@ use crate::util::{ use crate::NOSTR_CLIENT; use anyhow::{Error, Result}; +use fedimint_tonic_lnd::lnrpc::payment::PaymentStatus; use lnurl::lightning_address::LightningAddress; use mostro_core::message::{Action, Message}; use mostro_core::order::{Order, Status}; @@ -19,7 +20,6 @@ use sqlx_crud::Crud; use std::cmp::Ordering; use std::str::FromStr; use tokio::sync::mpsc::channel; -use tonic_openssl_lnd::lnrpc::payment::PaymentStatus; use tracing::{error, info}; pub async fn check_failure_retries(order: &Order) -> Result { @@ -176,7 +176,7 @@ pub async fn do_payment(mut order: Order) -> Result<()> { // We redeclare vars to use inside this block // Receiving msgs from send_payment() while let Some(msg) = rx.recv().await { - if let Some(status) = PaymentStatus::from_i32(msg.payment.status) { + if let Ok(status) = PaymentStatus::try_from(msg.payment.status) { match status { PaymentStatus::Succeeded => { info!( diff --git a/src/cli/settings.rs b/src/cli/settings.rs index 297b63cf..99c32f91 100644 --- a/src/cli/settings.rs +++ b/src/cli/settings.rs @@ -60,7 +60,6 @@ pub struct Lightning { pub lnd_cert_file: String, pub lnd_macaroon_file: String, pub lnd_grpc_host: String, - pub lnd_grpc_port: u32, pub invoice_expiration_window: u32, pub hold_invoice_cltv_delta: u32, pub hold_invoice_expiration_window: u32, diff --git a/src/lightning/mod.rs b/src/lightning/mod.rs index 3e625a1c..ae3fbd87 100644 --- a/src/lightning/mod.rs +++ b/src/lightning/mod.rs @@ -8,20 +8,21 @@ use crate::util::bytes_to_string; use anyhow::Result; use easy_hasher::easy_hasher::*; -use nostr_sdk::nostr::hashes::hex::FromHex; -use nostr_sdk::nostr::secp256k1::rand::{self, RngCore}; -use tokio::sync::mpsc::Sender; -use tonic_openssl_lnd::invoicesrpc::{ +use fedimint_tonic_lnd::invoicesrpc::{ AddHoldInvoiceRequest, AddHoldInvoiceResp, CancelInvoiceMsg, CancelInvoiceResp, SettleInvoiceMsg, SettleInvoiceResp, }; -use tonic_openssl_lnd::lnrpc::{invoice::InvoiceState, Payment}; -use tonic_openssl_lnd::routerrpc::{SendPaymentRequest, TrackPaymentRequest}; -use tonic_openssl_lnd::{LndClient, LndClientError}; +use fedimint_tonic_lnd::lnrpc::{invoice::InvoiceState, Payment}; +use fedimint_tonic_lnd::routerrpc::{SendPaymentRequest, TrackPaymentRequest}; +use fedimint_tonic_lnd::Client; +use nostr_sdk::nostr::hashes::hex::FromHex; +use nostr_sdk::nostr::secp256k1::rand::{self, RngCore}; +use tokio::sync::mpsc::Sender; use tracing::info; +// use tonic_lnd::lnrpc:: pub struct LndConnector { - client: LndClient, + client: Client, } #[derive(Debug, Clone)] @@ -40,9 +41,8 @@ impl LndConnector { let ln_settings = Settings::get_ln(); // Connecting to LND requires only host, port, cert file, and macaroon file - let client = tonic_openssl_lnd::connect( + let client = fedimint_tonic_lnd::connect( ln_settings.lnd_grpc_host, - ln_settings.lnd_grpc_port, ln_settings.lnd_cert_file, ln_settings.lnd_macaroon_file, ) @@ -57,7 +57,7 @@ impl LndConnector { &mut self, description: &str, amount: i64, - ) -> Result<(AddHoldInvoiceResp, Vec, Vec), LndClientError> { + ) -> Result<(AddHoldInvoiceResp, Vec, Vec), MostroError> { let mut preimage = [0u8; 32]; rand::thread_rng().fill_bytes(&mut preimage); let hash = raw_sha256(preimage.to_vec()); @@ -76,11 +76,11 @@ impl LndConnector { .invoices() .add_hold_invoice(invoice) .await - .map_err(|e| e.to_string()); + .map_err(|e| MostroError::LnNodeError(e.to_string())); match holdinvoice { Ok(holdinvoice) => Ok((holdinvoice.into_inner(), preimage.to_vec(), hash.to_vec())), - Err(e) => Err(LndClientError::cancelled(e)), + Err(e) => Err(e), } } @@ -93,7 +93,7 @@ impl LndConnector { .client .invoices() .subscribe_single_invoice( - tonic_openssl_lnd::invoicesrpc::SubscribeSingleInvoiceRequest { + fedimint_tonic_lnd::invoicesrpc::SubscribeSingleInvoiceRequest { r_hash: r_hash.clone(), }, ) @@ -107,8 +107,7 @@ impl LndConnector { .await .map_err(|e| MostroError::LnNodeError(e.to_string()))? { - if let Some(state) = - tonic_openssl_lnd::lnrpc::invoice::InvoiceState::from_i32(invoice.state) + let state = fedimint_tonic_lnd::lnrpc::invoice::InvoiceState::try_from(invoice.state)?; { let msg = InvoiceMessage { hash: r_hash.clone(), @@ -127,7 +126,7 @@ impl LndConnector { pub async fn settle_hold_invoice( &mut self, preimage: &str, - ) -> Result { + ) -> Result { let preimage = FromHex::from_hex(preimage).expect("Wrong preimage"); let preimage_message = SettleInvoiceMsg { preimage }; @@ -136,18 +135,18 @@ impl LndConnector { .invoices() .settle_invoice(preimage_message) .await - .map_err(|e| e.to_string()); + .map_err(|e| MostroError::LnNodeError(e.to_string())); match settle { Ok(settle) => Ok(settle.into_inner()), - Err(e) => Err(LndClientError::cancelled(e)), + Err(e) => Err(e), } } pub async fn cancel_hold_invoice( &mut self, hash: &str, - ) -> Result { + ) -> Result { let payment_hash = FromHex::from_hex(hash).expect("Wrong payment hash"); let cancel_message = CancelInvoiceMsg { payment_hash }; @@ -156,11 +155,11 @@ impl LndConnector { .invoices() .cancel_invoice(cancel_message) .await - .map_err(|e| e.to_string()); + .map_err(|e| MostroError::LnNodeError(e.to_string())); match cancel { Ok(cancel) => Ok(cancel.into_inner()), - Err(e) => Err(LndClientError::cancelled(e)), + Err(e) => Err(e), } } diff --git a/src/util.rs b/src/util.rs index 390791f0..c9e0cf22 100644 --- a/src/util.rs +++ b/src/util.rs @@ -26,7 +26,8 @@ use std::sync::Arc; use std::thread; use tokio::sync::mpsc::channel; use tokio::sync::Mutex; -use tonic_openssl_lnd::lnrpc::invoice::InvoiceState; +// use fedimint_tonic_lnd::Client; +use fedimint_tonic_lnd::lnrpc::invoice::InvoiceState; use tracing::error; use tracing::info; use uuid::Uuid;