@@ -6,8 +6,8 @@ use bitcoincore_rpc::bitcoin::hashes::hex::FromHex;
6
6
use bitcoincore_rpc:: bitcoin:: { Address , Network , Script } ;
7
7
use bitcoincore_rpc_json:: bitcoin:: Witness ;
8
8
use chainhook_types:: {
9
- BitcoinBlockData , OrdinalInscriptionRevealData , OrdinalInscriptionTransferData ,
10
- OrdinalOperation , TransactionIdentifier ,
9
+ BitcoinBlockData , OrdinalInscriptionCurseType , OrdinalInscriptionRevealData ,
10
+ OrdinalInscriptionTransferData , OrdinalOperation , TransactionIdentifier ,
11
11
} ;
12
12
use dashmap:: DashMap ;
13
13
use fxhash:: { FxBuildHasher , FxHasher } ;
@@ -56,18 +56,28 @@ pub fn parse_ordinal_operations(
56
56
for ( input_index, input) in tx. vin . iter ( ) . enumerate ( ) {
57
57
if let Some ( ref witness_data) = input. txinwitness {
58
58
let witness = Witness :: from_vec ( witness_data. clone ( ) ) ;
59
- let inscription = match InscriptionParser :: parse ( & witness) {
59
+ let mut inscription = match InscriptionParser :: parse ( & witness) {
60
60
Ok ( inscription) => inscription,
61
- Err ( e) => {
62
- ctx. try_log ( |logger| {
63
- slog:: warn!(
64
- logger,
65
- "Inscription parsing error at block {}: #{:?}" ,
66
- block_height,
67
- e
68
- )
69
- } ) ;
70
- continue ;
61
+ Err ( _e) => {
62
+ let mut cursed_inscription = None ;
63
+ for bytes in witness_data. iter ( ) {
64
+ let script = Script :: from ( bytes. to_vec ( ) ) ;
65
+ let parser = InscriptionParser {
66
+ instructions : script. instructions ( ) . peekable ( ) ,
67
+ } ;
68
+
69
+ let mut inscription = match parser. parse_script ( ) {
70
+ Ok ( inscription) => inscription,
71
+ Err ( _) => continue ,
72
+ } ;
73
+ inscription. curse = Some ( OrdinalInscriptionCurseType :: P2wsh ) ;
74
+ cursed_inscription = Some ( inscription) ;
75
+ break ;
76
+ }
77
+ match cursed_inscription {
78
+ Some ( inscription) => inscription,
79
+ None => continue ,
80
+ }
71
81
}
72
82
} ;
73
83
@@ -82,9 +92,6 @@ pub fn parse_ordinal_operations(
82
92
. and_then ( |o| Some ( o. value . to_sat ( ) ) )
83
93
. unwrap_or ( 0 ) ;
84
94
85
- let no_content_bytes = vec ! [ ] ;
86
- let inscription_content_bytes = inscription. body ( ) . unwrap_or ( & no_content_bytes) ;
87
-
88
95
let inscriber_address = if let Ok ( authors) = Address :: from_script (
89
96
& tx. vout [ 0 ] . script_pub_key . script ( ) . unwrap ( ) ,
90
97
bitcoincore_rpc:: bitcoin:: Network :: Bitcoin ,
@@ -94,6 +101,13 @@ pub fn parse_ordinal_operations(
94
101
None
95
102
} ;
96
103
104
+ if input_index > 0 {
105
+ inscription. curse = Some ( OrdinalInscriptionCurseType :: Batch ) ;
106
+ }
107
+
108
+ let no_content_bytes = vec ! [ ] ;
109
+ let inscription_content_bytes = inscription. body ( ) . take ( ) . unwrap_or ( & no_content_bytes) ;
110
+
97
111
let payload = OrdinalInscriptionRevealData {
98
112
content_type : inscription. content_type ( ) . unwrap_or ( "unknown" ) . to_string ( ) ,
99
113
content_bytes : format ! ( "0x{}" , hex:: encode( & inscription_content_bytes) ) ,
@@ -109,13 +123,13 @@ pub fn parse_ordinal_operations(
109
123
ordinal_offset : 0 ,
110
124
transfers_pre_inscription : 0 ,
111
125
satpoint_post_inscription : format ! ( "{}:0:0" , tx. txid. clone( ) ) ,
126
+ curse_type : inscription. curse . take ( ) ,
112
127
} ;
113
128
114
- if input_index == 0 {
115
- operations. push ( OrdinalOperation :: InscriptionRevealed ( payload) ) ;
116
- } else {
117
- operations. push ( OrdinalOperation :: CursedInscriptionRevealed ( payload) ) ;
118
- }
129
+ operations. push ( match & payload. curse_type {
130
+ Some ( _) => OrdinalOperation :: CursedInscriptionRevealed ( payload) ,
131
+ None => OrdinalOperation :: InscriptionRevealed ( payload) ,
132
+ } ) ;
119
133
}
120
134
}
121
135
operations
0 commit comments