hive-nectar 0.0.11__py3-none-any.whl → 0.1.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.

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.0.dist-info}/METADATA +10 -11
  2. hive_nectar-0.1.0.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 +34 -22
  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.0.dist-info}/WHEEL +0 -0
  55. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/entry_points.txt +0 -0
  56. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/licenses/LICENSE.txt +0 -0
nectar/amount.py CHANGED
@@ -5,10 +5,15 @@ from nectar.asset import Asset
5
5
  from nectar.instance import shared_blockchain_instance
6
6
 
7
7
 
8
- def check_asset(other, self, stm):
8
+ def check_asset(other, self, hv):
9
+ """
10
+ Assert that two asset representations refer to the same asset.
11
+
12
+ If both `other` and `self` are dicts containing an "asset" key, each asset id is wrapped in an Asset using the provided blockchain instance and compared for equality. Otherwise the two values are compared directly. Raises AssertionError if the values do not match.
13
+ """
9
14
  if isinstance(other, dict) and "asset" in other and isinstance(self, dict) and "asset" in self:
10
- if not Asset(other["asset"], blockchain_instance=stm) == Asset(
11
- self["asset"], blockchain_instance=stm
15
+ if not Asset(other["asset"], blockchain_instance=hv) == Asset(
16
+ self["asset"], blockchain_instance=hv
12
17
  ):
13
18
  raise AssertionError()
14
19
  else:
@@ -31,16 +36,16 @@ class Amount(dict):
31
36
  :param list args: Allows to deal with different representations of an amount
32
37
  :param float amount: Let's create an instance with a specific amount
33
38
  :param str asset: Let's you create an instance with a specific asset (symbol)
34
- :param boolean fixed_point_arithmetic: when set to True, all operation are fixed
39
+ :param boolean fixed_point_arithmetic: when set to True, all operations are fixed
35
40
  point operations and the amount is always be rounded down to the precision
36
- :param Steem steem_instance: Steem instance
41
+ :param Blockchain blockchain_instance: Blockchain instance
37
42
  :returns: All data required to represent an Amount/Asset
38
43
  :rtype: dict
39
44
  :raises ValueError: if the data provided is not recognized
40
45
 
41
46
  Way to obtain a proper instance:
42
47
 
43
- * ``args`` can be a string, e.g.: "1 SBD"
48
+ * ``args`` can be a string, e.g.: "1 HBD"
44
49
  * ``args`` can be a dictionary containing ``amount`` and ``asset_id``
45
50
  * ``args`` can be a dictionary containing ``amount`` and ``asset``
46
51
  * ``args`` can be a list of a ``float`` and ``str`` (symbol)
@@ -60,9 +65,9 @@ class Amount(dict):
60
65
 
61
66
  from nectar.amount import Amount
62
67
  from nectar.asset import Asset
63
- a = Amount("1 STEEM")
64
- b = Amount(1, "STEEM")
65
- c = Amount("20", Asset("STEEM"))
68
+ a = Amount("1 HIVE")
69
+ b = Amount(1, "HIVE")
70
+ c = Amount("20", Asset("HIVE"))
66
71
  a + b
67
72
  a * 2
68
73
  a += b
@@ -70,8 +75,8 @@ class Amount(dict):
70
75
 
71
76
  .. testoutput::
72
77
 
73
- 2.000 STEEM
74
- 2.000 STEEM
78
+ 2.000 HIVE
79
+ 2.000 HIVE
75
80
 
76
81
  """
77
82
 
@@ -84,15 +89,38 @@ class Amount(dict):
84
89
  blockchain_instance=None,
85
90
  **kwargs,
86
91
  ):
92
+ """
93
+ Initialize an Amount object representing a quantity of a specific blockchain asset.
94
+
95
+ The constructor accepts many input formats and normalizes them into internal keys:
96
+ - amount may be another Amount, a three-element list [amount, precision, asset],
97
+ a new appbase-format dict with keys ("amount", "nai", "precision"), a legacy dict
98
+ with ("amount", "asset_id") or ("amount", "asset"), a string like "1.000 HIVE",
99
+ or a numeric value (int, float, Decimal) paired with an `asset` argument.
100
+ - asset may be an Asset instance, an asset dict, or a symbol string; when omitted,
101
+ the asset will be inferred from the provided `amount` representation.
102
+
103
+ After parsing, the instance stores:
104
+ - "amount" as a Decimal (or quantized Decimal when fixed-point mode is enabled),
105
+ - "symbol" as the asset symbol,
106
+ - "asset" as an Asset-like object.
107
+
108
+ Parameters:
109
+ amount: Various accepted formats (see description) representing the quantity.
110
+ asset: Asset instance, asset dict, or asset symbol string used when `amount`
111
+ is a bare numeric value or when explicit asset resolution is required.
112
+ fixed_point_arithmetic (bool): When True, the numeric amount is quantized
113
+ to the asset's precision using floor rounding.
114
+ new_appbase_format (bool): Indicates whether to prefer the new appbase JSON
115
+ format when producing serialized representations.
116
+
117
+ Raises:
118
+ ValueError: If `amount` and `asset` do not match any supported input format.
119
+ """
87
120
  self["asset"] = {}
88
121
  self.new_appbase_format = new_appbase_format
89
122
  self.fixed_point_arithmetic = fixed_point_arithmetic
90
123
 
91
- if blockchain_instance is None:
92
- if kwargs.get("steem_instance"):
93
- blockchain_instance = kwargs["steem_instance"]
94
- elif kwargs.get("hive_instance"):
95
- blockchain_instance = kwargs["hive_instance"]
96
124
  self.blockchain = blockchain_instance or shared_blockchain_instance()
97
125
 
98
126
  if amount and asset is None and isinstance(amount, Amount):
@@ -221,8 +249,14 @@ class Amount(dict):
221
249
 
222
250
  @property
223
251
  def asset(self):
224
- """Returns the asset as instance of :class:`steem.asset.Asset`"""
225
- if not self["asset"]:
252
+ """
253
+ Return the Asset object for this Amount, constructing it lazily if missing.
254
+
255
+ If the internal 'asset' entry is falsy, this creates a nectar.asset.Asset using the stored symbol
256
+ and this Amount's blockchain instance, stores it in 'asset', and returns it. Always returns an
257
+ Asset instance.
258
+ """
259
+ if not isinstance(self["asset"], Asset):
226
260
  self["asset"] = Asset(self["symbol"], blockchain_instance=self.blockchain)
227
261
  return self["asset"]
228
262
 
@@ -381,9 +415,20 @@ class Amount(dict):
381
415
  return self
382
416
 
383
417
  def __idiv__(self, other):
418
+ """
419
+ In-place division: divide this Amount by another Amount or numeric value and return self.
420
+
421
+ If `other` is an Amount, asserts asset compatibility and divides this object's internal amount by the other's amount. If `other` is numeric, divides by Decimal(other). When `fixed_point_arithmetic` is enabled, the result is quantized to this asset's precision.
422
+
423
+ Returns:
424
+ self (Amount): The mutated Amount instance.
425
+
426
+ Raises:
427
+ AssertionError: If `other` is an Amount with a different asset (via check_asset).
428
+ """
384
429
  if isinstance(other, Amount):
385
430
  check_asset(other["asset"], self["asset"], self.blockchain)
386
- return self["amount"] / other["amount"]
431
+ self["amount"] = self["amount"] / other["amount"]
387
432
  else:
388
433
  self["amount"] /= Decimal(other)
389
434
  if self.fixed_point_arithmetic:
@@ -442,18 +487,33 @@ class Amount(dict):
442
487
  return quant_amount == quantize((other or 0), self["asset"]["precision"])
443
488
 
444
489
  def __ne__(self, other):
490
+ """
491
+ Return True if this Amount is not equal to `other`.
492
+
493
+ Compares values after quantizing both sides to this amount's asset precision. If `other` is an Amount, its asset must match this Amount's asset (an assertion is raised on mismatch) and the comparison uses both amounts quantized to the shared precision. If `other` is numeric or None, it is treated as a numeric value (None → 0) and compared after quantization.
494
+
495
+ Returns:
496
+ bool: True when the quantized values differ, False otherwise.
497
+ """
445
498
  quant_amount = quantize(self["amount"], self["asset"]["precision"])
446
499
  if isinstance(other, Amount):
447
500
  check_asset(other["asset"], self["asset"], self.blockchain)
448
- return self["amount"] != quantize(other["amount"], self["asset"]["precision"])
501
+ return quantize(self["amount"], self["asset"]["precision"]) != quantize(
502
+ other["amount"], self["asset"]["precision"]
503
+ )
449
504
  else:
450
505
  return quant_amount != quantize((other or 0), self["asset"]["precision"])
451
506
 
452
507
  def __ge__(self, other):
508
+ """
509
+ Return True if this Amount is greater than or equal to `other`.
510
+
511
+ Performs comparison after quantizing both values to this Amount's asset precision. If `other` is an Amount, its asset must match this Amount's asset (an AssertionError is raised on mismatch). If `other` is None, it is treated as zero. Returns a boolean.
512
+ """
453
513
  quant_amount = quantize(self["amount"], self["asset"]["precision"])
454
514
  if isinstance(other, Amount):
455
515
  check_asset(other["asset"], self["asset"], self.blockchain)
456
- return self["amount"] >= quantize(other["amount"], self["asset"]["precision"])
516
+ return quant_amount >= quantize(other["amount"], self["asset"]["precision"])
457
517
  else:
458
518
  return quant_amount >= quantize((other or 0), self["asset"]["precision"])
459
519
 
@@ -467,4 +527,5 @@ class Amount(dict):
467
527
 
468
528
  __repr__ = __str__
469
529
  __truediv__ = __div__
530
+ __itruediv__ = __idiv__
470
531
  __truemul__ = __mul__
nectar/asset.py CHANGED
@@ -9,8 +9,7 @@ class Asset(BlockchainObject):
9
9
  :param str Asset: Symbol name or object id of an asset
10
10
  :param bool lazy: Lazy loading
11
11
  :param bool full: Also obtain bitasset-data and dynamic asset dat
12
- :param Steem steem_instance: Steem
13
- instance
12
+ :param Blockchain blockchain_instance: Blockchain instance
14
13
  :returns: All data of an asset
15
14
 
16
15
  .. note:: This class comes with its own caching function to reduce the
nectar/block.py CHANGED
@@ -14,7 +14,7 @@ class Block(BlockchainObject):
14
14
  """Read a single block from the chain
15
15
 
16
16
  :param int block: block number
17
- :param Steem steem_instance: Steem
17
+ :param Hive blockchain_instance: Hive
18
18
  instance
19
19
  :param bool lazy: Use lazy loading
20
20
  :param bool only_ops: Includes only operations, when set to True (default: False)
@@ -51,15 +51,16 @@ class Block(BlockchainObject):
51
51
  blockchain_instance=None,
52
52
  **kwargs,
53
53
  ):
