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

Recognize OP_66 as manually cursed and inscription is bound #10

Closed
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
44 changes: 44 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/index/updater/inscription_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
Expand Down
10 changes: 10 additions & 0 deletions src/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -134,6 +135,7 @@ pub(crate) enum InscriptionError {
KeyPathSpend,
NoInscription,
Script(script::Error),
ManuallyCursed(Inscription),
UnrecognizedEvenField(Inscription),
}

Expand Down Expand Up @@ -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() {
Expand All @@ -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 }));
}

Expand Down