diff --git a/.gitignore b/.gitignore index 6dfb84d0..654825df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /target - +.env *.swp .idea diff --git a/CHANGELOG.md b/CHANGELOG.md index 098eee19..26d13255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details. ## [Unreleased] - Added support for Multipath (two-paths) descriptors. +- Add `env` feature that loads arguments from a .env file via dotenvy ## [4.0.0] diff --git a/Cargo.lock b/Cargo.lock index b88b288f..b551688b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,6 +261,7 @@ dependencies = [ "clap_complete", "cli-table", "dirs", + "dotenvy", "env_logger", "log", "payjoin", @@ -1230,6 +1231,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + [[package]] name = "dunce" version = "1.0.5" diff --git a/Cargo.toml b/Cargo.toml index adc1d9c9..50c541af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,9 +40,13 @@ reqwest = { version = "0.13.2", default-features = false, features = ["rustls"], url = { version = "2.5.8", optional = true } bdk_message_signer = { version = "0.2.0", optional = true } bitcoin-payment-instructions = { version = "0.7.0", optional = true} +dotenvy = { version = "0.15.7", optional = true } [features] -default = ["repl", "sqlite"] +default = ["repl", "sqlite", "env"] + +# Load arguments from a .env file instead of typing them manually +env = ["dotenvy"] # To use the app in a REPL mode repl = ["shlex"] @@ -56,7 +60,7 @@ cbf = ["bdk_kyoto", "_payjoin-dependencies"] electrum = ["bdk_electrum", "_payjoin-dependencies"] esplora = ["bdk_esplora", "_payjoin-dependencies"] rpc = ["bdk_bitcoind_rpc", "_payjoin-dependencies"] -dns_payment = ["bitcoin-payment-instructions"] +dns_payment = ["bitcoin-payment-instructions"] # Internal features _payjoin-dependencies = ["payjoin", "reqwest", "url", "sqlite"] diff --git a/README.md b/README.md index 94278f3c..948025c3 100644 --- a/README.md +++ b/README.md @@ -52,12 +52,13 @@ bdk-cli can be compiled with different features to suit your experimental needs. - `rpc`: Connects the wallet to Bitcoind server. - Extra Utility Tools - `repl` : use bdk-cli as a [REPL](https://codewith.mu/en/tutorials/1.0/repl) shell (useful for quick manual testing of wallet operations). + - `env` : loads arguments from a .env file via dotenvy - `compiler` : opens up bdk-cli policy compiler commands. - `message_signer`: BIP322 message signing/verification. - `silent-payments`: Experimental BIP-352 silent payment sending - `dns_payment`: BIP-353 DNS payment instructions -The `default` feature set is `repl` and `sqlite`. With the `default` features, `bdk-cli` can be used as an **air-gapped** wallet, and can do everything that doesn't require a network connection. +The `default` feature set is `repl`, `env` and `sqlite`. With the `default` features, `bdk-cli` can be used as an **air-gapped** wallet, and can do everything that doesn't require a network connection. ## Install bdk-cli diff --git a/src/main.rs b/src/main.rs index 06e3ea24..47226943 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,6 +34,7 @@ use clap::{CommandFactory, Parser}; #[tokio::main] async fn main() { env_logger::init(); + dotenvy::dotenv().ok(); let cli_opts: CliOpts = CliOpts::parse(); let network = &cli_opts.network;