Ignore messages that are signed by ourselves
This commit is contained in:
parent
87113f5a34
commit
078d2a0420
18
src/api.rs
18
src/api.rs
@ -508,7 +508,13 @@ fn handle_transaction(
|
||||
tx: &Transaction,
|
||||
tweak_data: PublicKey,
|
||||
) -> AnyhowResult<ApiReturn> {
|
||||
let b_scan = lock_local_device()?.get_wallet().get_client().get_scan_key();
|
||||
let b_scan: SecretKey;
|
||||
let local_address: SilentPaymentAddress;
|
||||
{
|
||||
let local_device = lock_local_device()?;
|
||||
b_scan = local_device.get_wallet().get_client().get_scan_key();
|
||||
local_address = local_device.get_wallet().get_client().get_receiving_address().try_into()?;
|
||||
}
|
||||
|
||||
let op_return: Vec<&sdk_common::sp_client::bitcoin::TxOut> = tx
|
||||
.output
|
||||
@ -554,7 +560,7 @@ fn handle_transaction(
|
||||
}) {
|
||||
// Calling this check that the prd we found check with the hashed commitment in transaction
|
||||
// We also check the signed proof that is included in the prd
|
||||
let prd = Prd::extract_from_message_with_commitment(&plaintext, &commitment)?;
|
||||
let prd = Prd::extract_from_message_with_commitment(&plaintext, local_address, &commitment)?;
|
||||
|
||||
// for now the previous method doesn't error if proof is missing,
|
||||
// We must define if there are cases where a valid prd doesn't have proof
|
||||
@ -807,6 +813,8 @@ fn confirm_prd(prd: Prd, shared_secret: &AnkSharedSecretHash) -> AnyhowResult<St
|
||||
|
||||
let prd_confirm = Prd::new_confirm(outpoint, member, pcd_commitment);
|
||||
|
||||
debug!("Sending confirm prd: {:?}", prd_confirm);
|
||||
|
||||
let prd_msg = prd_confirm.to_network_msg(local_device.get_wallet())?;
|
||||
|
||||
Ok(encrypt_with_key(shared_secret.as_byte_array(), prd_msg.as_bytes())?.to_lower_hex_string())
|
||||
@ -828,6 +836,7 @@ fn decrypt_with_cached_messages(
|
||||
messages: &mut MutexGuard<Vec<CachedMessage>>
|
||||
) -> anyhow::Result<Option<(Vec<u8>, AnkSharedSecretHash)>> {
|
||||
let nonce = Nonce::from_slice(&cipher[..12]);
|
||||
let local_address: SilentPaymentAddress = lock_local_device()?.get_wallet().get_client().get_receiving_address().try_into()?;
|
||||
|
||||
for message in messages.iter_mut() {
|
||||
for shared_secret in message.shared_secrets.iter() {
|
||||
@ -863,7 +872,7 @@ fn decrypt_with_cached_messages(
|
||||
)?;
|
||||
// A message matched against a new transaction must be a prd
|
||||
// We just check the commitment while we're at it
|
||||
let _ = Prd::extract_from_message_with_commitment(&plain, &commitment)?;
|
||||
let _ = Prd::extract_from_message_with_commitment(&plain, local_address, &commitment)?;
|
||||
// Update the message status
|
||||
message.status = CachedMessageStatus::NoStatus;
|
||||
message.shared_secrets = vec![]; // this way we won't check it again
|
||||
@ -907,8 +916,9 @@ fn handle_prd(
|
||||
plain: &[u8],
|
||||
new_shared_secret: Option<AnkSharedSecretHash>,
|
||||
) -> AnyhowResult<ApiReturn> {
|
||||
let local_address: SilentPaymentAddress = lock_local_device()?.get_wallet().get_client().get_receiving_address().try_into()?;
|
||||
// We already checked the commitment if any
|
||||
let prd = Prd::extract_from_message(plain)?;
|
||||
let prd = Prd::extract_from_message(plain, local_address)?;
|
||||
|
||||
debug!("found prd: {:#?}", prd);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user