diff --git a/.gitignore b/.gitignore index 74d5676..efb78d9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .github/workflows/dependency-review.yml .github/workflows/release.yml .github/workflows/security-audit.yml -.github/workflows/README.md \ No newline at end of file +.github/workflows/README.md +.env \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index cbb18f2..bb53483 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,6 +14,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "bitcoin-io" version = "0.1.4" @@ -30,6 +36,18 @@ dependencies = [ "hex-conservative", ] +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + [[package]] name = "block-buffer" version = "0.10.4" @@ -48,6 +66,18 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + [[package]] name = "cc" version = "1.2.56" @@ -64,6 +94,32 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -94,12 +150,129 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + [[package]] name = "find-msvc-tools" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -133,6 +306,31 @@ dependencies = [ "wasip2", ] +[[package]] +name = "h2" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + [[package]] name = "hex" version = "0.4.3" @@ -158,262 +356,1301 @@ dependencies = [ ] [[package]] -name = "libc" -version = "0.2.183" +name = "http" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] [[package]] -name = "num-bigint" +name = "http-body" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ - "num-integer", - "num-traits", + "bytes", + "http", + "pin-project-lite", ] [[package]] -name = "num-integer" -version = "0.1.46" +name = "httparse" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] -name = "num-traits" -version = "0.2.19" +name = "httpdate" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] -name = "ppv-lite86" -version = "0.2.21" +name = "hyper" +version = "0.14.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" dependencies = [ - "zerocopy", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.10", + "tokio", + "tower-service", + "tracing", + "want", ] [[package]] -name = "proc-macro2" -version = "1.0.106" +name = "hyper-tls" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "unicode-ident", + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", ] [[package]] -name = "programming_bitcoin" -version = "0.1.0" +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" dependencies = [ - "bs58", - "hex", - "hmac", - "num-bigint", - "rand 0.8.5", - "ripemd", - "secp256k1", - "sha2", + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", ] [[package]] -name = "quote" -version = "1.0.45" +name = "icu_locale_core" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" dependencies = [ - "proc-macro2", + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", ] [[package]] -name = "r-efi" -version = "5.3.0" +name = "icu_normalizer" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] [[package]] -name = "rand" -version = "0.8.5" +name = "icu_normalizer_data" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" [[package]] -name = "rand" -version = "0.9.2" +name = "icu_properties" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.5", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", ] [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "icu_properties_data" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" [[package]] -name = "rand_chacha" -version = "0.9.0" +name = "icu_provider" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" dependencies = [ - "ppv-lite86", - "rand_core 0.9.5", + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", ] [[package]] -name = "rand_core" -version = "0.6.4" +name = "idna" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" dependencies = [ - "getrandom 0.2.17", + "idna_adapter", + "smallvec", + "utf8_iter", ] [[package]] -name = "rand_core" -version = "0.9.5" +name = "idna_adapter" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" dependencies = [ - "getrandom 0.3.4", + "icu_normalizer", + "icu_properties", ] [[package]] -name = "ripemd" -version = "0.1.3" +name = "indexmap" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ - "digest", + "equivalent", + "hashbrown", ] [[package]] -name = "secp256k1" -version = "0.31.1" +name = "ipnet" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c3c81b43dc2d8877c216a3fccf76677ee1ebccd429566d3e67447290d0c42b2" -dependencies = [ - "bitcoin_hashes", - "rand 0.9.2", - "secp256k1-sys", -] +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" [[package]] -name = "secp256k1-sys" -version = "0.11.0" +name = "itoa" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb913707158fadaf0d8702c2db0e857de66eb003ccfdda5924b5f5ac98efb38" -dependencies = [ - "cc", -] +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] -name = "sha2" -version = "0.10.9" +name = "js-sys" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ - "cfg-if", - "cpufeatures", - "digest", + "once_cell", + "wasm-bindgen", ] [[package]] -name = "shlex" -version = "1.3.0" +name = "libc" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] -name = "subtle" -version = "2.6.1" +name = "linux-raw-sys" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] -name = "syn" -version = "2.0.117" +name = "litemap" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" [[package]] -name = "tinyvec" -version = "1.10.0" +name = "lock_api" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "tinyvec_macros", + "scopeguard", ] [[package]] -name = "tinyvec_macros" -version = "0.1.1" +name = "log" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] -name = "typenum" -version = "1.19.0" +name = "memchr" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] -name = "unicode-ident" -version = "1.0.24" +name = "mime" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] -name = "version_check" -version = "0.9.5" +name = "mio" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] [[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" +name = "native-tls" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] [[package]] -name = "wasip2" -version = "1.0.2+wasi-0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "openssl" +version = "0.10.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" +dependencies = [ + "bitflags 2.11.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "programming_bitcoin" +version = "0.1.0" +dependencies = [ + "bs58", + "dotenvy", + "hex", + "hmac", + "num-bigint", + "rand 0.8.5", + "reqwest", + "ripemd", + "secp256k1", + "serde", + "serde_json", + "sha2", + "tokio", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.11.0", +] + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags 2.11.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "secp256k1" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3c81b43dc2d8877c216a3fccf76677ee1ebccd429566d3e67447290d0c42b2" +dependencies = [ + "bitcoin_hashes", + "rand 0.9.2", + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb913707158fadaf0d8702c2db0e857de66eb003ccfdda5924b5f5ac98efb38" +dependencies = [ + "cc", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags 2.11.0", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.6.3", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" dependencies = [ "wit-bindgen", ] +[[package]] +name = "wasm-bindgen" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" +dependencies = [ + "cfg-if", + "futures-util", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.8.42" @@ -433,3 +1670,63 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index e61e0b6..e1448c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,3 +12,8 @@ sha2 = "0.10.9" secp256k1 = { version = "0.31.1", features = ["global-context"]} bs58 = "0.5.1" ripemd = "0.1.3" +dotenvy = "0.15.7" +serde_json = "1.0.149" +serde = { version = "1.0", features = ["derive"] } +reqwest = "0.11" +tokio = { version = "1", features = ["full"] } diff --git a/src/ch04_serialization/ser_private_key.rs b/src/ch04_serialization/ser_private_key.rs index d1c52e5..621c4a9 100644 --- a/src/ch04_serialization/ser_private_key.rs +++ b/src/ch04_serialization/ser_private_key.rs @@ -16,9 +16,11 @@ pub struct PrivateKey { } impl PrivateKey { - pub fn new() -> Self { - let mut key = [0_u8; 32]; - OsRng.fill_bytes(&mut key); + pub fn new(secret: &str) -> Self { + let bytes_secret = secret.as_bytes(); + let mut hasher = Sha256::new(); + hasher.update(bytes_secret); + let key: [u8; 32] = hasher.finalize().into(); let felt = S256Field::from_bytes(&key); let point = S256Point::generate_point(felt.clone().element); diff --git a/src/ch05_transactions/mod.rs b/src/ch05_transactions/mod.rs new file mode 100644 index 0000000..066c26c --- /dev/null +++ b/src/ch05_transactions/mod.rs @@ -0,0 +1,4 @@ +pub mod transaction; +pub mod tx_fetcher; +pub mod tx_input; +pub mod tx_output; diff --git a/src/ch05_transactions/transaction.rs b/src/ch05_transactions/transaction.rs new file mode 100644 index 0000000..5d3e9ce --- /dev/null +++ b/src/ch05_transactions/transaction.rs @@ -0,0 +1,209 @@ +use serde::Serialize; +use serde::ser::SerializeStruct; +use sha2::{Digest, Sha256}; + +use crate::{ + tx_input::{TxId, TxIn}, + tx_output::TxOut, +}; + +#[derive(Debug, Clone)] +pub struct Transaction { + pub version: u32, + pub inputs: Vec, + pub outputs: Vec, + pub locktime: u32, + pub testnet: bool, +} + +impl Serialize for Transaction { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut tx = serializer.serialize_struct("Transaction", 5)?; + tx.serialize_field("transaction_id", &self.compute_tx_id())?; + tx.serialize_field("version", &self.version)?; + tx.serialize_field("inputs", &self.inputs)?; + tx.serialize_field("outputs", &self.outputs)?; + tx.serialize_field("locktime", &self.locktime)?; + tx.serialize_field("testnet", &self.testnet)?; + + tx.end() + } +} + +// Reads the number, and then the index from where to begin the next read +pub fn decode_varint(data: &[u8], index: usize) -> (u64, usize) { + let i = data[index]; + + match i { + 0xfd => { + let start = index + 1; + let to_read = data[start..=start + 1].try_into().unwrap(); + (u16::from_le_bytes(to_read) as u64, start + 2) + } + 0xfe => { + let start = index + 1; + let to_read = data[start..=start + 3].try_into().unwrap(); + (u32::from_le_bytes(to_read) as u64, start + 4) + } + 0xff => { + let start = index + 1; + let to_read = data[start..=start + 7].try_into().unwrap(); + (u64::from_le_bytes(to_read), start + 8) + } + _ => (i as u64, index + 1), + } +} + +pub fn encode_varint(number: u64) -> Vec { + match number { + 0..=0xfc => (number as u8).to_le_bytes().to_vec(), + 0xfd..=0xFFFF => { + let mut bytes = vec![0xfd]; + bytes.extend_from_slice(&(number as u16).to_le_bytes()); + bytes + } + 0x10000..=0xFFFFFFFF => { + let mut bytes = vec![0xfe]; + bytes.extend_from_slice(&(number as u32).to_le_bytes()); + bytes + } + _ => { + let mut bytes = vec![0xff]; + bytes.extend_from_slice(&number.to_le_bytes()); + bytes + } + } +} + +impl Transaction { + pub fn new( + version: u32, + inputs: Vec, + outputs: Vec, + locktime: u32, + testnet: bool, + ) -> Transaction { + Transaction { + version, + inputs, + outputs, + locktime, + testnet, + } + } + + pub fn compute_tx_id(&self) -> TxId { + let tx = hex::decode(self.serialize()).unwrap(); + let mut hasher = Sha256::new(); + hasher.update(tx); + let hash1 = hasher.finalize(); + + let mut hasher = Sha256::new(); + hasher.update(hash1); + let hash2 = hasher.finalize(); + + TxId(hash2.into()) + } + + pub fn parse(serialization: &[u8]) -> Transaction { + let mut index = 0; + + let version_bytes: [u8; 4] = serialization[index..index + 4].try_into().unwrap(); + let version = u32::from_le_bytes(version_bytes); + + // Check out the stream thing on page 115 + index += 4; + + let (input_count, new_index) = decode_varint(serialization, index); + + index = new_index; + + let mut inputs = Vec::new(); + + for _ in 0..input_count { + let (input, displacement) = TxIn::parse(serialization, index); + inputs.push(input); + index += displacement; + } + + let (output_count, new_index) = decode_varint(serialization, index); + index = new_index; + + let mut outputs = Vec::new(); + + for _ in 0..output_count { + let (output, new_index) = TxOut::parse(serialization, index); + outputs.push(output); + index = new_index + } + + let locktime_bytes = serialization[index..index + 4].try_into().unwrap(); + let locktime = u32::from_le_bytes(locktime_bytes); + + Transaction { + inputs, + version, + outputs, + locktime, + testnet: true, + } + + // serde_json::to_string_pretty(&transaction).unwrap() + } + + pub fn serialize(&self) -> String { + let mut result = Vec::new(); + + let version_bytes = &self.version.to_le_bytes(); + result.extend_from_slice(version_bytes); + + let inputs_len = self.inputs.len(); + let inputs_len_bytes = encode_varint(inputs_len as u64); + result.extend_from_slice(&inputs_len_bytes); + + for txin in &self.inputs { + let ser = txin.serialize(); + result.extend_from_slice(&ser); + } + + let outputs_len = self.outputs.len(); + let outputs_len_bytes = encode_varint(outputs_len as u64); + result.extend_from_slice(&outputs_len_bytes); + + for txout in &self.outputs { + let ser = txout.serialize(); + result.extend_from_slice(&ser); + } + + let locktime_bytes = &self.locktime.to_le_bytes(); + result.extend_from_slice(locktime_bytes); + + hex::encode(result) + } + + pub async fn get_tx_fee(&self) -> u64 { + let mut input_amount = 0; + let mut output_amount = 0; + + for txin in &self.inputs { + let input_value = txin.value(true).await; + input_amount += input_value; + } + + for txout in &self.outputs { + let output_val = txout.amount; + output_amount += output_val; + } + + input_amount - output_amount + } +} + +// impl Decodable for Transaction { +// fn consensus_decode(r: &mut R) -> Result { + +// } +// } diff --git a/src/ch05_transactions/tx_fetcher.rs b/src/ch05_transactions/tx_fetcher.rs new file mode 100644 index 0000000..3e8ad73 --- /dev/null +++ b/src/ch05_transactions/tx_fetcher.rs @@ -0,0 +1,36 @@ +use crate::transaction::Transaction; +use reqwest; +use std::{collections::HashMap, io::Cursor}; + +#[derive(Debug, Clone, Copy)] +pub struct TxFetcher {} + +impl TxFetcher { + pub fn get_url(testnet: bool) -> String { + if testnet { + "http://testnet.programmingbitcoin.com/".to_string() + } else { + "http://mainnet.programmingbitcoin.com/".to_string() + } + } + + pub async fn fetch( + tx_id: &str, + testnet: bool, + fresh: bool, + cache: &mut Option>, + ) -> Result { + if fresh || !cache.clone().unwrap().contains_key(tx_id) { + let url = format!("{}/tx/{}.hex", Self::get_url(testnet), tx_id); + let response = reqwest::get(&url).await?; + let text = response.text().await?; + let raw = hex::decode(text.trim()).unwrap(); + + let tx = Transaction::parse(&Cursor::new(raw).into_inner()); + cache.clone().unwrap().insert(tx_id.to_string(), tx.clone()); + Ok(tx) + } else { + Ok(cache.clone().unwrap()[tx_id].clone()) + } + } +} diff --git a/src/ch05_transactions/tx_input.rs b/src/ch05_transactions/tx_input.rs new file mode 100644 index 0000000..8af0608 --- /dev/null +++ b/src/ch05_transactions/tx_input.rs @@ -0,0 +1,160 @@ +use std::io::Error; + +use serde::{Serialize, Serializer, ser::SerializeStruct}; +use sha2::{Digest, Sha256}; + +use crate::{ + transaction::{Transaction, decode_varint, encode_varint}, + tx_fetcher::TxFetcher, +}; + +#[derive(Debug, Clone, Copy)] +pub struct TxId(pub [u8; 32]); + +impl TxId { + pub fn from_hash(bytes: [u8; 32]) -> Self { + TxId(bytes) + } + + pub fn from_raw_transaction(tx: Vec) -> Result { + let mut hasher = Sha256::new(); + hasher.update(tx); + let hash1 = hasher.finalize(); + + let mut hasher = Sha256::new(); + hasher.update(hash1); + let hash2 = hasher.finalize(); + + Ok(TxId(hash2.into())) + } +} + +#[derive(Debug, Clone)] +pub struct TxIn { + // pub tx_id: [u8; 32], + pub tx_id: TxId, + pub output_index: u32, + pub script_sig: String, + pub sequence: u32, +} + +impl TxIn { + pub fn new(tx_id: [u8; 32], prev_index: u32, script_sig: String, sequence: u32) -> Self { + TxIn { + tx_id: TxId(tx_id), + output_index: prev_index, + script_sig, + sequence, + } + } + + pub fn repr(&self) -> String { + format!("{}:{}", hex::encode(self.tx_id.0), self.output_index) + } + + pub fn parse(data: &[u8], mut index: usize) -> (Self, usize) { + let mut displacement = 0; + let previous_tx_id: [u8; 32] = data[index..index + 32].try_into().unwrap(); + + index += 32; + displacement += 32; + + let output_index_bytes = &data[index..index + 4].try_into().unwrap(); + let output_index = u32::from_le_bytes(*output_index_bytes); + + index += 4; + displacement += 4; + + let start_index = index; + let (script_len, new_index) = decode_varint(data, index); + let varint_size = new_index - start_index; + index = new_index; + displacement += varint_size; + let script_buf = &data[index..index + (script_len as usize)]; + let script_sig = hex::encode(script_buf); + + index += script_len as usize; + displacement += script_len as usize; + + let seq_bytes = &data[index..index + 4].try_into().unwrap(); + let sequence = u32::from_le_bytes(*seq_bytes); + + displacement += 4; + + ( + TxIn { + tx_id: TxId(previous_tx_id), + output_index, + script_sig, + sequence, + }, + displacement, + ) + } + + pub fn serialize(&self) -> Vec { + let mut result = Vec::new(); + + let tx_id_bytes = &self.tx_id.0; + let output_index_bytes = &self.output_index.to_le_bytes(); + let script_sig_bytes = hex::decode(&self.script_sig).unwrap(); + let compact_size_len = encode_varint(script_sig_bytes.len() as u64); + let sequence_bytes = &self.sequence.to_le_bytes(); + + result.extend_from_slice(tx_id_bytes); + result.extend_from_slice(output_index_bytes); + result.extend_from_slice(&compact_size_len); + result.extend_from_slice(&script_sig_bytes); + result.extend_from_slice(sequence_bytes); + + result + } + + pub async fn fetch(&self, testnet: bool) -> Transaction { + TxFetcher::fetch(&hex::encode(self.tx_id.0), testnet, true, &mut None) + .await + .unwrap() + } + + pub async fn value(&self, testnet: bool) -> u64 { + let tx_outs = self.fetch(testnet).await.outputs; + + let index = self.output_index; + tx_outs[index as usize].amount + } + + pub async fn script_pubkey(&self, testnet: bool) -> String { + let tx_outs = self.fetch(testnet).await.outputs; + + let index = self.output_index; + let script_pubkey = &tx_outs[index as usize].script_pubkey; + + String::from(script_pubkey) + } +} + +impl Serialize for TxId { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut bytes = self.0; + bytes.reverse(); + serializer.serialize_str(&hex::encode(bytes)) + } +} + +impl Serialize for TxIn { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut txin = serializer.serialize_struct("TxIn", 4)?; + txin.serialize_field("txid", &self.tx_id)?; + txin.serialize_field("output_index", &self.output_index)?; + txin.serialize_field("script_sig", &self.script_sig)?; + txin.serialize_field("sequence", &self.sequence)?; + + txin.end() + } +} diff --git a/src/ch05_transactions/tx_output.rs b/src/ch05_transactions/tx_output.rs new file mode 100644 index 0000000..e0c0d55 --- /dev/null +++ b/src/ch05_transactions/tx_output.rs @@ -0,0 +1,59 @@ +use serde::Serialize; + +use crate::transaction::{decode_varint, encode_varint}; + +#[derive(Debug, Clone, Serialize)] +pub struct TxOut { + pub amount: u64, + pub script_pubkey: String, +} + +impl TxOut { + pub fn new(amount: u64, script_pubkey: String) -> Self { + Self { + amount, + script_pubkey, + } + } + + pub fn repr(&self) -> String { + format!("{}:{}", &self.amount, hex::encode(&self.script_pubkey)) + } + + pub fn parse(data: &[u8], mut index: usize) -> (Self, usize) { + let amount_bytes = data[index..index + 8].try_into().unwrap(); + let amount = u64::from_le_bytes(amount_bytes); + + index += 8; + + let (script_pubkey_len, new_index) = decode_varint(data, index); + + index = new_index; + let script_pubkey_buf = &data[index..index + (script_pubkey_len as usize)]; + let script_pubkey = hex::encode(script_pubkey_buf); + + index += script_pubkey_len as usize; + + ( + Self { + amount, + script_pubkey, + }, + index, + ) + } + + pub fn serialize(&self) -> Vec { + let mut result = Vec::new(); + + let amount_bytes = self.amount.to_le_bytes(); + let script_pubkey_bytes = hex::decode(&self.script_pubkey).unwrap(); + let compact_size_len = encode_varint(script_pubkey_bytes.len() as u64); + + result.extend_from_slice(&amount_bytes); + result.extend_from_slice(&compact_size_len); + result.extend_from_slice(&script_pubkey_bytes); + + result + } +} diff --git a/src/lib.rs b/src/lib.rs index 4268806..101de54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +use std::error::Error; + mod ch01_finite_fields; pub use ch01_finite_fields::*; @@ -9,3 +11,20 @@ pub use ch03_ecc::*; mod ch04_serialization; pub use ch04_serialization::*; + +mod ch05_transactions; +pub use ch05_transactions::*; + +use crate::transaction::Transaction; + +pub fn decode(transaction_hex: &str) -> Result> { + let tx_bytes = hex::decode(transaction_hex).map_err(|e| format!("Hex decode error: {}", e))?; + // let transaction = Transaction::consensus_decode(&mut tx_bytes.as_slice()); + Ok(serde_json::to_string_pretty(&Transaction::parse( + &tx_bytes, + ))?) + // serde_json::to_string_pretty(&transaction) + + // println!("Transaction: {}", json_transaction); + // Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 6d02582..e9bd14e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,24 +1,23 @@ -use programming_bitcoin::field_element::FieldElement; -use programming_bitcoin::s256_point::test_point; +use std::env; + +use dotenvy::dotenv; +// use programming_bitcoin::field_element::FieldElement; +// use programming_bitcoin::s256_point::test_point; +use programming_bitcoin::{decode, ser_private_key::PrivateKey}; fn main() { - // Create a new FieldElement - let fe1 = FieldElement::new(3, 7); - let fe2 = FieldElement::new(6, 7); + dotenv().ok(); + + let secret = env::var("PRIVATE_KEY_SECRET").expect("PRIVATE_KEY_SECRET must be set"); + let pk = PrivateKey::new(&secret); + let pub_key = pk.point; + + let test_addr = pub_key.address(false, true); + println!("Compressed testnet address: {test_addr}"); - // Use the repr method - println!("Field element 1: {}", fe1.repr()); - println!("Field element 2: {}", fe2.repr()); + let tx = "010000000456919960ac691763688d3d3bcea9ad6ecaf875df5339e148a1fc61c6ed7a069e010000006a47304402204585bcdef85e6b1c6af5c2669d4830ff86e42dd205c0e089bc2a821657e951c002201024a10366077f87d6bce1f7100ad8cfa8a064b39d4e8fe4ea13a7b71aa8180f012102f0da57e85eec2934a82a585ea337ce2f4998b50ae699dd79f5880e253dafafb7feffffffeb8f51f4038dc17e6313cf831d4f02281c2a468bde0fafd37f1bf882729e7fd3000000006a47304402207899531a52d59a6de200179928ca900254a36b8dff8bb75f5f5d71b1cdc26125022008b422690b8461cb52c3cc30330b23d574351872b7c361e9aae3649071c1a7160121035d5c93d9ac96881f19ba1f686f15f009ded7c62efe85a872e6a19b43c15a2937feffffff567bf40595119d1bb8a3037c356efd56170b64cbcc160fb028fa10704b45d775000000006a47304402204c7c7818424c7f7911da6cddc59655a70af1cb5eaf17c69dadbfc74ffa0b662f02207599e08bc8023693ad4e9527dc42c34210f7a7d1d1ddfc8492b654a11e7620a0012102158b46fbdff65d0172b7989aec8850aa0dae49abfb84c81ae6e5b251a58ace5cfeffffffd63a5e6c16e620f86f375925b21cabaf736c779f88fd04dcad51d26690f7f345010000006a47304402200633ea0d3314bea0d95b3cd8dadb2ef79ea8331ffe1e61f762c0f6daea0fabde022029f23b3e9c30f080446150b23852028751635dcee2be669c2a1686a4b5edf304012103ffd6f4a67e94aba353a00882e563ff2722eb4cff0ad6006e86ee20dfe7520d55feffffff0251430f00000000001976a914ab0c0b2e98b1ab6dbf67d4750b0a56244948a87988ac005a6202000000001976a9143c82d7df364eb6c75be8c80df2b3eda8db57397088ac46430600"; - // Check equality - let fe3 = FieldElement::new(3, 7); - println!("fe1 equals fe3: {}", fe1.equals(&fe3)); - println!("fe1 equals fe2: {}", fe1.equals(&fe2)); - println!("fe1 equals fe2: {}", fe1 == fe3); - println!("fe1 times fe2: {:?}", fe1 * fe2); - println!("fe1 raised to power 6: {:?}", fe1.pow(6)); - println!("fe1 divided by fe2: {:?}", fe1 / fe2); - println!("fe1 raised to power 6: {:?}", fe1.pow(-5)); + let json = decode(tx).unwrap(); - test_point(); + println!("{json}"); } diff --git a/tests/ch04_serialization_tests.rs b/tests/ch04_serialization_tests.rs index 75d5d04..d645bf7 100644 --- a/tests/ch04_serialization_tests.rs +++ b/tests/ch04_serialization_tests.rs @@ -272,9 +272,11 @@ fn test_base58_single_byte() { // UNIT TESTS - WIF Format (Wallet Import Format) // ============================================================ +const SECRET: &str = "secret"; + #[test] fn test_wif_mainnet_uncompressed() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let wif = pk.wif(false, false); // WIF should be a non-empty string @@ -286,7 +288,7 @@ fn test_wif_mainnet_uncompressed() { #[test] fn test_wif_mainnet_compressed() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let wif = pk.wif(true, false); // WIF should be a non-empty string @@ -299,7 +301,7 @@ fn test_wif_mainnet_compressed() { #[test] fn test_wif_testnet_uncompressed() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let wif = pk.wif(false, true); assert!(!wif.is_empty()); @@ -307,7 +309,7 @@ fn test_wif_testnet_uncompressed() { #[test] fn test_wif_testnet_compressed() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let wif = pk.wif(true, true); assert!(!wif.is_empty()); @@ -315,7 +317,7 @@ fn test_wif_testnet_compressed() { #[test] fn test_wif_different_networks() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let mainnet = pk.wif(true, false); let testnet = pk.wif(true, true); @@ -330,7 +332,7 @@ fn test_wif_different_networks() { #[test] fn test_address_mainnet_compressed() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let address = pk.point.address(true, false); // Address should be a non-empty string @@ -342,7 +344,7 @@ fn test_address_mainnet_compressed() { #[test] fn test_address_mainnet_uncompressed() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let address = pk.point.address(false, false); assert!(!address.is_empty()); @@ -350,7 +352,7 @@ fn test_address_mainnet_uncompressed() { #[test] fn test_address_testnet_compressed() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let address = pk.point.address(true, true); assert!(!address.is_empty()); @@ -358,7 +360,7 @@ fn test_address_testnet_compressed() { #[test] fn test_address_testnet_uncompressed() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let address = pk.point.address(false, true); assert!(!address.len() > 0); @@ -366,7 +368,7 @@ fn test_address_testnet_uncompressed() { #[test] fn test_address_different_compression() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let compressed = pk.point.address(true, false); let uncompressed = pk.point.address(false, false); @@ -377,7 +379,7 @@ fn test_address_different_compression() { #[test] fn test_address_different_networks() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let mainnet = pk.point.address(true, false); let testnet = pk.point.address(true, true); @@ -393,7 +395,7 @@ fn test_address_different_networks() { #[test] fn test_complete_key_serialization_workflow() { // Generate key - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); // Get WIF let wif = pk.wif(true, false); @@ -410,7 +412,7 @@ fn test_complete_key_serialization_workflow() { #[test] fn test_signature_serialization_workflow() { - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let z = S256Field::new(12345_u64.to_biguint().unwrap()); // Sign @@ -477,10 +479,10 @@ fn test_der_deterministic() { #[test] fn test_wif_deterministic() { - // Note: PrivateKey::new() uses random generation, so we can't test + // Note: PrivateKey::new(SECRET) uses random generation, so we can't test // determinism directly. This test just ensures WIF is consistent // for the same key object. - let pk = PrivateKey::new(); + let pk = PrivateKey::new(SECRET); let wif1 = pk.wif(true, false); let wif2 = pk.wif(true, false); @@ -573,8 +575,8 @@ fn test_base58_checksum_includes_hash() { #[test] fn test_multiple_keys_unique_wif() { - let pk1 = PrivateKey::new(); - let pk2 = PrivateKey::new(); + let pk1 = PrivateKey::new(SECRET); + let pk2 = PrivateKey::new("another_secret"); let wif1 = pk1.wif(true, false); let wif2 = pk2.wif(true, false); @@ -585,8 +587,8 @@ fn test_multiple_keys_unique_wif() { #[test] fn test_multiple_keys_unique_addresses() { - let pk1 = PrivateKey::new(); - let pk2 = PrivateKey::new(); + let pk1 = PrivateKey::new(SECRET); + let pk2 = PrivateKey::new("another_secret"); let addr1 = pk1.point.address(true, false); let addr2 = pk2.point.address(true, false); @@ -597,8 +599,8 @@ fn test_multiple_keys_unique_addresses() { #[test] fn test_multiple_keys_unique_sec() { - let pk1 = PrivateKey::new(); - let pk2 = PrivateKey::new(); + let pk1 = PrivateKey::new(SECRET); + let pk2 = PrivateKey::new("another_secret"); let sec1 = pk1.point.sec(true); let sec2 = pk2.point.sec(true);