From 6cdbb6b3863cea8fedffa2e47d1e4c26c0565155 Mon Sep 17 00:00:00 2001 From: 0xb10c Date: Thu, 30 Nov 2023 16:12:44 +0100 Subject: [PATCH] add: tag for transactions revealing an inscription --- Cargo.lock | 4 ++-- daemon/Cargo.toml | 2 +- daemon/src/processing.rs | 11 ++++++++++- shared/src/tags.rs | 15 ++++++++++++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6abefc4..dc3d54b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1708,9 +1708,9 @@ dependencies = [ [[package]] name = "rawtx-rs" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74a5171c76983382ec1301428821fbfa14e2fa6d84b131704ff56195cbd05c3b" +checksum = "929f6c77ec31c14ee939f2c9519ef358fb451c44b8014b70f6f0120225cf032f" dependencies = [ "bitcoin", "hex", diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 9689b64..79e84e3 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -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" diff --git a/daemon/src/processing.rs b/daemon/src/processing.rs index b2d96de..0d52b89 100644 --- a/daemon/src/processing.rs +++ b/daemon/src/processing.rs @@ -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; @@ -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() diff --git a/shared/src/tags.rs b/shared/src/tags.rs index fced1c4..ae2997f 100644 --- a/shared/src/tags.rs +++ b/shared/src/tags.rs @@ -68,6 +68,7 @@ pub enum TxTag { LockByTimestamp = 4160, Consolidation = 4170, DustOutput = 4180, + Inscription = 4190, } impl TryFrom for TxTag { @@ -97,6 +98,7 @@ impl TryFrom 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(()), } @@ -104,7 +106,7 @@ impl TryFrom for TxTag { } impl TxTag { - pub const TX_TAGS: &'static [TxTag; 22] = &[ + pub const TX_TAGS: &'static [TxTag; 23] = &[ // important / danger TxTag::FromSanctioned, TxTag::ToSanctioned, @@ -131,6 +133,7 @@ impl TxTag { TxTag::Coinjoin, TxTag::Consolidation, TxTag::DustOutput, + TxTag::Inscription, ]; pub fn value(&self) -> Tag { @@ -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, + } + }, } } }