Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: tag for transactions revealing an inscription #74

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ simple_logger = "1.9.0"

bitcoin = "0.30"
bitcoin-pool-identification = "0.2.4"
rawtx-rs = { version = "0.1.4", features = [ "counterparty" ]}
rawtx-rs = { version = "0.1.6", features = [ "counterparty" ]}

hex = "0.4"

Expand Down
11 changes: 10 additions & 1 deletion daemon/src/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rawtx_rs::tx::TxInfo as RawTxInfo;
use rawtx_rs::tx::{
is_opreturn_counterparty, is_p2ms_counterparty, is_p2sh_counterparty, TransactionSigops,
};
use rawtx_rs::{input::InputType, output::OutputType};
use rawtx_rs::{input::InputInscriptionDetection, input::InputType, output::OutputType};

use bitcoin::hash_types::Txid;
use bitcoin::hashes::Hash;
Expand Down Expand Up @@ -263,6 +263,15 @@ fn get_transaction_tags(
tags.push(tags::TxTag::CounterParty as i32);
}

if tx_info
.tx
.input
.iter()
.any(|input| input.reveals_inscription().unwrap_or(false))
{
tags.push(tags::TxTag::Inscription as i32);
}

if raw_tx_info
.input_infos
.iter()
Expand Down
15 changes: 14 additions & 1 deletion shared/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub enum TxTag {
LockByTimestamp = 4160,
Consolidation = 4170,
DustOutput = 4180,
Inscription = 4190,
}

impl TryFrom<i32> for TxTag {
Expand Down Expand Up @@ -97,14 +98,15 @@ impl TryFrom<i32> for TxTag {
x if x == TxTag::Conflicting as i32 => Ok(TxTag::Conflicting),
x if x == TxTag::Young as i32 => Ok(TxTag::Young),
x if x == TxTag::ManySigops as i32 => Ok(TxTag::ManySigops),
x if x == TxTag::Inscription as i32 => Ok(TxTag::Inscription),
// FIXME: add new tags here
_ => Err(()),
}
}
}

impl TxTag {
pub const TX_TAGS: &'static [TxTag; 22] = &[
pub const TX_TAGS: &'static [TxTag; 23] = &[
// important / danger
TxTag::FromSanctioned,
TxTag::ToSanctioned,
Expand All @@ -131,6 +133,7 @@ impl TxTag {
TxTag::Coinjoin,
TxTag::Consolidation,
TxTag::DustOutput,
TxTag::Inscription,
];

pub fn value(&self) -> Tag {
Expand Down Expand Up @@ -377,6 +380,16 @@ impl TxTag {
text_color: WHITE,
}
},
TxTag::Inscription => {
Tag {
name: "Inscription".to_string(),
description: vec![
format!("The transaction has at least one input revealing an Ordinals inscription."),
],
color: GRAY,
text_color: WHITE,
}
},
}
}
}
Expand Down
Loading