Skip to content
Merged
Show file tree
Hide file tree
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
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.11.0"
mostro-core = "0.11.1"
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
24 changes: 22 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,24 @@ pub enum Commands {
/// Order id
#[arg(short, long)]
order_id: Uuid,
/// Slash the seller's bond (anti-abuse-bond Phase 2)
#[arg(long, default_value_t = false)]
slash_seller: bool,
/// Slash the buyer's bond (anti-abuse-bond Phase 2)
#[arg(long, default_value_t = false)]
slash_buyer: bool,
},
/// Settle a seller's hold invoice (only admin)
AdmSettle {
/// Order id
#[arg(short, long)]
order_id: Uuid,
/// Slash the seller's bond (anti-abuse-bond Phase 2)
#[arg(long, default_value_t = false)]
slash_seller: bool,
/// Slash the buyer's bond (anti-abuse-bond Phase 2)
#[arg(long, default_value_t = false)]
slash_buyer: bool,
},
/// Requests open disputes from Mostro pubkey
ListDisputes {},
Expand Down Expand Up @@ -583,8 +595,16 @@ impl Commands {
// Admin commands
Commands::ListDisputes {} => execute_list_disputes(ctx).await,
Commands::AdmAddSolver { npubkey } => execute_admin_add_solver(npubkey, ctx).await,
Commands::AdmSettle { order_id } => execute_admin_settle_dispute(order_id, ctx).await,
Commands::AdmCancel { order_id } => execute_admin_cancel_dispute(order_id, ctx).await,
Commands::AdmSettle {
order_id,
slash_seller,
slash_buyer,
} => execute_admin_settle_dispute(order_id, *slash_seller, *slash_buyer, ctx).await,
Commands::AdmCancel {
order_id,
slash_seller,
slash_buyer,
} => execute_admin_cancel_dispute(order_id, *slash_seller, *slash_buyer, ctx).await,
Commands::AdmTakeDispute { dispute_id } => execute_take_dispute(dispute_id, ctx).await,

// Simple commands
Expand Down
48 changes: 44 additions & 4 deletions src/cli/take_dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ pub async fn execute_admin_add_solver(npubkey: &str, ctx: &Context) -> Result<()
Ok(())
}

pub async fn execute_admin_cancel_dispute(dispute_id: &Uuid, ctx: &Context) -> Result<()> {
pub async fn execute_admin_cancel_dispute(
dispute_id: &Uuid,
slash_seller: bool,
slash_buyer: bool,
ctx: &Context,
) -> Result<()> {
println!("👑 Admin Cancel Dispute");
println!("═══════════════════════════════════════");
let mut table = create_standard_table();
Expand All @@ -54,6 +59,12 @@ pub async fn execute_admin_cancel_dispute(dispute_id: &Uuid, ctx: &Context) -> R
"Dispute ID",
&dispute_id.to_string(),
));
if slash_seller {
table.add_row(create_emoji_field_row("⚔️ ", "Slash", "seller bond"));
}
if slash_buyer {
table.add_row(create_emoji_field_row("⚔️ ", "Slash", "buyer bond"));
}
table.add_row(create_emoji_field_row(
"🎯 ",
"Mostro PubKey",
Expand All @@ -64,9 +75,18 @@ pub async fn execute_admin_cancel_dispute(dispute_id: &Uuid, ctx: &Context) -> R

let _admin_keys = get_admin_keys(ctx)?;

let payload = if slash_seller || slash_buyer {
Some(Payload::BondResolution(BondResolution {
slash_seller,
slash_buyer,
}))
} else {
None
};

// Build admin dispute message
let take_dispute_message =
Message::new_dispute(Some(*dispute_id), None, None, Action::AdminCancel, None)
Message::new_dispute(Some(*dispute_id), None, None, Action::AdminCancel, payload)
.as_json()
.map_err(|_| anyhow::anyhow!("Failed to serialize message"))?;

Expand All @@ -77,7 +97,12 @@ pub async fn execute_admin_cancel_dispute(dispute_id: &Uuid, ctx: &Context) -> R
Ok(())
}

pub async fn execute_admin_settle_dispute(dispute_id: &Uuid, ctx: &Context) -> Result<()> {
pub async fn execute_admin_settle_dispute(
dispute_id: &Uuid,
slash_seller: bool,
slash_buyer: bool,
ctx: &Context,
) -> Result<()> {
println!("👑 Admin Settle Dispute");
println!("═══════════════════════════════════════");
let mut table = create_standard_table();
Expand All @@ -87,6 +112,12 @@ pub async fn execute_admin_settle_dispute(dispute_id: &Uuid, ctx: &Context) -> R
"Dispute ID",
&dispute_id.to_string(),
));
if slash_seller {
table.add_row(create_emoji_field_row("⚔️ ", "Slash", "seller bond"));
}
if slash_buyer {
table.add_row(create_emoji_field_row("⚔️ ", "Slash", "buyer bond"));
}
table.add_row(create_emoji_field_row(
"🎯 ",
"Mostro PubKey",
Expand All @@ -97,9 +128,18 @@ pub async fn execute_admin_settle_dispute(dispute_id: &Uuid, ctx: &Context) -> R

let _admin_keys = get_admin_keys(ctx)?;

let payload = if slash_seller || slash_buyer {
Some(Payload::BondResolution(BondResolution {
slash_seller,
slash_buyer,
}))
} else {
None
};

// Build admin dispute message
let take_dispute_message =
Message::new_dispute(Some(*dispute_id), None, None, Action::AdminSettle, None)
Message::new_dispute(Some(*dispute_id), None, None, Action::AdminSettle, payload)
.as_json()
.map_err(|_| anyhow::anyhow!("Failed to serialize message"))?;
admin_send_dm(ctx, take_dispute_message).await?;
Expand Down
Loading