54
- """Initilize a block
54
+ """
55
+ Initialize a Block object representing a single blockchain block.
55
56
 
56
- :param int block: block number
57
- :param Steem steem_instance: Steem
58
- instance
59
- :param bool lazy: Use lazy loading
60
- :param bool only_ops: Includes only operations, when set to True (default: False)
61
- :param bool only_virtual_ops: Includes only virtual operations (default: False)
57
+ block may be an integer (block number), a float (will be converted to int), or a dict containing block data (which will be parsed). Controls:
58
+ - only_ops: load only operations from the block.
59
+ - only_virtual_ops: load only virtual operations.
60
+ - full: if True, populate full block data; if False, keep a minimal representation.
61
+ - lazy: if True, defer fetching full data until needed.
62
62
 
63
+ If no identifier is present after initialization, the block's identifier is set to its numeric block number.
63
64
  """
64
65
  self.full = full
65
66
  self.lazy = lazy
@@ -317,7 +318,7 @@ class BlockHeader(BlockchainObject):
317
318
  """Read a single block header from the chain
318
319
 
319
320
  :param int block: block number
320
- :param Steem steem_instance: Steem
321
+ :param Hive blockchain_instance: Hive
321
322
  instance
322
323
  :param bool lazy: Use lazy loading
323
324
 
