fn finalize_transaction<K>(
		&mut self,
		keychain: &K,
		final_sig: &secp::Signature,
	) -> Result<(), Error>
	where
		K: Keychain,
	{
		let kernel_offset = self.tx.offset;

		self.check_fees()?;

		let mut final_tx = self.tx.clone();

		// build the final excess based on final tx and offset
		let final_excess = {
			// sum the input/output commitments on the final tx
			let overage = final_tx.fee() as i64;
			let tx_excess = final_tx.sum_commitments(overage)?;

			// subtract the kernel_excess (built from kernel_offset)
			let offset_excess = keychain
				.secp()
				.commit(0, kernel_offset.secret_key(&keychain.secp())?)?;
			keychain
				.secp()
				.commit_sum(vec![tx_excess], vec![offset_excess])?
		};

		// update the tx kernel to reflect the offset excess and sig
		assert_eq!(final_tx.kernels().len(), 1);
		final_tx.kernels_mut()[0].excess = final_excess.clone();
		final_tx.kernels_mut()[0].excess_sig = final_sig.clone();

		// confirm the kernel verifies successfully before proceeding
		debug!("Validating final transaction");
		final_tx.kernels()[0].verify()?;

		// confirm the overall transaction is valid (including the updated kernel)
		let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
		let _ = final_tx.validate(verifier_cache)?;

		self.tx = final_tx;
		Ok(())
	}
/// builds a final transaction after the aggregated sig exchange
builds a final transaction after the aggregated sig exchange
builds a final transaction after the aggregated sig exchange
fn finalize_transaction<K>(
		&mut self,
		keychain: &K,
		final_sig: &secp::Signature,
	) -> Result<(), Error>
	where
		K: Keychain,
	{
		let kernel_offset = self.tx.offset;
		self.check_fees()?;
		let mut final_tx = self.tx.clone();
		// build the final excess based on final tx and offset
		let final_excess = {
			// sum the input/output commitments on the final tx
			let overage = final_tx.fee() as i64;
			let tx_excess = final_tx.sum_commitments(overage)?;
			// subtract the kernel_excess (built from kernel_offset)
			let offset_excess = keychain
				.secp()
				.commit(0, kernel_offset.secret_key(&keychain.secp())?)?;
			keychain
				.secp()
				.commit_sum(vec![tx_excess], vec![offset_excess])?
		};
		// update the tx kernel to reflect the offset excess and sig
		assert_eq!(final_tx.kernels().len(), 1);
		final_tx.kernels_mut()[0].excess = final_excess.clone();
		final_tx.kernels_mut()[0].excess_sig = final_sig.clone();
		// confirm the kernel verifies successfully before proceeding
		debug!("Validating final transaction");
		final_tx.kernels()[0].verify()?;
		// confirm the overall transaction is valid (including the updated kernel)
		let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
		let _ = final_tx.validate(verifier_cache)?;
		self.tx = final_tx;
		Ok(())
	}
fn finalize_transaction < K > ( & mut self , keychain : & K , final_sig : & secp :: Signature , ) -> Result < ( ) , Error > where K : Keychain , { let kernel_offset = self . tx . offset ; self . check_fees ( ) ? ; let mut final_tx = self . tx . clone ( ) ; // build the final excess based on final tx and offset let final_excess = { // sum the input/output commitments on the final tx let overage = final_tx . fee ( ) as i64 ; let tx_excess = final_tx . sum_commitments ( overage ) ? ; // subtract the kernel_excess (built from kernel_offset) let offset_excess = keychain . secp ( ) . commit ( 0 , kernel_offset . secret_key ( & keychain . secp ( ) ) ? ) ? ; keychain . secp ( ) . commit_sum ( vec ! [ tx_excess ] , vec ! [ offset_excess ] ) ? } ; // update the tx kernel to reflect the offset excess and sig assert_eq ! ( final_tx kernels ( ) len ( ) 1 ) ; final_tx . kernels_mut ( ) [ 0 ] . excess = final_excess . clone ( ) ; final_tx . kernels_mut ( ) [ 0 ] . excess_sig = final_sig . clone ( ) ; // confirm the kernel verifies successfully before proceeding debug ! ( " " ) ; final_tx . kernels ( ) [ 0 ] . verify ( ) ? ; // confirm the overall transaction is valid (including the updated kernel) let verifier_cache = Arc :: new ( RwLock :: new ( LruVerifierCache :: new ( ) ) ) ; let _ = final_tx . validate ( verifier_cache ) ? ; self . tx = final_tx ; Ok ( ( ) ) }
builds a final transaction after the aggregated sig exchange
builds a final transaction after the aggregated sig exchange
&mut self
keychain
&K
final_sig
&secp::Signature