1
use anyhow::Result;
2
use risc0_zkvm::Receipt; 
3
use std::{fs::read, path::Path};
4

            
5
pub fn read_receipt_file(receipt_path: &Path) -> Result<()> {
6
    println!("Attempting to read receipt from: {}", receipt_path.to_string_lossy());
7
    let receipt_bytes = read(receipt_path)?;
8
    let receipt: Receipt = bincode::deserialize(&receipt_bytes)?;
9

            
10
    println!("Successfully deserialized receipt.");
11

            
12
    // Print the journal
13
    if receipt.journal.bytes.is_empty() {
14
        println!("Committed output (journal) is empty.");
15
    } else {
16
        match std::str::from_utf8(&receipt.journal.bytes) {
17
            Ok(s) => println!("Committed output (journal) as string: \"{}\"", s),
18
            Err(_) => println!("Committed output (journal) as bytes: {:?}", receipt.journal.bytes),
19
        }
20
    }
21

            
22
    // We can also print other information from the receipt if needed,
23
    // for example, the Image ID (hex-encoded):
24
    // if let Ok(image_id) = receipt.get_image_id() { // Assuming get_image_id() returns a Result<[u32; 8]>
25
    //     let image_id_hex = image_id.iter().map(|word| format!("{:08x}", word)).collect::<String>();
26
    //     println!("Image ID: 0x{}", image_id_hex);
27
    // }
28

            
29
    Ok(())
30
}