/// Commits an UnblindedOutput into a Transaction input
Commits an UnblindedOutput into a Transaction input
Commits an UnblindedOutput into a Transaction input
pub fn as_transaction_input(&self, factory: &CommitmentFactory) -> Result<TransactionInput, TransactionError> {
        let commitment = factory.commit(&self.spending_key, &self.value.into());
        let script_nonce_a = PrivateKey::random(&mut OsRng);
        let script_nonce_b = PrivateKey::random(&mut OsRng);
        let nonce_commitment = factory.commit(&script_nonce_b, &script_nonce_a);
        let challenge = TransactionInput::build_script_challenge(
            &nonce_commitment,
            &self.script,
            &self.input_data,
            &PublicKey::from_secret_key(&self.script_private_key),
            &commitment,
        );
        let script_signature = ComSignature::sign(
            self.value.into(),
            &self.script_private_key + &self.spending_key,
            script_nonce_a,
            script_nonce_b,
            &challenge,
            factory,
        )
        .map_err(|_| TransactionError::InvalidSignatureError("Generating script signature".to_string()))?;
        Ok(TransactionInput {
            features: self.features.clone(),
            commitment,
            script: self.script.clone(),
            input_data: self.input_data.clone(),
            script_signature,
            sender_offset_public_key: self.sender_offset_public_key.clone(),
        })
    }
pub fn as_transaction_input ( & self , factory : & CommitmentFactory ) -> Result < TransactionInput , TransactionError > { let commitment = factory . commit ( & self . spending_key , & self . value . into ( ) ) ; let script_nonce_a = PrivateKey :: random ( & mut OsRng ) ; let script_nonce_b = PrivateKey :: random ( & mut OsRng ) ; let nonce_commitment = factory . commit ( & script_nonce_b , & script_nonce_a ) ; let challenge = TransactionInput :: build_script_challenge ( & nonce_commitment , & self . script , & self . input_data , & PublicKey :: from_secret_key ( & self . script_private_key ) , & commitment , ) ; let script_signature = ComSignature :: sign ( self . value . into ( ) , & self . script_private_key + & self . spending_key , script_nonce_a , script_nonce_b , & challenge , factory , ) . map_err ( | _ | TransactionError :: InvalidSignatureError ( " " . to_string ( ) ) ) ? ; Ok ( TransactionInput { features : self . features . clone ( ) , commitment , script : self . script . clone ( ) , input_data : self . input_data . clone ( ) , script_signature , sender_offset_public_key : self . sender_offset_public_key . clone ( ) , } ) }
Commits an UnblindedOutput into a Transaction input
Commits an UnblindedOutput into a Transaction input
&self
factory
&CommitmentFactory