Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/crates/heuristics/src/change_identification.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use tx_indexer_primitives::hamming_weight::decimal_hamming_weight;
use tx_indexer_primitives::{
handle::TxHandle,
traits::abstract_types::{HasNLockTime, HasScriptPubkey, OutputCount, TxConstituent},
Expand All @@ -9,6 +10,12 @@ pub enum TxOutChangeAnnotation {
NotChange,
}

#[derive(Debug, PartialEq,Eq)]
pub enum RoundNumberAnnotation {
Round,
NotRound,
}

pub struct NaiveChangeIdentificationHueristic;

impl NaiveChangeIdentificationHueristic {
Expand Down Expand Up @@ -45,6 +52,24 @@ impl NLockTimeChangeIdentification {
}
}

pub struct RoundNumberAnnotator;

impl RoundNumberAnnotator {
/// Maximum decimal Hamming weight for an amount to be considered round.
pub const ROUNDNESS_THRESHOLD: u32 = 2;

/// judge how round an amount is via it's hamming weight
pub fn annontate(satoshi: u64) -> RoundNumberAnnotation {
if decimal_hamming_weight(satoshi) <= Self::ROUNDNESS_THRESHOLD {
RoundNumberAnnotation::Round
} else {
RoundNumberAnnotation::NotRound
}

}

}

pub struct ScriptTypesMatchingChangeIdentification;

impl ScriptTypesMatchingChangeIdentification {
Expand Down
Loading