Skip to content

Commit 0c4551d

Browse files
grunchclaude
andcommitted
refactor: migrate gift-wrap to mostro-core 0.9.1 nip59 module
Bump mostro-core to 0.9.1 and nostr-sdk to 0.44.1, then replace the local NIP-59 implementation with the centralized `wrap_message` / `unwrap_message` / `validate_response` API exposed by `mostro_core::nip59`. - send_dm now delegates to wrap_message; identity_keys parameter is dropped because nostr-sdk 0.44 enforces rumor.pubkey == seal.pubkey (SenderMismatch). The single signer drives rumor authorship, seal signing, and the inner tuple signature. - Admin flows (storage::admin_send_dm, take_dispute) now sign the whole pipeline with admin_keys, aligning with how send_admin_gift_wrap_dm already worked for plain DMs. - parse_dm_events uses unwrap_message; print_dm_events uses validate_response, with one documented exception for `NewOrder` pushes that arrive without a request_id (range-trade child). - Drops gift_wrap_from_seal_with_pow, create_gift_wrap_event, send_gift_wrap_dm{,_internal}, send_admin_gift_wrap_dm, determine_message_type, create_expiration_tags, and the MessageType enum, all subsumed by the new API. - NIP-17 `PrivateDirectMessage` (kind 14) and the per-dispute shared-key chat transport are out of scope and left untouched. Knock-on changes from the dependency bump: rename NOSTR_REPLACEABLE_EVENT_KIND to NOSTR_ORDER_EVENT_KIND (same value 38383, preserves derived BIP32 keys), Timestamp::as_u64 → as_secs, and add the new `initiator` / `solver_pubkey` fields to RestoredDisputesInfo in tests. Tests: 4 new wiring unit tests in messaging.rs (wrap→unwrap roundtrip, SECRET semantics, PoW, wrong-keys → None) and 2 new integration tests in tests/parser_dms.rs covering the wrap_message → parse_dm_events handshake. Closes #163 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 92e5e02 commit 0c4551d

24 files changed

Lines changed: 296 additions & 420 deletions

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ path = "src/main.rs"
2222
[dependencies]
2323
anyhow = "1.0.99"
2424
clap = { version = "4.5.46", features = ["derive"] }
25-
nostr-sdk = { version = "0.43.0", features = [
25+
nostr-sdk = { version = "0.44.1", features = [
2626
"nip06",
2727
"nip44",
2828
"nip59",
@@ -46,7 +46,7 @@ reqwest = { version = "0.12.23", default-features = false, features = [
4646
"json",
4747
"rustls-tls",
4848
] }
49-
mostro-core = "0.6.56"
49+
mostro-core = "0.9.1"
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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ 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-
Some(&ctx.identity_keys),
7978
&order_trade_keys,
8079
&ctx.mostro_pubkey,
8180
message_json,

src/cli/adm_send_dm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::parser::common::{
33
create_emoji_field_row, create_field_value_header, create_standard_table,
44
};
55
use crate::util::messaging::get_admin_keys;
6-
use crate::util::send_admin_gift_wrap_dm;
6+
use crate::util::send_plain_text_dm;
77
use anyhow::Result;
88
use nostr_sdk::prelude::*;
99

@@ -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_admin_gift_wrap_dm(&ctx.client, admin_keys, &receiver, message).await?;
32+
send_plain_text_dm(&ctx.client, admin_keys, &receiver, message).await?;
3333

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

src/cli/last_trade_index.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub async fn execute_last_trade_index(
2626
// Send the last trade index message to Mostro server
2727
let sent_message = send_dm(
2828
&ctx.client,
29-
Some(identity_keys),
3029
&ctx.trade_keys,
3130
&mostro_key,
3231
message_json,

src/cli/new_order.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ pub async fn execute_new_order(
183183
// Send the DM
184184
let sent_message = send_dm(
185185
&ctx.client,
186-
Some(&ctx.identity_keys),
187186
&ctx.trade_keys,
188187
&ctx.mostro_pubkey,
189188
message_json,

src/cli/orders_info.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub async fn execute_orders_info(order_ids: &[Uuid], ctx: &Context) -> Result<()
4444
// Send the DM
4545
let sent_message = send_dm(
4646
&ctx.client,
47-
Some(&ctx.identity_keys),
4847
&ctx.trade_keys,
4948
&ctx.mostro_pubkey,
5049
message_json,

src/cli/rate_user.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ 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-
Some(&ctx.identity_keys),
6463
&trade_keys,
6564
&ctx.mostro_pubkey,
6665
rate_message,

src/cli/restore.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub async fn execute_restore(
2222
// Send the restore message to Mostro server
2323
let sent_message = send_dm(
2424
&ctx.client,
25-
Some(identity_keys),
2625
&ctx.trade_keys,
2726
&mostro_key,
2827
message_json,

src/cli/send_admin_dm_attach.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async fn upload_to_blossom(trade_keys: &Keys, encrypted_blob: Vec<u8>) -> Result
8282
.collect::<String>();
8383

8484
// Expiration: 1 hour from now (BUD-01 requires expiration in the future)
85-
let expiration = Timestamp::from(Timestamp::now().as_u64() + 3600);
85+
let expiration = Timestamp::from_secs(Timestamp::now().as_secs() + 3600);
8686

8787
for server in BLOSSOM_SERVERS {
8888
let url_str = format!("{}/upload", server.trim_end_matches('/'));

0 commit comments

Comments
 (0)