Skip to content

Commit

Permalink
Fix #154 process_response return ResponseError
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Dec 29, 2023
1 parent 26f0d06 commit 3054ed8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions payjoin-cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,13 @@ impl App {
.await??;

println!("Sent fallback transaction");
let psbt = ctx.process_response(&mut response.into_reader())?;
if let Some(psbt) = psbt {
return Ok(psbt);
} else {
log::info!("No response yet for POST payjoin request, retrying some seconds");
std::thread::sleep(std::time::Duration::from_secs(5));
match ctx.process_response(&mut response.into_reader()) {
Ok(Some(psbt)) => return Ok(psbt),
Ok(None) => std::thread::sleep(std::time::Duration::from_secs(5)),
Err(re) => {
println!("{}", re);
log::debug!("{:?}", re);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion payjoin/src/send/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ impl ContextV2 {
pub fn process_response(
self,
response: &mut impl std::io::Read,
) -> Result<Option<Psbt>, ValidationError> {
) -> Result<Option<Psbt>, ResponseError> {
let mut res_buf = Vec::new();
response.read_to_end(&mut res_buf).map_err(InternalValidationError::Io)?;
let mut res_buf = crate::v2::ohttp_decapsulate(self.ohttp_res, &res_buf)
Expand Down

0 comments on commit 3054ed8

Please sign in to comment.