Skip to content

Commit 348b368

Browse files
authored
Merge pull request #165 from MostroP2P/migrate/mostro-core-0.10.0-dual-key-giftwrap
refactor: migrate gift-wrap to mostro-core 0.10 dual identity/trade keys
2 parents e30a1d5 + 72bdc75 commit 348b368

17 files changed

Lines changed: 131 additions & 43 deletions

.codex

Whitespace-only changes.

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ reqwest = { version = "0.12.23", default-features = false, features = [
4646
"json",
4747
"rustls-tls",
4848
] }
49-
mostro-core = "0.9.1"
49+
mostro-core = "0.10.0"
5050
lnurl-rs = { version = "0.9.0", default-features = false, features = ["ureq"] }
5151
pretty_env_logger = "0.5.0"
5252
sqlx = { version = "0.8.6", features = ["sqlite", "runtime-tokio-rustls"] }

src/cli/add_invoice.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub async fn execute_add_invoice(order_id: &Uuid, invoice: &str, ctx: &Context)
7575
// Send the DM
7676
let sent_message = send_dm(
7777
&ctx.client,
78+
&ctx.identity_keys,
7879
&order_trade_keys,
7980
&ctx.mostro_pubkey,
8081
message_json,

src/cli/adm_send_dm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub async fn execute_adm_send_dm(receiver: PublicKey, ctx: &Context, message: &s
2929
println!("{table}");
3030
println!("💡 Sending admin gift wrap message...\n");
3131

32-
send_plain_text_dm(&ctx.client, admin_keys, &receiver, message).await?;
32+
send_plain_text_dm(&ctx.client, admin_keys, admin_keys, &receiver, message).await?;
3333

3434
println!(
3535
"✅ Admin gift wrap message sent successfully to {}",

src/cli/last_trade_index.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ pub async fn execute_last_trade_index(
2424
.map_err(|_| anyhow::anyhow!("Failed to serialize message"))?;
2525

2626
// LastTradeIndex is account-scoped: the answer depends on which user
27-
// is asking, and Mostro looks that up by the sender pubkey. Sign with
28-
// `identity_keys` so the request resolves to the account, not to a
29-
// (possibly unregistered) trade key.
27+
// is asking, and Mostro looks that up by the sender pubkey. Sign both
28+
// seal and rumor with `identity_keys` so the request resolves to the
29+
// account, not to a (possibly unregistered) trade key.
3030
let sent_message = send_dm(
3131
&ctx.client,
3232
identity_keys,
33+
identity_keys,
3334
&mostro_key,
3435
message_json,
3536
None,

src/cli/new_order.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ pub async fn execute_new_order(
183183
// Send the DM
184184
let sent_message = send_dm(
185185
&ctx.client,
186+
&ctx.identity_keys,
186187
&ctx.trade_keys,
187188
&ctx.mostro_pubkey,
188189
message_json,

src/cli/orders_info.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ pub async fn execute_orders_info(order_ids: &[Uuid], ctx: &Context) -> Result<()
2727
// Create payload with the order IDs
2828
let payload = Payload::Ids(order_ids.to_vec());
2929

30-
// Create message using the proper Message structure
31-
let message = Message::new_order(
32-
None,
33-
Some(request_id),
34-
Some(ctx.trade_index),
35-
Action::Orders,
36-
Some(payload),
37-
);
30+
// Orders info is account-scoped — Mostro indexes users by their identity
31+
// pubkey, so the message carries no trade_index and the whole exchange
32+
// (send, wait, decrypt) runs on `identity_keys`.
33+
let message = Message::new_order(None, Some(request_id), None, Action::Orders, Some(payload));
3834

3935
// Serialize the message
4036
let message_json = message
@@ -44,18 +40,19 @@ pub async fn execute_orders_info(order_ids: &[Uuid], ctx: &Context) -> Result<()
4440
// Send the DM
4541
let sent_message = send_dm(
4642
&ctx.client,
47-
&ctx.trade_keys,
43+
&ctx.identity_keys,
44+
&ctx.identity_keys,
4845
&ctx.mostro_pubkey,
4946
message_json,
5047
None,
5148
false,
5249
);
5350

5451
// Wait for the DM response from mostro
55-
let recv_event = wait_for_dm(ctx, None, sent_message).await?;
52+
let recv_event = wait_for_dm(ctx, Some(&ctx.identity_keys), sent_message).await?;
5653

5754
// Parse the incoming DM and handle the response
58-
let messages = crate::parser::dms::parse_dm_events(recv_event, &ctx.trade_keys, None).await;
55+
let messages = crate::parser::dms::parse_dm_events(recv_event, &ctx.identity_keys, None).await;
5956
if let Some((message, _, _)) = messages.first() {
6057
let message_kind = message.get_inner_message_kind();
6158

src/cli/rate_user.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub async fn execute_rate_user(order_id: &Uuid, rating: &u8, ctx: &Context) -> R
6060

6161
let sent_message = send_dm(
6262
&ctx.client,
63+
&ctx.identity_keys,
6364
&trade_keys,
6465
&ctx.mostro_pubkey,
6566
rate_message,

src/cli/restore.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ pub async fn execute_restore(
2222
// Restore is account-scoped: Mostro indexes users by their identity
2323
// pubkey, so the whole exchange (send, wait, decrypt) runs on
2424
// `identity_keys` — an unregistered trade key would look like an
25-
// unknown user and recovery would silently return nothing.
25+
// unknown user and recovery would silently return nothing. With the
26+
// mostro-core 0.10 dual-key split we pass `identity_keys` as both
27+
// the seal signer and the rumor author.
2628
let sent_message = send_dm(
2729
&ctx.client,
2830
identity_keys,
31+
identity_keys,
2932
&mostro_key,
3033
message_json,
3134
None,

0 commit comments

Comments
 (0)