hive-nectar 0.0.11__py3-none-any.whl → 0.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.
Potentially problematic release.
This version of hive-nectar might be problematic. Click here for more details.
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/METADATA +12 -11
- hive_nectar-0.1.1.dist-info/RECORD +88 -0
- nectar/__init__.py +1 -4
- nectar/account.py +791 -685
- nectar/amount.py +82 -21
- nectar/asset.py +1 -2
- nectar/block.py +49 -23
- nectar/blockchain.py +111 -143
- nectar/blockchaininstance.py +396 -247
- nectar/blockchainobject.py +33 -5
- nectar/cli.py +1058 -1349
- nectar/comment.py +313 -181
- nectar/community.py +39 -43
- nectar/constants.py +1 -14
- nectar/discussions.py +793 -139
- nectar/hive.py +137 -77
- nectar/hivesigner.py +106 -68
- nectar/imageuploader.py +33 -23
- nectar/instance.py +31 -79
- nectar/market.py +128 -264
- nectar/memo.py +40 -13
- nectar/message.py +23 -10
- nectar/nodelist.py +115 -81
- nectar/price.py +80 -61
- nectar/profile.py +6 -3
- nectar/rc.py +45 -25
- nectar/snapshot.py +285 -163
- nectar/storage.py +16 -5
- nectar/transactionbuilder.py +132 -41
- nectar/utils.py +37 -17
- nectar/version.py +1 -1
- nectar/vote.py +171 -30
- nectar/wallet.py +26 -19
- nectar/witness.py +153 -54
- nectarapi/graphenerpc.py +147 -133
- nectarapi/noderpc.py +12 -6
- nectarapi/rpcutils.py +12 -6
- nectarapi/version.py +1 -1
- nectarbase/ledgertransactions.py +24 -1
- nectarbase/objects.py +17 -6
- nectarbase/operations.py +160 -90
- nectarbase/signedtransactions.py +38 -2
- nectarbase/version.py +1 -1
- nectargraphenebase/account.py +295 -17
- nectargraphenebase/chains.py +0 -135
- nectargraphenebase/ecdsasig.py +152 -176
- nectargraphenebase/types.py +18 -4
- nectargraphenebase/unsignedtransactions.py +1 -1
- nectargraphenebase/version.py +1 -1
- hive_nectar-0.0.11.dist-info/RECORD +0 -91
- nectar/blurt.py +0 -562
- nectar/conveyor.py +0 -308
- nectar/steem.py +0 -581
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/WHEEL +0 -0
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/entry_points.txt +0 -0
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/licenses/LICENSE.txt +0 -0
nectar/blockchain.py
CHANGED
|
@@ -9,7 +9,6 @@ from queue import Queue
|
|
|
9
9
|
from threading import Event, Thread
|
|
10
10
|
from time import sleep
|
|
11
11
|
|
|
12
|
-
import nectar as stm
|
|
13
12
|
from nectar.instance import shared_blockchain_instance
|
|
14
13
|
from nectarapi.exceptions import UnknownTransaction
|
|
15
14
|
|
|
@@ -181,7 +180,7 @@ class Blockchain(object):
|
|
|
181
180
|
"""This class allows to access the blockchain and read data
|
|
182
181
|
from it
|
|
183
182
|
|
|
184
|
-
:param
|
|
183
|
+
:param Blockchain blockchain_instance: Blockchain instance
|
|
185
184
|
:param str mode: (default) Irreversible block (``irreversible``) or
|
|
186
185
|
actual head block (``head``)
|
|
187
186
|
:param int max_block_wait_repetition: maximum wait repetition for next block
|
|
@@ -235,11 +234,18 @@ class Blockchain(object):
|
|
|
235
234
|
data_refresh_time_seconds=900,
|
|
236
235
|
**kwargs,
|
|
237
236
|
):
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
237
|
+
"""
|
|
238
|
+
Initialize the Blockchain helper.
|
|
239
|
+
|
|
240
|
+
Sets the underlying blockchain connection (uses shared instance if none provided), configures mode to map to the underlying RPC key ("last_irreversible_block_num" or "head_block_number"), sets max_block_wait_repetition (default 3), and reads the chain's block interval.
|
|
241
|
+
|
|
242
|
+
Parameters:
|
|
243
|
+
mode (str): "irreversible" to operate against the last irreversible block, or "head" to operate against the chain head.
|
|
244
|
+
max_block_wait_repetition (int, optional): Number of times to retry waiting for a block before giving up; defaults to 3.
|
|
245
|
+
|
|
246
|
+
Raises:
|
|
247
|
+
ValueError: If `mode` is not "irreversible" or "head".
|
|
248
|
+
"""
|
|
243
249
|
self.blockchain = blockchain_instance or shared_blockchain_instance()
|
|
244
250
|
|
|
245
251
|
if mode == "irreversible":
|
|
@@ -434,23 +440,34 @@ class Blockchain(object):
|
|
|
434
440
|
only_ops=False,
|
|
435
441
|
only_virtual_ops=False,
|
|
436
442
|
):
|
|
437
|
-
"""
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
:
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
443
|
+
"""
|
|
444
|
+
Yield Block objects from `start` up to `stop` (or the chain head).
|
|
445
|
+
|
|
446
|
+
This generator retrieves blocks from the connected blockchain instance and yields them as Block objects. It supports three retrieval modes:
|
|
447
|
+
- Single-threaded sequential fetching (default).
|
|
448
|
+
- Threaded parallel fetching across multiple blockchain instances when `threading=True`.
|
|
449
|
+
- Batched RPC calls for appbase-compatible nodes when `max_batch_size` is set (cannot be combined with `threading`).
|
|
450
|
+
|
|
451
|
+
Parameters:
|
|
452
|
+
start (int, optional): First block number to fetch. If omitted, defaults to the current block.
|
|
453
|
+
stop (int, optional): Last block number to fetch. If omitted, the generator follows the chain head indefinitely.
|
|
454
|
+
max_batch_size (int, optional): Use batched RPC calls (appbase only). Cannot be used with `threading`.
|
|
455
|
+
threading (bool): If True, fetch blocks in parallel using `thread_num` workers.
|
|
456
|
+
thread_num (int): Number of worker threads to use when `threading=True`.
|
|
457
|
+
only_ops (bool): If True, blocks will contain only regular operations (no block metadata).
|
|
458
|
+
Mutually exclusive with `only_virtual_ops=True`.
|
|
459
|
+
only_virtual_ops (bool): If True, yield only virtual operations.
|
|
460
|
+
|
|
461
|
+
Yields:
|
|
462
|
+
Block: A Block object for each fetched block (may contain only ops or only virtual ops depending on flags).
|
|
463
|
+
|
|
464
|
+
Exceptions:
|
|
465
|
+
OfflineHasNoRPCException: Raised if batched mode is requested while offline (no RPC available).
|
|
466
|
+
BatchedCallsNotSupported: Raised if the node does not support batched calls when `max_batch_size` is used.
|
|
467
|
+
|
|
468
|
+
Notes:
|
|
469
|
+
- For instant (non-irreversible) confirmations, initialize the Blockchain with mode="head"; otherwise this method will wait for irreversible blocks.
|
|
470
|
+
- `max_batch_size` requires appbase-compatible RPC; threaded mode creates additional blockchain instances for parallel RPC calls.
|
|
454
471
|
"""
|
|
455
472
|
# Let's find out how often blocks are generated!
|
|
456
473
|
current_block = self.get_current_block()
|
|
@@ -467,7 +484,7 @@ class Blockchain(object):
|
|
|
467
484
|
nodelist = self.blockchain.rpc.nodes.export_working_nodes()
|
|
468
485
|
for i in range(thread_num - 1):
|
|
469
486
|
blockchain_instance.append(
|
|
470
|
-
|
|
487
|
+
self.blockchain.__class__(
|
|
471
488
|
node=nodelist,
|
|
472
489
|
num_retries=self.blockchain.rpc.num_retries,
|
|
473
490
|
num_retries_call=self.blockchain.rpc.num_retries_call,
|
|
@@ -794,63 +811,33 @@ class Blockchain(object):
|
|
|
794
811
|
return ops_stat
|
|
795
812
|
|
|
796
813
|
def stream(self, opNames=[], raw_ops=False, *args, **kwargs):
|
|
797
|
-
"""
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
:
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
:
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
{
|
|
826
|
-
'type': 'transfer',
|
|
827
|
-
'from': 'johngreenfield',
|
|
828
|
-
'to': 'thundercurator',
|
|
829
|
-
'amount': '0.080 SBD',
|
|
830
|
-
'memo': 'https://steemit.com/lofi/@johngreenfield/lofi-joji-yeah-right',
|
|
831
|
-
'_id': '6d4c5f2d4d8ef1918acaee4a8dce34f9da384786',
|
|
832
|
-
'timestamp': datetime.datetime(2018, 5, 9, 11, 23, 6, tzinfo=<UTC>),
|
|
833
|
-
'block_num': 22277588, 'trx_num': 35, 'trx_id': 'cf11b2ac8493c71063ec121b2e8517ab1e0e6bea'
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
output when `raw_ops=True` is set:
|
|
837
|
-
|
|
838
|
-
.. code-block:: js
|
|
839
|
-
|
|
840
|
-
{
|
|
841
|
-
'block_num': 22277588,
|
|
842
|
-
'op':
|
|
843
|
-
[
|
|
844
|
-
'transfer',
|
|
845
|
-
{
|
|
846
|
-
'from': 'johngreenfield', 'to': 'thundercurator',
|
|
847
|
-
'amount': '0.080 SBD',
|
|
848
|
-
'memo': 'https://steemit.com/lofi/@johngreenfield/lofi-joji-yeah-right'
|
|
849
|
-
}
|
|
850
|
-
],
|
|
851
|
-
'timestamp': datetime.datetime(2018, 5, 9, 11, 23, 6, tzinfo=<UTC>)
|
|
852
|
-
}
|
|
853
|
-
|
|
814
|
+
"""
|
|
815
|
+
Yield blockchain operations filtered by type, normalizing several node event formats into a consistent output.
|
|
816
|
+
|
|
817
|
+
Parameters:
|
|
818
|
+
opNames (list): Operation type names to filter for (e.g., ['transfer', 'comment']). If empty, all operations are yielded.
|
|
819
|
+
raw_ops (bool): If True, yield raw operation tuples with minimal metadata; if False (default), yield a flattened dict with operation fields and metadata.
|
|
820
|
+
*args, **kwargs: Passed through to self.blocks(...) (e.g., start, stop, max_batch_size, threading, thread_num, only_ops, only_virtual_ops).
|
|
821
|
+
|
|
822
|
+
Yields:
|
|
823
|
+
dict: When raw_ops is False, yields a dictionary with at least:
|
|
824
|
+
- 'type': operation name
|
|
825
|
+
- operation fields (e.g., 'from', 'to', 'amount', ...)
|
|
826
|
+
- '_id': deterministic operation hash
|
|
827
|
+
- 'timestamp': block timestamp
|
|
828
|
+
- 'block_num': block number
|
|
829
|
+
- 'trx_num': transaction index within the block
|
|
830
|
+
- 'trx_id': transaction id
|
|
831
|
+
|
|
832
|
+
dict: When raw_ops is True, yields a compact dictionary:
|
|
833
|
+
- 'block_num': block number
|
|
834
|
+
- 'trx_num': transaction index
|
|
835
|
+
- 'op': [op_type, op_payload]
|
|
836
|
+
- 'timestamp': block timestamp
|
|
837
|
+
|
|
838
|
+
Notes:
|
|
839
|
+
- The method accepts the same control parameters as blocks(...) via kwargs. The block stream determines timestamps and block-related metadata.
|
|
840
|
+
- Operation events from different node formats (lists, legacy dicts, appbase-style dicts) are normalized by this method before yielding.
|
|
854
841
|
"""
|
|
855
842
|
for block in self.blocks(**kwargs):
|
|
856
843
|
if "transactions" in block:
|
|
@@ -1052,23 +1039,20 @@ class Blockchain(object):
|
|
|
1052
1039
|
skip_first = True
|
|
1053
1040
|
|
|
1054
1041
|
def get_similar_account_names(self, name, limit=5):
|
|
1055
|
-
"""
|
|
1056
|
-
|
|
1057
|
-
:param str name: account name to search similars for
|
|
1058
|
-
:param int limit: limits the number of accounts, which will be returned
|
|
1059
|
-
:returns: Similar account names as list
|
|
1060
|
-
:rtype: list
|
|
1042
|
+
"""
|
|
1043
|
+
Return a list of accounts with names similar to the given name.
|
|
1061
1044
|
|
|
1062
|
-
|
|
1045
|
+
Performs an RPC call to fetch accounts starting at `name`. If the underlying node uses the
|
|
1046
|
+
appbase API this returns the raw `accounts` list from the `list_accounts` response (list of
|
|
1047
|
+
account objects/dicts). If using the legacy API this returns the list of account names
|
|
1048
|
+
returned by `lookup_accounts`. If the local blockchain connection is offline, returns None.
|
|
1063
1049
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
>>> blockchain = Blockchain(blockchain_instance=stm)
|
|
1068
|
-
>>> ret = blockchain.get_similar_account_names("test", limit=5)
|
|
1069
|
-
>>> len(ret) == 5
|
|
1070
|
-
True
|
|
1050
|
+
Parameters:
|
|
1051
|
+
name (str): Prefix or starting account name to search for.
|
|
1052
|
+
limit (int): Maximum number of accounts to return.
|
|
1071
1053
|
|
|
1054
|
+
Returns:
|
|
1055
|
+
list or None: A list of account names or account objects (depending on RPC), or None if offline.
|
|
1072
1056
|
"""
|
|
1073
1057
|
if not self.blockchain.is_connected():
|
|
1074
1058
|
return None
|
|
@@ -1083,22 +1067,18 @@ class Blockchain(object):
|
|
|
1083
1067
|
return self.blockchain.rpc.lookup_accounts(name, limit)
|
|
1084
1068
|
|
|
1085
1069
|
def find_rc_accounts(self, name):
|
|
1086
|
-
"""
|
|
1087
|
-
|
|
1088
|
-
:param str name: account name to search rc params for (can also be a list of accounts)
|
|
1089
|
-
:returns: RC params
|
|
1090
|
-
:rtype: list
|
|
1070
|
+
"""
|
|
1071
|
+
Return resource credit (RC) parameters for one or more accounts.
|
|
1091
1072
|
|
|
1092
|
-
|
|
1073
|
+
If given a single account name (str), returns the RC parameters for that account as a dict.
|
|
1074
|
+
If given a list of account names, returns a list of RC-parameter dicts in the same order.
|
|
1075
|
+
Returns None when the underlying blockchain RPC is not connected or if the RPC returns no data.
|
|
1093
1076
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
>>> stm = Steem("https://api.steemit.com")
|
|
1097
|
-
>>> blockchain = Blockchain(blockchain_instance=stm)
|
|
1098
|
-
>>> ret = blockchain.find_rc_accounts(["test"])
|
|
1099
|
-
>>> len(ret) == 1
|
|
1100
|
-
True
|
|
1077
|
+
Parameters:
|
|
1078
|
+
name (str | list): An account name or a list of account names.
|
|
1101
1079
|
|
|
1080
|
+
Returns:
|
|
1081
|
+
dict | list | None: RC parameters for the account(s), or None if offline or no result.
|
|
1102
1082
|
"""
|
|
1103
1083
|
if not self.blockchain.is_connected():
|
|
1104
1084
|
return None
|
|
@@ -1113,29 +1093,21 @@ class Blockchain(object):
|
|
|
1113
1093
|
return account["rc_accounts"][0]
|
|
1114
1094
|
|
|
1115
1095
|
def list_change_recovery_account_requests(self, start="", limit=1000, order="by_account"):
|
|
1116
|
-
"""
|
|
1117
|
-
|
|
1118
|
-
:param str/list start: Start the listing from this entry.
|
|
1119
|
-
Leave empty to start from the beginning. If `order` is set
|
|
1120
|
-
to `by_account`, `start` has to be an account name. If
|
|
1121
|
-
`order` is set to `by_effective_date`, `start` has to be a
|
|
1122
|
-
list of [effective_on, account_to_recover],
|
|
1123
|
-
e.g. `start=['2018-12-18T01:46:24', 'bott']`.
|
|
1124
|
-
:param int limit: maximum number of results to return (default
|
|
1125
|
-
and maximum: 1000).
|
|
1126
|
-
:param str order: valid values are "by_account" (default) or
|
|
1127
|
-
"by_effective_date".
|
|
1128
|
-
:returns: list of `change_recovery_account` requests.
|
|
1129
|
-
:rtype: list
|
|
1096
|
+
"""
|
|
1097
|
+
Return pending change_recovery_account requests from the blockchain.
|
|
1130
1098
|
|
|
1131
|
-
|
|
1099
|
+
If the local blockchain connection is offline, returns None.
|
|
1132
1100
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1101
|
+
Parameters:
|
|
1102
|
+
start (str or list): Starting point for the listing.
|
|
1103
|
+
- For order="by_account": an account name (string).
|
|
1104
|
+
- For order="by_effective_date": a two-item list [effective_on, account_to_recover]
|
|
1105
|
+
e.g. ['2018-12-18T01:46:24', 'bott'].
|
|
1106
|
+
limit (int): Maximum number of results to return (default and max: 1000).
|
|
1107
|
+
order (str): Index to iterate: "by_account" (default) or "by_effective_date".
|
|
1138
1108
|
|
|
1109
|
+
Returns:
|
|
1110
|
+
list or None: A list of change_recovery_account request entries, or None if offline.
|
|
1139
1111
|
"""
|
|
1140
1112
|
if not self.blockchain.is_connected():
|
|
1141
1113
|
return None
|
|
@@ -1147,23 +1119,19 @@ class Blockchain(object):
|
|
|
1147
1119
|
return requests["requests"]
|
|
1148
1120
|
|
|
1149
1121
|
def find_change_recovery_account_requests(self, accounts):
|
|
1150
|
-
"""
|
|
1151
|
-
|
|
1122
|
+
"""
|
|
1123
|
+
Find pending change_recovery_account requests for one or more accounts.
|
|
1152
1124
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
given account(s).
|
|
1157
|
-
:rtype: list
|
|
1125
|
+
Accepts a single account name or a list of account names and queries the connected node for pending
|
|
1126
|
+
change_recovery_account requests. Returns the list of matching request entries, or None if the
|
|
1127
|
+
local blockchain instance is not connected or the RPC returned no data.
|
|
1158
1128
|
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
>>> from nectar.blockchain import Blockchain
|
|
1162
|
-
>>> from nectar import Steem
|
|
1163
|
-
>>> stm = Steem("https://api.steemit.com")
|
|
1164
|
-
>>> blockchain = Blockchain(blockchain_instance=stm)
|
|
1165
|
-
>>> ret = blockchain.find_change_recovery_account_requests('bott')
|
|
1129
|
+
Parameters:
|
|
1130
|
+
accounts (str | list): Account name or list of account names to search for.
|
|
1166
1131
|
|
|
1132
|
+
Returns:
|
|
1133
|
+
list | None: List of change_recovery_account request objects for the given account(s), or
|
|
1134
|
+
None if offline or no requests were returned.
|
|
1167
1135
|
"""
|
|
1168
1136
|
if not self.blockchain.is_connected():
|
|
1169
1137
|
return None
|