1
- use std:: error:: Error ;
2
- use std:: str:: FromStr ;
3
-
4
1
use clap:: Parser ;
5
- use nostr:: key:: SecretKey ;
6
- use nostr:: { Keys , PublicKey } ;
7
- use nostr_blossom:: client:: BlossomClient ;
2
+ use nostr:: prelude:: * ;
3
+ use nostr_blossom:: prelude:: * ;
8
4
9
5
#[ derive( Parser , Debug ) ]
10
6
#[ command( author, version, about = "List blob on a Blossom server" , long_about = None ) ]
@@ -13,30 +9,27 @@ struct Args {
13
9
#[ arg( long) ]
14
10
server : String ,
15
11
16
- /// The public key to list blobs for (in hex format)
12
+ /// The public key to list blobs for
17
13
#[ arg( long) ]
18
- pubkey : String ,
14
+ pubkey : PublicKey ,
19
15
20
16
/// Optional private key for authorization (in hex)
21
17
#[ arg( long) ]
22
- private_key : Option < String > ,
18
+ private_key : Option < SecretKey > ,
23
19
}
24
20
25
21
#[ tokio:: main]
26
- async fn main ( ) -> Result < ( ) , Box < dyn Error > > {
22
+ async fn main ( ) -> Result < ( ) > {
27
23
let args = Args :: parse ( ) ;
28
24
let client = BlossomClient :: new ( & args. server ) ;
29
25
30
- let pubkey = PublicKey :: from_str ( & args. pubkey ) ?;
31
-
32
26
// Check if a private key was provided and branch accordingly
33
- if let Some ( private_key_str ) = args. private_key {
27
+ if let Some ( private_key ) = args. private_key {
34
28
// Attempt to create the secret key, propagating error if parsing fails
35
- let secret_key = SecretKey :: from_hex ( & private_key_str) ?;
36
- let keys = Keys :: new ( secret_key) ;
29
+ let keys = Keys :: new ( private_key) ;
37
30
38
31
let descriptors = client
39
- . list_blobs ( & pubkey, None , None , None , Some ( & keys) )
32
+ . list_blobs ( & args . pubkey , None , None , None , Some ( & keys) )
40
33
. await ?;
41
34
42
35
println ! ( "Successfully listed blobs (with auth):" ) ;
@@ -45,7 +38,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
45
38
}
46
39
} else {
47
40
let descriptors = client
48
- . list_blobs ( & pubkey, None , None , None , None :: < & Keys > )
41
+ . list_blobs ( & args . pubkey , None , None , None , None :: < & Keys > )
49
42
. await ?;
50
43
51
44
println ! ( "Successfully listed blobs (without auth):" ) ;
0 commit comments