1

I want to read an ordinal transaction on the Bitcoin blockchain and see its payload data.

Say I use the getrawtransaction RPC Method for bitcoin receiving a JSON of the form specified here. Where would the ordinal data be assuming we received an ordinal transaction? Is it in vin.hex? If so how would you decode it? It would depend on if its a text or image or video right?

BAR
  • 119
  • 4

1 Answers1

2

As Vojtěch writes in the linked topic, the inscriptions will be found in an unexecuted part of the leaf script of the taproot input. “The leaf script is the second to last element of the witness stack after removing the optional annex (which is currently non-standard and has never been used on mainnet)”¹, which you find in vin.txinwitness. The Ordinal Theory Handbook describes the serialization format.

You could take a look at the ord software to find an implementation of the deserialization of inscriptions there. This file may or may not be related:incription.rs


¹ Thanks to Vojtěch for correcting my answer and providing this more precise description.

Murch
  • 75,206
  • 34
  • 186
  • 622
  • 3
    The script is called "leaf script", not "witness script" (source), and it's the second to last element of the witness stack after removing the optional annex (which is currently non-standard and has never been used on mainnet). – Vojtěch Strnad May 22 '23 at 14:51
  • 3
    Thanks, I’m glad you’re keeping me honest. – Murch May 22 '23 at 15:00
  • so pretty much have to call into Rust from whatever lang im using... – BAR May 27 '23 at 18:32
  • No, I was just pointing at an example for how inscriptions are deserialized which happens to be in Rust. – Murch May 29 '23 at 14:30