@@ -107,11 +107,32 @@ pub fn standardize_bitcoin_block(
107
107
) -> Result < BitcoinBlockData , String > {
108
108
let mut transactions = vec ! [ ] ;
109
109
110
- let expected_magic_bytes = get_canonical_magic_bytes ( & indexer_config. bitcoin_network ) ;
110
+ let expected_magic_bytes = get_stacks_canonical_magic_bytes ( & indexer_config. bitcoin_network ) ;
111
111
let pox_config = get_canonical_pox_config ( & indexer_config. bitcoin_network ) ;
112
112
113
- for mut tx in block. txdata . into_iter ( ) {
114
- let txid = tx. txid ( ) . to_string ( ) ;
113
+ ctx. try_log ( |logger| slog:: info!( logger, "Start processing Bitcoin block {}" , block. hash, ) ) ;
114
+
115
+ for mut tx in block. tx . into_iter ( ) {
116
+ let txid = tx. txid . to_string ( ) ;
117
+
118
+ ctx. try_log ( |logger| slog:: info!( logger, "Start processing Bitcoin transaction {txid}" ) ) ;
119
+
120
+ let mut stacks_operations = vec ! [ ] ;
121
+ if let Some ( op) = try_parse_stacks_operation (
122
+ & tx. vout ,
123
+ & pox_config,
124
+ & expected_magic_bytes,
125
+ block_height,
126
+ ctx,
127
+ ) {
128
+ stacks_operations. push ( op) ;
129
+ }
130
+
131
+ let mut ordinal_operations = vec ! [ ] ;
132
+ if let Some ( op) = try_parse_ordinal_operation ( & tx, block_height, ctx) {
133
+ ordinal_operations. push ( op) ;
134
+ }
135
+
115
136
let mut inputs = vec ! [ ] ;
116
137
for input in tx. vin . drain ( ..) {
117
138
if input. is_coinbase ( ) {
@@ -141,17 +162,6 @@ pub fn standardize_bitcoin_block(
141
162
}
142
163
143
164
let mut outputs = vec ! [ ] ;
144
- let mut stacks_operations = vec ! [ ] ;
145
-
146
- if let Some ( op) = try_parse_stacks_operation (
147
- & tx. output ,
148
- & pox_config,
149
- & expected_magic_bytes,
150
- block_height,
151
- ctx,
152
- ) {
153
- stacks_operations. push ( op) ;
154
- }
155
165
for output in tx. vout . drain ( ..) {
156
166
outputs. push ( TxOut {
157
167
value : output. value . to_sat ( ) ,
@@ -168,6 +178,7 @@ pub fn standardize_bitcoin_block(
168
178
inputs,
169
179
outputs,
170
180
stacks_operations,
181
+ ordinal_operations,
171
182
proof : None ,
172
183
} ,
173
184
} ;
@@ -189,6 +200,39 @@ pub fn standardize_bitcoin_block(
189
200
} )
190
201
}
191
202
203
+ fn try_parse_ordinal_operation (
204
+ tx : & GetRawTransactionResult ,
205
+ block_height : u64 ,
206
+ ctx : & Context ,
207
+ ) -> Option < OrdinalOperation > {
208
+ let ( pos, magic_bytes) = get_ordinal_canonical_magic_bytes ( ) ;
209
+ let limit = pos + magic_bytes. len ( ) ;
210
+
211
+ for input in tx. vin . iter ( ) {
212
+ if let Some ( ref witnesses) = input. txinwitness {
213
+ for witness in witnesses. iter ( ) {
214
+ if witness. len ( ) > limit && witness[ pos..limit] == magic_bytes {
215
+ ctx. try_log ( |logger| {
216
+ slog:: info!(
217
+ logger,
218
+ "Ordinal operation detected in transaction {}" ,
219
+ tx. txid,
220
+ )
221
+ } ) ;
222
+ return Some ( OrdinalOperation :: InscriptionReveal (
223
+ OrdinalInscriptionRevealData {
224
+ satoshi_point : "" . into ( ) ,
225
+ content_type : "" . into ( ) ,
226
+ content : vec ! [ ] ,
227
+ } ,
228
+ ) ) ;
229
+ }
230
+ }
231
+ }
232
+ }
233
+ None
234
+ }
235
+
192
236
fn try_parse_stacks_operation (
193
237
outputs : & Vec < GetRawTransactionResultVout > ,
194
238
pox_config : & PoxConfig ,
0 commit comments