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.

Files changed (56) hide show
  1. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/METADATA +12 -11
  2. hive_nectar-0.1.1.dist-info/RECORD +88 -0
  3. nectar/__init__.py +1 -4
  4. nectar/account.py +791 -685
  5. nectar/amount.py +82 -21
  6. nectar/asset.py +1 -2
  7. nectar/block.py +49 -23
  8. nectar/blockchain.py +111 -143
  9. nectar/blockchaininstance.py +396 -247
  10. nectar/blockchainobject.py +33 -5
  11. nectar/cli.py +1058 -1349
  12. nectar/comment.py +313 -181
  13. nectar/community.py +39 -43
  14. nectar/constants.py +1 -14
  15. nectar/discussions.py +793 -139
  16. nectar/hive.py +137 -77
  17. nectar/hivesigner.py +106 -68
  18. nectar/imageuploader.py +33 -23
  19. nectar/instance.py +31 -79
  20. nectar/market.py +128 -264
  21. nectar/memo.py +40 -13
  22. nectar/message.py +23 -10
  23. nectar/nodelist.py +115 -81
  24. nectar/price.py +80 -61
  25. nectar/profile.py +6 -3
  26. nectar/rc.py +45 -25
  27. nectar/snapshot.py +285 -163
  28. nectar/storage.py +16 -5
  29. nectar/transactionbuilder.py +132 -41
  30. nectar/utils.py +37 -17
  31. nectar/version.py +1 -1
  32. nectar/vote.py +171 -30
  33. nectar/wallet.py +26 -19
  34. nectar/witness.py +153 -54
  35. nectarapi/graphenerpc.py +147 -133
  36. nectarapi/noderpc.py +12 -6
  37. nectarapi/rpcutils.py +12 -6
  38. nectarapi/version.py +1 -1
  39. nectarbase/ledgertransactions.py +24 -1
  40. nectarbase/objects.py +17 -6
  41. nectarbase/operations.py +160 -90
  42. nectarbase/signedtransactions.py +38 -2
  43. nectarbase/version.py +1 -1
  44. nectargraphenebase/account.py +295 -17
  45. nectargraphenebase/chains.py +0 -135
  46. nectargraphenebase/ecdsasig.py +152 -176
  47. nectargraphenebase/types.py +18 -4
  48. nectargraphenebase/unsignedtransactions.py +1 -1
  49. nectargraphenebase/version.py +1 -1
  50. hive_nectar-0.0.11.dist-info/RECORD +0 -91
  51. nectar/blurt.py +0 -562
  52. nectar/conveyor.py +0 -308
  53. nectar/steem.py +0 -581
  54. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/WHEEL +0 -0
  55. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/entry_points.txt +0 -0
  56. {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 Steem/Hive blockchain_instance: Steem or Hive instance
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
- if blockchain_instance is None:
239
- if kwargs.get("steem_instance"):
240
- blockchain_instance = kwargs["steem_instance"]
241
- elif kwargs.get("hive_instance"):
242
- blockchain_instance = kwargs["hive_instance"]
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
- """Yields blocks starting from ``start``.
438
-
439
- :param int start: Starting block
440
- :param int stop: Stop at this block
441
- :param int max_batch_size: only for appbase nodes. When not None, batch calls of are used.
442
- Cannot be combined with threading
443
- :param bool threading: Enables threading. Cannot be combined with batch calls
444
- :param int thread_num: Defines the number of threads, when `threading` is set.
445
- :param bool only_ops: Only yield operations (default: False).
446
- Cannot be combined with ``only_virtual_ops=True``.
447
- :param bool only_virtual_ops: Only yield virtual operations (default: False)
448
-
449
- .. note:: If you want instant confirmation, you need to instantiate
450
- class:`nectar.blockchain.Blockchain` with
451
- ``mode="head"``, otherwise, the call will wait until
452
- confirmed in an irreversible block.
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
- stm.Steem(
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
- """Yield specific operations (e.g. comments) only
798
-
799
- :param array opNames: List of operations to filter for
800
- :param bool raw_ops: When set to True, it returns the unmodified operations (default: False)
801
- :param int start: Start at this block
802
- :param int stop: Stop at this block
803
- :param int max_batch_size: only for appbase nodes. When not None, batch calls of are used.
804
- Cannot be combined with threading
805
- :param bool threading: Enables threading. Cannot be combined with batch calls
806
- :param int thread_num: Defines the number of threads, when `threading` is set.
807
- :param bool only_ops: Only yield operations (default: False)
808
- Cannot be combined with ``only_virtual_ops=True``
809
- :param bool only_virtual_ops: Only yield virtual operations (default: False)
810
-
811
- The dict output is formated such that ``type`` carries the
812
- operation type. Timestamp and block_num are taken from the
813
- block the operation was stored in and the other keys depend
814
- on the actual operation.
815
-
816
- .. note:: If you want instant confirmation, you need to instantiate
817
- class:`nectar.blockchain.Blockchain` with
818
- ``mode="head"``, otherwise, the call will wait until
819
- confirmed in an irreversible block.
820
-
821
- output when `raw_ops=False` is set:
822
-
823
- .. code-block:: js
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
- """Returns limit similar accounts with name as list
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
- .. code-block:: python
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
- >>> from nectar.blockchain import Blockchain
1065
- >>> from nectar import Steem
1066
- >>> stm = Steem("https://api.steemit.com")
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
- """Returns the RC parameters of one or more accounts.
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
- .. code-block:: python
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
- >>> from nectar.blockchain import Blockchain
1095
- >>> from nectar import Steem
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
- """List pending `change_recovery_account` requests.
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
- .. code-block:: python
1099
+ If the local blockchain connection is offline, returns None.
1132
1100
 
1133
- >>> from nectar.blockchain import Blockchain
1134
- >>> from nectar import Steem
1135
- >>> stm = Steem("https://api.steemit.com")
1136
- >>> blockchain = Blockchain(blockchain_instance=stm)
1137
- >>> ret = blockchain.list_change_recovery_account_requests(limit=1)
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
- """Find pending `change_recovery_account` requests for one or more
1151
- specific accounts.
1122
+ """
1123
+ Find pending change_recovery_account requests for one or more accounts.
1152
1124
 
1153
- :param str/list accounts: account name or list of account
1154
- names to find `change_recovery_account` requests for.
1155
- :returns: list of `change_recovery_account` requests for the
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
- .. code-block:: python
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