diff --git a/Cargo.lock b/Cargo.lock index 8779450a69..5247b01bca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,9 +113,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" dependencies = [ "backtrace", ] @@ -273,7 +273,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -643,7 +643,7 @@ dependencies = [ "new_mime_guess", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -691,9 +691,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cast" @@ -801,7 +801,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -990,7 +990,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1001,7 +1001,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1052,7 +1052,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1062,7 +1062,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1082,7 +1082,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", "unicode-xid", ] @@ -1140,7 +1140,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1372,7 +1372,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2368,7 +2368,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2561,7 +2561,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2679,9 +2679,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -2813,7 +2813,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2993,7 +2993,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.82", + "syn 2.0.85", "walkdir", ] @@ -3254,9 +3254,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] @@ -3274,13 +3274,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -3345,7 +3345,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -3430,7 +3430,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -3512,9 +3512,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.82" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -3619,22 +3619,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -3695,9 +3695,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -3717,7 +3717,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -4046,7 +4046,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", "wasm-bindgen-shared", ] @@ -4080,7 +4080,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4177,7 +4177,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -4188,7 +4188,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -4439,7 +4439,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] diff --git a/src/index.rs b/src/index.rs index c5b9f36e99..73d13f8ee9 100644 --- a/src/index.rs +++ b/src/index.rs @@ -7,6 +7,7 @@ use { event::Event, lot::Lot, reorg::Reorg, + signal::{Signal, SignalEntry}, updater::Updater, utxo_entry::{ParsedUtxoEntry, UtxoEntry, UtxoEntryBuf}, }, @@ -44,13 +45,14 @@ mod fetcher; mod lot; mod reorg; mod rtx; +pub mod signal; mod updater; mod utxo_entry; #[cfg(test)] pub(crate) mod testing; -const SCHEMA_VERSION: u64 = 29; +const SCHEMA_VERSION: u64 = 30; define_multimap_table! { SAT_TO_SEQUENCE_NUMBER, u64, u32 } define_multimap_table! { SEQUENCE_NUMBER_TO_CHILDREN, u32, u32 } @@ -72,6 +74,7 @@ define_table! { STATISTIC_TO_COUNT, u64, u64 } define_table! { TRANSACTION_ID_TO_RUNE, &TxidValue, u128 } define_table! { TRANSACTION_ID_TO_TRANSACTION, &TxidValue, &[u8] } define_table! { WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP, u32, u128 } +define_table! { OUTPOINT_TO_SIGNAL, &OutPointValue, SignalEntry } #[derive(Copy, Clone)] pub(crate) enum Statistic { @@ -91,6 +94,7 @@ pub(crate) enum Statistic { Runes = 13, SatRanges = 14, UnboundInscriptions = 16, + IndexSignals = 17, } impl Statistic { @@ -202,6 +206,7 @@ pub struct Index { index_inscriptions: bool, index_runes: bool, index_sats: bool, + index_signals: bool, index_transactions: bool, path: PathBuf, settings: Settings, @@ -322,6 +327,7 @@ impl Index { tx.open_table(SEQUENCE_NUMBER_TO_SATPOINT)?; tx.open_table(TRANSACTION_ID_TO_RUNE)?; tx.open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP)?; + tx.open_table(OUTPOINT_TO_SIGNAL)?; { let mut statistics = tx.open_table(STATISTIC_TO_COUNT)?; @@ -350,6 +356,12 @@ impl Index { u64::from(settings.index_sats_raw()), )?; + Self::set_statistic( + &mut statistics, + Statistic::IndexSignals, + u64::from(settings.index_signals_raw()), + )?; + Self::set_statistic( &mut statistics, Statistic::IndexTransactions, @@ -413,6 +425,7 @@ impl Index { let index_addresses; let index_runes; let index_sats; + let index_signals; let index_transactions; let index_inscriptions; @@ -423,6 +436,7 @@ impl Index { index_inscriptions = Self::is_statistic_set(&statistics, Statistic::IndexInscriptions)?; index_runes = Self::is_statistic_set(&statistics, Statistic::IndexRunes)?; index_sats = Self::is_statistic_set(&statistics, Statistic::IndexSats)?; + index_signals = Self::is_statistic_set(&statistics, Statistic::IndexSignals)?; index_transactions = Self::is_statistic_set(&statistics, Statistic::IndexTransactions)?; } @@ -451,6 +465,7 @@ impl Index { index_addresses, index_runes, index_sats, + index_signals, index_transactions, index_inscriptions, settings: settings.clone(), @@ -505,6 +520,52 @@ impl Index { self.index_sats } + pub fn has_signal_index(&self) -> bool { + self.index_signals + } + + pub fn set_signal(&self, outpoint: OutPoint, signal: Signal) -> Result { + let wtx = self.database.begin_write()?; + + let mut outpoint_to_signal = wtx.open_table(OUTPOINT_TO_SIGNAL)?; + + outpoint_to_signal.insert(&outpoint.store(), signal.store())?; + + Ok(()) + } + + pub fn get_signal(&self, outpoint: OutPoint) -> Result { + let rtx = self.database.begin_read()?; + + let outpoint_to_signal = rtx.open_table(OUTPOINT_TO_SIGNAL)?; + + Ok(Signal::load( + outpoint_to_signal + .get(&outpoint.store())? + .map(|guard| guard.value()) + .unwrap(), + )) + } + + pub fn get_all_signals(&self) -> Result> { + let rtx = self.database.begin_read()?; + + rtx + .open_table(OUTPOINT_TO_SIGNAL)? + .iter()? + .map(|result| { + result + .map(|(outpoint, signal)| { + ( + OutPoint::load(*outpoint.value()), + Signal::load(signal.value()), + ) + }) + .map_err(|err| err.into()) + }) + .collect::>>() + } + pub fn status(&self, json_api: bool) -> Result { let rtx = self.database.begin_read()?; diff --git a/src/index/signal.rs b/src/index/signal.rs new file mode 100644 index 0000000000..1184bec129 --- /dev/null +++ b/src/index/signal.rs @@ -0,0 +1,31 @@ +use super::*; + +/// A signal is emitted by a UTXO. It should have strict size constraint +/// Should there be a content type? +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct Signal { + pub message: Vec, + pub signature: Witness, +} + +// This is wrong it should be (Vec, Vec>) +// Running into redb issues +pub(crate) type SignalEntry = (Vec, Vec); + +impl Entry for Signal { + type Value = SignalEntry; + + fn load(value: Self::Value) -> Self { + Self { + message: value.0.to_vec(), + signature: Witness::from_slice(&[&value.1]), + } + } + + fn store(self) -> Self::Value { + ( + self.message, + self.signature.to_vec().first().unwrap().clone(), + ) + } +} diff --git a/src/index/updater.rs b/src/index/updater.rs index d60fa73b3b..76f45da252 100644 --- a/src/index/updater.rs +++ b/src/index/updater.rs @@ -422,6 +422,7 @@ impl<'index> Updater<'index> { let mut sequence_number_to_inscription_entry = wtx.open_table(SEQUENCE_NUMBER_TO_INSCRIPTION_ENTRY)?; let mut transaction_id_to_transaction = wtx.open_table(TRANSACTION_ID_TO_TRANSACTION)?; + let mut outpoint_to_signal = wtx.open_table(OUTPOINT_TO_SIGNAL)?; let index_inscriptions = self.height >= self.index.settings.first_inscription_height() && self.index.index_inscriptions; @@ -548,6 +549,10 @@ impl<'index> Updater<'index> { .map(|input| { let outpoint = input.previous_output.store(); + if self.index.index_signals { + outpoint_to_signal.remove(&outpoint)?; + } + let entry = if let Some(entry) = utxo_cache.remove(&OutPoint::load(outpoint)) { self.outputs_cached += 1; entry diff --git a/src/options.rs b/src/options.rs index 7ae22186ac..a3f8d0160d 100644 --- a/src/options.rs +++ b/src/options.rs @@ -53,6 +53,8 @@ pub struct Options { pub(crate) index_runes: bool, #[arg(long, help = "Track location of all satoshis.")] pub(crate) index_sats: bool, + #[arg(long, help = "Index UTXO signals.")] + pub(crate) index_signals: bool, #[arg(long, help = "Store transactions in index.")] pub(crate) index_transactions: bool, #[arg(long, help = "Run in integration test mode.")] diff --git a/src/settings.rs b/src/settings.rs index 7cc5ffb1ff..dea8b6491a 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -22,6 +22,7 @@ pub struct Settings { index_cache_size: Option, index_runes: bool, index_sats: bool, + index_signals: bool, index_transactions: bool, integration_test: bool, no_index_inscriptions: bool, @@ -135,6 +136,7 @@ impl Settings { index_cache_size: self.index_cache_size.or(source.index_cache_size), index_runes: self.index_runes || source.index_runes, index_sats: self.index_sats || source.index_sats, + index_signals: self.index_signals || source.index_signals, index_transactions: self.index_transactions || source.index_transactions, integration_test: self.integration_test || source.integration_test, no_index_inscriptions: self.no_index_inscriptions || source.no_index_inscriptions, @@ -170,6 +172,7 @@ impl Settings { index_cache_size: options.index_cache_size, index_runes: options.index_runes, index_sats: options.index_sats, + index_signals: options.index_signals, index_transactions: options.index_transactions, integration_test: options.integration_test, no_index_inscriptions: options.no_index_inscriptions, @@ -258,6 +261,7 @@ impl Settings { index_cache_size: get_usize("INDEX_CACHE_SIZE")?, index_runes: get_bool("INDEX_RUNES"), index_sats: get_bool("INDEX_SATS"), + index_signals: get_bool("INDEX_SIGNALS"), index_transactions: get_bool("INDEX_TRANSACTIONS"), integration_test: get_bool("INTEGRATION_TEST"), no_index_inscriptions: get_bool("NO_INDEX_INSCRIPTIONS"), @@ -288,6 +292,7 @@ impl Settings { index_cache_size: None, index_runes: true, index_sats: true, + index_signals: true, index_transactions: false, integration_test: false, no_index_inscriptions: false, @@ -362,6 +367,7 @@ impl Settings { }), index_runes: self.index_runes, index_sats: self.index_sats, + index_signals: self.index_signals, index_transactions: self.index_transactions, integration_test: self.integration_test, no_index_inscriptions: self.no_index_inscriptions, @@ -545,6 +551,10 @@ impl Settings { self.index_sats } + pub fn index_signals_raw(&self) -> bool { + self.index_signals + } + pub fn index_transactions_raw(&self) -> bool { self.index_transactions } @@ -1019,6 +1029,7 @@ mod tests { ("INDEX_ADDRESSES", "1"), ("INDEX_RUNES", "1"), ("INDEX_SATS", "1"), + ("INDEX_SIGNALS", "1"), ("INDEX_TRANSACTIONS", "1"), ("INTEGRATION_TEST", "1"), ("NO_INDEX_INSCRIPTIONS", "1"), @@ -1063,6 +1074,7 @@ mod tests { index_cache_size: Some(4), index_runes: true, index_sats: true, + index_signals: true, index_transactions: true, integration_test: true, no_index_inscriptions: true, @@ -1095,6 +1107,7 @@ mod tests { "--index-cache-size=4", "--index-runes", "--index-sats", + "--index-signals", "--index-transactions", "--index=index", "--integration-test", @@ -1124,6 +1137,7 @@ mod tests { index_cache_size: Some(4), index_runes: true, index_sats: true, + index_signals: true, index_transactions: true, integration_test: true, no_index_inscriptions: true, diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 8cc7763f57..29daf3388d 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -5,12 +5,15 @@ use { error::{OptionExt, ServerError, ServerResult}, }, super::*, - crate::templates::{ - AddressHtml, BlockHtml, BlocksHtml, ChildrenHtml, ClockSvg, CollectionsHtml, HomeHtml, - InputHtml, InscriptionHtml, InscriptionsBlockHtml, InscriptionsHtml, OutputHtml, PageContent, - PageHtml, ParentsHtml, PreviewAudioHtml, PreviewCodeHtml, PreviewFontHtml, PreviewImageHtml, - PreviewMarkdownHtml, PreviewModelHtml, PreviewPdfHtml, PreviewTextHtml, PreviewUnknownHtml, - PreviewVideoHtml, RareTxt, RuneHtml, RunesHtml, SatHtml, TransactionHtml, + crate::{ + index::signal::Signal, + templates::{ + AddressHtml, BlockHtml, BlocksHtml, ChildrenHtml, ClockSvg, CollectionsHtml, HomeHtml, + InputHtml, InscriptionHtml, InscriptionsBlockHtml, InscriptionsHtml, OutputHtml, PageContent, + PageHtml, ParentsHtml, PreviewAudioHtml, PreviewCodeHtml, PreviewFontHtml, PreviewImageHtml, + PreviewMarkdownHtml, PreviewModelHtml, PreviewPdfHtml, PreviewTextHtml, PreviewUnknownHtml, + PreviewVideoHtml, RareTxt, RuneHtml, RunesHtml, SatHtml, TransactionHtml, + }, }, axum::{ body, @@ -58,6 +61,12 @@ struct Search { query: String, } +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +struct UtxoSignal { + outpoint: OutPoint, + signal: Signal, +} + #[derive(RustEmbed)] #[folder = "static"] struct StaticAssets; @@ -157,6 +166,7 @@ impl Server { decompress: self.decompress, domain: acme_domains.first().cloned(), index_sats: index.has_sat_index(), + index_signals: index.has_signal_index(), json_api_enabled: !self.disable_json_api, proxy: self.proxy.clone(), }); @@ -259,6 +269,9 @@ impl Server { .route("/satpoint/:satpoint", get(Self::satpoint)) .route("/search", get(Self::search_by_query)) .route("/search/*query", get(Self::search_by_path)) + .route("/signal", post(Self::signal)) + .route("/signals", get(Self::signals)) + .route("/signal/:outpoint", get(Self::get_signal)) .route("/static/*path", get(Self::static_asset)) .route("/status", get(Self::status)) .route("/tx/:txid", get(Self::transaction)) @@ -1157,6 +1170,64 @@ impl Server { }) } + async fn signal( + Extension(server_config): Extension>, + Extension(index): Extension>, + AcceptJson(accept_json): AcceptJson, + Json(utxo_signal): Json, + ) -> ServerResult { + task::block_in_place(|| { + Ok(if accept_json && server_config.index_signals { + let Some(address) = index + .get_output_info(utxo_signal.outpoint)? + .and_then(|(a, _)| a.address) + else { + return Ok(StatusCode::NOT_FOUND.into_response()); + }; + + let message = utxo_signal.signal.message.clone(); + let signature = utxo_signal.signal.signature.clone(); + + if bip322::verify_simple(&address.assume_checked(), message.as_slice(), signature).is_ok() { + Json(index.set_signal(utxo_signal.outpoint, utxo_signal.signal)?).into_response() + } else { + StatusCode::FORBIDDEN.into_response() + } + } else { + StatusCode::NOT_FOUND.into_response() + }) + }) + } + + async fn signals( + Extension(server_config): Extension>, + Extension(index): Extension>, + AcceptJson(accept_json): AcceptJson, + ) -> ServerResult { + task::block_in_place(|| { + Ok(if accept_json && server_config.index_signals { + Json(index.get_all_signals()?).into_response() + } else { + StatusCode::NOT_FOUND.into_response() + }) + }) + } + + async fn get_signal( + Extension(server_config): Extension>, + Extension(index): Extension>, + AcceptJson(accept_json): AcceptJson, + Path(outpoint): Path, + ) -> ServerResult { + task::block_in_place(|| { + Ok(if accept_json && server_config.index_signals { + Json(index.get_signal(outpoint)?).into_response() + } else { + StatusCode::NOT_FOUND.into_response() + }) + }) + } + async fn favicon() -> ServerResult { Ok( Self::static_asset(Path("/favicon.png".to_string())) diff --git a/src/subcommand/server/server_config.rs b/src/subcommand/server/server_config.rs index 8a426888ba..d8f2cbb7eb 100644 --- a/src/subcommand/server/server_config.rs +++ b/src/subcommand/server/server_config.rs @@ -7,6 +7,7 @@ pub(crate) struct ServerConfig { pub(crate) decompress: bool, pub(crate) domain: Option, pub(crate) index_sats: bool, + pub(crate) index_signals: bool, pub(crate) json_api_enabled: bool, pub(crate) proxy: Option, } diff --git a/tests/settings.rs b/tests/settings.rs index 4591092611..938e4fc391 100644 --- a/tests/settings.rs +++ b/tests/settings.rs @@ -25,6 +25,7 @@ fn default() { "index_cache_size": \d+, "index_runes": false, "index_sats": false, + "index_signals": false, "index_transactions": false, "integration_test": false, "no_index_inscriptions": false,