diff --git a/src/index.rs b/src/index.rs index f6cf813790..b0ff3ee5f7 100644 --- a/src/index.rs +++ b/src/index.rs @@ -2326,6 +2326,50 @@ mod tests { } } + #[test] + fn manually_cursed_tag_makes_inscription_cursed_but_bound() { + for context in Context::configurations() { + context.mine_blocks(1); + + let witness = envelope(&[ + b"ord", + &[1], + b"text/plain;charset=utf-8", + &[66], + b"cursed" + ]); + + let txid = context.rpc_server.broadcast_tx(TransactionTemplate { + inputs: &[(1, 0, 0)], + witness, + ..Default::default() + }); + + let inscription_id = InscriptionId { txid, index: 0 }; + + context.mine_blocks(1); + + context.index.assert_inscription_location( + inscription_id, + SatPoint { + outpoint: OutPoint { txid, vout: 0 }, + offset: 0, + }, + None, + ); + + assert_eq!( + context + .index + .get_inscription_entry(inscription_id) + .unwrap() + .unwrap() + .number, + -1 + ); + } + } + #[test] fn cursed_inscriptions_assigned_negative_numbers() { for context in Context::configurations() { diff --git a/src/index/updater/inscription_updater.rs b/src/index/updater/inscription_updater.rs index 4950a710db..0bc33c9570 100644 --- a/src/index/updater/inscription_updater.rs +++ b/src/index/updater/inscription_updater.rs @@ -129,6 +129,7 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> { let (inscription, cursed, unbound) = match Inscription::from_transaction(tx) { Ok(inscription) => (Some(inscription), false, false), + Err(InscriptionError::ManuallyCursed(inscription)) => (Some(inscription), true, false), Err(InscriptionError::UnrecognizedEvenField(inscription)) => (Some(inscription), true, true), _ => (None, false, false), }; diff --git a/src/inscription.rs b/src/inscription.rs index 9b6af7450f..01aae07cac 100644 --- a/src/inscription.rs +++ b/src/inscription.rs @@ -15,6 +15,7 @@ const PROTOCOL_ID: &[u8] = b"ord"; const BODY_TAG: &[u8] = &[]; const CONTENT_TYPE_TAG: &[u8] = &[1]; +const MANUALLY_CURSED_TAG: &[u8] = &[66]; #[derive(Debug, PartialEq, Clone)] pub(crate) struct Inscription { @@ -134,6 +135,7 @@ pub(crate) enum InscriptionError { KeyPathSpend, NoInscription, Script(script::Error), + ManuallyCursed(Inscription), UnrecognizedEvenField(Inscription), } @@ -228,6 +230,7 @@ impl<'a> InscriptionParser<'a> { let body = fields.remove(BODY_TAG); let content_type = fields.remove(CONTENT_TYPE_TAG); + let cursed_tag = fields.remove(MANUALLY_CURSED_TAG); for tag in fields.keys() { if let Some(lsb) = tag.first() { @@ -240,6 +243,13 @@ impl<'a> InscriptionParser<'a> { } } + if cursed_tag.is_some() { + return Err(InscriptionError::ManuallyCursed(Inscription { + body, + content_type, + })); + } + return Ok(Some(Inscription { body, content_type })); }