diff --git a/packages/wasm-utxo/cli/src/psbt/extract_transparent_only.rs b/packages/wasm-utxo/cli/src/psbt/extract_transparent_only.rs new file mode 100644 index 00000000000..8b196888fa9 --- /dev/null +++ b/packages/wasm-utxo/cli/src/psbt/extract_transparent_only.rs @@ -0,0 +1,25 @@ +use anyhow::{anyhow, Context, Result}; +use std::path::PathBuf; +use wasm_utxo::fixed_script_wallet::bitgo_psbt::ZcashBitGoPsbt; +use wasm_utxo::Network; + +use crate::input::{decode_input, read_input_bytes}; + +/// Finalize transparent inputs and extract the broadcast-ready v6 transaction for a PSBT that +/// has no shielded output (no PCZT). This is the transparent-only v6 counterpart of +/// `combine-ironwood-proof`: it calls `extract_transparent_only_v6_tx()` instead of +/// `combine_ironwood_proof()`. Prints the raw transaction as hex to stdout. +pub fn handle_extract_transparent_only_command(path: PathBuf, network: Network) -> Result<()> { + let raw_bytes = read_input_bytes(&path, "PSBT")?; + let bytes = decode_input(&raw_bytes)?; + let psbt = ZcashBitGoPsbt::deserialize(&bytes, network) + .map_err(|e| anyhow!("Failed to parse v6 PSBT: {e}"))?; + + let tx_bytes = psbt + .extract_transparent_only_v6_tx() + .map_err(|e| anyhow!(e)) + .context("failed to extract transparent-only v6 transaction")?; + + println!("{}", hex::encode(tx_bytes)); + Ok(()) +} diff --git a/packages/wasm-utxo/cli/src/psbt/mod.rs b/packages/wasm-utxo/cli/src/psbt/mod.rs index ac6da5b26c5..caac4d1cb9f 100644 --- a/packages/wasm-utxo/cli/src/psbt/mod.rs +++ b/packages/wasm-utxo/cli/src/psbt/mod.rs @@ -11,6 +11,7 @@ mod combine_ironwood_proof; mod common; mod create; mod create_zcash_v6; +mod extract_transparent_only; mod parse; mod sign; mod sign_v6_input; @@ -174,6 +175,16 @@ pub enum PsbtCommand { #[arg(long)] local_proof: bool, }, + /// Finalize transparent inputs and extract the broadcast-ready v6 transaction for a PSBT + /// that has **no shielded output** (no PCZT). This is the transparent-only v6 counterpart + /// of `combine-ironwood-proof`. Prints the raw transaction as hex to stdout. + ExtractTransparentOnly { + /// Path to the PSBT file (use '-' to read from stdin) + path: PathBuf, + /// Network (must be zec or tzec) + #[arg(long, short, value_enum)] + network: NetworkArg, + }, /// Sign all inputs with a single private key, then finalize and extract. The sighash /// algorithm is selected by --network: plain for BTC-like networks, FORKID for the /// BCH family, or Zcash ZIP-243. Prints the signed wire hex to stdout (overwintered @@ -277,6 +288,9 @@ pub fn handle_command(command: PsbtCommand) -> Result<()> { proof, local_proof, ), + PsbtCommand::ExtractTransparentOnly { path, network } => { + extract_transparent_only::handle_extract_transparent_only_command(path, network.into()) + } PsbtCommand::Sign { path, network,