nerva-py 1.0.1__py3-none-any.whl → 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nerva/__init__.py +1 -1
- nerva/__main__.py +2 -2
- nerva/daemon.py +25 -14
- nerva/wallet.py +8 -9
- {nerva_py-1.0.1.dist-info → nerva_py-1.1.1.dist-info}/METADATA +20 -17
- nerva_py-1.1.1.dist-info/RECORD +9 -0
- {nerva_py-1.0.1.dist-info → nerva_py-1.1.1.dist-info}/WHEEL +1 -1
- nerva_py-1.0.1.dist-info/RECORD +0 -9
- {nerva_py-1.0.1.dist-info → nerva_py-1.1.1.dist-info}/licenses/LICENSE +0 -0
nerva/__init__.py
CHANGED
nerva/__main__.py
CHANGED
|
@@ -2,7 +2,7 @@ import sys
|
|
|
2
2
|
import argparse
|
|
3
3
|
import platform
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import httpx
|
|
6
6
|
|
|
7
7
|
import nerva
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ def show_version() -> None:
|
|
|
18
18
|
|
|
19
19
|
entries.append(f"- nerva-py v{nerva.__version__}")
|
|
20
20
|
|
|
21
|
-
entries.append(f"-
|
|
21
|
+
entries.append(f"- httpx v{httpx.__version__}")
|
|
22
22
|
|
|
23
23
|
uname = platform.uname()
|
|
24
24
|
entries.append(f"- System Info: {uname.system} {uname.release} {uname.version}")
|
nerva/daemon.py
CHANGED
|
@@ -2,12 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Any, Dict, List, Optional
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import httpx
|
|
6
6
|
|
|
7
|
-
__all__ = ["
|
|
7
|
+
__all__ = ["Daemon", "DaemonLegacy"]
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class
|
|
10
|
+
class Daemon:
|
|
11
11
|
"""
|
|
12
12
|
A class to interact with the Nerva daemon's JSON-RPC interface.
|
|
13
13
|
|
|
@@ -32,7 +32,7 @@ class DaemonRPC:
|
|
|
32
32
|
The headers for the request.
|
|
33
33
|
"""
|
|
34
34
|
|
|
35
|
-
__slots__ = ["url", "timeout", "headers"]
|
|
35
|
+
__slots__ = ["url", "timeout", "headers", "auth"]
|
|
36
36
|
|
|
37
37
|
def __init__(
|
|
38
38
|
self,
|
|
@@ -40,20 +40,26 @@ class DaemonRPC:
|
|
|
40
40
|
port: Optional[int] = 17566,
|
|
41
41
|
ssl: Optional[bool] = False,
|
|
42
42
|
timeout: Optional[float] = 10.0,
|
|
43
|
+
username: Optional[str] = None,
|
|
44
|
+
password: Optional[str] = None,
|
|
43
45
|
) -> None:
|
|
44
46
|
self.url: str = f"{'https' if ssl else 'http'}://{host}:{port}"
|
|
45
47
|
self.timeout: float = timeout
|
|
46
48
|
self.headers: Dict[str, str] = {"Content-Type": "application/json"}
|
|
49
|
+
self.auth: Optional[httpx.DigestAuth] = (
|
|
50
|
+
httpx.DigestAuth(username, password) if username and password else None
|
|
51
|
+
)
|
|
47
52
|
|
|
48
53
|
async def _request(self, method: str, params: Dict[str, Any]) -> Dict[str, Any]:
|
|
49
|
-
async with
|
|
50
|
-
|
|
54
|
+
async with httpx.AsyncClient() as client:
|
|
55
|
+
response = await client.post(
|
|
51
56
|
f"{self.url}/json_rpc",
|
|
52
57
|
json={"jsonrpc": "2.0", "id": 0, "method": method, "params": params},
|
|
53
58
|
headers=self.headers,
|
|
54
59
|
timeout=self.timeout,
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
auth=self.auth,
|
|
61
|
+
)
|
|
62
|
+
return response.json()
|
|
57
63
|
|
|
58
64
|
async def get_block_count(self) -> Dict[str, Any]:
|
|
59
65
|
"""
|
|
@@ -660,7 +666,7 @@ class DaemonLegacy:
|
|
|
660
666
|
|
|
661
667
|
"""
|
|
662
668
|
|
|
663
|
-
__slots__ = ["url", "timeout", "headers"]
|
|
669
|
+
__slots__ = ["url", "timeout", "headers", "auth"]
|
|
664
670
|
|
|
665
671
|
def __init__(
|
|
666
672
|
self,
|
|
@@ -668,23 +674,28 @@ class DaemonLegacy:
|
|
|
668
674
|
port: Optional[int] = 17566,
|
|
669
675
|
ssl: Optional[bool] = False,
|
|
670
676
|
timeout: Optional[float] = 10.0,
|
|
677
|
+
username: Optional[str] = None,
|
|
678
|
+
password: Optional[str] = None,
|
|
671
679
|
):
|
|
672
680
|
self.url = f"{'https' if ssl else 'http'}://{host}:{port}"
|
|
673
681
|
self.timeout = timeout
|
|
674
|
-
|
|
675
682
|
self.headers = {"Content-Type": "application/json"}
|
|
683
|
+
self.auth = (
|
|
684
|
+
httpx.DigestAuth(username, password) if username and password else None
|
|
685
|
+
)
|
|
676
686
|
|
|
677
687
|
async def _request(
|
|
678
688
|
self, endpoint: str, params: Dict[str, Any]
|
|
679
689
|
) -> Dict[str, Any]:
|
|
680
|
-
async with
|
|
681
|
-
|
|
690
|
+
async with httpx.AsyncClient() as client:
|
|
691
|
+
response = await client.post(
|
|
682
692
|
f"{self.url}/{endpoint}",
|
|
683
693
|
json=params,
|
|
684
694
|
headers=self.headers,
|
|
685
695
|
timeout=self.timeout,
|
|
686
|
-
|
|
687
|
-
|
|
696
|
+
auth=self.auth,
|
|
697
|
+
)
|
|
698
|
+
return response.json()
|
|
688
699
|
|
|
689
700
|
async def get_height(self) -> Dict[str, Any]:
|
|
690
701
|
"""
|
nerva/wallet.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Any, Dict, List, Optional
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import httpx
|
|
6
6
|
|
|
7
7
|
__all__ = ["Wallet"]
|
|
8
8
|
|
|
@@ -56,23 +56,22 @@ class Wallet:
|
|
|
56
56
|
password: str = "",
|
|
57
57
|
) -> None:
|
|
58
58
|
self.url: str = f"http{'s' if ssl else ''}://{host}:{port}"
|
|
59
|
-
self.auth: Optional[aiohttp.BasicAuth] = (
|
|
60
|
-
aiohttp.BasicAuth(username, password) if username and password else None
|
|
61
|
-
)
|
|
62
59
|
self.timeout: float = timeout
|
|
63
|
-
|
|
64
60
|
self.headers: Dict[str, str] = {"Content-Type": "application/json"}
|
|
61
|
+
self.auth: Optional[httpx.DigestAuth] = (
|
|
62
|
+
httpx.DigestAuth(username, password) if username and password else None
|
|
63
|
+
)
|
|
65
64
|
|
|
66
65
|
async def _request(self, method: str, params: Dict[str, Any]) -> Dict[str, Any]:
|
|
67
|
-
async with
|
|
68
|
-
|
|
66
|
+
async with httpx.AsyncClient() as client:
|
|
67
|
+
response = await client.post(
|
|
69
68
|
f"{self.url}/json_rpc",
|
|
70
69
|
json={"jsonrpc": "2.0", "id": 0, "method": method, "params": params},
|
|
71
70
|
headers=self.headers,
|
|
72
71
|
auth=self.auth,
|
|
73
72
|
timeout=self.timeout,
|
|
74
|
-
)
|
|
75
|
-
|
|
73
|
+
)
|
|
74
|
+
return response.json()
|
|
76
75
|
|
|
77
76
|
async def get_balance(
|
|
78
77
|
self, account_index: int, address_indices: Optional[List[int]] = None
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: nerva-py
|
|
3
|
-
Version: 1.
|
|
4
|
-
Summary: Python bindings for the JSON RPC interface of the Nerva cryptocurrency.
|
|
3
|
+
Version: 1.1.1
|
|
4
|
+
Summary: Python bindings for the JSON RPC interface of the Nerva (XNV) cryptocurrency.
|
|
5
5
|
Author-email: Sayan Bhattacharyya <sayan@sn1f3rt.dev>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
License-File: LICENSE
|
|
@@ -18,15 +18,14 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
-
Requires-Python: >=3.
|
|
22
|
-
Requires-Dist:
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: httpx==0.28.1
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
|
|
25
|
-
# Nerva Python Library
|
|
25
|
+
# Nerva (XNV) Python Library
|
|
26
26
|
|
|
27
|
-
[](LICENSE)
|
|
27
|
+
[](https://github.com/sn1f3rt/nerva-py/actions/workflows/ruff.yml)
|
|
28
|
+
[](https://github.com/sn1f3rt/nerva-py/actions/workflows/build.yml)
|
|
30
29
|
|
|
31
30
|
## Table of Contents
|
|
32
31
|
|
|
@@ -40,13 +39,13 @@ Description-Content-Type: text/markdown
|
|
|
40
39
|
|
|
41
40
|
## About
|
|
42
41
|
|
|
43
|
-
Python bindings for the JSON RPC interface of the Nerva cryptocurrency.
|
|
42
|
+
Python bindings for the JSON RPC interface of the [Nerva (XNV)](https://nerva.one/) cryptocurrency.
|
|
44
43
|
|
|
45
44
|
## Installation
|
|
46
45
|
|
|
47
46
|
### Requirements
|
|
48
47
|
|
|
49
|
-
- Python 3.
|
|
48
|
+
- Python 3.10+
|
|
50
49
|
- [`uv`](https://docs.astral.sh/uv/) (for development only)
|
|
51
50
|
|
|
52
51
|
### Setup
|
|
@@ -70,12 +69,16 @@ Here is a simple example to get you started:
|
|
|
70
69
|
```python
|
|
71
70
|
import asyncio
|
|
72
71
|
|
|
73
|
-
from nerva.daemon import
|
|
72
|
+
from nerva.daemon import Daemon
|
|
74
73
|
|
|
75
74
|
|
|
76
75
|
async def main():
|
|
77
|
-
daemon =
|
|
78
|
-
host="
|
|
76
|
+
daemon = Daemon(
|
|
77
|
+
host="localhost",
|
|
78
|
+
port=17566,
|
|
79
|
+
ssl=False,
|
|
80
|
+
username="rpcuser", # omit if daemon was not started with the rpc-login flag
|
|
81
|
+
password="rpcpassword" # omit if daemon was not started with the rpc-login flag
|
|
79
82
|
)
|
|
80
83
|
|
|
81
84
|
print(await daemon.get_info())
|
|
@@ -86,11 +89,11 @@ asyncio.run(main())
|
|
|
86
89
|
|
|
87
90
|
## Support
|
|
88
91
|
|
|
89
|
-
- [Issues](https://github.com/
|
|
92
|
+
- [Issues](https://github.com/sn1f3rt/nerva-py/issues)
|
|
90
93
|
- [Discord](https://discord.gg/ufysfvcFwe) - `Development > #nerva-py`
|
|
91
94
|
|
|
92
95
|
## License
|
|
93
96
|
|
|
94
|
-
[
|
|
97
|
+
[](LICENSE)
|
|
95
98
|
|
|
96
|
-
Copyright © 2024 [Sayan "
|
|
99
|
+
Copyright © 2024-present [Sayan "sn1f3rt" Bhattacharyya](https://sn1f3rt.dev)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
nerva/__init__.py,sha256=H_ZSg7FWII2egr0ABxBirhSo3L0vJXOJIgAKPTJSlCQ,1128
|
|
2
|
+
nerva/__main__.py,sha256=vcuFqUiFv6xclYd1ME59lNH_d_E429SwMV-ShxmXCsg,1219
|
|
3
|
+
nerva/daemon.py,sha256=zMq1LUuJ1tggvVHTZGVGRksrqnHjnCNZ2AVogG6Vi9s,33573
|
|
4
|
+
nerva/utils.py,sha256=UzyhRTE2w7_H2YCz50ospggApyFbTOnrB92fuED9laQ,999
|
|
5
|
+
nerva/wallet.py,sha256=aomyDwd-a2kadX3v9FKHvhswFjYZOnELX95wQhxGkUo,59289
|
|
6
|
+
nerva_py-1.1.1.dist-info/METADATA,sha256=4sIffAUzSnAHTBV28iZU8gmboz4Rq12A5WmGCzrDeh8,2933
|
|
7
|
+
nerva_py-1.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
8
|
+
nerva_py-1.1.1.dist-info/licenses/LICENSE,sha256=OB3n91B4pOwIG9kD-nL-INDB0A7ma5fL9q32FGyoIQ4,1086
|
|
9
|
+
nerva_py-1.1.1.dist-info/RECORD,,
|
nerva_py-1.0.1.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
nerva/__init__.py,sha256=ie6yjXkAEzgUdstvjvV_MHkYAaeVO-7Sbq5mxMcVLrw,1128
|
|
2
|
-
nerva/__main__.py,sha256=Ro0JgLqHkRB_laQfYgdyLkiLfj5VMV0azK0K8UhorsM,1225
|
|
3
|
-
nerva/daemon.py,sha256=xeX3Ei5nGosvqlHmTFQsbjPVoumuX574zRWUjnqrJAI,33162
|
|
4
|
-
nerva/utils.py,sha256=UzyhRTE2w7_H2YCz50ospggApyFbTOnrB92fuED9laQ,999
|
|
5
|
-
nerva/wallet.py,sha256=EhQBS9PNq9QZdiP5I8y_jTPr_PtRHCf81dNwRdblDZA,59334
|
|
6
|
-
nerva_py-1.0.1.dist-info/METADATA,sha256=j_ZUNLAW7sccYDIGGytpZGc8YBoCSxc7AFWDl3QWXnM,2709
|
|
7
|
-
nerva_py-1.0.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
8
|
-
nerva_py-1.0.1.dist-info/licenses/LICENSE,sha256=OB3n91B4pOwIG9kD-nL-INDB0A7ma5fL9q32FGyoIQ4,1086
|
|
9
|
-
nerva_py-1.0.1.dist-info/RECORD,,
|
|
File without changes
|