nerva-py 1.0.0__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 +45 -0
- nerva/__main__.py +54 -0
- nerva/daemon.py +1326 -0
- nerva/utils.py +53 -0
- nerva/wallet.py +2179 -0
- nerva_py-1.0.0.dist-info/METADATA +96 -0
- nerva_py-1.0.0.dist-info/RECORD +9 -0
- nerva_py-1.0.0.dist-info/WHEEL +4 -0
- nerva_py-1.0.0.dist-info/licenses/LICENSE +21 -0
nerva/utils.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import random
|
|
4
|
+
import string
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def generate_payment_id() -> str:
|
|
8
|
+
"""
|
|
9
|
+
Generate a random payment ID for transactions.
|
|
10
|
+
|
|
11
|
+
Returns
|
|
12
|
+
-------
|
|
13
|
+
str
|
|
14
|
+
A random 64-bit payment ID.
|
|
15
|
+
|
|
16
|
+
"""
|
|
17
|
+
return "".join(random.choices(string.hexdigits, k=64)).lower()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def calculate_seconds_from_time_string(time_string: str) -> int:
|
|
21
|
+
"""
|
|
22
|
+
Calculate seconds from time string.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
time_string : str
|
|
27
|
+
The time string to convert to seconds.
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
int
|
|
32
|
+
The number of seconds in the time string.
|
|
33
|
+
|
|
34
|
+
"""
|
|
35
|
+
time: list = time_string.split(" ")
|
|
36
|
+
|
|
37
|
+
seconds: int = 0
|
|
38
|
+
|
|
39
|
+
t: str
|
|
40
|
+
for t in time:
|
|
41
|
+
if t.endswith("s"):
|
|
42
|
+
seconds += int(t[:-1])
|
|
43
|
+
|
|
44
|
+
if t.endswith("m"):
|
|
45
|
+
seconds += int(t[:-1]) * 60
|
|
46
|
+
|
|
47
|
+
if t.endswith("h"):
|
|
48
|
+
seconds += int(t[:-1]) * 3600
|
|
49
|
+
|
|
50
|
+
if t.endswith("d"):
|
|
51
|
+
seconds += int(t[:-1]) * 86400
|
|
52
|
+
|
|
53
|
+
return seconds
|