@@ -333,13 +334,19 @@ class BlockHeader(BlockchainObject):
333
334
  """
334
335
 
335
336
  def __init__(self, block, full=True, lazy=False, blockchain_instance=None, **kwargs):
336
- """Initilize a block
337
+ """
338
+ Initialize a BlockHeader.
337
339
 
338
- :param int block: block number
339
- :param Steem steem_instance: Steem
340
- instance
341
- :param bool lazy: Use lazy loading
340
+ One-line summary:
341
+ Create a BlockHeader wrapper for a block header, optionally in lazy or full mode.
342
342
 
343
+ Parameters:
344
+ block (int | float | dict): Block number (floats are converted to int) or a header dict.
345
+ full (bool): If True, populate the object with full header data; otherwise keep a minimal representation.
346
+ lazy (bool): If True, delay API fetching until data is accessed.
347
+
348
+ Notes:
349
+ If no blockchain_instance is provided, the module's shared blockchain instance is used.
343
350
  """
344
351
  self.full = full
345
352
  self.lazy = lazy
@@ -410,8 +417,8 @@ class Blocks(list):
410
417
  :param list name_list: list of accounts to fetch
411
418
  :param int count: (optional) maximum number of accounts
412
419
  to fetch per call, defaults to 100
413
- :param Steem/Hive blockchain_instance: Steem() or Hive() instance to use when
414
- accessing a RPCcreator = Account(creator, blockchain_instance=self)
420
+ :param Hive blockchain_instance: Hive() instance to use when
421
+ accessing RPC
415
422
  """
416
423
 
417
424
  def __init__(
@@ -421,13 +428,18 @@ class Blocks(list):
421
428
  lazy=False,
422
429
  full=True,
423
430
  blockchain_instance=None,
424
- **kwargs,
425
431
  ):
426
- if blockchain_instance is None:
427
- if kwargs.get("steem_instance"):
428
- blockchain_instance = kwargs["steem_instance"]
429
- elif kwargs.get("hive_instance"):
430
- blockchain_instance = kwargs["hive_instance"]
432
+ """
433
+ Initialize a Blocks collection by fetching a contiguous range of blocks from the chain and populating the list with Block objects.
434
+
435
+ If a blockchain_instance is provided it is used; otherwise the shared blockchain instance is used. If the chosen instance is not connected, the initializer returns early and the Blocks object remains empty.
436
+
437
+ Parameters:
438
+ starting_block_num (int): First block number to retrieve.
439
+ count (int, optional): Number of consecutive blocks to fetch. Defaults to 1000.
440
+ lazy (bool, optional): If True, create Block objects in lazy mode (defer full parsing). Defaults to False.
441
+ full (bool, optional): If True, create Block objects with full data loaded (subject to lazy). Defaults to True.
442
+ """
431
443
  self.blockchain = blockchain_instance or shared_blockchain_instance()
432
444
 
433
445
  if not self.blockchain.is_connected():
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