diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d2ef2c..4f29295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.3.0] + +- Add RPC backend support, after bdk v0.12.0 release - Update default feature to not include electrum - Upgrade to `bdk` v0.12.x - Add top level command "Compile" which compiles a miniscript policy to an output descriptor @@ -38,7 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.1.0-beta.1] -[unreleased]: https://github.com/bitcoindevkit/bdk-cli/compare/v0.2.0...HEAD +[unreleased]: https://github.com/bitcoindevkit/bdk-cli/compare/v0.3.0...HEAD +[0.3.0]: https://github.com/bitcoindevkit/bdk-cli/compare/v0.2.0...v0.3.0 [0.2.0]: https://github.com/bitcoindevkit/bdk-cli/compare/v0.1.0...v0.2.0 [0.1.0]: https://github.com/bitcoindevkit/bdk-cli/compare/0.1.0-beta.1...v0.1.0 [0.1.0-beta.1]: https://github.com/bitcoindevkit/bdk-cli/compare/84a02e35...0.1.0-beta.1 diff --git a/Cargo.lock b/Cargo.lock index 9906bfd..422594ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,7 +71,7 @@ checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" dependencies = [ "addr2line", "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", "miniz_oxide", "object", @@ -118,6 +118,7 @@ dependencies = [ "bdk-macros 0.6.0", "bitcoin", "cc", + "core-rpc", "electrum-client", "futures", "js-sys", @@ -138,14 +139,14 @@ dependencies = [ [[package]] name = "bdk-cli" -version = "0.2.1-dev" +version = "0.3.1-dev" dependencies = [ "base64 0.11.0", "bdk", "bdk-macros 0.4.0", "bdk-reserves", "clap", - "dirs-next 2.0.0", + "dirs-next", "env_logger", "log", "regex", @@ -248,9 +249,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.3.2" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bitvec" @@ -287,9 +288,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.7.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" +checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" [[package]] name = "byte-tools" @@ -311,9 +312,9 @@ checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "cc" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" dependencies = [ "jobserver", ] @@ -327,12 +328,6 @@ dependencies = [ "nom", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -371,11 +366,22 @@ dependencies = [ "vec_map", ] +[[package]] +name = "clipboard-win" +version = "4.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4ea1881992efc993e4dc50a324cdbd03216e41bdc8385720ff47efc9bd2ca8" +dependencies = [ + "error-code", + "str-buf", + "winapi 0.3.9", +] + [[package]] name = "core-foundation" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" dependencies = [ "core-foundation-sys", "libc", @@ -383,9 +389,33 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.2" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core-rpc" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" +checksum = "ec1785f0b884d8a2a2a420e09da1c1d15f36f2a5b85dd19d7331f66777de50ca" +dependencies = [ + "core-rpc-json", + "jsonrpc", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "core-rpc-json" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443b2a9969ea2ecd42a5c717570f7ef127e3dd0d2548c1d0b3713f6fa102d4fa" +dependencies = [ + "bitcoin", + "serde", + "serde_json", +] [[package]] name = "crc32fast" @@ -393,7 +423,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -402,7 +432,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", "lazy_static", "memoffset", @@ -415,7 +445,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "lazy_static", ] @@ -438,23 +468,13 @@ dependencies = [ "generic-array", ] -[[package]] -name = "dirs-next" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf36e65a80337bea855cd4ef9b8401ffce06a7baedf2e85ec467b1ac3f6e82b6" -dependencies = [ - "cfg-if 1.0.0", - "dirs-sys-next", -] - [[package]] name = "dirs-next" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "dirs-sys-next", ] @@ -493,13 +513,19 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.28" +version = "0.8.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" +checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + [[package]] name = "env_logger" version = "0.7.1" @@ -513,6 +539,16 @@ dependencies = [ "termcolor", ] +[[package]] +name = "error-code" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5115567ac25674e0043e472be13d14e537f37ea8aa4bdc4aef0c89add1db1ff" +dependencies = [ + "libc", + "str-buf", +] + [[package]] name = "failure" version = "0.1.8" @@ -541,6 +577,17 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "fd-lock" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8806dd91a06a7a403a8e596f9bfbfb34e469efbc363fc9c9713e79e26472e36" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.9", +] + [[package]] name = "fnv" version = "1.0.7" @@ -706,7 +753,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", @@ -719,7 +766,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] @@ -738,9 +785,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "h2" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f3675cfef6a30c8031cf9e6493ebdc3bb3272a3fea3923c4210d1830e6a472" +checksum = "6c06815895acec637cd6ed6e9662c935b866d20a106f8361892893a7d9234964" dependencies = [ "bytes", "fnv", @@ -791,9 +838,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" +checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" dependencies = [ "bytes", "fnv", @@ -892,11 +939,11 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -929,6 +976,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpc" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad24d69a8a0698db8ffb9048e937e8ae3ee3bc45772a5d7b6979b1d2d5b6a9f7" +dependencies = [ + "base64-compat", + "serde", + "serde_derive", + "serde_json", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -943,17 +1002,17 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.102" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" +checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce" [[package]] name = "libloading" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +checksum = "c0cf036d15402bea3c5d4de17b3fce76b3e4a56ebc1f577be0e7a72f7c607cf0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "winapi 0.3.9", ] @@ -984,7 +1043,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1036,9 +1095,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" dependencies = [ "libc", "log", @@ -1074,16 +1133,26 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + [[package]] name = "nix" -version = "0.18.0" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" +checksum = "d3bb9a13fa32bc5aeb64150cd3f32d6cf4c748f8f8a417cce5d2eb976a8370ba" dependencies = [ "bitflags", "cc", - "cfg-if 0.1.10", + "cfg-if", "libc", + "memoffset", ] [[package]] @@ -1135,7 +1204,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a" dependencies = [ "bitflags", - "cfg-if 1.0.0", + "cfg-if", "foreign-types", "libc", "once_cell", @@ -1150,9 +1219,9 @@ checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" [[package]] name = "openssl-sys" -version = "0.9.66" +version = "0.9.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1996d2d305e561b70d1ee0c53f1542833f4e1ac6ce9a6708b6ff2738ca67dc82" +checksum = "69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058" dependencies = [ "autocfg", "cc", @@ -1178,7 +1247,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "instant", "libc", "redox_syscall", @@ -1222,15 +1291,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb" [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741" [[package]] name = "proc-macro-error" @@ -1270,9 +1339,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" dependencies = [ "unicode-xid", ] @@ -1285,9 +1354,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] @@ -1298,6 +1367,16 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + [[package]] name = "rand" version = "0.7.3" @@ -1426,9 +1505,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.4" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22" +checksum = "66d2927ca2f685faf0fc620ac4834690d29e7abb153add10f5812eef20b5e280" dependencies = [ "base64 0.13.0", "bytes", @@ -1525,17 +1604,22 @@ dependencies = [ [[package]] name = "rustyline" -version = "6.3.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0d5e7b0219a3eadd5439498525d4765c59b7c993ef0c12244865cd2d988413" +checksum = "790487c3881a63489ae77126f57048b42d62d3b2bafbf37453ea19eedb6340d6" dependencies = [ - "cfg-if 0.1.10", - "dirs-next 1.0.2", + "bitflags", + "cfg-if", + "clipboard-win", + "dirs-next", + "fd-lock", "libc", "log", "memchr", "nix", + "radix_trie", "scopeguard", + "smallvec", "unicode-segmentation", "unicode-width", "utf8parse", @@ -1595,9 +1679,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.4.2" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" dependencies = [ "bitflags", "core-foundation", @@ -1679,9 +1763,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "slab" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "sled" @@ -1701,9 +1785,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "socket2" @@ -1733,6 +1817,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "str-buf" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d44a3643b4ff9caf57abcee9c2c621d6c03d9135e0d8b589bd9afb5992cb176a" + [[package]] name = "strsim" version = "0.8.0" @@ -1741,9 +1831,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.23" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa" +checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" dependencies = [ "clap", "lazy_static", @@ -1752,9 +1842,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.16" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck", "proc-macro-error", @@ -1771,9 +1861,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "syn" -version = "1.0.76" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" +checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" dependencies = [ "proc-macro2", "quote", @@ -1782,9 +1872,9 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", @@ -1804,7 +1894,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "rand 0.8.4", "redox_syscall", @@ -1832,18 +1922,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -1868,9 +1958,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5241dd6f21443a3606b432718b166d3cedc962fd4b8bea54a8bc7f514ebda986" +checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" dependencies = [ "tinyvec_macros", ] @@ -1883,9 +1973,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4efe6fc2395938c8155973d7be49fe8d03a843726e285e100a8a383cc0154ce" +checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc" dependencies = [ "autocfg", "bytes", @@ -1940,20 +2030,20 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.27" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ba9ab62b7d6497a8638dfda5e5c4fb3b2d5a7fca4118f2b96151c8ef1a437e" +checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" dependencies = [ "lazy_static", ] @@ -1972,9 +2062,9 @@ checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "unicode-bidi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" [[package]] name = "unicode-normalization" @@ -2092,9 +2182,7 @@ version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ - "cfg-if 1.0.0", - "serde", - "serde_json", + "cfg-if", "wasm-bindgen-macro", ] @@ -2119,7 +2207,7 @@ version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "wasm-bindgen", "web-sys", diff --git a/Cargo.toml b/Cargo.toml index 7765bb6..b55e174 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bdk-cli" -version = "0.2.1-dev" +version = "0.3.1-dev" edition = "2018" authors = ["Alekos Filini ", "Riccardo Casatta ", "Steve Myers "] homepage = "https://bitcoindevkit.org" @@ -21,7 +21,7 @@ base64 = "^0.11" zeroize = { version = "<1.4.0" } # Optional dependencies -rustyline = { version = "6.0", optional = true } +rustyline = { version = "9.0", optional = true } dirs-next = { version = "2.0", optional = true } env_logger = { version = "0.7", optional = true } clap = { version = "2.33", optional = true } @@ -38,6 +38,7 @@ esplora-ureq = ["esplora", "bdk/use-esplora-ureq"] esplora-reqwest = ["esplora", "bdk/use-esplora-reqwest"] compiler = ["bdk/compiler"] compact_filters = ["bdk/compact_filters"] +rpc = ["bdk/rpc"] reserves = ["bdk/electrum", "bdk-reserves", "electrum"] [[bin]] diff --git a/README.md b/README.md index cbb9d42..b0bfeb0 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ RUST_LOG=debug cargo run --features esplora-ureq -- wallet --descriptor "wpkh(tp ``` At most one blockchain feature can be enabled, available blockchain client features are: -`electrum`, `esplora-ureq` (blocking), `esplora-reqwest` (async), and `compact_filters`. +`electrum`, `esplora-ureq` (blocking), `esplora-reqwest` (async), `compact_filters` and `rpc`. ### From crates.io You can the install the binaries for the latest tag of `bdk-cli` with online wallet features @@ -52,6 +52,12 @@ To sync a wallet to the default electrum server: cargo run --features electrum -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync ``` +To sync a wallet to Bitcoin Core node (assuming a regtest node at 127.0.0.1:18443) using the core rpc: + +```shell +cargo run --features rpc -- --network regtest wallet --node 127.0.0.1:18443 --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync +``` + To sync a wallet to Bitcoin Core node (assuming a regtest node at 127.0.0.1:18444) serving compact filters: Note: - This will increase build time by few minutes for the binaries because of `librocksdb`. diff --git a/build.rs b/build.rs index dcd5321..92e4946 100644 --- a/build.rs +++ b/build.rs @@ -5,8 +5,9 @@ fn main() { let esplora = env::var_os("CARGO_FEATURE_ESPLORA").map(|_| "esplora".to_string()); let compact_filters = env::var_os("CARGO_FEATURE_COMPACT_FILTERS").map(|_| "compact_filters".to_string()); + let rpc = env::var_os("CARGO_FEATURE_RPC").map(|_| "rpc".to_string()); - let blockchain_features: Vec = vec![electrum, esplora, compact_filters] + let blockchain_features: Vec = vec![electrum, esplora, compact_filters, rpc] .iter() .map(|f| f.to_owned()) .flatten() diff --git a/src/bdk_cli.rs b/src/bdk_cli.rs index 4f8dc4b..38e3a96 100644 --- a/src/bdk_cli.rs +++ b/src/bdk_cli.rs @@ -25,6 +25,8 @@ use std::fs; use std::path::PathBuf; +#[cfg(feature = "rpc")] +use bitcoin::secp256k1::Secp256k1; use bitcoin::Network; use clap::AppSettings; use log::{debug, error, info, warn}; @@ -43,9 +45,17 @@ use bdk::blockchain::electrum::ElectrumBlockchainConfig; #[cfg(feature = "esplora")] use bdk::blockchain::esplora::EsploraBlockchainConfig; -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] use bdk::blockchain::{AnyBlockchain, AnyBlockchainConfig, ConfigurableBlockchain}; +#[cfg(feature = "rpc")] +use bdk::blockchain::rpc::{wallet_name_from_descriptor, Auth, RpcConfig}; + use bdk::database::BatchDatabase; use bdk::sled; use bdk::sled::Tree; @@ -54,7 +64,12 @@ use bdk::{bitcoin, Error}; use bdk_cli::WalletSubCommand; use bdk_cli::{CliOpts, CliSubCommand, KeySubCommand, OfflineWalletSubCommand, WalletOpts}; -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] use bdk_cli::OnlineWalletSubCommand; #[cfg(feature = "repl")] @@ -69,7 +84,12 @@ const REPL_LINE_SPLIT_REGEX: &str = r#""([^"]*)"|'([^']*)'|([\w\-]+)"#; version = option_env ! ("CARGO_PKG_VERSION").unwrap_or("unknown"), author = option_env ! ("CARGO_PKG_AUTHORS").unwrap_or(""))] pub enum ReplSubCommand { - #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" + ))] #[structopt(flatten)] OnlineWalletSubCommand(OnlineWalletSubCommand), #[structopt(flatten)] @@ -107,7 +127,12 @@ fn open_database(wallet_opts: &WalletOpts) -> Tree { tree } -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] fn new_online_wallet( network: Network, wallet_opts: &WalletOpts, @@ -163,6 +188,34 @@ where }) }; + #[cfg(feature = "rpc")] + let config: AnyBlockchainConfig = { + let auth = Auth::UserPass { + username: wallet_opts.rpc_opts.auth.0.clone(), + password: wallet_opts.rpc_opts.auth.1.clone(), + }; + + // Use deterministic wallet name derived from descriptor + let wallet_name = wallet_name_from_descriptor( + &wallet_opts.descriptor[..], + wallet_opts.change_descriptor.as_deref(), + network, + &Secp256k1::new(), + )?; + + let mut rpc_url = "http://".to_string(); + rpc_url.push_str(&wallet_opts.rpc_opts.address[..]); + + let rpc_config = RpcConfig { + url: rpc_url, + auth, + network, + wallet_name, + skip_blocks: wallet_opts.rpc_opts.skip_blocks, + }; + + AnyBlockchainConfig::Rpc(rpc_config) + }; let descriptor = wallet_opts.descriptor.as_str(); let change_descriptor = wallet_opts.change_descriptor.as_deref(); @@ -214,7 +267,12 @@ fn main() { fn handle_command(cli_opts: CliOpts, network: Network) -> Result { let result = match cli_opts.subcommand { - #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" + ))] CliSubCommand::Wallet { wallet_opts, subcommand: WalletSubCommand::OnlineWalletSubCommand(online_subcommand), @@ -255,13 +313,19 @@ fn handle_command(cli_opts: CliOpts, network: Network) -> Result CliSubCommand::Repl { wallet_opts } => { let database = open_database(&wallet_opts); - #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" + ))] let wallet = new_online_wallet(network, &wallet_opts, database)?; #[cfg(not(any( feature = "electrum", feature = "esplora", - feature = "compact_filters" + feature = "compact_filters", + feature = "rpc" )))] let wallet = new_offline_wallet(network, &wallet_opts, database)?; @@ -307,7 +371,8 @@ fn handle_command(cli_opts: CliOpts, network: Network) -> Result #[cfg(any( feature = "electrum", feature = "esplora", - feature = "compact_filters" + feature = "compact_filters", + feature = "rpc" ))] ReplSubCommand::OnlineWalletSubCommand(online_subcommand) => { bdk_cli::handle_online_wallet_subcommand(&wallet, online_subcommand) diff --git a/src/lib.rs b/src/lib.rs index 096ed13..e44fee9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -99,7 +99,12 @@ pub extern crate bdk; #[macro_use] extern crate serde_json; -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] #[macro_use] extern crate bdk_macros; @@ -110,18 +115,33 @@ pub use structopt; use structopt::StructOpt; use crate::OfflineWalletSubCommand::*; -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] use crate::OnlineWalletSubCommand::*; #[cfg(feature = "reserves")] use bdk::bitcoin::blockdata::transaction::TxOut; use bdk::bitcoin::consensus::encode::{deserialize, serialize, serialize_hex}; -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] use bdk::bitcoin::hashes::hex::FromHex; use bdk::bitcoin::secp256k1::Secp256k1; use bdk::bitcoin::util::bip32::{DerivationPath, ExtendedPrivKey, KeySource}; use bdk::bitcoin::util::psbt::PartiallySignedTransaction; use bdk::bitcoin::{Address, Network, OutPoint, Script, Txid}; -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] use bdk::blockchain::{log_progress, Blockchain}; use bdk::database::BatchDatabase; use bdk::descriptor::Segwitv0; @@ -150,7 +170,7 @@ use bdk_reserves::reserves::{verify_proof, ProofOfReserves}; /// # Example /// /// ``` -/// # #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +/// # #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters", feature = "rpc"))] /// # { /// # use bdk::bitcoin::Network; /// # use structopt::StructOpt; @@ -159,6 +179,8 @@ use bdk_reserves::reserves::{verify_proof, ProofOfReserves}; /// # use bdk_cli::ElectrumOpts; /// # #[cfg(feature = "esplora")] /// # use bdk_cli::EsploraOpts; +/// # #[cfg(feature = "rpc")] +/// # use bdk_cli::RpcOpts; /// # #[cfg(feature = "compact_filters")] /// # use bdk_cli::CompactFilterOpts; /// # #[cfg(any(feature = "compact_filters", feature = "electrum", feature="esplora"))] @@ -200,6 +222,12 @@ use bdk_reserves::reserves::{verify_proof, ProofOfReserves}; /// conc: 4, /// stop_gap: 10 /// }, +/// #[cfg(feature = "rpc")] +/// rpc_opts: RpcOpts{ +/// address: "127.0.0.1:18443".to_string(), +/// auth: ("user".to_string(), "password".to_string()), +/// skip_blocks: None, +/// }, /// #[cfg(feature = "compact_filters")] /// compactfilter_opts: CompactFilterOpts{ /// address: vec!["127.0.0.1:18444".to_string()], @@ -222,6 +250,7 @@ use bdk_reserves::reserves::{verify_proof, ProofOfReserves}; /// assert_eq!(expected_cli_opts, cli_opts); /// # } /// ``` + #[derive(Debug, StructOpt, Clone, PartialEq)] #[structopt(name = "BDK CLI", version = option_env ! ("CARGO_PKG_VERSION").unwrap_or("unknown"), @@ -309,7 +338,12 @@ pub enum CliSubCommand { /// client and network connection and an [`OfflineWalletSubCommand`] does not. #[derive(Debug, StructOpt, Clone, PartialEq)] pub enum WalletSubCommand { - #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" + ))] #[structopt(flatten)] OnlineWalletSubCommand(OnlineWalletSubCommand), #[structopt(flatten)] @@ -334,6 +368,8 @@ pub enum WalletSubCommand { /// # use bdk_cli::EsploraOpts; /// # #[cfg(feature = "compact_filters")] /// # use bdk_cli::CompactFilterOpts; +/// # #[cfg(feature = "rpc")] +/// # use bdk_cli::RpcOpts; /// # #[cfg(any(feature = "compact_filters", feature = "electrum", feature="esplora"))] /// # use bdk_cli::ProxyOpts; /// @@ -375,6 +411,12 @@ pub enum WalletSubCommand { /// conn_count: 4, /// skip_blocks: 0, /// }, +/// #[cfg(feature = "rpc")] +/// rpc_opts: RpcOpts{ +/// address: "127.0.0.1:18443".to_string(), +/// auth: ("user".to_string(), "password".to_string()), +/// skip_blocks: None, +/// }, /// #[cfg(any(feature="compact_filters", feature="electrum", feature="esplora"))] /// proxy_opts: ProxyOpts{ /// proxy: None, @@ -385,6 +427,7 @@ pub enum WalletSubCommand { /// /// assert_eq!(expected_wallet_opts, wallet_opts); /// ``` + #[derive(Debug, StructOpt, Clone, PartialEq)] pub struct WalletOpts { /// Selects the wallet to use @@ -413,6 +456,9 @@ pub struct WalletOpts { #[cfg(feature = "compact_filters")] #[structopt(flatten)] pub compactfilter_opts: CompactFilterOpts, + #[cfg(feature = "rpc")] + #[structopt(flatten)] + pub rpc_opts: RpcOpts, #[cfg(any(feature = "compact_filters", feature = "electrum", feature = "esplora"))] #[structopt(flatten)] pub proxy_opts: ProxyOpts, @@ -471,6 +517,33 @@ pub struct CompactFilterOpts { pub skip_blocks: usize, } +#[cfg(feature = "rpc")] +#[derive(Debug, StructOpt, Clone, PartialEq)] +pub struct RpcOpts { + /// Sets the full node address for rpc connection + #[structopt( + name = "ADDRESS:PORT", + short = "n", + long = "node", + default_value = "127.0.0.1:18443" + )] + pub address: String, + + /// Sets the rpc authentication username:password + #[structopt( + name = "USER:PASSWD", + short = "a", + long = "auth", + parse(try_from_str = parse_proxy_auth), + default_value = "user:password", + )] + pub auth: (String, String), + + /// Optionally skip initial `skip_blocks` blocks + #[structopt(name = "SKIP_BLOCKS", short = "s", long = "skip-blocks")] + pub skip_blocks: Option, +} + /// Electrum options /// /// Electrum blockchain client information used by [`OnlineWalletSubCommand`]s. @@ -726,7 +799,12 @@ blockchain client and network connection. )] #[derive(Debug, StructOpt, Clone, PartialEq)] #[structopt(rename_all = "snake")] -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] pub enum OnlineWalletSubCommand { /// Syncs with the chosen blockchain server Sync { @@ -789,8 +867,12 @@ fn parse_recipient(s: &str) -> Result<(Script, u64), String> { Ok((addr.unwrap().script_pubkey(), val.unwrap())) } - -#[cfg(any(feature = "electrum", feature = "compact_filters", feature = "esplora"))] +#[cfg(any( + feature = "electrum", + feature = "compact_filters", + feature = "esplora", + feature = "rpc" +))] fn parse_proxy_auth(s: &str) -> Result<(String, String), String> { let parts: Vec<_> = s.split(':').collect(); if parts.len() != 2 { @@ -998,7 +1080,12 @@ where /// /// Online wallet sub-commands are described in [`OnlineWalletSubCommand`]. See [`crate`] for /// example usage. -#[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] +#[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" +))] #[maybe_async] pub fn handle_online_wallet_subcommand( wallet: &Wallet, @@ -1288,12 +1375,19 @@ mod test { #[cfg(feature = "esplora")] use crate::EsploraOpts; use crate::OfflineWalletSubCommand::{CreateTx, GetNewAddress}; - #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" + ))] use crate::OnlineWalletSubCommand::{Broadcast, Sync}; #[cfg(feature = "reserves")] use crate::OnlineWalletSubCommand::{ProduceProof, VerifyProof}; #[cfg(any(feature = "compact_filters", feature = "electrum", feature = "esplora"))] use crate::ProxyOpts; + #[cfg(feature = "rpc")] + use crate::RpcOpts; use crate::{handle_key_subcommand, CliSubCommand, KeySubCommand, WalletSubCommand}; #[cfg(feature = "reserves")] use crate::{handle_online_wallet_subcommand, handle_reserves_subcommand}; @@ -1359,7 +1453,13 @@ mod test { proxy: None, proxy_auth: None, retries: 5, - } + }, + #[cfg(feature = "rpc")] + rpc_opts: RpcOpts { + address: "127.0.0.1:18443".to_string(), + auth: ("user".to_string(), "password".to_string()), + skip_blocks: None, + }, }, subcommand: WalletSubCommand::OfflineWalletSubCommand(GetNewAddress), }, @@ -1398,6 +1498,12 @@ mod test { proxy: Some("127.0.0.1:9150".to_string()), proxy_auth: None, retries: 3, + }, + #[cfg(feature = "rpc")] + rpc_opts: RpcOpts { + address: "127.0.0.1:18443".to_string(), + auth: ("user".to_string(), "password".to_string()), + skip_blocks: None, } }, subcommand: WalletSubCommand::OfflineWalletSubCommand(GetNewAddress), @@ -1487,6 +1593,63 @@ mod test { assert_eq!(expected_cli_opts, cli_opts); } + #[cfg(feature = "rpc")] + #[test] + fn test_parse_wallet_rpc() { + let cli_args = vec!["bdk-cli", "--network", "bitcoin", "wallet", + "--descriptor", "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)", + "--change_descriptor", "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)", + "--node", "125.67.89.101:56678", + "--auth", "user:password", + "--skip-blocks", "5", + "get_new_address"]; + + let cli_opts = CliOpts::from_iter(&cli_args); + + let expected_cli_opts = CliOpts { + network: Network::Bitcoin, + subcommand: CliSubCommand::Wallet { + wallet_opts: WalletOpts { + wallet: "main".to_string(), + verbose: false, + descriptor: "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), + change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), + #[cfg(feature = "electrum")] + electrum_opts: ElectrumOpts { + timeout: None, + server: "ssl://electrum.blockstream.info:60002".to_string(), + }, + #[cfg(feature = "esplora")] + esplora_opts: EsploraOpts { + server: "https://blockstream.info/api/".to_string(), + concurrency: 5, + }, + #[cfg(feature = "compact_filters")] + compactfilter_opts: CompactFilterOpts{ + address: vec!["127.0.0.1:18444".to_string()], + skip_blocks: 0, + conn_count: 4, + }, + #[cfg(any(feature="compact_filters", feature="electrum"))] + proxy_opts: ProxyOpts{ + proxy: None, + proxy_auth: None, + retries: 5, + }, + #[cfg(feature = "rpc")] + rpc_opts: RpcOpts { + address: "125.67.89.101:56678".to_string(), + auth: ("user".to_string(), "password".to_string()), + skip_blocks: Some(5), + }, + }, + subcommand: WalletSubCommand::OfflineWalletSubCommand(GetNewAddress), + }, + }; + + assert_eq!(expected_cli_opts, cli_opts); + } + #[cfg(feature = "compact_filters")] #[test] fn test_parse_wallet_compact_filters() { @@ -1528,7 +1691,12 @@ mod test { assert_eq!(expected_cli_opts, cli_opts); } - #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" + ))] #[test] fn test_parse_wallet_sync() { let cli_args = vec!["bdk-cli", "--network", "testnet", "wallet", @@ -1575,7 +1743,13 @@ mod test { proxy: None, proxy_auth: None, retries: 5, - } + }, + #[cfg(feature = "rpc")] + rpc_opts: RpcOpts { + address: "127.0.0.1:18443".to_string(), + auth: ("user".to_string(), "password".to_string()), + skip_blocks: None, + }, }, subcommand: WalletSubCommand::OnlineWalletSubCommand(Sync { max_addresses: Some(50) @@ -1650,7 +1824,13 @@ mod test { proxy: None, proxy_auth: None, retries: 5, - } + }, + #[cfg(feature = "rpc")] + rpc_opts: RpcOpts { + address: "127.0.0.1:18443".to_string(), + auth: ("user".to_string(), "password".to_string()), + skip_blocks: None, + }, }, subcommand: WalletSubCommand::OfflineWalletSubCommand(CreateTx { recipients: vec![(script1, 123456), (script2, 78910)], @@ -1669,7 +1849,12 @@ mod test { assert_eq!(expected_cli_opts, cli_opts); } - #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))] + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" + ))] #[test] fn test_parse_wallet_broadcast() { let cli_args = vec!["bdk-cli", "--network", "testnet", "wallet", @@ -1717,7 +1902,13 @@ mod test { proxy: None, proxy_auth: None, retries: 5, - } + }, + #[cfg(feature = "rpc")] + rpc_opts: RpcOpts { + address: "127.0.0.1:18443".to_string(), + auth: ("user".to_string(), "password".to_string()), + skip_blocks: None, + }, }, subcommand: WalletSubCommand::OnlineWalletSubCommand(Broadcast { psbt: Some("cHNidP8BAEICAAAAASWhGE1AhvtO+2GjJHopssFmgfbq+WweHd8zN/DeaqmDAAAAAAD/////AQAAAAAAAAAABmoEAAECAwAAAAAAAAA=".to_string()),