diff --git a/Cargo.lock b/Cargo.lock index 2604d257..4b56c4f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,28 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "1.0.1" @@ -17,6 +39,21 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.71" @@ -130,21 +167,78 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f1e31e207a6b8fb791a38ea3105e6cb541f55e4d029902d3039a4ad07cc4105" +[[package]] +name = "base64-compat" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a8d4d2746f89841e49230dd26917df1876050f95abafafbe34f47cb534b88d7" +dependencies = [ + "byteorder", +] + +[[package]] +name = "bdk" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9b650f45ae7dc8558544448253f3e1ae443433637ccd9f9d14d2089ff913480" +dependencies = [ + "ahash 0.7.6", + "async-trait", + "bdk-macros", + "bip39", + "bitcoin 0.29.2", + "esplora-client", + "futures", + "getrandom", + "js-sys", + "log", + "miniscript", + "rand", + "rusqlite", + "serde", + "serde_json", + "tokio", +] + +[[package]] +name = "bdk-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81c1980e50ae23bb6efa9283ae8679d6ea2c6fa6a99fe62533f65f4a25a1a56c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bech32" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bip39" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" +dependencies = [ + "bitcoin_hashes 0.11.0", + "serde", + "unicode-normalization", +] + [[package]] name = "bitcoin" version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0694ea59225b0c5f3cb405ff3f670e4828358ed26aec49dc352f730f0cb1a8a3" dependencies = [ + "base64 0.13.1", "bech32", "bitcoin_hashes 0.11.0", "secp256k1 0.24.3", + "serde", ] [[package]] @@ -172,6 +266,9 @@ name = "bitcoin_hashes" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" +dependencies = [ + "serde", +] [[package]] name = "bitcoin_hashes" @@ -183,6 +280,48 @@ dependencies = [ "serde", ] +[[package]] +name = "bitcoincore-rpc" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0261b2bb7617e0c91b452a837bbd1291fd34ad6990cb8e3ffc28239cc045b5ca" +dependencies = [ + "bitcoincore-rpc-json", + "jsonrpc 0.12.1", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "bitcoincore-rpc-json" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c231bea28e314879c5aef240f6052e8a72a369e3c9f9b20d9bfbb33ad18029b2" +dependencies = [ + "bitcoin 0.29.2", + "serde", + "serde_json", +] + +[[package]] +name = "bitcoind" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1722c7bec3e2f0b1beef49db78a56bd3f6cb3c694cf16ae11f3dd87199874937" +dependencies = [ + "bitcoin_hashes 0.11.0", + "bitcoincore-rpc", + "filetime", + "flate2", + "log", + "tar", + "tempfile", + "ureq", + "which", + "zip 0.5.13", +] + [[package]] name = "bitcoind" version = "0.30.0" @@ -198,7 +337,7 @@ dependencies = [ "tar", "tempfile", "which", - "zip", + "zip 0.5.13", ] [[package]] @@ -268,6 +407,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "time 0.1.45", + "wasm-bindgen", + "winapi", +] + [[package]] name = "colored" version = "2.0.0" @@ -307,6 +461,12 @@ dependencies = [ "void", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + [[package]] name = "core-rpc" version = "0.17.0" @@ -315,7 +475,7 @@ checksum = "26d77079e1b71c2778d6e1daf191adadcd4ff5ec3ccad8298a79061d865b235b" dependencies = [ "bitcoin-private", "core-rpc-json", - "jsonrpc", + "jsonrpc 0.13.0", "log", "serde", "serde_json", @@ -342,6 +502,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if", +] + [[package]] name = "difflib" version = "0.4.0" @@ -360,6 +529,42 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +[[package]] +name = "electrsd" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a51f3d3808c1ec7e7e0b434fd9e2be0e5ac973441c9929395ab2b14a952333d9" +dependencies = [ + "bitcoin_hashes 0.11.0", + "bitcoind 0.28.0", + "electrum-client", + "log", + "nix", + "ureq", + "zip 0.6.6", +] + +[[package]] +name = "electrum-client" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8e1e1e452aef3ee772d19cc6272ef642f22ce0f4a9fb715ffe98010934e2ae1" +dependencies = [ + "bitcoin 0.29.2", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + [[package]] name = "errno" version = "0.3.1" @@ -381,6 +586,30 @@ dependencies = [ "libc", ] +[[package]] +name = "esplora-client" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "847e59bd6ee1c3f2bdf217118ee3640b97a1b1d8becb55771e67e533b87da66f" +dependencies = [ + "bitcoin 0.29.2", + "log", + "reqwest", + "serde", +] + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + [[package]] name = "fastrand" version = "1.9.0" @@ -439,6 +668,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fragile" version = "2.0.0" @@ -570,6 +808,24 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + +[[package]] +name = "hashlink" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0761a1b9491c4f2e3d66aa0f62d0fba0af9a0e2852e4d48ea506632a4b56e6aa" +dependencies = [ + "hashbrown 0.13.2", +] + [[package]] name = "heck" version = "0.3.3" @@ -673,6 +929,19 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" +dependencies = [ + "http", + "hyper", + "rustls 0.21.1", + "tokio", + "tokio-rustls 0.24.0", +] + [[package]] name = "hyper-timeout" version = "0.4.1" @@ -685,6 +954,39 @@ dependencies = [ "tokio-io-timeout", ] +[[package]] +name = "iana-time-zone" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -692,7 +994,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -715,6 +1017,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "ipnet" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" + [[package]] name = "itertools" version = "0.10.5" @@ -739,6 +1047,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpc" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8423b78fc94d12ef1a4a9d13c348c9a78766dda0cc18817adf0faf77e670c8" +dependencies = [ + "base64-compat", + "serde", + "serde_derive", + "serde_json", +] + [[package]] name = "jsonrpc" version = "0.13.0" @@ -756,12 +1076,49 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "ldk-node" +version = "0.1.0-alpha" +source = "git+https://github.com/lightningdevkit/ldk-node#ab6c0099507562c4c3dd57f9fa6df33a1e4872b3" +dependencies = [ + "bdk", + "bip39", + "bitcoin 0.29.2", + "chrono", + "esplora-client", + "futures", + "libc", + "lightning 0.0.115", + "lightning-background-processor", + "lightning-invoice", + "lightning-net-tokio", + "lightning-persister", + "lightning-rapid-gossip-sync", + "lightning-transaction-sync", + "rand", + "reqwest", + "rusqlite", + "serde_json", + "tokio", +] + [[package]] name = "libc" version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +[[package]] +name = "libsqlite3-sys" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29f835d03d717946d28b1d1ed632eb6f0e24a299388ee623d0c23118d3e8a7fa" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "lightning" version = "0.0.114" @@ -771,6 +1128,87 @@ dependencies = [ "bitcoin 0.29.2", ] +[[package]] +name = "lightning" +version = "0.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e009e1c0c21f66378b491bb40f548682138c63e09db6f3a05af59f8804bb9f4a" +dependencies = [ + "bitcoin 0.29.2", +] + +[[package]] +name = "lightning-background-processor" +version = "0.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721b05b9848a09d5b943915449b5ffb31e24708007763640cf9d79b124a17e19" +dependencies = [ + "bitcoin 0.29.2", + "lightning 0.0.115", + "lightning-rapid-gossip-sync", +] + +[[package]] +name = "lightning-invoice" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4e44b0e2822c8811470137d2339fdfe67a699b3248bb1606d1d02eb6a1e9f0a" +dependencies = [ + "bech32", + "bitcoin 0.29.2", + "bitcoin_hashes 0.11.0", + "lightning 0.0.115", + "num-traits", + "secp256k1 0.24.3", +] + +[[package]] +name = "lightning-net-tokio" +version = "0.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4561ec5d4df2dd410a8b80955791fcfb007ef9210395db6e914b9527397b868c" +dependencies = [ + "bitcoin 0.29.2", + "lightning 0.0.115", + "tokio", +] + +[[package]] +name = "lightning-persister" +version = "0.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c52ed57ec33fb945f464b7e91b5df49f49fec649e1b44909f3ce517e96b0449a" +dependencies = [ + "bitcoin 0.29.2", + "libc", + "lightning 0.0.115", + "winapi", +] + +[[package]] +name = "lightning-rapid-gossip-sync" +version = "0.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd84d74a9b3892db22a60ac11dfc12e76b257b3174db6743e818ecc24834f3be" +dependencies = [ + "bitcoin 0.29.2", + "lightning 0.0.115", +] + +[[package]] +name = "lightning-transaction-sync" +version = "0.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173e4fc554de3fdb88dde6d4fb63fbaa01a44b466a0e4d0a07abdcfcd4869ac8" +dependencies = [ + "bdk-macros", + "bitcoin 0.29.2", + "esplora-client", + "futures", + "lightning 0.0.115", + "reqwest", +] + [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -783,15 +1221,17 @@ version = "0.0.1" dependencies = [ "async-trait", "bitcoin 0.29.2", - "bitcoind", + "bitcoind 0.30.0", "bytes", "configure_me", "configure_me_codegen", "core-rpc", + "electrsd", "flate2", "futures", "hex", - "lightning", + "ldk-node", + "lightning 0.0.114", "log", "minreq", "mockall", @@ -835,12 +1275,31 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "miniscript" +version = "9.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9601439f168c13bdc5bf84349c2e61c815be4a4dcebe8c4ff4af58f4e8a6d20" +dependencies = [ + "bitcoin 0.29.2", + "serde", +] + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -908,6 +1367,20 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +[[package]] +name = "nix" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +dependencies = [ + "autocfg", + "bitflags", + "cfg-if", + "libc", + "memoffset", + "pin-utils", +] + [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -1224,6 +1697,46 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +[[package]] +name = "reqwest" +version = "0.11.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +dependencies = [ + "base64 0.21.1", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls 0.21.1", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-rustls 0.24.0", + "tokio-socks", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + [[package]] name = "ring" version = "0.16.20" @@ -1245,6 +1758,20 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e33e4fb37ba46888052c763e4ec2acfedd8f00f62897b630cadb6298b833675e" +[[package]] +name = "rusqlite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rustix" version = "0.37.19" @@ -1284,6 +1811,18 @@ dependencies = [ "webpki 0.22.0", ] +[[package]] +name = "rustls" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct 0.7.0", +] + [[package]] name = "rustls-pemfile" version = "1.0.2" @@ -1293,6 +1832,16 @@ dependencies = [ "base64 0.21.1", ] +[[package]] +name = "rustls-webpki" +version = "0.100.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.12" @@ -1334,6 +1883,7 @@ dependencies = [ "bitcoin_hashes 0.11.0", "rand", "secp256k1-sys 0.6.1", + "serde", ] [[package]] @@ -1397,6 +1947,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "simple_logger" version = "4.1.0" @@ -1419,6 +1981,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + [[package]] name = "socket2" version = "0.4.9" @@ -1553,6 +2121,21 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.28.1" @@ -1602,6 +2185,28 @@ dependencies = [ "webpki 0.21.4", ] +[[package]] +name = "tokio-rustls" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5" +dependencies = [ + "rustls 0.21.1", + "tokio", +] + +[[package]] +name = "tokio-socks" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.14" @@ -1672,7 +2277,7 @@ dependencies = [ "prost 0.9.0", "prost-derive 0.9.0", "tokio", - "tokio-rustls", + "tokio-rustls 0.22.0", "tokio-stream", "tokio-util 0.6.10", "tower", @@ -1822,12 +2427,27 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + [[package]] name = "unicode-ident" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.10.1" @@ -1840,6 +2460,45 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "ureq" +version = "2.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338b31dd1314f68f3aabf3ed57ab922df95ffcd902476ca7ba3c4ce7b908c46d" +dependencies = [ + "base64 0.13.1", + "flate2", + "log", + "once_cell", + "rustls 0.20.8", + "url", + "webpki 0.22.0", + "webpki-roots", +] + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "void" version = "1.0.2" @@ -1893,6 +2552,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.86" @@ -1994,6 +2665,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -2141,6 +2821,15 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "xattr" version = "0.2.3" @@ -2163,3 +2852,16 @@ dependencies = [ "thiserror", "time 0.1.45", ] + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "bzip2", + "crc32fast", + "crossbeam-utils", + "flate2", +] diff --git a/Cargo.toml b/Cargo.toml index fec1bd60..a510065d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,9 @@ bytes = "1.4.0" [dev-dependencies] bitcoincore-rpc = { package="core-rpc", version = "0.17.0" } bitcoind = { version = "0.30.0", features = [ "22_0" ] } +electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_23_0"] } flate2 = "1.0.25" +ldk-node = { git = "https://github.com/lightningdevkit/ldk-node" } minreq = { version = "2.7.0", features = [ "https" ] } mockall = "0.11.3" tar = "0.4.38" diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 00fd71b3..b591c8ab 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,8 +1,14 @@ use bitcoincore_rpc::{bitcoin::Network, json, RpcApi}; use bitcoind::{BitcoinD, Conf, ConnectParams}; +use electrsd::ElectrsD; use flate2::read::GzDecoder; +use ldk_node::bitcoin::Network as LdkNetwork; +use ldk_node::io::FilesystemStore; +use ldk_node::{Builder as LdkBuilder, NetAddress, Node}; use std::env; use std::process::{Child, Command, Stdio}; +use std::str::FromStr; +use std::sync::Arc; use std::thread; use tar::Archive; use tempfile::{tempdir, Builder, TempDir}; @@ -12,14 +18,34 @@ const LND_VERSION: &str = "0.16.2"; // setup_test_infrastructure spins up all of the infrastructure we need to test LNDK, including a bitcoind node and two // LND nodes. LNDK can then use this test environment to run. -pub async fn setup_test_infrastructure() -> (BitcoinD, LndNode, TempDir) { +pub async fn setup_test_infrastructure() -> ( + BitcoinD, + LndNode, + TempDir, + ElectrsD, + Arc>, + TempDir, +) { let (bitcoind, bitcoind_dir) = setup_bitcoind().await; let lnd_exe_dir = download_lnd().await; let lnd_node = LndNode::new(bitcoind.params.clone(), lnd_exe_dir); lnd_node.setup_client().await; - return (bitcoind, lnd_node, bitcoind_dir); + // We also need to set up electrs, because that's the way ldk-node (currently) communicates with bitcoind to get + // bitcoin blocks and transactions. + let electrsd = setup_electrs().await; + let esplora_url = format!("http://{}", electrsd.esplora_url.as_ref().unwrap()); + let (ldk_node, ldk_dir) = setup_ldk(esplora_url).await; + + return ( + bitcoind, + lnd_node, + bitcoind_dir, + electrsd, + ldk_node, + ldk_dir, + ); } pub async fn setup_bitcoind() -> (BitcoinD, TempDir) { @@ -46,6 +72,48 @@ pub async fn setup_bitcoind() -> (BitcoinD, TempDir) { (bitcoind, bitcoind_dir) } +// setup_electrs sets up the electrs instance required (for the time being) for us to connect to an LDK node. +pub async fn setup_electrs() -> ElectrsD { + let bitcoind_exe = env::var("BITCOIND_EXE") + .ok() + .or_else(|| electrsd::bitcoind::downloaded_exe_path().ok()) + .expect( + "you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature", + ); + let bitcoind_dir = tempdir().unwrap(); + let bitcoind_dir_path = bitcoind_dir.path().clone().to_path_buf(); + let mut bitcoind_conf = electrsd::bitcoind::Conf::default(); + let port = bitcoind::get_available_port().unwrap(); + let zmq_block_port = bitcoind::get_available_port().unwrap(); + let zmq_tx_port = bitcoind::get_available_port().unwrap(); + let port_str = format!("-port={}", port); + let bind_str = format!("-bind=127.0.0.1:{}=onion", port); + let zmq_block_str = format!("-zmqpubrawblock=tcp://127.0.0.1:{}", zmq_block_port); + let zmq_tx_str = format!("-zmqpubrawtx=tcp://127.0.0.1:{}", zmq_tx_port); + bitcoind_conf.tmpdir = Some(bitcoind_dir_path); + bitcoind_conf.p2p = electrsd::bitcoind::P2P::Yes; + bitcoind_conf.args = vec![ + "-server", + "-regtest", + &port_str, + &bind_str, + &zmq_block_str, + &zmq_tx_str, + ]; + let bitcoind = electrsd::bitcoind::BitcoinD::with_conf(bitcoind_exe, &bitcoind_conf).unwrap(); + + let electrs_exe = + electrsd::downloaded_exe_path().expect("electrs version feature must be enabled"); + let mut electrsd_conf = electrsd::Conf::default(); + let electrsd_dir = tempdir().unwrap(); + let electrsd_dir_path = electrsd_dir.path().clone().to_path_buf(); + electrsd_conf.tmpdir = Some(electrsd_dir_path); + electrsd_conf.http_enabled = true; + electrsd_conf.network = "regtest"; + + ElectrsD::with_conf(electrs_exe, &bitcoind, &electrsd_conf).unwrap() +} + #[cfg(all(target_os = "linux", target_arch = "x86_64"))] fn lnd_download_filename() -> String { format!("lnd-linux-amd64-v{}-beta.tar.gz", &LND_VERSION) @@ -195,3 +263,21 @@ impl LndNode { } } } + +// setup_ldk sets up an ldk node. +async fn setup_ldk(esplora_url: String) -> (Arc>, TempDir) { + let builder = LdkBuilder::new(); + builder.set_network(LdkNetwork::Regtest); + builder.set_esplora_server(esplora_url); + + let ldk_dir = tempdir().unwrap(); + let ldk_dir_path = ldk_dir.path().to_str().unwrap().to_string(); + builder.set_storage_dir_path(ldk_dir_path); + + let open_port = bitcoind::get_available_port().unwrap(); + let listening_addr = NetAddress::from_str(&format!("127.0.0.1:{open_port}")).unwrap(); + builder.set_listening_address(listening_addr); + + let node = builder.build(); + (node, ldk_dir) +} diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 9be08667..3865d4b5 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -3,5 +3,6 @@ mod common; #[tokio::test] async fn test_setup() { // Spin up a bitcoind and lnd node, which are required for our tests. - let (_bitcoind, _lnd, _bitcoind_dir) = common::setup_test_infrastructure().await; + let (_bitcoind, _lnd, _bitcoind_dir, _electrsd, _ldk_node, _ldk_dir) = + common::setup_test_infrastructure().await; }