Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit 66d95a5

Browse files
authored
update README.md
1 parent 083d887 commit 66d95a5

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

README.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ A Python library for making [Nostr](https://github.com/nostr-protocol/nostr) cli
44
## Usage
55
**Generate a key**
66
```python
7-
from nostr.key import generate_private_key, get_public_key
7+
from nostr.key import PrivateKey
88

9-
private_key = generate_private_key()
10-
public_key = get_public_key(private_key)
9+
private_key = PrivateKey()
10+
public_key = private_key.public_key
11+
print(f"Private key: {private_key.bech32()}")
12+
print(f"Public key: {public_key.bech32()}")
1113
```
1214
**Connect to relays**
1315
```python
@@ -32,19 +34,18 @@ import time
3234
from nostr.event import Event
3335
from nostr.relay_manager import RelayManager
3436
from nostr.message_type import ClientMessageType
35-
from nostr.key import generate_private_key, get_public_key
37+
from nostr.key import PrivateKey
3638

3739
relay_manager = RelayManager()
3840
relay_manager.add_relay("wss://nostr-pub.wellorder.net")
3941
relay_manager.add_relay("wss://relay.damus.io")
4042
relay_manager.open_connections({"cert_reqs": ssl.CERT_NONE}) # NOTE: This disables ssl certificate verification
4143
time.sleep(1.25) # allow the connections to open
4244

43-
private_key = generate_private_key()
44-
public_key = get_public_key(private_key)
45+
private_key = PrivateKey()
4546

46-
event = Event(public_key, "Hello Nostr")
47-
event.sign(private_key)
47+
event = Event(private_key.public_key.hex(), "Hello Nostr")
48+
event.sign(private_key.hex())
4849

4950
message = json.dumps([ClientMessageType.EVENT, event.to_json_object()])
5051
relay_manager.publish_message(message)
@@ -59,7 +60,6 @@ from nostr.filter import Filter, Filters
5960
from nostr.event import Event, EventKind
6061
from nostr.relay_manager import RelayManager
6162
from nostr.message_type import ClientMessageType
62-
from nostr.key import generate_private_key, get_public_key
6363

6464
filters = Filters([Filter(authors=[<a nostr pubkey in hex>], kinds=[EventKind.TEXT_NOTE])])
6565
subscription_id = <a string to identify a subscription>
@@ -85,13 +85,21 @@ relay_manager.close_connections()
8585
```
8686

8787
## Installation
88-
1. Clone repository \
89-
```git clone https://github.com/jeffthibault/python-nostr.git```
90-
2. Install dependencies in repo \
91-
```python -m venv venv``` \
92-
```pip install -r requirements.txt```
88+
1. Clone repository
89+
```bash
90+
git clone https://github.com/jeffthibault/python-nostr.git
91+
```
92+
2. Install dependencies in repo
93+
```bash
94+
python -m venv venv
95+
pip install -r requirements.txt
96+
```
9397

94-
Note: If the pip install fails, you might need to install wheel. Try ```pip install wheel``` then ```pip install -r requirements.txt```
98+
Note: If the pip install fails, you might need to install ```wheel```. Try the following:
99+
```bash
100+
pip install wheel
101+
pip install -r requirements.txt
102+
```
95103

96104
## Dependencies
97105
- [websocket-client](https://github.com/websocket-client/websocket-client) for websocket operations

0 commit comments

Comments
 (0)