Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/wasm-utxo/cli/src/psbt/extract_transparent_only.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
14 changes: 14 additions & 0 deletions packages/wasm-utxo/cli/src/psbt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading