diff --git a/src/stdlib/btc.minsc b/src/stdlib/btc.minsc index febbebb..f007947 100644 --- a/src/stdlib/btc.minsc +++ b/src/stdlib/btc.minsc @@ -68,8 +68,8 @@ fn psbt::finalize_witness($psbt, $input_witnesses) = psbt::update($psbt, [ ) ]); -fn psbt::sign_extract($psbt, $keys) = - psbt::extract(psbt::finalize(psbt::sign($psbt, $keys))); +fn psbt::finalize_extract($psbt) = psbt::extract(psbt::finalize($psbt)); +fn psbt::sign_extract($psbt, $keys) = psbt::extract(psbt::finalize(psbt::sign($psbt, $keys))); // // Script utilities diff --git a/src/stdlib/psbt.rs b/src/stdlib/psbt.rs index 3b6c2d5..512acb2 100644 --- a/src/stdlib/psbt.rs +++ b/src/stdlib/psbt.rs @@ -110,20 +110,16 @@ pub mod fns { Ok((psbt, errors).into()) } - // psbt::sign(Psbt, Xpriv|Array|Array sign_keys, Bool finalize=false) -> Psbt + // psbt::sign(Psbt, Xpriv|Array|Array sign_keys) -> Psbt // // Attempt to sign all transaction inputs, raising an error if any fail. pub fn sign(args: Array, _: &ScopeRef) -> Result { - let (mut psbt, keys, finalize): (_, _, Option) = args.args_into()?; + let (mut psbt, keys) = args.args_into()?; let (_signed, failed) = sign_psbt(&mut psbt, keys)?; ensure!(failed.is_empty(), Error::PsbtSigning(failed)); // XXX check signed? - if finalize.unwrap_or(false) { - psbt.finalize_mut(&EC).map_err(Error::PsbtFinalize)?; - } - Ok(psbt.into()) } @@ -139,15 +135,12 @@ pub mod fns { Ok((psbt, signed, failed).into()) } - /// psbt::extract(Psbt, Bool finalize=false) -> Transaction + /// psbt::extract(Psbt) -> Transaction /// - /// Extract the PSBT finalized transaction. Will run the Miniscript interpreter sanity checks. - /// Also possible using `tx(Psbt)` (without the `finalize` option, for pre-finalized PSBT only) + /// Extract the PSBT finalized transaction (The PSBT must already be finalized). + /// Will run the Miniscript interpreter sanity checks. Also possible using `tx(Psbt)`. pub fn extract(args: Array, _: &ScopeRef) -> Result { - let (mut psbt, finalize): (Psbt, Option) = args.args_into()?; - if finalize.unwrap_or(false) { - psbt.finalize_mut(&EC).map_err(Error::PsbtFinalize)?; - } + let psbt: Psbt = args.arg_into()?; // Uses rust-miniscript's PsbtExt::extract(), which only works with Miniscript-compatible Scripts Ok(psbt.extract(&EC)?.into()) }