Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/handlers/payjoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ impl<'a> PayjoinManager<'a> {
})?;

let pj_uri = receiver.pj_uri();
println!("Request Payjoin by sharing this Payjoin Uri:");
println!("{pj_uri}");
eprintln!("Request Payjoin by sharing this Payjoin Uri:");
eprintln!("{pj_uri}");

self.proceed_receiver_session(
ReceiveSession::Initialized(receiver.clone()),
Expand Down Expand Up @@ -268,7 +268,7 @@ impl<'a> PayjoinManager<'a> {
replay_sender_event_log(&sender_persister).map_err(|e| {
Error::Generic(format!("Failed to replay sender event log: {e:?}"))
})?;
println!("Resuming existing sender session");
eprintln!("Resuming existing sender session");
(send_session, sender_persister)
} else {
let persister = {
Expand Down Expand Up @@ -378,7 +378,7 @@ impl<'a> PayjoinManager<'a> {
.save(persister);
match state_transition {
Ok(OptionalTransitionOutcome::Progress(next_state)) => {
println!("Got a request from the sender. Responding with a Payjoin proposal.");
eprintln!("Got a request from the sender. Responding with a Payjoin proposal.");
break next_state;
}
Ok(OptionalTransitionOutcome::Stasis(current_state)) => {
Expand Down Expand Up @@ -417,10 +417,10 @@ impl<'a> PayjoinManager<'a> {
))
})?;

println!(
eprintln!(
"Checking whether the original proposal can be broadcasted itself is not supported. If the Payjoin fails, manually fall back to the transaction below."
);
println!(
eprintln!(
"{}",
serialize_hex(&next_receiver_typestate.extract_tx_to_schedule_broadcast())
);
Expand Down Expand Up @@ -620,7 +620,7 @@ impl<'a> PayjoinManager<'a> {
let next_receiver_typestate = receiver
.process_response(&res.bytes().await?, ctx)
.save(persister)?;
println!(
eprintln!(
"Response successful. TXID: {}",
payjoin_psbt.extract_tx_unchecked_fee_rate().compute_txid()
);
Expand All @@ -645,7 +645,7 @@ impl<'a> PayjoinManager<'a> {
let sync_interval = tokio::time::Duration::from_secs(3);
let timeout_duration = tokio::time::Duration::from_secs(15);

println!(
eprintln!(
"Polling for Payjoin transaction broadcast. This may take up to {} seconds...",
timeout_duration.as_secs()
);
Expand Down Expand Up @@ -678,7 +678,7 @@ impl<'a> PayjoinManager<'a> {
.save(persister);

if let Ok(OptionalTransitionOutcome::Progress(_)) = check_result {
println!("Payjoin transaction detected in the mempool!");
eprintln!("Payjoin transaction detected in the mempool!");
return Ok(());
}
// For Stasis or Err, continue polling (implicit - falls through to next loop iteration)
Expand Down Expand Up @@ -787,11 +787,11 @@ impl<'a> PayjoinManager<'a> {
.save(persister);
match processed_response {
Ok(OptionalTransitionOutcome::Progress(psbt)) => {
println!("Proposal received. Processing...");
eprintln!("Proposal received. Processing...");
return self.process_payjoin_proposal(psbt, blockchain_client).await;
}
Ok(OptionalTransitionOutcome::Stasis(current_state)) => {
println!("No response yet. Continuing polling...");
eprintln!("No response yet. Continuing polling...");
sender = current_state;
continue;
}
Expand Down Expand Up @@ -894,14 +894,14 @@ impl<'a> PayjoinManager<'a> {
let mut timed_out = 0usize;
let mut failed = 0usize;

println!("Resuming {} payjoin session(s)...\n", total_sessions);
eprintln!("Resuming {} payjoin session(s)...\n", total_sessions);

// Resume receiver sessions
for session_id in recv_session_ids {
let persister = ReceiverPersister::from_id(db.clone(), session_id.clone());
match replay_receiver_event_log(&persister) {
Ok((receiver_state, _)) => {
println!("Resuming receiver session {}", session_id);
eprintln!("Resuming receiver session {}", session_id);
match tokio::time::timeout(
std::time::Duration::from_secs(30),
self.proceed_receiver_session(
Expand All @@ -918,17 +918,17 @@ impl<'a> PayjoinManager<'a> {
}
Ok(Err(e)) => {
failed += 1;
println!("Receiver session {} failed: {}", session_id, e);
eprintln!("Receiver session {} failed: {}", session_id, e);
}
Err(_) => {
timed_out += 1;
println!("Receiver session {} timed out", session_id);
eprintln!("Receiver session {} timed out", session_id);
}
}
}
Err(e) => {
failed += 1;
println!("Failed to replay receiver session {}: {:?}", session_id, e);
eprintln!("Failed to replay receiver session {}: {:?}", session_id, e);
}
}
}
Expand All @@ -938,7 +938,7 @@ impl<'a> PayjoinManager<'a> {
let persister = SenderPersister::from_id(db.clone(), session_id.clone());
match replay_sender_event_log(&persister) {
Ok((sender_state, _)) => {
println!("Resuming sender session {}", session_id);
eprintln!("Resuming sender session {}", session_id);
match tokio::time::timeout(
std::time::Duration::from_secs(30),
self.proceed_sender_session(sender_state, &persister, blockchain_client),
Expand All @@ -950,17 +950,17 @@ impl<'a> PayjoinManager<'a> {
}
Ok(Err(e)) => {
failed += 1;
println!("Sender session {} failed: {}", session_id, e);
eprintln!("Sender session {} failed: {}", session_id, e);
}
Err(_) => {
timed_out += 1;
println!("Sender session {} timed out", session_id);
eprintln!("Sender session {} timed out", session_id);
}
}
}
Err(e) => {
failed += 1;
println!("Failed to replay sender session {}: {:?}", session_id, e);
eprintln!("Failed to replay sender session {}: {:?}", session_id, e);
}
}
}
Expand Down
Loading