From 0430926a93392cc2a72a3da1460afcafcfb5fbb3 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Sun, 2 Mar 2025 01:16:04 +0100 Subject: [PATCH] Add receive command --- blacklist.txt | 1 - src/subcommand/wallet/receive.rs | 9 ++++++--- src/wallet.rs | 3 +-- tests/lib.rs | 7 ++++++- tests/wallet/receive.rs | 3 ++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/blacklist.txt b/blacklist.txt index ff4d285f4e..1a459d64b7 100644 --- a/blacklist.txt +++ b/blacklist.txt @@ -181,7 +181,6 @@ wallet::outputs::outputs_includes_runes_and_inscriptions wallet::outputs::outputs_includes_sat_ranges wallet::outputs::outputs_includes_unbound_outputs wallet::pending::wallet_pending -wallet::receive::receive wallet::resume::commitment_output_is_locked wallet::resume::resume_suspended wallet::resume::wallet_resume diff --git a/src/subcommand/wallet/receive.rs b/src/subcommand/wallet/receive.rs index 0087b92529..1c58960f37 100644 --- a/src/subcommand/wallet/receive.rs +++ b/src/subcommand/wallet/receive.rs @@ -12,14 +12,17 @@ pub(crate) struct Receive { } impl Receive { - pub(crate) fn run(self, wallet: Wallet) -> SubcommandResult { + pub(crate) fn run(self, mut wallet: Wallet) -> SubcommandResult { let mut addresses: Vec> = Vec::new(); for _ in 0..self.number.unwrap_or(1) { addresses.push( wallet - .bitcoin_client() - .get_new_address(None, Some(bitcoincore_rpc::json::AddressType::Bech32m))?, + .wallet + .reveal_next_address(bdk_wallet::KeychainKind::External) + .address + .as_unchecked() + .clone(), ); } diff --git a/src/wallet.rs b/src/wallet.rs index 01b35503b0..d8f26840f7 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -70,8 +70,7 @@ pub(crate) struct Wallet { ord_client: reqwest::blocking::Client, rpc_url: Url, settings: Settings, - #[allow(unused)] - wallet: PersistedWallet, + pub(crate) wallet: PersistedWallet, } impl Wallet { diff --git a/tests/lib.rs b/tests/lib.rs index 8e4ee75089..73812cff7e 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -87,12 +87,17 @@ type Send = ord::subcommand::wallet::send::Output; type Split = ord::subcommand::wallet::split::Output; type Supply = ord::subcommand::supply::Output; -fn create_wallet(core: &mockcore::Handle, ord: &TestServer) { +fn create_wallet(core: &mockcore::Handle, ord: &TestServer) -> Arc { + let tempdir = Arc::new(TempDir::new().unwrap()); + CommandBuilder::new(format!("--chain {} wallet create", core.network())) + .temp_dir(tempdir.clone()) .core(core) .ord(ord) .stdout_regex(".*") .run_and_extract_stdout(); + + tempdir } fn sats( diff --git a/tests/wallet/receive.rs b/tests/wallet/receive.rs index 210e32de57..e857067211 100644 --- a/tests/wallet/receive.rs +++ b/tests/wallet/receive.rs @@ -5,9 +5,10 @@ fn receive() { let core = mockcore::spawn(); let ord = TestServer::spawn(&core); - create_wallet(&core, &ord); + let tempdir = create_wallet(&core, &ord); let output = CommandBuilder::new("wallet receive") + .temp_dir(tempdir) .core(&core) .ord(&ord) .run_and_deserialize_output::();