pub fn verify_payment_proof<'a, L, C, K>(
	wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
	keychain_mask: Option<&SecretKey>,
	proof: &PaymentProof,
) -> Result<(bool, bool), Error>
where
	L: WalletLCProvider<'a, C, K>,
	C: NodeClient + 'a,
	K: Keychain + 'a,
{
	let sender_pubkey = proof.sender_address.clone().public_key;
	let msg = tx::payment_proof_message(proof.amount, &proof.excess, sender_pubkey)?;

	let (client, parent_key_id, keychain) = {
		wallet_lock!(wallet_inst, w);
		(
			w.w2n_client().clone(),
			w.parent_key_id(),
			w.keychain(keychain_mask)?,
		)
	};

	// Check kernel exists
	match client.get_kernel(&proof.excess, None, None) {
		Err(e) => {
			return Err(ErrorKind::PaymentProof(format!(
				"Error retrieving kernel from chain: {}",
				e
			))
			.into());
		}
		Ok(None) => {
			return Err(ErrorKind::PaymentProof(format!(
				"Transaction kernel with excess {:?} not found on chain",
				proof.excess
			))
			.into());
		}
		Ok(Some(_)) => {}
	};

	// Check Sigs
	let recipient_pubkey = proof.recipient_address.public_key()?;
	//	std::str::from_utf8(&msg).unwrap(),
	crypto::verify_signature(
		&msg,
		&crypto::signature_from_string(&proof.recipient_sig).unwrap(),
		&recipient_pubkey,
	)
	.map_err(|e| ErrorKind::TxProofVerifySignature(format!("{}", e)))?;

	let sender_pubkey = proof.sender_address.public_key()?;

	crypto::verify_signature(
		&msg,
		&crypto::signature_from_string(&proof.sender_sig).unwrap(),
		&sender_pubkey,
	)
	.map_err(|e| ErrorKind::TxProofVerifySignature(format!("{}", e)))?;

	let my_address_pubkey =
		proofaddress::payment_proof_address_pubkey(&keychain, &parent_key_id, 0)?;
	let sender_mine = my_address_pubkey == sender_pubkey;
	let recipient_mine = my_address_pubkey == recipient_pubkey;

	Ok((sender_mine, recipient_mine))
}
/// Verify/validate arbitrary payment proof
/// Returns (whether this wallet is the sender, whether this wallet is the recipient)
Verify/validate arbitrary payment proof
Returns (whether this wallet is the sender, whether this wallet is the recipient)
Verify / validate arbitrary payment proof Returns ( whether this wallet is the sender whether this wallet is the recipient )
pub fn verify_payment_proof<'a, L, C, K>(
	wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
	keychain_mask: Option<&SecretKey>,
	proof: &PaymentProof,
) -> Result<(bool, bool), Error>
where
	L: WalletLCProvider<'a, C, K>,
	C: NodeClient + 'a,
	K: Keychain + 'a,
{
	let sender_pubkey = proof.sender_address.clone().public_key;
	let msg = tx::payment_proof_message(proof.amount, &proof.excess, sender_pubkey)?;
	let (client, parent_key_id, keychain) = {
		wallet_lock!(wallet_inst, w);
		(
			w.w2n_client().clone(),
			w.parent_key_id(),
			w.keychain(keychain_mask)?,
		)
	};
	// Check kernel exists
	match client.get_kernel(&proof.excess, None, None) {
		Err(e) => {
			return Err(ErrorKind::PaymentProof(format!(
				"Error retrieving kernel from chain: {}",
				e
			))
			.into());
		}
		Ok(None) => {
			return Err(ErrorKind::PaymentProof(format!(
				"Transaction kernel with excess {:?} not found on chain",
				proof.excess
			))
			.into());
		}
		Ok(Some(_)) => {}
	};
	// Check Sigs
	let recipient_pubkey = proof.recipient_address.public_key()?;
	//	std::str::from_utf8(&msg).unwrap(),
	crypto::verify_signature(
		&msg,
		&crypto::signature_from_string(&proof.recipient_sig).unwrap(),
		&recipient_pubkey,
	)
	.map_err(|e| ErrorKind::TxProofVerifySignature(format!("{}", e)))?;
	let sender_pubkey = proof.sender_address.public_key()?;
	crypto::verify_signature(
		&msg,
		&crypto::signature_from_string(&proof.sender_sig).unwrap(),
		&sender_pubkey,
	)
	.map_err(|e| ErrorKind::TxProofVerifySignature(format!("{}", e)))?;
	let my_address_pubkey =
		proofaddress::payment_proof_address_pubkey(&keychain, &parent_key_id, 0)?;
	let sender_mine = my_address_pubkey == sender_pubkey;
	let recipient_mine = my_address_pubkey == recipient_pubkey;
	Ok((sender_mine, recipient_mine))
}
pub fn verify_payment_proof < ' a , L , C , K > ( wallet_inst : Arc < Mutex < Box < dyn WalletInst < ' a , L , C , K > > > > , keychain_mask : Option < & SecretKey > , proof : & PaymentProof , ) -> Result < ( bool , bool ) , Error > where L : WalletLCProvider < ' a , C , K > , C : NodeClient + ' a , K : Keychain + ' a , { let sender_pubkey = proof . sender_address . clone ( ) . public_key ; let msg = tx :: payment_proof_message ( proof . amount , & proof . excess , sender_pubkey ) ? ; let ( client , parent_key_id , keychain ) = { wallet_lock ! ( wallet_inst w ) ; ( w . w2n_client ( ) . clone ( ) , w . parent_key_id ( ) , w . keychain ( keychain_mask ) ? , ) } ; // Check kernel exists match client . get_kernel ( & proof . excess , None , None ) { Err ( e ) => { return Err ( ErrorKind :: PaymentProof ( format ! ( " " e ) ) . into ( ) ) ; } Ok ( None ) => { return Err ( ErrorKind :: PaymentProof ( format ! ( " " proof excess ) ) . into ( ) ) ; } Ok ( Some ( _ ) ) => { } } ; // Check Sigs let recipient_pubkey = proof . recipient_address . public_key ( ) ? ; //	std::str::from_utf8(&msg).unwrap(), crypto :: verify_signature ( & msg , & crypto :: signature_from_string ( & proof . recipient_sig ) . unwrap ( ) , & recipient_pubkey , ) . map_err ( | e | ErrorKind :: TxProofVerifySignature ( format ! ( " " e ) ) ) ? ; let sender_pubkey = proof . sender_address . public_key ( ) ? ; crypto :: verify_signature ( & msg , & crypto :: signature_from_string ( & proof . sender_sig ) . unwrap ( ) , & sender_pubkey , ) . map_err ( | e | ErrorKind :: TxProofVerifySignature ( format ! ( " " e ) ) ) ? ; let my_address_pubkey = proofaddress :: payment_proof_address_pubkey ( & keychain , & parent_key_id , 0 ) ? ; let sender_mine = my_address_pubkey == sender_pubkey ; let recipient_mine = my_address_pubkey == recipient_pubkey ; Ok ( ( sender_mine , recipient_mine ) ) }
Verify/validate arbitrary payment proof
Returns (whether this wallet is the sender, whether this wallet is the recipient)
Verify / validate arbitrary payment proof Returns ( whether this wallet is the sender whether this wallet is the recipient )
wallet_inst
Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>
keychain_mask
Option<&SecretKey>
proof
&PaymentProof
wallet_inst
Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>
keychain_mask
Option<&SecretKey>
proof
&PaymentProof