Skip to content

Commit

Permalink
feat: attempt to recognize the source of a recovered output (#4580)
Browse files Browse the repository at this point in the history
Description
---
Attempts to recognize the source of a recovered output

Motivation and Context
---
Recovered outputs lack details of how they are received, so this is an attempt to perform at least some recognition.

How Has This Been Tested?
---
existing unit tests
  • Loading branch information
agubarev committed Aug 31, 2022
1 parent 2182c5c commit 095196b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Expand Up @@ -37,7 +37,7 @@ use tari_crypto::{
keys::{PublicKey as PublicKeyTrait, SecretKey},
tari_utilities::hex::Hex,
};
use tari_script::{inputs, script};
use tari_script::{inputs, script, Opcode};

use crate::{
key_manager_service::KeyManagerInterface,
Expand Down Expand Up @@ -146,13 +146,21 @@ where

let mut rewound_outputs_with_tx_id: Vec<RecoveredOutput> = Vec::new();
for (output, proof) in &mut rewound_outputs {
// Attempting to recognize output source by i.e., standard MimbleWimble, simple or stealth one-sided
let output_source = match *output.script.as_slice() {
[Opcode::Nop] => OutputSource::Standard,
[Opcode::PushPubKey(_), Opcode::Drop, Opcode::PushPubKey(_)] => OutputSource::StealthOneSided,
[Opcode::PushPubKey(_)] => OutputSource::OneSided,
_ => OutputSource::RecoveredButUnrecognized,
};

let db_output = DbUnblindedOutput::rewindable_from_unblinded_output(
output.clone(),
&self.factories,
&self.rewind_data,
None,
Some(proof),
OutputSource::Recovered,
output_source,
)?;
let tx_id = TxId::new_random();
let output_hex = db_output.commitment.to_hex();
Expand Down
Expand Up @@ -36,7 +36,7 @@ use crate::output_manager_service::error::OutputManagerStorageError;
pub enum OutputSource {
Unknown,
Coinbase,
Recovered,
RecoveredButUnrecognized,
#[default]
Standard,
OneSided,
Expand All @@ -52,7 +52,7 @@ impl TryFrom<i32> for OutputSource {
Ok(match value {
0 => OutputSource::Unknown,
1 => OutputSource::Coinbase,
2 => OutputSource::Recovered,
2 => OutputSource::RecoveredButUnrecognized,
3 => OutputSource::Standard,
4 => OutputSource::OneSided,
5 => OutputSource::StealthOneSided,
Expand Down

0 comments on commit 095196b

Please sign in to comment.