File tree 6 files changed +313
-105
lines changed
6 files changed +313
-105
lines changed Original file line number Diff line number Diff line change @@ -499,6 +499,23 @@ impl Index {
499
499
)
500
500
}
501
501
502
+ pub fn get_output_script ( & self , output : & OutPoint ) -> Result < Option < ScriptBuf > > {
503
+ let rtx = self . database . begin_read ( ) ?;
504
+ let outpoint_to_utxo_entry = rtx. open_table ( OUTPOINT_TO_UTXO_ENTRY ) ?;
505
+
506
+ let entry = outpoint_to_utxo_entry
507
+ . get ( & output. store ( ) ) ?
508
+ . ok_or_else ( || anyhow ! ( "UTXO entry not found for output: {:?}" , output) ) ?;
509
+
510
+ let parsed = entry. value ( ) . parse ( self ) ;
511
+
512
+ Ok (
513
+ parsed
514
+ . script_pubkey ( )
515
+ . map ( |bytes| ScriptBuf :: from_bytes ( bytes. to_vec ( ) ) ) ,
516
+ )
517
+ }
518
+
502
519
pub fn has_address_index ( & self ) -> bool {
503
520
self . index_addresses
504
521
}
@@ -744,6 +761,7 @@ impl Index {
744
761
. value ( )
745
762
. parse ( self )
746
763
. script_pubkey ( )
764
+ . unwrap ( )
747
765
. to_vec ( ) ,
748
766
)
749
767
} else {
@@ -6621,7 +6639,7 @@ mod tests {
6621
6639
6622
6640
let ( event_sender, mut event_receiver) = tokio:: sync:: mpsc:: channel ( 1024 ) ;
6623
6641
let context = Context :: builder ( )
6624
- . arg ( "--index-runes" )
6642
+ . args ( [ "--index-runes" , "--index-addresses" ] )
6625
6643
. event_sender ( event_sender)
6626
6644
. build ( ) ;
6627
6645
Original file line number Diff line number Diff line change @@ -128,7 +128,22 @@ impl Context {
128
128
let balances = balances. as_mut ( ) ;
129
129
balances. sort_by_key ( |( outpoint, _) | * outpoint) ;
130
130
131
- for ( _, balances) in balances. iter_mut ( ) {
131
+ let mut burned_balances = 0 ;
132
+
133
+ for ( outpoint, balances) in balances. iter_mut ( ) {
134
+ if self
135
+ . index
136
+ . get_output_script ( outpoint)
137
+ . ok ( )
138
+ . flatten ( )
139
+ . map_or ( false , |script| script. is_op_return ( ) )
140
+ {
141
+ for ( _, balance) in balances. iter ( ) {
142
+ println ! ( "burned_balances: {}" , burned_balances) ;
143
+ burned_balances += * balance;
144
+ }
145
+ }
146
+
132
147
balances. sort_by_key ( |( id, _) | * id) ;
133
148
}
134
149
@@ -146,7 +161,7 @@ impl Context {
146
161
147
162
for ( id, entry) in runes {
148
163
pretty_assert_eq ! (
149
- outstanding. get( id) . copied( ) . unwrap_or_default( ) ,
164
+ outstanding. get( id) . copied( ) . unwrap_or_default( ) - burned_balances ,
150
165
entry. supply( ) - entry. burned
151
166
) ;
152
167
}
Original file line number Diff line number Diff line change @@ -556,7 +556,7 @@ impl Updater<'_> {
556
556
entry
557
557
} else if let Some ( entry) = outpoint_to_utxo_entry. remove ( & outpoint) ? {
558
558
if self . index . index_addresses {
559
- let script_pubkey = entry. value ( ) . parse ( self . index ) . script_pubkey ( ) ;
559
+ let script_pubkey = entry. value ( ) . parse ( self . index ) . script_pubkey ( ) . unwrap ( ) ;
560
560
if !script_pubkey_to_outpoint. remove ( script_pubkey, outpoint) ? {
561
561
panic ! ( "script pubkey entry ({script_pubkey:?}, {outpoint:?}) not found" ) ;
562
562
}
@@ -845,7 +845,7 @@ impl Updater<'_> {
845
845
846
846
let utxo_entry = utxo_entry. parse ( self . index ) ;
847
847
if self . index . index_addresses {
848
- let script_pubkey = utxo_entry. script_pubkey ( ) ;
848
+ let script_pubkey = utxo_entry. script_pubkey ( ) . unwrap ( ) ;
849
849
script_pubkey_to_outpoint. insert ( script_pubkey, & outpoint. store ( ) ) ?;
850
850
}
851
851
Original file line number Diff line number Diff line change @@ -153,8 +153,8 @@ impl<'a> ParsedUtxoEntry<'a> {
153
153
ranges
154
154
}
155
155
156
- pub fn script_pubkey ( & self ) -> & ' a [ u8 ] {
157
- self . script_pubkey . unwrap ( )
156
+ pub fn script_pubkey ( & self ) -> Option < & ' a [ u8 ] > {
157
+ self . script_pubkey
158
158
}
159
159
160
160
pub fn inscriptions ( & self ) -> & ' a [ u8 ] {
@@ -279,8 +279,8 @@ impl UtxoEntryBuf {
279
279
}
280
280
281
281
if index. index_addresses {
282
- assert ! ( a_parsed. script_pubkey( ) . is_empty( ) ) ;
283
- assert ! ( b_parsed. script_pubkey( ) . is_empty( ) ) ;
282
+ assert ! ( a_parsed. script_pubkey( ) . unwrap ( ) . is_empty( ) ) ;
283
+ assert ! ( b_parsed. script_pubkey( ) . unwrap ( ) . is_empty( ) ) ;
284
284
merged. push_script_pubkey ( & [ ] , index) ;
285
285
}
286
286
You can’t perform that action at this time.
0 commit comments