diff --git a/Cargo.lock b/Cargo.lock index 6d0aadac5..7fef399bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,44 +1,31 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "addr2line" -version = "0.13.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ "gimli", ] [[package]] name = "adler" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccc9a9dd069569f212bc4330af9f17c4afb5e8ce185e83dbb14f1349dda18b10" - -[[package]] -name = "aho-corasick" -version = "0.7.13" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" -dependencies = [ - "memchr", -] +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "arc-swap" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" - [[package]] name = "arraydeque" version = "0.4.5" @@ -51,12 +38,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - [[package]] name = "ascii" version = "1.0.0" @@ -65,28 +46,38 @@ checksum = "bbf56136a5198c7b01a49e3afcbef6cf84597273d298f54432926024107b0109" [[package]] name = "atty" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ + "hermit-abi", "libc", - "termion", "winapi 0.3.9", ] [[package]] name = "autocfg" -version = "1.0.0" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] + +[[package]] +name = "autocfg" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.50" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" +checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" dependencies = [ "addr2line", + "cc", "cfg-if", "libc", "miniz_oxide", @@ -94,12 +85,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base-x" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b20b618342cf9891c292c4f5ac2cde7287cc5c87e87e9c769d617793607dec1" - [[package]] name = "base64" version = "0.10.1" @@ -111,161 +96,155 @@ dependencies = [ [[package]] name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - -[[package]] -name = "base64" -version = "0.12.3" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bech32" -version = "0.7.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdcf67bb7ba7797a081cd19009948ab533af7c355d5caf1d08c777582d351e9c" +checksum = "cf9ff0bbfd639f15c74af777d81383cf53efb7c93613f6cab67c6c11e05bbf8b" [[package]] name = "bincode" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "byteorder", "serde", ] [[package]] name = "bindgen" -version = "0.53.3" +version = "0.59.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c72a978d268b1d70b0e963217e60fdabd9523a941457a6c42a7315d15c7e89e5" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" dependencies = [ "bitflags", "cexpr", - "cfg-if", "clang-sys", - "clap", - "env_logger", - "lazy_static 1.4.0", + "lazy_static", "lazycell", - "log", "peeking_take_while", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "which", ] [[package]] name = "bitcoin" -version = "0.23.0" -source = "git+https://github.com/blockstream/rust-bitcoin?rev=0.23-electrs#dd131855022c2cdd691a531c1d5c2f5ab707e4d4" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a41df6ad9642c5c15ae312dd3d074de38fd3eb7cc87ad4ce10f90292a83fe4d" dependencies = [ "bech32", - "bitcoin_hashes", - "hex 0.3.2", - "secp256k1", + "bitcoin_hashes 0.10.0", + "secp256k1 0.20.3", "serde", ] [[package]] -name = "bitcoin_hashes" -version = "0.7.6" +name = "bitcoin" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b375d62f341cef9cd9e77793ec8f1db3fc9ce2e4d57e982c8fe697a2c16af3b6" +checksum = "42b2a9a8e3c7544f5ce2b475f2f56580a3102b37e0ee001558ad4faedcf56cf4" dependencies = [ + "bech32", + "bitcoin_hashes 0.10.0", + "secp256k1 0.22.1", "serde", ] [[package]] -name = "bitflags" -version = "1.2.1" +name = "bitcoin_hashes" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "b375d62f341cef9cd9e77793ec8f1db3fc9ce2e4d57e982c8fe697a2c16af3b6" [[package]] -name = "blake2b_simd" -version = "0.5.10" +name = "bitcoin_hashes" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" +checksum = "006cc91e1a1d99819bc5b8214be3555c1f0611b169f527a1fdc54ed1f2b745b0" dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", + "serde", ] +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "0.5.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "118cf036fbb97d0816e3c34b2d7a1e8cfc60f68fcf63d550ddbe9bd5f59c213b" -dependencies = [ - "loom", -] +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "cc" -version = "1.0.41" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" dependencies = [ - "rayon", + "jobserver", ] [[package]] name = "cexpr" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ "nom", ] [[package]] name = "cfg-if" -version = "0.1.10" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.13" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c74d84029116787153e02106bf53e66828452a4b325cc8652b788b5967c0a0b6" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ + "libc", "num-integer", "num-traits", "time 0.1.43", + "winapi 0.3.9", ] [[package]] name = "chunked_transfer" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d29eb15132782371f71da8f947dba48b3717bdb6fa771b9b434d645e40a7193" +checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" [[package]] name = "clang-sys" -version = "0.29.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" +checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21" dependencies = [ "glob", "libc", @@ -274,9 +253,9 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.1" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -288,16 +267,19 @@ dependencies = [ ] [[package]] -name = "constant_time_eq" -version = "0.1.5" +name = "cloudabi" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] [[package]] name = "crossbeam-channel" -version = "0.4.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" +checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" dependencies = [ "cfg-if", "crossbeam-utils", @@ -305,83 +287,64 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.7.3" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ + "cfg-if", "crossbeam-epoch", "crossbeam-utils", - "maybe-uninit", ] [[package]] name = "crossbeam-epoch" -version = "0.8.2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" dependencies = [ - "autocfg", + "autocfg 1.1.0", "cfg-if", "crossbeam-utils", - "lazy_static 1.4.0", - "maybe-uninit", + "lazy_static", "memoffset", "scopeguard", ] -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "maybe-uninit", -] - [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ - "autocfg", "cfg-if", - "lazy_static 1.4.0", + "lazy_static", ] [[package]] name = "dirs" -version = "3.0.1" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", "winapi 0.3.9", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "either" -version = "1.5.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "electrs" @@ -389,9 +352,9 @@ version = "0.4.1" dependencies = [ "arraydeque", "arrayref", - "base64 0.12.3", + "base64 0.13.0", "bincode", - "bitcoin", + "bitcoin 0.28.0", "clap", "crossbeam-channel", "dirs", @@ -399,11 +362,11 @@ dependencies = [ "elements", "error-chain", "glob", - "hex 0.4.2", + "hex", "hyper", "hyperlocal", "itertools", - "lazy_static 1.4.0", + "lazy_static", "libc", "log", "num_cpus", @@ -411,7 +374,7 @@ dependencies = [ "prometheus", "rayon", "rocksdb 0.12.4", - "rocksdb 0.14.0", + "rocksdb 0.17.0", "rust-crypto", "serde", "serde_derive", @@ -421,7 +384,7 @@ dependencies = [ "stderrlog", "sysconf", "tempfile", - "time 0.2.16", + "time 0.3.9", "tiny_http", "tokio", "url", @@ -429,10 +392,10 @@ dependencies = [ [[package]] name = "electrum-client" -version = "0.1.0-beta.6" -source = "git+https://github.com/Blockstream/rust-electrum-client?rev=bd783aa70604fa1a0d8b29a3459326c640001354#bd783aa70604fa1a0d8b29a3459326c640001354" +version = "0.8.0" +source = "git+https://github.com/Blockstream/rust-electrum-client?rev=d3792352992a539afffbe11501d1aff9fd5b919d#d3792352992a539afffbe11501d1aff9fd5b919d" dependencies = [ - "bitcoin", + "bitcoin 0.27.1", "log", "rustls", "serde", @@ -444,32 +407,23 @@ dependencies = [ [[package]] name = "elements" -version = "0.12.1" -source = "git+https://github.com/elementsproject/rust-elements?rev=98e0c4ba1b55cd876d1d8bcff64bcf01c4c370b6#98e0c4ba1b55cd876d1d8bcff64bcf01c4c370b6" -dependencies = [ - "bitcoin", - "bitcoin_hashes", - "serde", -] - -[[package]] -name = "env_logger" -version = "0.7.1" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "61c5ef61d480567b862631efcc22f704eeed7291dbf929ae008a8d5b7f5c4527" dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "bitcoin 0.28.0", + "bitcoin_hashes 0.10.0", + "secp256k1-zkp", + "serde", + "serde_json", + "slip21", ] [[package]] name = "errno" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480f641ccf0faf324e20c1d3e53d81b7484c698b42ea677f6907ae4db195371" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" dependencies = [ "errno-dragonfly", "libc", @@ -478,107 +432,98 @@ dependencies = [ [[package]] name = "errno-dragonfly" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" dependencies = [ - "gcc", + "cc", "libc", ] [[package]] name = "error-chain" -version = "0.12.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" dependencies = [ "backtrace", "version_check", ] [[package]] -name = "fnv" -version = "1.0.7" +name = "fastrand" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] [[package]] -name = "fuchsia-cprng" -version = "0.1.1" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "fuchsia-zircon" -version = "0.3.3" +name = "form_urlencoded" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ - "bitflags", - "fuchsia-zircon-sys", + "matches", + "percent-encoding", ] [[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" +name = "fuchsia-cprng" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "futures-channel" -version = "0.3.5" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.5" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-macro" -version = "0.3.5" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ - "proc-macro-hack", "proc-macro2", "quote", "syn", ] -[[package]] -name = "futures-sink" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" - [[package]] name = "futures-task" -version = "0.3.5" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" -dependencies = [ - "once_cell", -] +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-util" -version = "0.3.5" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-core", "futures-macro", "futures-task", - "pin-project", + "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] @@ -588,35 +533,22 @@ version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -[[package]] -name = "generator" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add72f17bb81521258fcc8a7a3245b1e184e916bfbe34f0ea89558f440df5c68" -dependencies = [ - "cc", - "libc", - "log", - "rustc_version", - "winapi 0.3.9", -] - [[package]] name = "getrandom" -version = "0.1.14" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.22.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "glob" @@ -624,51 +556,26 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -[[package]] -name = "h2" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "log", - "slab", - "tokio", - "tokio-util", -] - [[package]] name = "hermit-abi" -version = "0.1.15" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] [[package]] name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - -[[package]] -name = "hex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "0.2.1" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ "bytes", "fnv", @@ -677,61 +584,58 @@ dependencies = [ [[package]] name = "http-body" -version = "0.3.1" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" dependencies = [ "bytes", "http", + "pin-project-lite", ] [[package]] name = "httparse" -version = "1.3.4" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "6330e8a36bd8c859f3fa6d9382911fbb7147ec39807f63b923933a247240b9ba" [[package]] -name = "humantime" -version = "1.3.0" +name = "httpdate" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.13.6" +version = "0.14.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6e7655b9594024ad0ee439f3b5a7299369dc2a3f459b47c696f9ff676f9aa1f" +checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", - "h2", "http", "http-body", "httparse", + "httpdate", "itoa", - "log", - "pin-project", + "pin-project-lite", "socket2", - "time 0.1.43", "tokio", "tower-service", + "tracing", "want", ] [[package]] name = "hyperlocal" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f192a5a791c0781b93e69f60a652eb6ae9331f77b9efe90c9827a75df5141a9b" +checksum = "0fafdf7b2b2de7c9784f76e02c0935e65a8117ec3b768644379983ab333ac98c" dependencies = [ "futures-util", - "hex 0.4.2", + "hex", "hyper", "pin-project", "tokio", @@ -739,9 +643,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.2.0" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" dependencies = [ "matches", "unicode-bidi", @@ -749,43 +653,43 @@ dependencies = [ ] [[package]] -name = "indexmap" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" -dependencies = [ - "autocfg", -] - -[[package]] -name = "iovec" -version = "0.1.4" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "libc", + "cfg-if", ] [[package]] name = "itertools" -version = "0.9.0" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.6" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + +[[package]] +name = "jobserver" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] [[package]] name = "js-sys" -version = "0.3.41" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4b9172132a62451e56142bff9afc91c8e4a4500aa5b847da36815b63bfda916" +checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" dependencies = [ "wasm-bindgen", ] @@ -800,12 +704,6 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "lazy_static" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" - [[package]] name = "lazy_static" version = "1.4.0" @@ -814,31 +712,31 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lazycell" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.71" +version = "0.2.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" +checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" [[package]] name = "libloading" -version = "0.5.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" dependencies = [ - "cc", + "cfg-if", "winapi 0.3.9", ] [[package]] name = "librocksdb-sys" -version = "6.7.4" +version = "6.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883213ae3d09bfc3d104aefe94b25ebb183b6f4d3a515b23b14817e1f4854005" +checksum = "c309a9d2470844aceb9a4a098cf5286154d20596868b75a6b36357d2bb9ca25d" dependencies = [ "bindgen", "cc", @@ -847,170 +745,154 @@ dependencies = [ ] [[package]] -name = "log" -version = "0.4.8" +name = "lock_api" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ - "cfg-if", + "autocfg 1.1.0", + "scopeguard", ] [[package]] -name = "loom" -version = "0.3.4" +name = "log" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ecc775857611e1df29abba5c41355cdf540e7e9d4acfdf0f355eefee82330b7" +checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" dependencies = [ "cfg-if", - "generator", - "scoped-tls", ] [[package]] name = "matches" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "memchr" -version = "2.3.3" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" -version = "0.5.5" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ - "autocfg", + "autocfg 1.1.0", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.6.22" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" dependencies = [ - "cfg-if", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", "libc", "log", "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", + "ntapi", + "wasi 0.11.0+wasi-snapshot-preview1", + "winapi 0.3.9", ] [[package]] name = "miow" -version = "0.2.1" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", + "winapi 0.3.9", ] [[package]] -name = "net2" -version = "0.2.34" +name = "nom" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" dependencies = [ - "cfg-if", - "libc", - "winapi 0.3.9", + "memchr", + "minimal-lexical", ] [[package]] -name = "nom" -version = "5.1.2" +name = "ntapi" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" dependencies = [ - "memchr", - "version_check", + "winapi 0.3.9", ] [[package]] name = "num-integer" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg", + "autocfg 1.1.0", ] [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", ] [[package]] -name = "numtoa" -version = "0.1.0" +name = "num_threads" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" - -[[package]] +checksum = "aba1801fb138d8e85e11d0fc70baf4fe1cdfffda7c6cd34a854905df588e5ed0" +dependencies = [ + "libc", +] + +[[package]] name = "object" -version = "0.20.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +checksum = "40bec70ba014595f99f7aa110b84331ffe1ee9aece7fe6f387cc7e3ecda4d456" +dependencies = [ + "memchr", +] [[package]] name = "once_cell" -version = "1.4.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" [[package]] name = "page_size" @@ -1022,6 +904,31 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi 0.3.9", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -1036,18 +943,18 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pin-project" -version = "0.4.22" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "0.4.22" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" dependencies = [ "proc-macro2", "quote", @@ -1056,9 +963,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" [[package]] name = "pin-utils" @@ -1066,64 +973,41 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "ppv-lite86" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" - -[[package]] -name = "proc-macro-hack" -version = "0.5.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" - -[[package]] -name = "proc-macro-nested" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" - [[package]] name = "proc-macro2" -version = "1.0.18" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" dependencies = [ "unicode-xid", ] [[package]] name = "prometheus" -version = "0.9.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0ced56dee39a6e960c15c74dc48849d614586db2eaada6497477af7c7811cd" +checksum = "b7f64969ffd5dd8f39bd57a68ac53c163a095ed9d0fb707146da1b27025a3504" dependencies = [ "cfg-if", "fnv", - "lazy_static 1.4.0", + "lazy_static", + "memchr", + "parking_lot", "protobuf", - "spin", "thiserror", ] [[package]] name = "protobuf" -version = "2.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d883f78645c21b7281d21305181aa1f4dd9e9363e7cf2566c93121552cff003e" - -[[package]] -name = "quick-error" -version = "1.2.3" +version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96" [[package]] name = "quote" -version = "1.0.7" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" dependencies = [ "proc-macro2", ] @@ -1153,25 +1037,31 @@ dependencies = [ [[package]] name = "rand" -version = "0.7.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" dependencies = [ - "getrandom", + "autocfg 0.1.8", "libc", "rand_chacha", - "rand_core 0.5.1", + "rand_core 0.4.2", "rand_hc", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi 0.3.9", ] [[package]] name = "rand_chacha" -version = "0.2.2" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "autocfg 0.1.8", + "rand_core 0.3.1", ] [[package]] @@ -1190,30 +1080,74 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" [[package]] -name = "rand_core" -version = "0.5.1" +name = "rand_hc" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" dependencies = [ - "getrandom", + "rand_core 0.3.1", ] [[package]] -name = "rand_hc" -version = "0.2.0" +name = "rand_isaac" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" dependencies = [ - "rand_core 0.5.1", + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi 0.3.9", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.9", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", ] [[package]] name = "rayon" -version = "1.3.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221" dependencies = [ - "autocfg", + "autocfg 1.1.0", "crossbeam-deque", "either", "rayon-core", @@ -1221,14 +1155,13 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", - "lazy_static 1.4.0", "num_cpus", ] @@ -1243,47 +1176,38 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ - "redox_syscall", + "bitflags", ] [[package]] name = "redox_users" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", "redox_syscall", - "rust-argon2", + "thiserror", ] [[package]] name = "regex" -version = "1.3.9" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ - "aho-corasick", - "memchr", "regex-syntax", - "thread_local 1.0.1", ] [[package]] name = "regex-syntax" -version = "0.6.18" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "remove_dir_all" @@ -1296,13 +1220,13 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.12" +version = "0.16.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", - "lazy_static 1.4.0", "libc", + "once_cell", "spin", "untrusted", "web-sys", @@ -1321,26 +1245,14 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.14.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61aa17a99a2413cd71c1106691bf59dad7de0cd5099127f90e9d99c429c40d4a" +checksum = "7a62eca5cacf2c8261128631bed9f045598d40bfbe4b29f5163f0f802f8f44a7" dependencies = [ "libc", "librocksdb-sys", ] -[[package]] -name = "rust-argon2" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" -dependencies = [ - "base64 0.11.0", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils", -] - [[package]] name = "rust-crypto" version = "0.2.36" @@ -1356,9 +1268,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.16" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "rustc-hash" @@ -1372,15 +1284,6 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - [[package]] name = "rustls" version = "0.16.0" @@ -1396,15 +1299,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" - -[[package]] -name = "scoped-tls" -version = "0.1.2" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "scopeguard" @@ -1414,9 +1311,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "sct" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ "ring", "untrusted", @@ -1424,52 +1321,80 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.17.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2932dc07acd2066ff2e3921a4419606b220ba6cd03a9935123856cc534877056" +checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" dependencies = [ - "secp256k1-sys", + "secp256k1-sys 0.4.2", + "serde", +] + +[[package]] +name = "secp256k1" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0" +dependencies = [ + "bitcoin_hashes 0.10.0", + "rand 0.6.5", + "secp256k1-sys 0.5.0", "serde", ] [[package]] name = "secp256k1-sys" -version = "0.1.2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" +dependencies = [ + "cc", +] + +[[package]] +name = "secp256k1-sys" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab2c26f0d3552a0f12e639ae8a64afc2e3db9c52fe32f5fc6c289d38519f220" +checksum = "07b5b9d7322572e1f3aeed208668ce87789b3645dbb73082c5ce99a004103a35" dependencies = [ "cc", ] [[package]] -name = "semver" -version = "0.9.0" +name = "secp256k1-zkp" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +checksum = "c724fda6aae465ed9a39320202bc6164e0adb3cdf9bc16d5af4be7eebaba75e5" dependencies = [ - "semver-parser", + "rand 0.6.5", + "secp256k1 0.22.1", + "secp256k1-zkp-sys", + "serde", ] [[package]] -name = "semver-parser" -version = "0.7.0" +name = "secp256k1-zkp-sys" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "e6f880412a627e79d3ce17355150ea1e0e76570efb7f0f70df51504cbe2582e3" +dependencies = [ + "cc", + "secp256k1-sys 0.5.0", +] [[package]] name = "serde" -version = "1.0.114" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.114" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -1478,32 +1403,26 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.56" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3433e879a558dde8b5e8feb2a04899cf34fdde1fafb894687e52105fc1162ac3" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ "itoa", "ryu", "serde", ] -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" - [[package]] name = "shlex" -version = "0.1.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook" -version = "0.1.16" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" +checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d" dependencies = [ "libc", "signal-hook-registry", @@ -1511,42 +1430,53 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" dependencies = [ - "arc-swap", "libc", ] [[package]] name = "slab" -version = "0.4.2" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" + +[[package]] +name = "slip21" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acff9a1a0f4d902c8184bdde5338861dd95eb1397a12c4df78fb0b6ebeed4cbe" +dependencies = [ + "bitcoin_hashes 0.7.6", +] + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "socket2" -version = "0.3.12" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ - "cfg-if", "libc", - "redox_syscall", "winapi 0.3.9", ] [[package]] name = "socks" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a64cfa9346d26e836a49fcc1ddfcb4d3df666b6787b6864db61d4918e1cbc2" +checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b" dependencies = [ "byteorder", "libc", - "winapi 0.2.8", - "ws2_32-sys", + "winapi 0.3.9", ] [[package]] @@ -1555,77 +1485,19 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "standback" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0437cfb83762844799a60e1e3b489d5ceb6a650fbacb86437badc1b6d87b246" -dependencies = [ - "version_check", -] - [[package]] name = "stderrlog" -version = "0.4.3" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e5ee9b90a5452c570a0b0ac1c99ae9498db7e56e33d74366de7f2a7add7f25" +checksum = "45a53e2eff3e94a019afa6265e8ee04cb05b9d33fe9f5078b14e4e391d155a38" dependencies = [ "atty", "chrono", "log", "termcolor", - "thread_local 0.3.4", -] - -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn", + "thread_local", ] -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - [[package]] name = "strsim" version = "0.8.0" @@ -1634,9 +1506,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.33" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" +checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" dependencies = [ "proc-macro2", "quote", @@ -1657,13 +1529,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.1.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", + "fastrand", "libc", - "rand 0.7.3", "redox_syscall", "remove_dir_all", "winapi 0.3.9", @@ -1671,25 +1543,13 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] -[[package]] -name = "termion" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22cec9d8978d906be5ac94bceb5a010d885c626c4c8855721a4dbd20e3ac905" -dependencies = [ - "libc", - "numtoa", - "redox_syscall", - "redox_termios", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -1701,41 +1561,31 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.20" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.20" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "thread_local" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" -dependencies = [ - "lazy_static 0.2.11", - "unreachable", -] - [[package]] name = "thread_local" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" dependencies = [ - "lazy_static 1.4.0", + "lazy_static", ] [[package]] @@ -1750,86 +1600,70 @@ dependencies = [ [[package]] name = "time" -version = "0.2.16" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a51cadc5b1eec673a685ff7c33192ff7b7603d0b75446fb354939ee615acb15" +checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" dependencies = [ - "cfg-if", + "itoa", "libc", - "standback", - "stdweb", + "num_threads", "time-macros", - "version_check", - "winapi 0.3.9", ] [[package]] name = "time-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ae9b6e9f095bc105e183e3cd493d72579be3181ad4004fceb01adbe9eecab2d" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn", -] +checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" [[package]] name = "tiny_http" -version = "0.7.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15ce4fc3c4cdea1a4399bb1819a539195fb69db4bbe0bde5b7c7f18fed412e02" +checksum = "e0d6ef4e10d23c1efb862eecad25c5054429a71958b4eeef85eb5e7170b477ca" dependencies = [ "ascii", - "chrono", "chunked_transfer", "log", + "time 0.3.9", "url", ] [[package]] name = "tinyvec" -version = "0.3.3" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "0.2.6" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1bef565a52394086ecac0a6fa3b8ace4cb3a138ee1d96bd2b93283b56824e3" +checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" dependencies = [ - "bytes", - "fnv", - "futures-core", - "iovec", - "lazy_static 1.4.0", "libc", - "memchr", "mio", - "mio-uds", + "num_cpus", "pin-project-lite", - "slab", + "socket2", "tokio-macros", + "winapi 0.3.9", ] [[package]] name = "tokio-macros" -version = "0.2.5" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", @@ -1837,69 +1671,63 @@ dependencies = [ ] [[package]] -name = "tokio-util" +name = "tower-service" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + +[[package]] +name = "tracing" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", + "cfg-if", "pin-project-lite", - "tokio", + "tracing-core", ] [[package]] -name = "tower-service" -version = "0.3.0" +name = "tracing-core" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" +dependencies = [ + "lazy_static", +] [[package]] name = "try-lock" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "unicode-bidi" -version = "0.3.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" [[package]] name = "unicode-normalization" -version = "0.1.13" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "unreachable" -version = "1.0.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "untrusted" @@ -1909,10 +1737,11 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.1.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ + "form_urlencoded", "idna", "matches", "percent-encoding", @@ -1926,15 +1755,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" - -[[package]] -name = "void" -version = "1.0.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "want" @@ -1948,15 +1771,21 @@ dependencies = [ [[package]] name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.64" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2" +checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1964,12 +1793,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.64" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df" +checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" dependencies = [ "bumpalo", - "lazy_static 1.4.0", + "lazy_static", "log", "proc-macro2", "quote", @@ -1979,9 +1808,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.64" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8" +checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1989,9 +1818,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.64" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75" +checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" dependencies = [ "proc-macro2", "quote", @@ -2002,15 +1831,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.64" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae" +checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" [[package]] name = "web-sys" -version = "0.3.41" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863539788676619aac1a23e2df3655e96b32b0e05eb72ca34ba045ad573c625d" +checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" dependencies = [ "js-sys", "wasm-bindgen", @@ -2018,9 +1847,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.21.2" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ "ring", "untrusted", @@ -2035,15 +1864,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "which" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" -dependencies = [ - "libc", -] - [[package]] name = "winapi" version = "0.2.8" @@ -2086,13 +1906,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] diff --git a/Cargo.toml b/Cargo.toml index a04d1fb34..7b8ec562c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,51 +20,45 @@ oldcpu = [ "rocksdb-oldcpu" ] [dependencies] arraydeque = "0.4" arrayref = "0.3.6" -base64 = "0.12.3" +base64 = "0.13.0" bincode = "1.3.1" -clap = "2.31" -crossbeam-channel = "0.4" -dirs = "3.0.1" -error-chain = "0.12.2" +bitcoin = { version = "0.28", features = [ "use-serde" ] } +clap = "2.33.3" +crossbeam-channel = "0.5.0" +dirs = "4.0.0" +elements = { version = "0.19.1", features = [ "serde-feature" ], optional = true } +error-chain = "0.12.4" glob = "0.3" hex = "0.4.2" -itertools = "0.9.0" +itertools = "0.10" lazy_static = "1.3.0" -libc = "0.2.68" -log = "0.4" -socket2 = { version = "0.3.12", features = ["reuseport"] } +libc = "0.2.81" +log = "0.4.11" +socket2 = { version = "0.4", features = ["all"] } num_cpus = "1.12.0" page_size = "0.4.2" -prometheus = "0.9" -rayon = "1.3.1" -rocksdb = { version = "0.14.0", optional = true } +prometheus = "0.13" +rayon = "1.5.0" +rocksdb = { version = "0.17.0", optional = true } rocksdb-oldcpu = { version = "0.12.4", optional = true, package = "rocksdb" } rust-crypto = "0.2" -serde = "1.0.114" -serde_derive = "1.0.114" -serde_json = "1.0.56" -signal-hook = "0.1" -stderrlog = "0.4.3" +serde = "1.0.118" +serde_derive = "1.0.118" +serde_json = "1.0.60" +signal-hook = "0.3" +stderrlog = "0.5.0" sysconf = ">=0.3.4" -time = "0.2.16" -tiny_http = "0.7.0" -url = "2.1.1" -hyper = "0.13.6" -hyperlocal = "0.7" -# close to same tokio version as dependent by hyper v0.13.6 and hyperlocal 0.7 -- things can go awry if they mismatch -tokio = { version = "=0.2.6", features = ["sync", "macros"] } +time = { version = "0.3", features = ["formatting"] } +tiny_http = "0.11" +url = "2.2.0" +hyper = "0.14" +hyperlocal = "0.8" +# close to same tokio version as dependent by hyper v0.14 and hyperlocal 0.8 -- things can go awry if they mismatch +tokio = { version = "1", features = ["sync", "macros"] } # optional dependencies for electrum-discovery -electrum-client = { version = "0.1.0-beta.6", optional = true } +electrum-client = { version = "0.8", optional = true } -[dependencies.bitcoin] -version = "0.23.0" -features = ["use-serde"] - -[dependencies.elements] -optional = true -version = "0.12.1" -features = ["serde-feature"] [dev-dependencies] tempfile = "3.0" @@ -74,14 +68,6 @@ lto = true panic = 'abort' codegen-units = 1 -[patch.crates-io.bitcoin] -git = "https://github.com/blockstream/rust-bitcoin" -rev = "0.23-electrs" - -[patch.crates-io.elements] -git = "https://github.com/elementsproject/rust-elements" -rev = "98e0c4ba1b55cd876d1d8bcff64bcf01c4c370b6" - [patch.crates-io.electrum-client] git = "https://github.com/Blockstream/rust-electrum-client" -rev = "bd783aa70604fa1a0d8b29a3459326c640001354" # add-peer +rev = "d3792352992a539afffbe11501d1aff9fd5b919d" # add-peer branch diff --git a/src/bin/electrs.rs b/src/bin/electrs.rs index 14f563adb..5511593c8 100644 --- a/src/bin/electrs.rs +++ b/src/bin/electrs.rs @@ -1,4 +1,3 @@ -extern crate bitcoin; extern crate error_chain; #[macro_use] extern crate log; diff --git a/src/chain.rs b/src/chain.rs index 5e5e3fd8a..a7feb3ffd 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -1,66 +1,75 @@ #[cfg(not(feature = "liquid"))] // use regular Bitcoin data structures -pub use bitcoin::{util::address, Block, BlockHeader, OutPoint, Transaction, TxIn, TxOut}; +pub use bitcoin::{ + blockdata::script, consensus::deserialize, util::address, Block, BlockHash, BlockHeader, + OutPoint, Script, Transaction, TxIn, TxOut, Txid, +}; #[cfg(feature = "liquid")] pub use { crate::elements::asset, elements::{ - address, confidential, Address, AssetId, Block, BlockHeader, OutPoint, Transaction, TxIn, - TxOut, + address, confidential, encode::deserialize, script, Address, AssetId, Block, BlockHash, + BlockHeader, OutPoint, Script, Transaction, TxIn, TxOut, Txid, }, }; use bitcoin::blockdata::constants::genesis_block; -use bitcoin::network::constants::Network as BNetwork; -use bitcoin::util::hash::BitcoinHash; -use bitcoin::BlockHash; - -use std::collections::HashMap; -use std::sync::{Arc, RwLock}; +pub use bitcoin::network::constants::Network as BNetwork; #[cfg(not(feature = "liquid"))] pub type Value = u64; #[cfg(feature = "liquid")] pub use confidential::Value; -lazy_static! { - static ref CACHED_GENESIS: Arc>> = - Arc::new(RwLock::new(HashMap::new())); -} - #[derive(Debug, Copy, Clone, PartialEq, Hash, Serialize, Ord, PartialOrd, Eq)] pub enum Network { + #[cfg(not(feature = "liquid"))] Bitcoin, + #[cfg(not(feature = "liquid"))] Testnet, + #[cfg(not(feature = "liquid"))] Regtest, + #[cfg(not(feature = "liquid"))] + Signet, #[cfg(feature = "liquid")] Liquid, #[cfg(feature = "liquid")] + LiquidTestnet, + #[cfg(feature = "liquid")] LiquidRegtest, } -impl Network { - pub fn genesis_hash(self) -> BlockHash { - if let Some(block_hash) = CACHED_GENESIS.read().unwrap().get(&self) { - return *block_hash; - } +#[cfg(feature = "liquid")] +pub const LIQUID_TESTNET_PARAMS: address::AddressParams = address::AddressParams { + p2pkh_prefix: 36, + p2sh_prefix: 19, + blinded_prefix: 23, + bech_hrp: "tex", + blech_hrp: "tlq", +}; - let block_hash = genesis_block(BNetwork::from(self)).bitcoin_hash(); - CACHED_GENESIS.write().unwrap().insert(self, block_hash); - block_hash +impl Network { + #[cfg(not(feature = "liquid"))] + pub fn magic(self) -> u32 { + BNetwork::from(self).magic() } + #[cfg(feature = "liquid")] pub fn magic(self) -> u32 { match self { - Network::Bitcoin => 0xD9B4_BEF9, - Network::Testnet => 0x0709_110B, - Network::Regtest => 0xDAB5_BFFA, + Network::Liquid | Network::LiquidRegtest => 0xDAB5_BFFA, + Network::LiquidTestnet => 0x62DD_0E41, + } + } + pub fn is_regtest(self) -> bool { + match self { + #[cfg(not(feature = "liquid"))] + Network::Regtest => true, #[cfg(feature = "liquid")] - Network::Liquid => 0xDAB5_BFFA, - #[cfg(feature = "liquid")] - Network::LiquidRegtest => 0xDAB5_BFFA, + Network::LiquidRegtest => true, + _ => false, } } @@ -70,7 +79,7 @@ impl Network { match self { Network::Liquid => &address::AddressParams::LIQUID, Network::LiquidRegtest => &address::AddressParams::ELEMENTS, - _ => panic!("the liquid-only address_params() called with non-liquid network"), + Network::LiquidTestnet => &LIQUID_TESTNET_PARAMS, } } @@ -78,9 +87,16 @@ impl Network { pub fn native_asset(self) -> &'static AssetId { match self { Network::Liquid => &*asset::NATIVE_ASSET_ID, - // same for testnet and regtest - Network::LiquidRegtest => &*asset::NATIVE_ASSET_ID_TESTNET, - _ => panic!("the liquid-only native_asset_id() called with non-liquid network"), + Network::LiquidTestnet => &*asset::NATIVE_ASSET_ID_TESTNET, + Network::LiquidRegtest => &*asset::NATIVE_ASSET_ID_REGTEST, + } + } + + #[cfg(feature = "liquid")] + pub fn pegged_asset(self) -> Option<&'static AssetId> { + match self { + Network::Liquid => Some(&*asset::NATIVE_ASSET_ID), + Network::LiquidTestnet | Network::LiquidRegtest => None, } } @@ -90,29 +106,79 @@ impl Network { "mainnet".to_string(), "testnet".to_string(), "regtest".to_string(), + "signet".to_string(), ]; #[cfg(feature = "liquid")] return vec![ - "mainnet".to_string(), - "testnet".to_string(), - "regtest".to_string(), "liquid".to_string(), + "liquidtestnet".to_string(), "liquidregtest".to_string(), ]; } } +pub fn genesis_hash(network: Network) -> BlockHash { + #[cfg(not(feature = "liquid"))] + return bitcoin_genesis_hash(network.into()); + #[cfg(feature = "liquid")] + return liquid_genesis_hash(network); +} + +pub fn bitcoin_genesis_hash(network: BNetwork) -> bitcoin::BlockHash { + lazy_static! { + static ref BITCOIN_GENESIS: bitcoin::BlockHash = + genesis_block(BNetwork::Bitcoin).block_hash(); + static ref TESTNET_GENESIS: bitcoin::BlockHash = + genesis_block(BNetwork::Testnet).block_hash(); + static ref REGTEST_GENESIS: bitcoin::BlockHash = + genesis_block(BNetwork::Regtest).block_hash(); + static ref SIGNET_GENESIS: bitcoin::BlockHash = + genesis_block(BNetwork::Signet).block_hash(); + } + match network { + BNetwork::Bitcoin => *BITCOIN_GENESIS, + BNetwork::Testnet => *TESTNET_GENESIS, + BNetwork::Regtest => *REGTEST_GENESIS, + BNetwork::Signet => *SIGNET_GENESIS, + } +} + +#[cfg(feature = "liquid")] +pub fn liquid_genesis_hash(network: Network) -> elements::BlockHash { + lazy_static! { + static ref LIQUID_GENESIS: BlockHash = + "1466275836220db2944ca059a3a10ef6fd2ea684b0688d2c379296888a206003" + .parse() + .unwrap(); + } + + match network { + Network::Liquid => *LIQUID_GENESIS, + // The genesis block for liquid regtest chains varies based on the chain configuration. + // This instead uses an all zeroed-out hash, which doesn't matter in practice because its + // only used for Electrum server discovery, which isn't active on regtest. + _ => Default::default(), + } +} + impl From<&str> for Network { fn from(network_name: &str) -> Self { match network_name { + #[cfg(not(feature = "liquid"))] "mainnet" => Network::Bitcoin, + #[cfg(not(feature = "liquid"))] "testnet" => Network::Testnet, + #[cfg(not(feature = "liquid"))] "regtest" => Network::Regtest, + #[cfg(not(feature = "liquid"))] + "signet" => Network::Signet, #[cfg(feature = "liquid")] "liquid" => Network::Liquid, #[cfg(feature = "liquid")] + "liquidtestnet" => Network::LiquidTestnet, + #[cfg(feature = "liquid")] "liquidregtest" => Network::LiquidRegtest, _ => panic!("unsupported Bitcoin network: {:?}", network_name), @@ -120,34 +186,26 @@ impl From<&str> for Network { } } +#[cfg(not(feature = "liquid"))] impl From for BNetwork { fn from(network: Network) -> Self { match network { Network::Bitcoin => BNetwork::Bitcoin, Network::Testnet => BNetwork::Testnet, Network::Regtest => BNetwork::Regtest, - - #[cfg(feature = "liquid")] - Network::Liquid => BNetwork::Bitcoin, // @FIXME - #[cfg(feature = "liquid")] - Network::LiquidRegtest => BNetwork::Regtest, // @FIXME + Network::Signet => BNetwork::Signet, } } } +#[cfg(not(feature = "liquid"))] impl From for Network { fn from(network: BNetwork) -> Self { match network { - #[cfg(not(feature = "liquid"))] BNetwork::Bitcoin => Network::Bitcoin, - #[cfg(not(feature = "liquid"))] + BNetwork::Testnet => Network::Testnet, BNetwork::Regtest => Network::Regtest, - - #[cfg(feature = "liquid")] - BNetwork::Bitcoin => Network::Liquid, // @FIXME - #[cfg(feature = "liquid")] - BNetwork::Regtest => Network::LiquidRegtest, // @FIXME - BNetwork::Testnet => Network::Testnet, // @FIXME + BNetwork::Signet => Network::Signet, } } } diff --git a/src/config.rs b/src/config.rs index 189ac5579..309b4f19b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,9 +9,11 @@ use stderrlog; use crate::chain::Network; use crate::daemon::CookieGetter; - use crate::errors::*; +#[cfg(feature = "liquid")] +use bitcoin::Network as BNetwork; + const ELECTRS_VERSION: &str = env!("CARGO_PKG_VERSION"); #[derive(Debug, Clone)] @@ -39,7 +41,7 @@ pub struct Config { pub electrum_banner: String, #[cfg(feature = "liquid")] - pub parent_network: Network, + pub parent_network: BNetwork, #[cfg(feature = "liquid")] pub asset_db_path: Option, @@ -62,10 +64,7 @@ fn str_to_socketaddr(address: &str, what: &str) -> SocketAddr { impl Config { pub fn from_args() -> Config { - let network_help = format!( - "Select Bitcoin network type ({})", - Network::names().join(", ") - ); + let network_help = format!("Select network type ({})", Network::names().join(", ")); let args = App::new("Electrum Rust Server") .version(crate_version!()) @@ -234,54 +233,80 @@ impl Config { #[cfg(feature = "liquid")] let parent_network = m .value_of("parent_network") - .map(Network::from) + .map(|s| s.parse().expect("invalid parent network")) .unwrap_or_else(|| match network_type { - Network::Liquid => Network::Bitcoin, - Network::LiquidRegtest => Network::Regtest, - _ => panic!("unknown liquid network, --parent-network is required"), + Network::Liquid => BNetwork::Bitcoin, + // XXX liquid testnet/regtest don't have a parent chain + Network::LiquidTestnet | Network::LiquidRegtest => BNetwork::Regtest, }); #[cfg(feature = "liquid")] let asset_db_path = m.value_of("asset_db_path").map(PathBuf::from); let default_daemon_port = match network_type { + #[cfg(not(feature = "liquid"))] Network::Bitcoin => 8332, + #[cfg(not(feature = "liquid"))] Network::Testnet => 18332, + #[cfg(not(feature = "liquid"))] Network::Regtest => 18443, + #[cfg(not(feature = "liquid"))] + Network::Signet => 38332, #[cfg(feature = "liquid")] Network::Liquid => 7041, #[cfg(feature = "liquid")] - Network::LiquidRegtest => 7041, + Network::LiquidTestnet | Network::LiquidRegtest => 7040, }; let default_electrum_port = match network_type { + #[cfg(not(feature = "liquid"))] Network::Bitcoin => 50001, + #[cfg(not(feature = "liquid"))] Network::Testnet => 60001, + #[cfg(not(feature = "liquid"))] Network::Regtest => 60401, + #[cfg(not(feature = "liquid"))] + Network::Signet => 60601, #[cfg(feature = "liquid")] Network::Liquid => 51000, #[cfg(feature = "liquid")] + Network::LiquidTestnet => 51301, + #[cfg(feature = "liquid")] Network::LiquidRegtest => 51401, }; let default_http_port = match network_type { + #[cfg(not(feature = "liquid"))] Network::Bitcoin => 3000, + #[cfg(not(feature = "liquid"))] Network::Testnet => 3001, + #[cfg(not(feature = "liquid"))] Network::Regtest => 3002, + #[cfg(not(feature = "liquid"))] + Network::Signet => 3003, #[cfg(feature = "liquid")] Network::Liquid => 3000, #[cfg(feature = "liquid")] + Network::LiquidTestnet => 3001, + #[cfg(feature = "liquid")] Network::LiquidRegtest => 3002, }; let default_monitoring_port = match network_type { + #[cfg(not(feature = "liquid"))] Network::Bitcoin => 4224, + #[cfg(not(feature = "liquid"))] Network::Testnet => 14224, + #[cfg(not(feature = "liquid"))] Network::Regtest => 24224, + #[cfg(not(feature = "liquid"))] + Network::Signet => 54224, #[cfg(feature = "liquid")] Network::Liquid => 34224, #[cfg(feature = "liquid")] + Network::LiquidTestnet => 44324, + #[cfg(feature = "liquid")] Network::LiquidRegtest => 44224, }; @@ -317,13 +342,20 @@ impl Config { default_dir }); match network_type { + #[cfg(not(feature = "liquid"))] Network::Bitcoin => (), + #[cfg(not(feature = "liquid"))] Network::Testnet => daemon_dir.push("testnet3"), + #[cfg(not(feature = "liquid"))] Network::Regtest => daemon_dir.push("regtest"), + #[cfg(not(feature = "liquid"))] + Network::Signet => daemon_dir.push("signet"), #[cfg(feature = "liquid")] Network::Liquid => daemon_dir.push("liquidv1"), #[cfg(feature = "liquid")] + Network::LiquidTestnet => daemon_dir.push("liquidtestnet"), + #[cfg(feature = "liquid")] Network::LiquidRegtest => daemon_dir.push("liquidregtest"), } let blocks_dir = m diff --git a/src/daemon.rs b/src/daemon.rs index 529369954..eb05680b3 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -7,8 +7,6 @@ use std::time::Duration; use base64; use bitcoin::hashes::hex::{FromHex, ToHex}; -use bitcoin::util::hash::BitcoinHash; -use bitcoin::{BlockHash, Txid}; use glob; use hex; use serde_json::{from_str, from_value, Value}; @@ -18,7 +16,7 @@ use bitcoin::consensus::encode::{deserialize, serialize}; #[cfg(feature = "liquid")] use elements::encode::{deserialize, serialize}; -use crate::chain::{Block, BlockHeader, Network, Transaction}; +use crate::chain::{Block, BlockHash, BlockHeader, Network, Transaction, Txid}; use crate::metrics::{HistogramOpts, HistogramVec, Metrics}; use crate::signal::Waiter; use crate::util::HeaderList; @@ -461,7 +459,7 @@ impl Daemon { let block = block_from_value( self.request("getblock", json!([blockhash.to_hex(), /*verbose=*/ false]))?, )?; - assert_eq!(block.bitcoin_hash(), *blockhash); + assert_eq!(block.block_hash(), *blockhash); Ok(block) } @@ -588,7 +586,7 @@ impl Daemon { let mut blockhash = BlockHash::default(); for header in &result { assert_eq!(header.prev_blockhash, blockhash); - blockhash = header.bitcoin_hash(); + blockhash = header.block_hash(); } assert_eq!(blockhash, *tip); Ok(result) diff --git a/src/electrum/client.rs b/src/electrum/client.rs index f6326e620..04d6ffba6 100644 --- a/src/electrum/client.rs +++ b/src/electrum/client.rs @@ -1,66 +1,15 @@ use std::collections::HashMap; -use std::convert::{TryFrom, TryInto}; -use std::net::ToSocketAddrs; +use std::convert::TryFrom; -use bitcoin::{hashes::Hash, BlockHash}; -use electrum_client::client::{ - Client as RClient, ElectrumPlaintextStream, ElectrumProxyStream, ElectrumSslStream, -}; -pub use electrum_client::types::ServerFeaturesRes; +use bitcoin::hashes::Hash; +pub use electrum_client::client::Client; pub use electrum_client::Error as ElectrumError; +pub use electrum_client::ServerFeaturesRes; +use crate::chain::BlockHash; use crate::electrum::ServerFeatures; use crate::errors::{Error, ResultExt}; -pub enum Client { - Tcp(RClient), - Ssl(RClient), - ProxyTcp(RClient), - // proxy+ssl on the same connection appears to be unsupported by the electrum_client crate -} - -// impl Client { - -impl Client { - pub fn new(socket_addr: A) -> Result { - Ok(Client::Tcp(RClient::new(socket_addr)?)) - } - - pub fn new_ssl(domain_addr: (&str, u16)) -> Result { - // SSL certificates are not validated - Ok(Client::Ssl(RClient::new_ssl(domain_addr, false)?)) - // XXX this should ideally use the previously resolved IP address instead of the hostname, which - // shuold be possible because we don't validate, but it appears like rustls does not support this. - } - - pub fn new_proxy( - target_addr: (&str, u16), - proxy_addr: A, - ) -> Result { - Ok(Client::ProxyTcp(RClient::new_proxy( - target_addr, - proxy_addr, - )?)) - } - - pub fn server_features(&mut self) -> Result { - match self { - Client::Tcp(c) => c.server_features(), - Client::Ssl(c) => c.server_features(), - Client::ProxyTcp(c) => c.server_features(), - }? - .try_into() - } - - pub fn server_add_peer(&mut self, features: &ServerFeatures) -> Result { - match self { - Client::Tcp(c) => c.server_add_peer(features), - Client::Ssl(c) => c.server_add_peer(features), - Client::ProxyTcp(c) => c.server_add_peer(features), - } - } -} - // Convert from electrum-client's server features struct to ours. We're using a different struct because // the electrum-client's one doesn't support the "hosts" key. impl TryFrom for ServerFeatures { diff --git a/src/electrum/discovery.rs b/src/electrum/discovery.rs index 3eecc55dc..cf70221f6 100644 --- a/src/electrum/discovery.rs +++ b/src/electrum/discovery.rs @@ -1,5 +1,6 @@ use std::cmp::Ordering; use std::collections::{hash_map::Entry, BinaryHeap, HashMap, HashSet}; +use std::convert::TryInto; use std::fmt; use std::net::{IpAddr, SocketAddr, ToSocketAddrs}; use std::str::FromStr; @@ -7,7 +8,7 @@ use std::sync::{Arc, RwLock}; use std::thread; use std::time::{Duration, Instant}; -use bitcoin::BlockHash; +use electrum_client::ElectrumApi; use crate::chain::Network; use crate::electrum::{Client, Hostname, Port, ProtocolVersion, ServerFeatures}; @@ -32,9 +33,6 @@ pub struct DiscoveryManager { /// A list of servers that were found to be healthy on their last health check healthy: RwLock>, - /// Used to test for network compatibility - our_genesis_hash: BlockHash, - /// Used to test for protocol version compatibility our_version: ProtocolVersion, @@ -110,7 +108,6 @@ impl DiscoveryManager { }) .collect(); let discovery = Self { - our_genesis_hash: our_network.genesis_hash(), our_addrs, our_version, our_features, @@ -322,19 +319,29 @@ impl DiscoveryManager { ) -> Result { debug!("checking service {:?} {:?}", addr, service); - let mut client: Client = match (addr, service) { - (ServerAddr::Clearnet(ip), Service::Tcp(port)) => Client::new((*ip, port))?, - (ServerAddr::Clearnet(_), Service::Ssl(port)) => Client::new_ssl((hostname, port))?, - (ServerAddr::Onion(hostname), Service::Tcp(port)) => { - let tor_proxy = self - .tor_proxy - .chain_err(|| "no tor proxy configured, onion hosts are unsupported")?; - Client::new_proxy((hostname, port), tor_proxy)? + let server_url = match (addr, service) { + (ServerAddr::Clearnet(ip), Service::Tcp(port)) => format!("tcp://{}:{}", ip, port), + (ServerAddr::Clearnet(_), Service::Ssl(port)) => format!("ssl://{}:{}", hostname, port), + (ServerAddr::Onion(onion_host), Service::Tcp(port)) => { + format!("tcp://{}:{}", onion_host, port) + } + (ServerAddr::Onion(onion_host), Service::Ssl(port)) => { + format!("ssl://{}:{}", onion_host, port) } - (ServerAddr::Onion(_), Service::Ssl(_)) => bail!("ssl over onion is unsupported"), }; - let features = client.server_features()?; + let mut config = electrum_client::ConfigBuilder::new(); + if let ServerAddr::Onion(_) = addr { + let socks = electrum_client::Socks5Config::new( + self.tor_proxy + .chain_err(|| "no tor proxy configured, onion hosts are unsupported")?, + ); + config = config.socks5(Some(socks)).unwrap() + } + + let client = Client::from_config(&server_url, config.build())?; + + let features = client.server_features()?.try_into()?; self.verify_compatibility(&features)?; if self.announce { @@ -350,7 +357,7 @@ impl DiscoveryManager { fn verify_compatibility(&self, features: &ServerFeatures) -> Result<()> { ensure!( - features.genesis_hash == self.our_genesis_hash, + features.genesis_hash == self.our_features.genesis_hash, "incompatible networks" ); @@ -514,36 +521,49 @@ fn is_remote_addr(addr: &ServerAddr) -> bool { #[cfg(test)] mod tests { use super::*; + use crate::chain::genesis_hash; use crate::chain::Network; use std::time; + const PROTOCOL_VERSION: ProtocolVersion = ProtocolVersion::new(1, 4); + #[test] fn test() -> Result<()> { stderrlog::new().verbosity(4).init().unwrap(); - let discovery = DiscoveryManager::new( + let features = ServerFeatures { + hosts: serde_json::from_str("{\"test.foobar.example\":{\"tcp_port\":60002}}").unwrap(), + server_version: format!("electrs-esplora 9"), + genesis_hash: genesis_hash(Network::Testnet), + protocol_min: PROTOCOL_VERSION, + protocol_max: PROTOCOL_VERSION, + hash_function: "sha256".into(), + pruning: None, + }; + let discovery = Arc::new(DiscoveryManager::new( Network::Testnet, - "1.4".parse().unwrap(), - Some("127.0.0.1:9150".parse().unwrap()), - ); - + features, + PROTOCOL_VERSION, + false, + None, + )); discovery.add_default_server( "electrum.blockstream.info".into(), vec![Service::Tcp(60001)], - ); - discovery.add_default_server("testnet.hsmiths.com".into(), vec![Service::Ssl(53012)]); + ).unwrap(); + discovery.add_default_server("testnet.hsmiths.com".into(), vec![Service::Ssl(53012)]).unwrap(); discovery.add_default_server( "tn.not.fyi".into(), vec![Service::Tcp(55001), Service::Ssl(55002)], - ); + ).unwrap(); discovery.add_default_server( "electrum.blockstream.info".into(), vec![Service::Tcp(60001), Service::Ssl(60002)], - ); + ).unwrap(); discovery.add_default_server( "explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion".into(), vec![Service::Tcp(143)], - ); + ).unwrap(); debug!("{:#?}", discovery); diff --git a/src/electrum/discovery/default_servers.rs b/src/electrum/discovery/default_servers.rs index 5d021237d..95754ecef 100644 --- a/src/electrum/discovery/default_servers.rs +++ b/src/electrum/discovery/default_servers.rs @@ -3,6 +3,7 @@ use crate::electrum::discovery::{DiscoveryManager, Service}; pub fn add_default_servers(discovery: &DiscoveryManager, network: Network) { match network { + #[cfg(not(feature = "liquid"))] Network::Bitcoin => { discovery .add_default_server( @@ -401,6 +402,7 @@ pub fn add_default_servers(discovery: &DiscoveryManager, network: Network) { ) .ok(); } + #[cfg(not(feature = "liquid"))] Network::Testnet => { discovery .add_default_server( diff --git a/src/electrum/mod.rs b/src/electrum/mod.rs index b618a2ec6..d28426d7d 100644 --- a/src/electrum/mod.rs +++ b/src/electrum/mod.rs @@ -14,8 +14,7 @@ use std::str::FromStr; use serde::{de, Deserialize, Deserializer, Serialize}; -use bitcoin::BlockHash; - +use crate::chain::BlockHash; use crate::errors::ResultExt; use crate::util::BlockId; diff --git a/src/electrum/server.rs b/src/electrum/server.rs index b35ed3f6c..9fac5065e 100644 --- a/src/electrum/server.rs +++ b/src/electrum/server.rs @@ -1,12 +1,11 @@ use std::collections::HashMap; use std::io::{BufRead, BufReader, Write}; -use std::net::{Shutdown, SocketAddr, TcpStream}; +use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream}; use std::sync::mpsc::{Sender, SyncSender, TrySendError}; use std::sync::{Arc, Mutex}; use std::thread; use bitcoin::hashes::sha256d::Hash as Sha256dHash; -use bitcoin::Txid; use crypto::digest::Digest; use crypto::sha2::Sha256; use error_chain::ChainedError; @@ -18,6 +17,7 @@ use bitcoin::consensus::encode::serialize; #[cfg(feature = "liquid")] use elements::encode::serialize; +use crate::chain::Txid; use crate::config::Config; use crate::electrum::{get_electrum_height, ProtocolVersion}; use crate::errors::*; @@ -287,7 +287,7 @@ impl Connection { Ok(json!({ "confirmed": chain_stats.funded_txo_sum - chain_stats.spent_txo_sum, - "unconfirmed": mempool_stats.funded_txo_sum - mempool_stats.spent_txo_sum, + "unconfirmed": mempool_stats.funded_txo_sum as i64 - mempool_stats.spent_txo_sum as i64, })) } @@ -653,7 +653,7 @@ impl RPC { socket .set_nonblocking(false) .expect("cannot set nonblocking to false"); - let listener = socket.into_tcp_listener(); + let listener = TcpListener::from(socket); info!("Electrum RPC server running on {}", addr); loop { @@ -687,10 +687,11 @@ impl RPC { // Discovery is enabled when electrum-public-hosts is set #[cfg(feature = "electrum-discovery")] let discovery = config.electrum_public_hosts.clone().map(|hosts| { + use crate::chain::genesis_hash; let features = ServerFeatures { hosts, server_version: format!("electrs-esplora {}", ELECTRS_VERSION), - genesis_hash: config.network_type.genesis_hash(), + genesis_hash: genesis_hash(config.network_type), protocol_min: PROTOCOL_VERSION, protocol_max: PROTOCOL_VERSION, hash_function: "sha256".into(), diff --git a/src/elements/asset.rs b/src/elements/asset.rs index 188e939f1..44ee43625 100644 --- a/src/elements/asset.rs +++ b/src/elements/asset.rs @@ -2,12 +2,12 @@ use std::collections::{HashMap, HashSet}; use std::sync::{Arc, RwLock}; use bitcoin::hashes::{hex::FromHex, sha256, Hash}; -use bitcoin::{BlockHash, Txid}; use elements::confidential::{Asset, Value}; use elements::encode::{deserialize, serialize}; +use elements::secp256k1_zkp::ZERO_TWEAK; use elements::{issuance::ContractHash, AssetId, AssetIssuance, OutPoint, Transaction, TxIn}; -use crate::chain::Network; +use crate::chain::{BNetwork, BlockHash, Network, Txid}; use crate::elements::peg::{get_pegin_data, get_pegout_data, PeginInfo, PegoutInfo}; use crate::elements::registry::{AssetMeta, AssetRegistry}; use crate::errors::*; @@ -20,6 +20,9 @@ lazy_static! { AssetId::from_hex("6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d") .unwrap(); pub static ref NATIVE_ASSET_ID_TESTNET: AssetId = + AssetId::from_hex("144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49") + .unwrap(); + pub static ref NATIVE_ASSET_ID_REGTEST: AssetId = AssetId::from_hex("5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225") .unwrap(); } @@ -32,20 +35,21 @@ fn parse_asset_id(sl: &[u8]) -> AssetId { #[serde(untagged)] pub enum LiquidAsset { Issued(IssuedAsset), - Native(NativeAsset), + Native(PeggedAsset), } #[derive(Serialize)] -pub struct NativeAsset { +pub struct PeggedAsset { pub asset_id: AssetId, - pub chain_stats: NativeAssetStats, - pub mempool_stats: NativeAssetStats, + pub chain_stats: PeggedAssetStats, + pub mempool_stats: PeggedAssetStats, } #[derive(Serialize)] pub struct IssuedAsset { pub asset_id: AssetId, pub issuance_txin: TxInput, + #[serde(serialize_with = "crate::util::serialize_outpoint")] pub issuance_prevout: OutPoint, pub reissuance_token: AssetId, @@ -169,7 +173,7 @@ pub fn index_confirmed_tx_assets( tx: &Transaction, confirmed_height: u32, network: Network, - parent_network: Network, + parent_network: BNetwork, rows: &mut Vec, ) { let (history, issuances) = index_tx_assets(tx, network, parent_network); @@ -193,7 +197,7 @@ pub fn index_confirmed_tx_assets( pub fn index_mempool_tx_assets( tx: &Transaction, network: Network, - parent_network: Network, + parent_network: BNetwork, asset_history: &mut HashMap>, asset_issuance: &mut HashMap, ) { @@ -231,7 +235,7 @@ pub fn remove_mempool_tx_assets( fn index_tx_assets( tx: &Transaction, network: Network, - parent_network: Network, + parent_network: BNetwork, ) -> (Vec<(AssetId, TxHistoryInfo)>, Vec<(AssetId, AssetRow)>) { let mut history = vec![]; let mut issuances = vec![]; @@ -248,7 +252,7 @@ fn index_tx_assets( value: pegout.value, }), )); - } else if txo.script_pubkey.is_provably_unspendable() { + } else if txo.script_pubkey.is_provably_unspendable() && !txo.is_fee() { if let (Asset::Explicit(asset_id), Value::Explicit(value)) = (txo.asset, txo.value) { if value > 0 { history.push(( @@ -275,7 +279,7 @@ fn index_tx_assets( }), )); } else if txi.has_issuance() { - let is_reissuance = txi.asset_issuance.asset_blinding_nonce != [0u8; 32]; + let is_reissuance = txi.asset_issuance.asset_blinding_nonce != ZERO_TWEAK; let asset_entropy = get_issuance_entropy(txi).expect("invalid issuance"); let asset_id = AssetId::from_entropy(asset_entropy); @@ -348,10 +352,10 @@ pub fn lookup_asset( asset_id: &AssetId, meta: Option<&AssetMeta>, // may optionally be provided if already known ) -> Result> { - if asset_id == query.network().native_asset() { - let (chain_stats, mempool_stats) = native_asset_stats(query); + if query.network().pegged_asset() == Some(asset_id) { + let (chain_stats, mempool_stats) = pegged_asset_stats(query, asset_id); - return Ok(Some(LiquidAsset::Native(NativeAsset { + return Ok(Some(LiquidAsset::Native(PeggedAsset { asset_id: *asset_id, chain_stats: chain_stats, mempool_stats: mempool_stats, @@ -392,7 +396,7 @@ pub fn get_issuance_entropy(txin: &TxIn) -> Result { bail!("input has no issuance"); } - let is_reissuance = txin.asset_issuance.asset_blinding_nonce != [0u8; 32]; + let is_reissuance = txin.asset_issuance.asset_blinding_nonce != ZERO_TWEAK; Ok(if !is_reissuance { let contract_hash = ContractHash::from_slice(&txin.asset_issuance.asset_entropy) @@ -408,7 +412,7 @@ pub fn get_issuance_entropy(txin: &TxIn) -> Result { // Asset stats // -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Default)] pub struct IssuedAssetStats { pub tx_count: usize, pub issuance_count: usize, @@ -419,22 +423,8 @@ pub struct IssuedAssetStats { pub burned_reissuance_tokens: u64, } -impl Default for IssuedAssetStats { - fn default() -> Self { - Self { - tx_count: 0, - issuance_count: 0, - issued_amount: 0, - burned_amount: 0, - has_blinded_issuances: false, - reissuance_tokens: None, - burned_reissuance_tokens: 0, - } - } -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct NativeAssetStats { +#[derive(Serialize, Deserialize, Debug, Default)] +pub struct PeggedAssetStats { pub tx_count: usize, pub peg_in_count: usize, pub peg_in_amount: u64, @@ -444,20 +434,6 @@ pub struct NativeAssetStats { pub burned_amount: u64, } -impl Default for NativeAssetStats { - fn default() -> Self { - Self { - tx_count: 0, - peg_in_count: 0, - peg_in_amount: 0, - peg_out_count: 0, - peg_out_amount: 0, - burn_count: 0, - burned_amount: 0, - } - } -} - type AssetStatApplyFn = fn(&TxHistoryInfo, &mut T, &mut HashSet); fn asset_cache_key(asset_id: &AssetId) -> Bytes { @@ -474,17 +450,15 @@ where } } -// Get stats for the network's native asset -fn native_asset_stats(query: &Query) -> (NativeAssetStats, NativeAssetStats) { - let asset_id = query.network().native_asset(); - +// Get stats for the network's pegged asset +fn pegged_asset_stats(query: &Query, asset_id: &AssetId) -> (PeggedAssetStats, PeggedAssetStats) { ( - chain_asset_stats(query.chain(), asset_id, apply_native_asset_stats), - mempool_asset_stats(&query.mempool(), asset_id, apply_native_asset_stats), + chain_asset_stats(query.chain(), asset_id, apply_pegged_asset_stats), + mempool_asset_stats(&query.mempool(), asset_id, apply_pegged_asset_stats), ) } -// Get stats for user-issued assets +// Get stats for issued assets fn issued_asset_stats( query: &Query, asset_id: &AssetId, @@ -505,7 +479,7 @@ fn issued_asset_stats( (chain_stats, mempool_stats) } -// Get on-chain confirmed asset stats (user-issued or the native asset) +// Get on-chain confirmed asset stats (issued or the pegged asset) fn chain_asset_stats(chain: &ChainQuery, asset_id: &AssetId, apply_fn: AssetStatApplyFn) -> T where T: Default + serde::Serialize + serde::de::DeserializeOwned, @@ -574,7 +548,7 @@ fn chain_asset_stats_delta( (stats, lastblock) } -// Get mempool asset stats (user-issued or the native asset) +// Get mempool asset stats (issued or the pegged asset) pub fn mempool_asset_stats( mempool: &Mempool, asset_id: &AssetId, @@ -634,9 +608,9 @@ fn apply_issued_asset_stats( } } -fn apply_native_asset_stats( +fn apply_pegged_asset_stats( info: &TxHistoryInfo, - stats: &mut NativeAssetStats, + stats: &mut PeggedAssetStats, seen_txids: &mut HashSet, ) { if seen_txids.insert(info.get_txid()) { diff --git a/src/elements/mod.rs b/src/elements/mod.rs index 3da54f0d6..a73e4d0ea 100644 --- a/src/elements/mod.rs +++ b/src/elements/mod.rs @@ -1,4 +1,5 @@ use bitcoin::hashes::{hex::ToHex, Hash}; +use elements::secp256k1_zkp::ZERO_TWEAK; use elements::{confidential::Value, encode::serialize, issuance::ContractHash, AssetId, TxIn}; pub mod asset; @@ -31,7 +32,7 @@ pub struct IssuanceValue { impl From<&TxIn> for IssuanceValue { fn from(txin: &TxIn) -> Self { let issuance = &txin.asset_issuance; - let is_reissuance = issuance.asset_blinding_nonce != [0u8; 32]; + let is_reissuance = issuance.asset_blinding_nonce != ZERO_TWEAK; let asset_entropy = get_issuance_entropy(txin).expect("invalid issuance"); let asset_id = AssetId::from_entropy(asset_entropy); @@ -48,7 +49,7 @@ impl From<&TxIn> for IssuanceValue { contract_hash: contract_hash.map(|h| h.to_hex()), is_reissuance, asset_blinding_nonce: if is_reissuance { - Some(hex::encode(issuance.asset_blinding_nonce)) + Some(hex::encode(issuance.asset_blinding_nonce.as_ref())) } else { None }, @@ -72,4 +73,4 @@ impl From<&TxIn> for IssuanceValue { }, } } -} +} \ No newline at end of file diff --git a/src/elements/peg.rs b/src/elements/peg.rs index f980ae05a..6efc074bd 100644 --- a/src/elements/peg.rs +++ b/src/elements/peg.rs @@ -1,23 +1,25 @@ -use bitcoin::{hashes::hex::ToHex, Script}; +use bitcoin::hashes::hex::ToHex; use elements::{confidential::Asset, PeginData, PegoutData, TxIn, TxOut}; -use crate::chain::Network; -use crate::util::{get_script_asm, script_to_address, FullHash}; +use crate::chain::{bitcoin_genesis_hash, BNetwork, Network}; +use crate::util::{FullHash, ScriptToAsm}; pub fn get_pegin_data(txout: &TxIn, network: Network) -> Option { + let pegged_asset_id = network.pegged_asset()?; txout .pegin_data() - .filter(|pegin| pegin.asset == Asset::Explicit(*network.native_asset())) + .filter(|pegin| pegin.asset == Asset::Explicit(*pegged_asset_id)) } pub fn get_pegout_data( txout: &TxOut, network: Network, - parent_network: Network, + parent_network: BNetwork, ) -> Option { + let pegged_asset_id = network.pegged_asset()?; txout.pegout_data().filter(|pegout| { - pegout.asset == Asset::Explicit(*network.native_asset()) - && pegout.genesis_hash == parent_network.genesis_hash() + pegout.asset == Asset::Explicit(*pegged_asset_id) + && pegout.genesis_hash == bitcoin_genesis_hash(parent_network) }) } @@ -25,21 +27,25 @@ pub fn get_pegout_data( #[derive(Serialize, Deserialize, Clone)] pub struct PegoutValue { pub genesis_hash: String, - pub scriptpubkey: Script, + pub scriptpubkey: bitcoin::Script, pub scriptpubkey_asm: String, #[serde(skip_serializing_if = "Option::is_none")] pub scriptpubkey_address: Option, } impl PegoutValue { - pub fn from_txout(txout: &TxOut, network: Network, parent_network: Network) -> Option { + pub fn from_txout(txout: &TxOut, network: Network, parent_network: BNetwork) -> Option { let pegoutdata = get_pegout_data(txout, network, parent_network)?; + // pending https://github.com/ElementsProject/rust-elements/pull/69 is merged + let scriptpubkey = bitcoin::Script::from(pegoutdata.script_pubkey.into_bytes()); + let address = bitcoin::Address::from_script(&scriptpubkey, parent_network); + Some(PegoutValue { genesis_hash: pegoutdata.genesis_hash.to_hex(), - scriptpubkey_asm: get_script_asm(&pegoutdata.script_pubkey), - scriptpubkey_address: script_to_address(&pegoutdata.script_pubkey, parent_network), - scriptpubkey: pegoutdata.script_pubkey, + scriptpubkey_asm: scriptpubkey.to_asm(), + scriptpubkey_address: address.map(|s| s.to_string()), + scriptpubkey, }) } } diff --git a/src/elements/registry.rs b/src/elements/registry.rs index 3d1bba43d..5febf28de 100644 --- a/src/elements/registry.rs +++ b/src/elements/registry.rs @@ -5,7 +5,7 @@ use std::{cmp, fs, path, thread}; use serde_json::Value as JsonValue; -use elements::bitcoin_hashes::hex::FromHex; +use bitcoin::hashes::hex::FromHex; use elements::AssetId; use crate::errors::*; @@ -35,14 +35,22 @@ impl AssetRegistry { .map(|(_, metadata)| metadata) } - pub fn list(&self, start_index: usize, limit: usize, sorting: AssetSorting) -> Vec { + pub fn list( + &self, + start_index: usize, + limit: usize, + sorting: AssetSorting, + ) -> (usize, Vec) { let mut assets: Vec = self .assets_cache .iter() .map(|(asset_id, (_, metadata))| (asset_id, metadata)) .collect(); assets.sort_by(sorting.as_comparator()); - assets.into_iter().skip(start_index).take(limit).collect() + ( + assets.len(), + assets.into_iter().skip(start_index).take(limit).collect(), + ) } pub fn fs_sync(&mut self) -> Result<()> { @@ -144,7 +152,7 @@ impl AssetSorting { Box::new(|a, b| lc_cmp(&a.1.name, &b.1.name).then_with(|| a.0.cmp(b.0))) } AssetSortField::Domain => Box::new(|a, b| a.1.domain().cmp(&b.1.domain())), - AssetSortField::Ticker => Box::new(|a, b| lc_cmp(&a.1.ticker, &b.1.ticker)), + AssetSortField::Ticker => Box::new(|a, b| lc_cmp_opt(&a.1.ticker, &b.1.ticker)), }; match self.1 { @@ -176,3 +184,9 @@ impl AssetSorting { fn lc_cmp(a: &str, b: &str) -> cmp::Ordering { a.to_lowercase().cmp(&b.to_lowercase()) } + +fn lc_cmp_opt(a: &Option, b: &Option) -> cmp::Ordering { + a.as_ref() + .map(|a| a.to_lowercase()) + .cmp(&b.as_ref().map(|b| b.to_lowercase())) +} diff --git a/src/new_index/fetch.rs b/src/new_index/fetch.rs index 6b9651445..20d0bfde0 100644 --- a/src/new_index/fetch.rs +++ b/src/new_index/fetch.rs @@ -1,6 +1,3 @@ -use crate::chain::Block; - -use bitcoin::{BitcoinHash, BlockHash}; use rayon::prelude::*; #[cfg(not(feature = "liquid"))] @@ -10,11 +7,12 @@ use elements::encode::{deserialize, Decodable}; use std::collections::HashMap; use std::fs; -use std::io::{Cursor, Seek, SeekFrom}; +use std::io::Cursor; use std::path::PathBuf; use std::sync::mpsc::Receiver; use std::thread; +use crate::chain::{Block, BlockHash}; use crate::daemon::Daemon; use crate::errors::*; use crate::util::{spawn_thread, HeaderEntry, SyncChannel}; @@ -90,7 +88,7 @@ fn bitcoind_fetcher( .zip(entries) .map(|(block, entry)| BlockEntry { entry: entry.clone(), // TODO: remove this clone() - size: block.get_size() as u32, + size: block.size() as u32, block, }) .collect(); @@ -124,7 +122,7 @@ fn blkfiles_fetcher( let block_entries: Vec = sizedblocks .into_iter() .filter_map(|(block, size)| { - let blockhash = block.bitcoin_hash(); + let blockhash = block.block_hash(); entry_map .remove(&blockhash) .map(|entry| BlockEntry { block, entry, size }) @@ -190,39 +188,37 @@ fn parse_blocks(blob: Vec, magic: u32) -> Result> { let mut cursor = Cursor::new(&blob); let mut slices = vec![]; let max_pos = blob.len() as u64; + while cursor.position() < max_pos { + let offset = cursor.position(); match u32::consensus_decode(&mut cursor) { Ok(value) => { if magic != value { - cursor - .seek(SeekFrom::Current(-3)) - .expect("failed to seek back"); + cursor.set_position(offset + 1); continue; } } Err(_) => break, // EOF }; let block_size = u32::consensus_decode(&mut cursor).chain_err(|| "no block size")?; - let start = cursor.position() as usize; - cursor - .seek(SeekFrom::Current(block_size as i64)) - .chain_err(|| format!("seek {} failed", block_size))?; - let end = cursor.position() as usize; - - // If Core's WriteBlockToDisk ftell fails, only the magic byte and size will be written - // and the block body will be unwritten data. skip that's data. - let mut tmp_cursor = Cursor::new(&blob[start..(start + 4)]); - match u32::consensus_decode(&mut tmp_cursor) { + let start = cursor.position(); + let end = start + block_size as u64; + + // If Core's WriteBlockToDisk ftell fails, only the magic bytes and size will be written + // and the block body won't be written to the blk*.dat file. + // Since the first 4 bytes should contain the block's version, we can skip such blocks + // by peeking the cursor (and skipping previous `magic` and `block_size`). + match u32::consensus_decode(&mut cursor) { Ok(value) => { if magic == value { - cursor.set_position(start as u64); + cursor.set_position(start); continue; } } Err(_) => break, // EOF } - - slices.push((&blob[start..end], block_size)); + slices.push((&blob[start as usize..end as usize], block_size)); + cursor.set_position(end as u64); } let pool = rayon::ThreadPoolBuilder::new() diff --git a/src/new_index/mempool.rs b/src/new_index/mempool.rs index cf67790bf..9586c5168 100644 --- a/src/new_index/mempool.rs +++ b/src/new_index/mempool.rs @@ -1,6 +1,4 @@ use arraydeque::{ArrayDeque, Wrapping}; -use bitcoin::consensus::encode::deserialize; -use bitcoin::Txid; use itertools::Itertools; #[cfg(not(feature = "liquid"))] @@ -13,7 +11,7 @@ use std::iter::FromIterator; use std::sync::Arc; use std::time::{Duration, Instant}; -use crate::chain::{Network, OutPoint, Transaction, TxOut}; +use crate::chain::{deserialize, Network, OutPoint, Transaction, TxOut, Txid}; use crate::config::Config; use crate::daemon::Daemon; use crate::errors::*; @@ -291,7 +289,7 @@ impl Mempool { let to_add = match daemon.gettransactions(&txids) { Ok(txs) => txs, Err(err) => { - warn!("failed to get transactions {:?}: {}", txids, err); // e.g. new block or RBF + warn!("failed to get {} transactions: {}", txids.len(), err); // e.g. new block or RBF return Ok(()); // keep the mempool until next update() } }; @@ -317,8 +315,10 @@ impl Mempool { } pub fn add_by_txid(&mut self, daemon: &Daemon, txid: &Txid) { - if let Ok(tx) = daemon.getmempooltx(&txid) { - self.add(vec![tx]) + if self.txstore.get(txid).is_none() { + if let Ok(tx) = daemon.getmempooltx(&txid) { + self.add(vec![tx]) + } } } diff --git a/src/new_index/query.rs b/src/new_index/query.rs index fa1ddf6ef..1e621ac0d 100644 --- a/src/new_index/query.rs +++ b/src/new_index/query.rs @@ -4,15 +4,13 @@ use std::collections::{BTreeSet, HashMap}; use std::sync::{Arc, RwLock, RwLockReadGuard}; use std::time::{Duration, Instant}; -use crate::chain::{Network, OutPoint, Transaction, TxOut}; +use crate::chain::{Network, OutPoint, Transaction, TxOut, Txid}; use crate::config::Config; use crate::daemon::Daemon; use crate::errors::*; use crate::new_index::{ChainQuery, Mempool, ScriptStats, SpendingInput, Utxo}; use crate::util::{is_spendable, BlockId, Bytes, TransactionStatus}; -use bitcoin::Txid; - #[cfg(feature = "liquid")] use crate::{ chain::AssetId, @@ -165,7 +163,7 @@ impl Query { } pub fn estimate_fee(&self, conf_target: u16) -> Option { - if self.config.network_type == Network::Regtest { + if self.config.network_type.is_regtest() { return self.get_relayfee().ok(); } if let (ref cache, Some(cache_time)) = *self.cached_estimates.read().unwrap() { @@ -245,20 +243,20 @@ impl Query { start_index: usize, limit: usize, sorting: AssetSorting, - ) -> Result> { + ) -> Result<(usize, Vec)> { let asset_db = match &self.asset_db { - None => return Ok(vec![]), + None => return Ok((0, vec![])), Some(db) => db.read().unwrap(), }; - Ok(asset_db - .list(start_index, limit, sorting) + let (total_num, results) = asset_db.list(start_index, limit, sorting); + // Attach on-chain information alongside the registry metadata + let results = results .into_iter() - .filter_map(|(asset_id, metadata)| { - // Attach on-chain information alongside the registry metadata - lookup_asset(&self, None, asset_id, Some(metadata)) - .ok() - .flatten() + .map(|(asset_id, metadata)| { + Ok(lookup_asset(&self, None, asset_id, Some(metadata))? + .chain_err(|| "missing registered asset")?) }) - .collect()) + .collect::>>()?; + Ok((total_num, results)) } } diff --git a/src/new_index/schema.rs b/src/new_index/schema.rs index 707f15816..35e49f8de 100644 --- a/src/new_index/schema.rs +++ b/src/new_index/schema.rs @@ -1,8 +1,7 @@ -use bitcoin::blockdata::script::Script; use bitcoin::hashes::sha256d::Hash as Sha256dHash; #[cfg(not(feature = "liquid"))] use bitcoin::util::merkleblock::MerkleBlock; -use bitcoin::{BlockHash, Txid, VarInt}; +use bitcoin::VarInt; use crypto::digest::Digest; use crypto::sha2::Sha256; use itertools::Itertools; @@ -20,14 +19,16 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use std::path::Path; use std::sync::{Arc, RwLock}; -use crate::chain::{BlockHeader, Network, OutPoint, Transaction, TxOut, Value}; +use crate::chain::{ + BlockHash, BlockHeader, Network, OutPoint, Script, Transaction, TxOut, Txid, Value, +}; use crate::config::Config; use crate::daemon::Daemon; use crate::errors::*; -use crate::metrics::{HistogramOpts, HistogramTimer, HistogramVec, Metrics}; +use crate::metrics::{Gauge, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics}; use crate::util::{ - full_hash, has_prevout, is_spendable, script_to_address, BlockHeaderMeta, BlockId, BlockMeta, - BlockStatus, Bytes, HeaderEntry, HeaderList, + full_hash, has_prevout, is_spendable, BlockHeaderMeta, BlockId, BlockMeta, BlockStatus, Bytes, + HeaderEntry, HeaderList, ScriptToAddr, }; use crate::new_index::db::{DBFlush, DBRow, ReverseScanIterator, ScanIterator, DB}; @@ -164,6 +165,7 @@ pub struct Indexer { from: FetchFrom, iconfig: IndexerConfig, duration: HistogramVec, + tip_metric: Gauge, } struct IndexerConfig { @@ -172,7 +174,7 @@ struct IndexerConfig { index_unspendables: bool, network: Network, #[cfg(feature = "liquid")] - parent_network: Network, + parent_network: crate::chain::BNetwork, } impl From<&Config> for IndexerConfig { @@ -208,6 +210,7 @@ impl Indexer { HistogramOpts::new("index_duration", "Index update duration (in seconds)"), &["step"], ), + tip_metric: metrics.gauge(MetricOpts::new("tip_height", "Current chain tip height")), } } @@ -296,6 +299,8 @@ impl Indexer { self.from = FetchFrom::Bitcoind; } + self.tip_metric.set(headers.len() as i64 - 1); + Ok(tip) } @@ -422,7 +427,7 @@ impl ChainQuery { pub fn get_block_header(&self, hash: &BlockHash) -> Option { let _timer = self.start_timer("get_block_header"); - Some(*self.header_by_hash(hash)?.header()) + Some(self.header_by_hash(hash)?.header().clone()) } pub fn get_mtp(&self, height: usize) -> u32 { @@ -910,12 +915,11 @@ impl ChainQuery { let blockid = self.tx_confirming_block(txid)?; let headerentry = self.header_by_hash(&blockid.hash)?; let block_txids = self.get_block_txids(&blockid.hash)?; - let match_txids = vec![*txid].into_iter().collect(); - Some(MerkleBlock::from_header_txids( + Some(MerkleBlock::from_header_txids_with_predicate( headerentry.header(), &block_txids, - &match_txids, + |t| t == txid, )) } @@ -1147,7 +1151,7 @@ fn index_transaction( } fn addr_search_row(spk: &Script, network: Network) -> Option { - script_to_address(spk, network).map(|address| DBRow { + spk.to_address_str(network).map(|address| DBRow { key: [b"a", address.as_bytes()].concat(), value: vec![], }) diff --git a/src/rest.rs b/src/rest.rs index e657a364c..6a5cc96aa 100644 --- a/src/rest.rs +++ b/src/rest.rs @@ -1,18 +1,19 @@ -use crate::chain::{address, Network, OutPoint, Transaction, TxIn, TxOut}; +use crate::chain::{address, BlockHash, Network, OutPoint, Script, Transaction, TxIn, TxOut, Txid}; use crate::config::Config; use crate::errors; use crate::new_index::{compute_script_hash, Query, SpendingInput, Utxo}; use crate::util::{ - create_socket, electrum_merkle, extract_tx_prevouts, full_hash, get_innerscripts, - get_script_asm, get_tx_fee, has_prevout, is_coinbase, script_to_address, BlockHeaderMeta, - BlockId, FullHash, TransactionStatus, + create_socket, electrum_merkle, extract_tx_prevouts, full_hash, get_innerscripts, get_tx_fee, + has_prevout, is_coinbase, BlockHeaderMeta, BlockId, FullHash, ScriptToAddr, ScriptToAsm, + TransactionStatus, }; #[cfg(not(feature = "liquid"))] -use bitcoin::consensus::encode; +use {bitcoin::consensus::encode, std::str::FromStr}; + +use bitcoin::blockdata::opcodes; use bitcoin::hashes::hex::{FromHex, ToHex}; use bitcoin::hashes::Error as HashError; -use bitcoin::{BitcoinHash, BlockHash, Script, Txid}; use hex::{self, FromHexError}; use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Method, Response, Server, StatusCode}; @@ -34,7 +35,6 @@ use serde_json; use std::collections::HashMap; use std::num::ParseIntError; use std::os::unix::fs::FileTypeExt; -use std::str::FromStr; use std::sync::Arc; use std::thread; use url::form_urlencoded; @@ -84,9 +84,9 @@ impl BlockValue { fn new(blockhm: BlockHeaderMeta, network: Network) -> Self { let header = blockhm.header_entry.header(); BlockValue { - id: header.bitcoin_hash().to_hex(), + id: header.block_hash().to_hex(), height: blockhm.header_entry.height() as u32, - version: header.version, + version: header.version as u32, timestamp: header.time, tx_count: blockhm.meta.tx_count, size: blockhm.meta.size, @@ -152,12 +152,12 @@ impl TransactionValue { TransactionValue { txid: tx.txid(), - version: tx.version, + version: tx.version as u32, locktime: tx.lock_time, vin: vins, vout: vouts, - size: tx.get_size() as u32, - weight: tx.get_weight() as u32, + size: tx.size() as u32, + weight: tx.weight() as u32, fee, status: Some(TransactionStatus::from(blockid)), } @@ -208,17 +208,17 @@ impl TxInValue { txid: txin.previous_output.txid, vout: txin.previous_output.vout, prevout: prevout.map(|prevout| TxOutValue::new(prevout, config)), - scriptsig_asm: get_script_asm(&txin.script_sig), + scriptsig_asm: txin.script_sig.to_asm(), witness, inner_redeemscript_asm: innerscripts .as_ref() .and_then(|i| i.redeem_script.as_ref()) - .map(get_script_asm), + .map(ScriptToAsm::to_asm), inner_witnessscript_asm: innerscripts .as_ref() .and_then(|i| i.witness_script.as_ref()) - .map(get_script_asm), + .map(ScriptToAsm::to_asm), is_coinbase, sequence: txin.sequence, @@ -299,8 +299,8 @@ impl TxOutValue { let is_fee = txout.is_fee(); let script = &txout.script_pubkey; - let script_asm = get_script_asm(&script); - let script_addr = script_to_address(&script, config.network_type); + let script_asm = script.to_asm(); + let script_addr = script.to_address_str(config.network_type); // TODO should the following something to put inside rust-elements lib? let script_type = if is_fee { @@ -319,6 +319,8 @@ impl TxOutValue { "v0_p2wpkh" } else if script.is_v0_p2wsh() { "v0_p2wsh" + } else if is_v1_p2tr(script) { + "v1_p2tr" } else if script.is_provably_unspendable() { "provably_unspendable" } else { @@ -345,6 +347,11 @@ impl TxOutValue { } } } +fn is_v1_p2tr(script: &Script) -> bool { + script.len() == 34 + && script[0] == opcodes::all::OP_PUSHNUM_1.into_u8() + && script[1] == opcodes::all::OP_PUSHBYTES_32.into_u8() +} #[derive(Serialize)] struct UtxoValue { @@ -428,9 +435,12 @@ impl From for UtxoValue { _ => None, }, #[cfg(feature = "liquid")] - surjection_proof: utxo.witness.surjection_proof, + surjection_proof: utxo + .witness + .surjection_proof + .map_or(vec![], |p| (*p).serialize()), #[cfg(feature = "liquid")] - range_proof: utxo.witness.rangeproof, + range_proof: utxo.witness.rangeproof.map_or(vec![], |p| (*p).serialize()), } } } @@ -546,7 +556,7 @@ async fn run_server(config: Arc, query: Arc, rx: oneshot::Receive let socket = create_socket(&addr); socket.listen(511).expect("setting backlog failed"); - Server::from_tcp(socket.into_tcp_listener()) + Server::from_tcp(socket.into()) .expect("Server::from_tcp failed") .serve(make_service_fn(move |_| make_service_fn_inn())) .with_graceful_shutdown(async { @@ -962,7 +972,7 @@ fn handle_request( let height = query .chain() - .height_by_hash(&merkleblock.header.bitcoin_hash()); + .height_by_hash(&merkleblock.header.block_hash()); http_message( StatusCode::OK, @@ -1050,9 +1060,15 @@ fn handle_request( let sorting = AssetSorting::from_query_params(&query_params)?; - let assets = query.list_registry_assets(start_index, limit, sorting)?; + let (total_num, assets) = query.list_registry_assets(start_index, limit, sorting)?; - json_response(assets, TTL_SHORT) + Ok(Response::builder() + // Disable caching because we don't currently support caching with query string params + .header("Cache-Control", "no-store") + .header("Content-Type", "application/json") + .header("X-Total-Results", total_num.to_string()) + .body(Body::from(serde_json::to_string(&assets)?)) + .unwrap()) } #[cfg(feature = "liquid")] @@ -1226,14 +1242,21 @@ fn to_scripthash( } } -#[allow(unused_variables)] // `network` is unused in liquid mode fn address_to_scripthash(addr: &str, network: Network) -> Result { + #[cfg(not(feature = "liquid"))] let addr = address::Address::from_str(addr)?; + #[cfg(feature = "liquid")] + let addr = address::Address::parse_with_params(addr, network.address_params())?; #[cfg(not(feature = "liquid"))] let is_expected_net = { let addr_network = Network::from(addr.network); - addr_network == network || (addr_network == Network::Testnet && network == Network::Regtest) + + // Testnet, Regtest and Signet all share the same version bytes, + // `addr_network` will be detected as Testnet for all of them. + addr_network == network + || (addr_network == Network::Testnet + && matches!(network, Network::Regtest | Network::Signet)) }; #[cfg(feature = "liquid")] diff --git a/src/signal.rs b/src/signal.rs index 26fdeeaa2..6b32aae19 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -3,6 +3,8 @@ use crossbeam_channel::RecvTimeoutError; use std::thread; use std::time::Duration; +use signal_hook::consts::{SIGINT, SIGTERM, SIGUSR1}; + use crate::errors::*; #[derive(Clone)] // so multiple threads could wait on signals @@ -12,7 +14,7 @@ pub struct Waiter { fn notify(signals: &[i32]) -> channel::Receiver { let (s, r) = channel::bounded(1); - let signals = + let mut signals = signal_hook::iterator::Signals::new(signals).expect("failed to register signal hook"); thread::spawn(move || { for signal in signals.forever() { @@ -27,15 +29,14 @@ impl Waiter { pub fn start() -> Waiter { Waiter { receiver: notify(&[ - signal_hook::SIGINT, - signal_hook::SIGTERM, - signal_hook::SIGUSR1, // allow external triggering (e.g. via bitcoind `blocknotify`) + SIGINT, SIGTERM, + SIGUSR1, // allow external triggering (e.g. via bitcoind `blocknotify`) ]), } } pub fn wait(&self, duration: Duration, accept_sigusr: bool) -> Result<()> { match self.receiver.recv_timeout(duration) { - Ok(sig) if sig == signal_hook::SIGUSR1 => { + Ok(sig) if sig == SIGUSR1 => { trace!("notified via SIGUSR1"); if accept_sigusr { Ok(()) diff --git a/src/util/block.rs b/src/util/block.rs index 1bb7cd294..1f6b98508 100644 --- a/src/util/block.rs +++ b/src/util/block.rs @@ -1,13 +1,12 @@ -use crate::chain::BlockHeader; +use crate::chain::{BlockHash, BlockHeader}; use crate::errors::*; use crate::new_index::BlockEntry; -use bitcoin::{BitcoinHash, BlockHash}; - use std::collections::HashMap; use std::fmt; use std::iter::FromIterator; use std::slice; +use time::format_description::well_known::Rfc3339; use time::OffsetDateTime as DateTime; const MTP_SPAN: usize = 11; @@ -52,13 +51,13 @@ impl HeaderEntry { impl fmt::Debug for HeaderEntry { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let last_block_time = DateTime::from_unix_timestamp(self.header().time as i64); + let last_block_time = DateTime::from_unix_timestamp(self.header().time as i64).unwrap(); write!( f, "hash={} height={} @ {}", self.hash(), self.height(), - last_block_time.format(time::Format::Rfc3339), + last_block_time.format(&Rfc3339).unwrap(), ) } } @@ -97,7 +96,7 @@ impl HeaderList { panic!( "missing expected blockhash in headers map: {:?}, pointed from: {:?}", blockhash, - headers_chain.last().map(|h| h.bitcoin_hash()) + headers_chain.last().map(|h| h.block_hash()) ) }); blockhash = header.prev_blockhash; @@ -124,7 +123,7 @@ impl HeaderList { } let hashed_headers = Vec::::from_iter(new_headers.into_iter().map(|header| HashedHeader { - blockhash: header.bitcoin_hash(), + blockhash: header.block_hash(), header, })); for i in 1..hashed_headers.len() { @@ -295,7 +294,7 @@ impl From<&BlockEntry> for BlockMeta { fn from(b: &BlockEntry) -> BlockMeta { BlockMeta { tx_count: b.block.txdata.len() as u32, - weight: b.block.get_weight() as u32, + weight: b.block.weight() as u32, size: b.size, } } diff --git a/src/util/electrum_merkle.rs b/src/util/electrum_merkle.rs index a8048b155..954782a7d 100644 --- a/src/util/electrum_merkle.rs +++ b/src/util/electrum_merkle.rs @@ -1,8 +1,7 @@ -use bitcoin::hashes::{sha256d::Hash as Sha256dHash, Hash}; -use bitcoin::{BlockHash, Txid}; - +use crate::chain::{BlockHash, Txid}; use crate::errors::*; use crate::new_index::ChainQuery; +use bitcoin::hashes::{sha256d::Hash as Sha256dHash, Hash}; pub fn get_tx_merkle_proof( chain: &ChainQuery, diff --git a/src/util/fees.rs b/src/util/fees.rs index 1e28ac784..828be6cd1 100644 --- a/src/util/fees.rs +++ b/src/util/fees.rs @@ -12,7 +12,7 @@ pub struct TxFeeInfo { impl TxFeeInfo { pub fn new(tx: &Transaction, prevouts: &HashMap, network: Network) -> Self { let fee = get_tx_fee(tx, prevouts, network); - let vsize = tx.get_weight() / 4; + let vsize = tx.weight() / 4; TxFeeInfo { fee, diff --git a/src/util/mod.rs b/src/util/mod.rs index 6ef04b3f6..233e3efea 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -7,9 +7,10 @@ pub mod fees; pub use self::block::{BlockHeaderMeta, BlockId, BlockMeta, BlockStatus, HeaderEntry, HeaderList}; pub use self::fees::get_tx_fee; -pub use self::script::{get_innerscripts, get_script_asm, script_to_address}; +pub use self::script::{get_innerscripts, ScriptToAddr, ScriptToAsm}; pub use self::transaction::{ - extract_tx_prevouts, has_prevout, is_coinbase, is_spendable, TransactionStatus, TxInput, + extract_tx_prevouts, has_prevout, is_coinbase, is_spendable, serialize_outpoint, + TransactionStatus, TxInput, }; use std::collections::HashMap; @@ -113,11 +114,11 @@ impl BoolThen for bool { pub fn create_socket(addr: &SocketAddr) -> Socket { let domain = match &addr { - SocketAddr::V4(_) => Domain::ipv4(), - SocketAddr::V6(_) => Domain::ipv6(), + SocketAddr::V4(_) => Domain::IPV4, + SocketAddr::V6(_) => Domain::IPV6, }; let socket = - Socket::new(domain, Type::stream(), Some(Protocol::tcp())).expect("creating socket failed"); + Socket::new(domain, Type::STREAM, Some(Protocol::TCP)).expect("creating socket failed"); #[cfg(unix)] socket diff --git a/src/util/script.rs b/src/util/script.rs index 5d1bb7958..61be03e65 100644 --- a/src/util/script.rs +++ b/src/util/script.rs @@ -1,37 +1,46 @@ -use bitcoin::blockdata::script::{Instruction::PushBytes, Script}; - #[cfg(feature = "liquid")] use elements::address as elements_address; -use crate::chain::Network; -use crate::chain::{TxIn, TxOut}; +use crate::chain::{script, Network, Script, TxIn, TxOut}; +use script::Instruction::PushBytes; pub struct InnerScripts { pub redeem_script: Option