Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ reqwest = { version = "0.12.23", default-features = false, features = [
"json",
"rustls-tls",
] }
mostro-core = "0.10.0"
mostro-core = "0.11.0"
lnurl-rs = { version = "0.9.0", default-features = false, features = ["ureq"] }
pretty_env_logger = "0.5.0"
sqlx = { version = "0.8.6", features = ["sqlite", "runtime-tokio-rustls"] }
Expand Down
49 changes: 49 additions & 0 deletions src/parser/dms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@ fn handle_pay_invoice_display(order: &Option<mostro_core::order::SmallOrder>, in
println!();
}

fn handle_pay_bond_invoice_display(order: &Option<mostro_core::order::SmallOrder>, invoice: &str) {
print_section_header("🪙 Anti-Abuse Bond Invoice");
if let Some(order) = order {
if let Some(order_id) = order.id {
println!("📋 Order ID: {}", order_id);
}
print_amount_info(order.amount);
print_fiat_code(&order.fiat_code);
println!("💵 Fiat Amount: {}", order.fiat_amount);
}
println!();
println!("⚡ LIGHTNING BOND INVOICE TO PAY:");
println!("─────────────────────────────────────");
println!("{}", invoice);
println!("─────────────────────────────────────");
println!("💡 Pay this hold invoice to lock your taker bond.");
println!("💡 The trade hold invoice will arrive next.");
println!();
}

/// Format payload details for DM table display
fn format_payload_details(payload: &Payload, action: &Action) -> String {
match payload {
Expand Down Expand Up @@ -113,6 +133,7 @@ fn format_payload_details(payload: &Payload, action: &Action) -> String {
Status::Expired => "⏰",
Status::SettledHoldInvoice => "💰",
Status::InProgress => "🔄",
Status::WaitingTakerBond => "🪙",
};

let kind_emoji = match o.kind.as_ref().unwrap_or(&mostro_core::order::Kind::Sell) {
Expand Down Expand Up @@ -486,6 +507,33 @@ pub async fn print_commands_results(message: &MessageKind, ctx: &Context) -> Res
}
Ok(())
}
// mostro-core 0.11: anti-abuse bond invoice sent right after a takebuy/takesell.
Action::PayBondInvoice => {
if let Some(Payload::PaymentRequest(order, invoice, _)) = &message.payload {
handle_pay_bond_invoice_display(order, invoice);

if let Some(order) = order {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return error when bond invoice payload has no order

Action::PayBondInvoice silently returns Ok(()) when Payload::PaymentRequest carries order = None, while the analogous Action::PayInvoice path treats missing order data as an error. Because this branch is where the taken order is persisted with trade keys, a null order here leaves the CLI without a saved order context and the command appears successful even though follow-up workflow state was not recorded.

Useful? React with 👍 / 👎.

if let Some(req_id) = message.request_id {
if let Err(e) = save_order(
order.clone(),
&ctx.trade_keys,
req_id,
ctx.trade_index,
&ctx.pool,
)
.await
{
println!("❌ Failed to save order: {}", e);
return Err(anyhow::anyhow!("Failed to save order: {}", e));
}
print_success_message("Order saved successfully!");
} else {
return Err(anyhow::anyhow!("No request id found in message"));
}
}
}
Ok(())
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Action::CantDo => {
println!("❌ Action Cannot Be Completed");
println!("═══════════════════════════════════════");
Expand Down Expand Up @@ -844,6 +892,7 @@ pub async fn print_direct_messages(
let action_icon = match inner.action {
Action::NewOrder => "🆕",
Action::AddInvoice | Action::PayInvoice => "⚡",
Action::PayBondInvoice => "🪙",
Action::FiatSent | Action::FiatSentOk => "💸",
Action::Release | Action::Released => "🔓",
Action::Cancel | Action::Canceled => "🚫",
Expand Down
Loading