From ec3828b1080fef795143666db1e4e718bd8c6107 Mon Sep 17 00:00:00 2001 From: CalDescent <> Date: Fri, 13 May 2022 15:34:39 +0100 Subject: [PATCH] Added add_transparent_output_with_script_pubkey() --- zcash_primitives/src/transaction/builder.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index d37ff14..4c5bb8f 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -13,6 +13,7 @@ use crate::{ consensus, keys::OutgoingViewingKey, legacy::TransparentAddress, + legacy::Script, merkle_tree::MerklePath, note_encryption::{generate_esk, Memo, SaplingNoteEncryption}, prover::TxProver, @@ -419,6 +420,25 @@ impl Builder { Ok(()) } + /// Adds a transparent address to send funds to, using supplied script pubkey + pub fn add_transparent_output_with_script_pubkey( + &mut self, + to: &TransparentAddress, + value: Amount, + script_pubkey: Script, + ) -> Result<(), Error> { + if value.is_negative() { + return Err(Error::InvalidAmount); + } + + self.mtx.vout.push(TxOut { + value, + script_pubkey + }); + + Ok(()) + } + /// Sets the Sapling address to which any change will be sent. /// /// By default, change is sent to the Sapling address corresponding to the first note