Skip to content

Commit bc557bb

Browse files
committed
Bump nostr and nwc to 0.44.0
1 parent 155278d commit bc557bb

File tree

6 files changed

+39
-109
lines changed

6 files changed

+39
-109
lines changed

Cargo.lock

Lines changed: 26 additions & 61 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
@@ -43,8 +43,8 @@ image = { version = "0.25", features = ["jpeg", "png", "webp"] }
4343
indexmap = "2.6.0"
4444
log = "0.4.17"
4545
md5 = "0.7.0"
46-
nostr = { version = "0.37.0", default-features = false, features = ["std", "nip49"] }
47-
nwc = "0.39.0"
46+
nostr = { version = "0.44.0", default-features = false, features = ["std", "nip49"] }
47+
nwc = "0.44.0"
4848
mio = { version = "1.0.3", features = ["os-poll", "net"] }
4949
nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "2b2e5e43c019b80b98f1db6a03a1b88ca699bfa3" }
5050
#nostrdb = "0.6.1"

crates/enostr/src/keypair.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl FullKeypair {
105105
pub fn generate() -> Self {
106106
let mut rng = nostr::secp256k1::rand::rngs::OsRng;
107107
let (secret_key, _) = &nostr::SECP256K1.generate_keypair(&mut rng);
108-
let (xopk, _) = secret_key.x_only_public_key(&nostr::SECP256K1);
108+
let (xopk, _) = secret_key.x_only_public_key(nostr::SECP256K1);
109109
let secret_key = nostr::SecretKey::from(*secret_key);
110110
FullKeypair {
111111
pubkey: Pubkey::new(xopk.serialize()),
@@ -161,7 +161,7 @@ impl SerializableKeypair {
161161
Keypair::new(
162162
self.pubkey,
163163
self.encrypted_secret_key
164-
.and_then(|e| e.to_secret_key(pass).ok()),
164+
.and_then(|e| e.decrypt(pass).ok()),
165165
)
166166
}
167167
}
@@ -236,7 +236,7 @@ fn parse_seckey<'a>(parser: &mut TokenParser<'a>) -> Result<SecretKey, ParseErro
236236
let eseckey = EncryptedSecretKey::from_bech32(raw).map_err(|_| ParseError::DecodeFailed)?;
237237

238238
let seckey = eseckey
239-
.to_secret_key(ESECKEY_PASS)
239+
.decrypt(ESECKEY_PASS)
240240
.map_err(|_| ParseError::DecodeFailed)?;
241241

242242
Ok(seckey)

crates/enostr/src/relay/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl RelayPool {
316316
return Ok(());
317317
}
318318
let relay = Relay::new(
319-
nostr::RelayUrl::parse(url).map_err(|_| Error::InvalidRelayUrl)?,
319+
nostr::RelayUrl::parse(&url).map_err(|_| Error::InvalidRelayUrl)?,
320320
wakeup,
321321
)?;
322322
let pool_relay = PoolRelay::websocket(relay);

crates/notedeck/src/note/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use nostr::RelayUrl;
12
use enostr::{ClientMessage, NoteId, Pubkey, RelayPool};
23
use nostrdb::{Note, NoteKey};
34
use tracing::error;
@@ -70,8 +71,7 @@ impl NoteContextSelection {
7071
if note_author_is_selected_acc {
7172
let nip19event = nostr::nips::nip19::Nip19Event::new(
7273
nostr::event::EventId::from_byte_array(*note.id()),
73-
pool.urls(),
74-
);
74+
).relays(pool.urls().iter().filter_map(|url| RelayUrl::parse(url).ok()));
7575
let Ok(bech) = nostr::nips::nip19::ToBech32::to_bech32(&nip19event) else {
7676
return;
7777
};

crates/notedeck/src/wallet.rs

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{fmt::Display, sync::Arc};
1+
use std::sync::Arc;
22

33
use nwc::{
44
nostr::nips::nip47::{NostrWalletConnectURI, PayInvoiceRequest, PayInvoiceResponse},
@@ -68,7 +68,7 @@ pub enum WalletError {
6868
pub struct Wallet {
6969
pub uri: String,
7070
wallet: Arc<RwLock<NWC>>,
71-
balance: Option<Promise<Result<u64, NwcError>>>,
71+
balance: Option<Promise<Result<u64, nwc::Error>>>,
7272
}
7373

7474
impl Clone for Wallet {
@@ -116,7 +116,7 @@ impl Wallet {
116116
})
117117
}
118118

119-
pub fn get_balance(&mut self) -> Option<&Result<u64, NwcError>> {
119+
pub fn get_balance(&mut self) -> Option<&Result<u64, nwc::Error>> {
120120
if self.balance.is_none() {
121121
self.balance = Some(get_balance(self.wallet.clone()));
122122
return None;
@@ -138,50 +138,15 @@ impl Wallet {
138138
}
139139
}
140140

141-
#[derive(Clone)]
142-
pub enum NwcError {
143-
/// NIP47 error
144-
NIP47(String),
145-
/// Relay
146-
Relay(String),
147-
/// Premature exit
148-
PrematureExit,
149-
/// Request timeout
150-
Timeout,
151-
}
152-
153-
impl From<nwc::Error> for NwcError {
154-
fn from(value: nwc::Error) -> Self {
155-
match value {
156-
nwc::error::Error::NIP47(error) => NwcError::NIP47(error.to_string()),
157-
nwc::error::Error::Relay(error) => NwcError::Relay(error.to_string()),
158-
nwc::error::Error::PrematureExit => NwcError::PrematureExit,
159-
nwc::error::Error::Timeout => NwcError::Timeout,
160-
}
161-
}
162-
}
163-
164-
impl Display for NwcError {
165-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
166-
match self {
167-
NwcError::NIP47(err) => write!(f, "NIP47 error: {err}"),
168-
NwcError::Relay(err) => write!(f, "Relay error: {err}"),
169-
NwcError::PrematureExit => write!(f, "Premature exit"),
170-
NwcError::Timeout => write!(f, "Request timed out"),
171-
}
172-
}
173-
}
174-
175-
fn get_balance(nwc: Arc<RwLock<NWC>>) -> Promise<Result<u64, NwcError>> {
141+
fn get_balance(nwc: Arc<RwLock<NWC>>) -> Promise<Result<u64, nwc::Error>> {
176142
let (sender, promise) = Promise::new();
177143

178144
tokio::spawn(async move {
179145
sender.send(
180146
nwc.read()
181147
.await
182148
.get_balance()
183-
.await
184-
.map_err(nwc::Error::into),
149+
.await,
185150
);
186151
});
187152

0 commit comments

Comments
 (0)