diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index dc60bd1..b149105 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -142,6 +142,7 @@ struct TransparentInputInfo { pubkey: [u8; secp256k1::constants::PUBLIC_KEY_SIZE], coin: TxOut, secret: Vec, + redeem_script: Vec, } #[cfg(feature = "transparent-inputs")] @@ -173,6 +174,7 @@ impl TransparentInputs { utxo: OutPoint, coin: TxOut, secret: Vec, + redeem_script: Vec, ) -> Result<(), Error> { if coin.value.is_negative() { return Err(Error::InvalidAmount); @@ -192,7 +194,7 @@ impl TransparentInputs { } mtx.vin.push(TxIn::new(utxo)); - self.inputs.push(TransparentInputInfo { sk, pubkey, coin, secret }); + self.inputs.push(TransparentInputInfo { sk, pubkey, coin, secret, redeem_script }); Ok(()) } @@ -234,9 +236,9 @@ impl TransparentInputs { let mut sig_bytes: Vec = sig.serialize_der()[..].to_vec(); sig_bytes.extend(&[SIGHASH_ALL as u8]); - if (&info.secret.len() > 0) { + if (!&info.secret.is_empty()) { // Include secret and redeem script - mtx.vin[i].script_sig = Script::default() << &info.secret[..] << &sig_bytes[..] << &info.pubkey[..] << &info.coin.script_pubkey[..]; + mtx.vin[i].script_sig = Script::default() << &info.secret[..] << &sig_bytes[..] << &info.pubkey[..] << &info.redeem_script[..]; } else { // P2PKH scriptSig @@ -406,7 +408,7 @@ impl Builder { utxo: OutPoint, coin: TxOut, ) -> Result<(), Error> { - self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin, Vec::new()) + self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin, Vec::new(), Vec::new()) } /// Adds a transparent coin to be spent in this transaction, with HTLC secret. @@ -417,8 +419,9 @@ impl Builder { utxo: OutPoint, coin: TxOut, secret: Vec, + redeem_script: Vec, ) -> Result<(), Error> { - self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin, secret) + self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin, secret, redeem_script) } /// Adds a transparent address to send funds to.