Skip to content

Commit 19756ee

Browse files
committed
nostr: rename public_key to remote_signer_public_key in NostrConnectRequest::Connect variant
Pull-Request: #1111 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 806c46e commit 19756ee

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

crates/nostr/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- Change NIP-47 `GetInfoResponse` `pubkey` type from `PublicKey` to `String`
3636
- Change `methods` type to `Vec<Method>` in `GetInfoResponse` (https://github.com/rust-nostr/nostr/pull/1094)
3737
- Merge `ClientMessage::Req` and `ClientMessage::ReqMultiFilter` variants (https://github.com/rust-nostr/nostr/pull/1101)
38+
- Rename `public_key` to `remote_signer_public_key` in `NostrConnectRequest::Connect` variant (https://github.com/rust-nostr/nostr/pull/1111)
3839

3940
### Added
4041

crates/nostr/src/nips/nip46.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ impl<'de> Deserialize<'de> for NostrConnectMethod {
197197
pub enum NostrConnectRequest {
198198
/// Connect
199199
Connect {
200-
/// Remote public key
201-
public_key: PublicKey,
200+
/// Remote signer public key
201+
remote_signer_public_key: PublicKey,
202202
/// Optional secret
203203
secret: Option<String>,
204204
},
@@ -243,10 +243,15 @@ impl NostrConnectRequest {
243243
pub fn from_message(method: NostrConnectMethod, params: Vec<String>) -> Result<Self, Error> {
244244
match method {
245245
NostrConnectMethod::Connect => {
246-
let public_key = params.first().ok_or(Error::InvalidRequest)?;
247-
let public_key: PublicKey = PublicKey::from_hex(public_key)?;
246+
let remote_signer_public_key: &String =
247+
params.first().ok_or(Error::InvalidRequest)?;
248+
let remote_signer_public_key: PublicKey =
249+
PublicKey::from_hex(remote_signer_public_key)?;
248250
let secret: Option<String> = params.get(1).cloned();
249-
Ok(Self::Connect { public_key, secret })
251+
Ok(Self::Connect {
252+
remote_signer_public_key,
253+
secret,
254+
})
250255
}
251256
NostrConnectMethod::GetPublicKey => Ok(Self::GetPublicKey),
252257
NostrConnectMethod::SignEvent => {
@@ -315,8 +320,11 @@ impl NostrConnectRequest {
315320
/// Get req params
316321
pub fn params(&self) -> Vec<String> {
317322
match self {
318-
Self::Connect { public_key, secret } => {
319-
let mut params = vec![public_key.to_hex()];
323+
Self::Connect {
324+
remote_signer_public_key,
325+
secret,
326+
} => {
327+
let mut params = vec![remote_signer_public_key.to_hex()];
320328
if let Some(secret) = secret {
321329
params.push(secret.to_owned());
322330
}
@@ -1190,7 +1198,7 @@ mod test {
11901198
assert_eq!(
11911199
req,
11921200
NostrConnectRequest::Connect {
1193-
public_key: PublicKey::from_hex(
1201+
remote_signer_public_key: PublicKey::from_hex(
11941202
"79dff8f82963424e0bb02708a22e44b4980893e3a4be0fa3cb60a43b946764e3"
11951203
)
11961204
.unwrap(),

0 commit comments

Comments
 (0)