diff --git a/src/subcommand/preview.rs b/src/subcommand/preview.rs index 1b1cd09104..d9f402e47e 100644 --- a/src/subcommand/preview.rs +++ b/src/subcommand/preview.rs @@ -85,6 +85,7 @@ impl Preview { satpoint: None, dry_run: false, no_limit: false, + destination: None, }, )), } diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index 93269f2080..92a33b21e2 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -52,6 +52,8 @@ pub(crate) struct Inscribe { pub(crate) no_limit: bool, #[clap(long, help = "Don't sign or broadcast transactions.")] pub(crate) dry_run: bool, + #[clap(long, help = "Send inscription to .")] + pub(crate) destination: Option
, } impl Inscribe { @@ -69,7 +71,10 @@ impl Inscribe { let commit_tx_change = [get_change_address(&client)?, get_change_address(&client)?]; - let reveal_tx_destination = get_change_address(&client)?; + let reveal_tx_destination = self + .destination + .map(Ok) + .unwrap_or_else(|| get_change_address(&client))?; let (unsigned_commit_tx, reveal_tx, recovery_key_pair) = Inscribe::create_inscription_transactions( diff --git a/tests/wallet/inscribe.rs b/tests/wallet/inscribe.rs index 09a89ba222..4be097c8dd 100644 --- a/tests/wallet/inscribe.rs +++ b/tests/wallet/inscribe.rs @@ -355,6 +355,33 @@ fn inscribe_with_dry_run_flag_fees_inscrease() { assert!(total_fee_dry_run < total_fee_normal); } +#[test] +fn inscribe_to_specific_destination() { + let rpc_server = test_bitcoincore_rpc::spawn(); + create_wallet(&rpc_server); + rpc_server.mine_blocks(1); + + let destination = CommandBuilder::new("wallet receive") + .rpc_server(&rpc_server) + .output::() + .address; + + let txid = CommandBuilder::new(format!( + "wallet inscribe --destination {destination} degenerate.png" + )) + .write("degenerate.png", [1; 520]) + .rpc_server(&rpc_server) + .output::() + .reveal; + + let reveal_tx = &rpc_server.mempool()[1]; // item 0 is the commit, item 1 is the reveal. + assert_eq!(reveal_tx.txid(), txid); + assert_eq!( + reveal_tx.output.first().unwrap().script_pubkey, + destination.script_pubkey() + ); +} + #[test] fn inscribe_with_no_limit() { let rpc_server = test_bitcoincore_rpc::spawn();