Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Various NWC fixes #986

Merged
merged 3 commits into from
Jan 25, 2024
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
2 changes: 1 addition & 1 deletion mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ impl<S: MutinyStorage> InvoiceHandler for MutinyWallet<S> {
}

async fn get_outbound_payment_status(&self, payment_hash: &[u8; 32]) -> Option<HTLCStatus> {
self.get_invoice_by_hash(&sha256::Hash::hash(payment_hash))
self.get_invoice_by_hash(&sha256::Hash::from_inner(*payment_hash))
.await
.ok()
.map(|p| p.status)
Expand Down
9 changes: 6 additions & 3 deletions mutiny-core/src/nostr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<S: MutinyStorage> NostrManager<S> {
self.storage.set_nwc_sync_time(now.as_u64())?;
now
}
Some(time) => Timestamp::from(time),
Some(time) => Timestamp::from(time + 1), // add one so we get only new events
};

let vec = self
Expand Down Expand Up @@ -168,7 +168,7 @@ impl<S: MutinyStorage> NostrManager<S> {
self.storage.set_dm_sync_time(now.as_u64())?;
now
}
Some(time) => Timestamp::from(time),
Some(time) => Timestamp::from(time + 1), // add one so we get only new events
};

let received_dm_filter = Filter::new()
Expand Down Expand Up @@ -509,7 +509,10 @@ impl<S: MutinyStorage> NostrManager<S> {
) -> Result<NwcProfile, MutinyError> {
let profile = self.create_new_profile(profile_type, spending_conditions, tag)?;
// add relay if needed
self.client.add_relay(profile.relay.as_str()).await?;
let needs_connect = self.client.add_relay(profile.relay.as_str()).await?;
if needs_connect {
self.client.connect_relay(profile.relay.as_str()).await?;
}

let info_event = self.nwc.read().unwrap().iter().find_map(|nwc| {
if nwc.profile.index == profile.index {
Expand Down
Loading