Selaa lähdekoodia

feat: nostr_signing key as p2pk key

thesimplekid 9 kuukautta sitten
vanhempi
säilyke
762713692b
2 muutettua tiedostoa jossa 14 lisäystä ja 3 poistoa
  1. 9 1
      crates/cdk/src/nuts/nut01/public_key.rs
  2. 5 2
      crates/cdk/src/wallet.rs

+ 9 - 1
crates/cdk/src/nuts/nut01/public_key.rs

@@ -39,6 +39,14 @@ impl TryFrom<PublicKey> for nostr_sdk::PublicKey {
 }
 
 #[cfg(feature = "nostr")]
+impl TryFrom<&PublicKey> for nostr_sdk::PublicKey {
+    type Error = Error;
+    fn try_from(pubkey: &PublicKey) -> Result<Self, Self::Error> {
+        Ok(nostr_sdk::PublicKey::from_slice(&pubkey.to_bytes())?)
+    }
+}
+
+#[cfg(feature = "nostr")]
 impl TryFrom<nostr_sdk::PublicKey> for PublicKey {
     type Error = Error;
     fn try_from(pubkey: nostr_sdk::PublicKey) -> Result<Self, Self::Error> {
@@ -95,7 +103,7 @@ impl PublicKey {
     }
 
     #[inline]
-    pub fn x_only_pubkey(&self) -> XOnlyPublicKey {
+    pub fn x_only_public_key(&self) -> XOnlyPublicKey {
         self.inner.x_only_public_key().0
     }
 

+ 5 - 2
crates/cdk/src/wallet.rs

@@ -1176,7 +1176,7 @@ impl Wallet {
         let verifying_key = nostr_signing_key.public_key();
 
         let nostr_pubkey =
-            nostr_sdk::PublicKey::from_hex(verifying_key.x_only_pubkey().to_string())?;
+            nostr_sdk::PublicKey::from_hex(verifying_key.x_only_public_key().to_string())?;
 
         let filter = match self
             .localstore
@@ -1215,7 +1215,10 @@ impl Wallet {
 
         let mut total_received = Amount::ZERO;
         for token in tokens.iter() {
-            match self.receive(token, None, None).await {
+            match self
+                .receive(token, Some(vec![nostr_signing_key.clone()]), None)
+                .await
+            {
                 Ok(amount) => total_received += amount,
                 Err(err) => {
                     tracing::error!("Could not receive token: {}", err);