diff --git a/src/index/entry.rs b/src/index/entry.rs index 34cc3c8bcd..bf1e8afa44 100644 --- a/src/index/entry.rs +++ b/src/index/entry.rs @@ -255,6 +255,7 @@ pub(crate) struct InscriptionEntry { pub(crate) height: u32, pub(crate) id: InscriptionId, pub(crate) inscription_number: i32, + pub(crate) outpoint: OutPoint, pub(crate) parent: Option, pub(crate) sat: Option, pub(crate) sequence_number: u32, @@ -271,6 +272,8 @@ pub(crate) type InscriptionEntryValue = ( Option, // sat u32, // sequence number u32, // timestamp + (u128, u128), // txid + u32, // vout ); impl Entry for InscriptionEntry { @@ -288,6 +291,8 @@ impl Entry for InscriptionEntry { sat, sequence_number, timestamp, + txid, + vout, ): InscriptionEntryValue, ) -> Self { Self { @@ -296,6 +301,19 @@ impl Entry for InscriptionEntry { height, id: InscriptionId::load(id), inscription_number, + outpoint: OutPoint { + txid: { + let low = txid.0.to_le_bytes(); + let high = txid.1.to_le_bytes(); + Txid::from_byte_array([ + low[0], low[1], low[2], low[3], low[4], low[5], low[6], low[7], low[8], low[9], low[10], + low[11], low[12], low[13], low[14], low[15], high[0], high[1], high[2], high[3], high[4], + high[5], high[6], high[7], high[8], high[9], high[10], high[11], high[12], high[13], + high[14], high[15], + ]) + }, + vout, + }, parent, sat: sat.map(Sat), sequence_number, @@ -314,6 +332,20 @@ impl Entry for InscriptionEntry { self.sat.map(Sat::n), self.sequence_number, self.timestamp, + { + let bytes = self.outpoint.txid.to_byte_array(); + ( + u128::from_le_bytes([ + bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], + bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15], + ]), + u128::from_le_bytes([ + bytes[16], bytes[17], bytes[18], bytes[19], bytes[20], bytes[21], bytes[22], bytes[23], + bytes[24], bytes[25], bytes[26], bytes[27], bytes[28], bytes[29], bytes[30], bytes[31], + ]), + ) + }, + self.outpoint.vout, ) } } diff --git a/src/index/updater/inscription_updater.rs b/src/index/updater/inscription_updater.rs index 1038ebd7c6..a4e4109faa 100644 --- a/src/index/updater/inscription_updater.rs +++ b/src/index/updater/inscription_updater.rs @@ -513,6 +513,7 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> { height: self.height, id: inscription_id, inscription_number, + outpoint: if unbound { unbound_outpoint() } else { new_satpoint.outpoint }, parent, sat, sequence_number, diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 147641649a..b3317f1bcc 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -1676,6 +1676,19 @@ impl Server { let info = Index::inscription_info(&index, query)? .ok_or_not_found(|| format!("inscription {query}"))?; + let genesis_outpoint = info.entry.outpoint; + let genesis_output = if genesis_outpoint == OutPoint::null() || genesis_outpoint == unbound_outpoint() { + TxOut {value: 0, script_pubkey: ScriptBuf::new()} + } else { + index + .get_transaction(genesis_outpoint.txid)? + .ok_or_not_found(|| format!("output {genesis_outpoint}"))? + .output + .into_iter() + .nth(genesis_outpoint.vout as usize) + .ok_or_not_found(|| format!("output {genesis_outpoint}"))? + }; + Ok(if accept_json { Json(InscriptionJson { inscription_id: info.entry.id, @@ -1717,6 +1730,8 @@ impl Server { children: info.children, genesis_fee: info.entry.fee, genesis_height: info.entry.height, + genesis_outpoint, + genesis_output, inscription: info.inscription, inscription_id: info.entry.id, inscription_number: info.entry.inscription_number, diff --git a/src/templates/inscription.rs b/src/templates/inscription.rs index 2470424a35..369faf9ece 100644 --- a/src/templates/inscription.rs +++ b/src/templates/inscription.rs @@ -6,6 +6,8 @@ pub(crate) struct InscriptionHtml { pub(crate) children: Vec, pub(crate) genesis_fee: u64, pub(crate) genesis_height: u32, + pub(crate) genesis_outpoint: OutPoint, + pub(crate) genesis_output: TxOut, pub(crate) inscription: Inscription, pub(crate) inscription_id: InscriptionId, pub(crate) inscription_number: i32, diff --git a/templates/inscription.html b/templates/inscription.html index 8294498cf2..2958394b28 100644 --- a/templates/inscription.html +++ b/templates/inscription.html @@ -94,6 +94,11 @@

Inscription {{ self.inscription_number }}

{{ self.genesis_fee }}
genesis transaction
{{ self.inscription_id.txid }}
+
genesis outpoint
+
{{ self.genesis_outpoint }}
+%% if let Ok(address) = self.chain.address_from_script(&self.genesis_output.script_pubkey ) { +
genesis address
{{ address }}
+%% }
location
{{ self.satpoint }}
output