Skip to content

Commit fa44980

Browse files
committed
chore: some fixes on logs and added a check on take dispute to verify sender of the answer is mostro
1 parent 05210e4 commit fa44980

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/cli/take_dispute.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub async fn execute_admin_cancel_dispute(dispute_id: &Uuid, ctx: &Context) -> R
6363
.as_json()
6464
.map_err(|_| anyhow::anyhow!("Failed to serialize message"))?;
6565

66-
println!("🔑 Admin Keys: {}", ctx.context_keys.public_key);
66+
println!("🔑 Admin PubKey: {}", ctx.context_keys.public_key);
6767

6868
admin_send_dm(ctx, take_dispute_message).await?;
6969

@@ -148,8 +148,11 @@ pub async fn execute_take_dispute(dispute_id: &Uuid, ctx: &Context) -> Result<()
148148

149149
// Parse the incoming DM
150150
let messages = parse_dm_events(recv_event, &ctx.context_keys, None).await;
151-
if let Some((message, _, _)) = messages.first() {
151+
if let Some((message, _, sender_pubkey)) = messages.first() {
152152
let message_kind = message.get_inner_message_kind();
153+
if *sender_pubkey != ctx.mostro_pubkey {
154+
return Err(anyhow::anyhow!("Received response from wrong sender"));
155+
}
153156
if message_kind.action == Action::AdminTookDispute {
154157
print_commands_results(message_kind, ctx).await?;
155158
} else {

src/parser/dms.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn display_solver_dispute_info(dispute_info: &mostro_core::dispute::SolverDisput
254254

255255
// Basic dispute information
256256
rows.push(Row::from(vec![
257-
Cell::new("🆔 Dispute ID"),
257+
Cell::new("📋 Order ID:"),
258258
Cell::new(dispute_info.id.to_string()),
259259
]));
260260
rows.push(Row::from(vec![
@@ -589,12 +589,14 @@ pub async fn print_commands_results(message: &MessageKind, ctx: &Context) -> Res
589589
print_success_message("Trade index synchronized successfully!");
590590
}
591591
}
592-
Err(_) => return Err(anyhow::anyhow!("Failed to get user")),
592+
Err(_) => {
593+
println!("⚠️ Warning: Last trade index but received unexpected payload structure: {:#?}", message.payload);
594+
}
593595
}
594-
Ok(())
595596
} else {
596-
Err(anyhow::anyhow!("No trade index found in message"))
597+
println!("⚠️ Warning: Last trade index but received unexpected payload structure: {:#?}", message.payload);
597598
}
599+
Ok(())
598600
}
599601
Action::DisputeInitiatedByYou => {
600602
if let Some(Payload::Dispute(dispute_id, _)) = &message.payload {
@@ -627,6 +629,22 @@ pub async fn print_commands_results(message: &MessageKind, ctx: &Context) -> Res
627629
Ok(())
628630
}
629631
}
632+
Action::HoldInvoicePaymentAccepted => {
633+
if let Some(order_id) = &message.id {
634+
println!("🎉 Hold Invoice Payment Accepted");
635+
println!("═══════════════════════════════════════");
636+
println!("📋 Order ID: {}", order_id);
637+
println!("✅ Hold invoice payment accepted successfully!");
638+
println!("💰 Bitcoin has been released to the buyer");
639+
println!("🎊 Trade completed successfully!");
640+
Ok(())
641+
} else {
642+
println!(
643+
"⚠️ Warning: Hold invoice payment accepted but received unexpected payload structure"
644+
);
645+
Ok(())
646+
}
647+
}
630648
Action::HoldInvoicePaymentSettled | Action::Released => {
631649
println!("🎉 Payment Settled & Released");
632650
println!("═══════════════════════════════════════");
@@ -638,10 +656,13 @@ pub async fn print_commands_results(message: &MessageKind, ctx: &Context) -> Res
638656
Action::Orders => {
639657
if let Some(Payload::Orders(orders)) = &message.payload {
640658
handle_orders_list_display(orders);
641-
Ok(())
642659
} else {
643-
Err(anyhow::anyhow!("No orders payload found in message"))
660+
println!(
661+
"⚠️ Warning: Orders list but received unexpected payload structure: {:#?}",
662+
message.payload
663+
);
644664
}
665+
Ok(())
645666
}
646667
Action::AdminTookDispute => {
647668
if let Some(Payload::Dispute(_, Some(dispute_info))) = &message.payload {

0 commit comments

Comments
 (0)