@@ -484,11 +484,9 @@ pub fn find_all_inscriptions_in_block(
484
484
let inscription_number: i64 = row. get ( 0 ) . unwrap ( ) ;
485
485
let ordinal_number: u64 = row. get ( 1 ) . unwrap ( ) ;
486
486
let block_height: u64 = row. get ( 2 ) . unwrap ( ) ;
487
- let transaction_id = {
487
+ let ( transaction_id, _ ) = {
488
488
let inscription_id: String = row. get ( 3 ) . unwrap ( ) ;
489
- TransactionIdentifier {
490
- hash : format ! ( "0x{}" , & inscription_id[ 0 ..inscription_id. len( ) - 2 ] ) ,
491
- }
489
+ parse_inscription_id ( & inscription_id)
492
490
} ;
493
491
let inscription_offset: u64 = row. get ( 4 ) . unwrap ( ) ;
494
492
let outpoint_to_watch: String = row. get ( 5 ) . unwrap ( ) ;
@@ -517,10 +515,8 @@ pub struct WatchedSatpoint {
517
515
518
516
impl WatchedSatpoint {
519
517
pub fn get_genesis_satpoint ( & self ) -> String {
520
- format ! (
521
- "{}:0" ,
522
- & self . inscription_id[ 0 ..self . inscription_id. len( ) - 2 ]
523
- )
518
+ let ( transaction_id, input) = parse_inscription_id ( & self . inscription_id ) ;
519
+ format ! ( "{}:{}" , transaction_id. hash, input)
524
520
}
525
521
}
526
522
@@ -902,6 +898,15 @@ pub fn format_outpoint_to_watch(
902
898
)
903
899
}
904
900
901
+ pub fn parse_inscription_id ( inscription_id : & str ) -> ( TransactionIdentifier , usize ) {
902
+ let comps: Vec < & str > = inscription_id. split ( "i" ) . collect ( ) ;
903
+ let tx = TransactionIdentifier {
904
+ hash : format ! ( "0x{}" , comps[ 0 ] ) ,
905
+ } ;
906
+ let output_index = comps[ 1 ] . to_string ( ) . parse :: < usize > ( ) . unwrap ( ) ;
907
+ ( tx, output_index)
908
+ }
909
+
905
910
pub fn parse_outpoint_to_watch ( outpoint_to_watch : & str ) -> ( TransactionIdentifier , usize ) {
906
911
let comps: Vec < & str > = outpoint_to_watch. split ( ":" ) . collect ( ) ;
907
912
let tx = TransactionIdentifier {
0 commit comments