-pub(crate) fn read_channelmonitors_from_disk(path: String, keys_manager: Arc<KeysManager>) ->
- Result<HashMap<OutPoint, (BlockHash, ChannelMonitor<InMemorySigner>)>, std::io::Error>
-{
- if !Path::new(&path).exists() {
- return Ok(HashMap::new())
- }
- let mut outpoint_to_channelmonitor = HashMap::new();
- for file_option in fs::read_dir(path).unwrap() {
- let file = file_option.unwrap();
- let owned_file_name = file.file_name();
- let filename = owned_file_name.to_str();
- if !filename.is_some() || !filename.unwrap().is_ascii() || filename.unwrap().len() < 65 {
- return Err(std::io::Error::new(std::io::ErrorKind::Other, "Invalid ChannelMonitor file name"));
- }
-
- let txid = Txid::from_hex(filename.unwrap().split_at(64).0);
- if txid.is_err() {
- return Err(std::io::Error::new(std::io::ErrorKind::Other, "Invalid tx ID in filename"));
- }
-
- let index = filename.unwrap().split_at(65).1.split('.').next().unwrap().parse();
- if index.is_err() {
- return Err(std::io::Error::new(std::io::ErrorKind::Other, "Invalid tx index in filename"));
- }
+pub(crate) fn read_inbound_payment_info(path: &Path) -> InboundPaymentInfoStorage {
+ if let Ok(file) = File::open(path) {
+ if let Ok(info) = InboundPaymentInfoStorage::read(&mut BufReader::new(file)) {
+ return info;
+ }
+ }
+ InboundPaymentInfoStorage { payments: HashMap::new() }
+}