Skip to content

Commit

Permalink
Add receive command
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Mar 2, 2025
1 parent d8f11c0 commit 0430926
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion blacklist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/subcommand/wallet/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Address<NetworkUnchecked>> = 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(),
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ pub(crate) struct Wallet {
ord_client: reqwest::blocking::Client,
rpc_url: Url,
settings: Settings,
#[allow(unused)]
wallet: PersistedWallet<DatabasePersister>,
pub(crate) wallet: PersistedWallet<DatabasePersister>,
}

impl Wallet {
Expand Down
7 changes: 6 additions & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TempDir> {
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(
Expand Down
3 changes: 2 additions & 1 deletion tests/wallet/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<receive::Output>();
Expand Down

0 comments on commit 0430926

Please sign in to comment.