Added add_transparent_output_with_script_pubkey()

This commit is contained in:
CalDescent 2022-05-13 15:34:39 +01:00
parent 82ba685f61
commit ec3828b108

View File

@ -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<R: RngCore + CryptoRng> Builder<R> {
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