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.
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/METADATA +10 -11
- hive_nectar-0.1.0.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 +34 -22
- 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.0.dist-info}/WHEEL +0 -0
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/entry_points.txt +0 -0
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/licenses/LICENSE.txt +0 -0
nectar/account.py
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
import json
|
|
3
3
|
import logging
|
|
4
4
|
import random
|
|
5
|
+
import warnings
|
|
5
6
|
from datetime import date, datetime, time, timedelta, timezone
|
|
7
|
+
from typing import Any, Dict, List, Optional, Union
|
|
6
8
|
|
|
7
9
|
from prettytable import PrettyTable
|
|
8
10
|
|
|
9
11
|
from nectar.amount import Amount
|
|
10
12
|
from nectar.constants import (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
HIVE_1_PERCENT,
|
|
14
|
+
HIVE_100_PERCENT,
|
|
15
|
+
HIVE_VOTE_REGENERATION_SECONDS,
|
|
16
|
+
HIVE_VOTING_MANA_REGENERATION_SECONDS,
|
|
15
17
|
)
|
|
16
18
|
from nectar.instance import shared_blockchain_instance
|
|
17
19
|
from nectar.rc import RC
|
|
@@ -53,13 +55,10 @@ class Account(BlockchainObject):
|
|
|
53
55
|
"""This class allows to easily access Account data
|
|
54
56
|
|
|
55
57
|
:param str account: Name of the account
|
|
56
|
-
:param
|
|
57
|
-
instance
|
|
58
|
+
:param Blockchain blockchain_instance: Blockchain instance
|
|
58
59
|
:param bool lazy: Use lazy loading
|
|
59
60
|
:param bool full: Obtain all account data including orders, positions,
|
|
60
61
|
etc.
|
|
61
|
-
:param Hive hive_instance: Hive instance
|
|
62
|
-
:param Steem steem_instance: Steem instance
|
|
63
62
|
:returns: Account data
|
|
64
63
|
:rtype: dictionary
|
|
65
64
|
:raises nectar.exceptions.AccountDoesNotExistsException: if account
|
|
@@ -76,8 +75,8 @@ class Account(BlockchainObject):
|
|
|
76
75
|
>>> from nectar.nodelist import NodeList
|
|
77
76
|
>>> nodelist = NodeList()
|
|
78
77
|
>>> nodelist.update_nodes()
|
|
79
|
-
>>>
|
|
80
|
-
>>> account = Account("gtg", blockchain_instance=
|
|
78
|
+
>>> hv = Hive(node=nodelist.get_hive_nodes())
|
|
79
|
+
>>> account = Account("gtg", blockchain_instance=hv)
|
|
81
80
|
>>> print(account)
|
|
82
81
|
<Account gtg>
|
|
83
82
|
>>> print(account.balances) # doctest: +SKIP
|
|
@@ -92,27 +91,47 @@ class Account(BlockchainObject):
|
|
|
92
91
|
type_id = 2
|
|
93
92
|
|
|
94
93
|
def __init__(self, account, full=True, lazy=False, blockchain_instance=None, **kwargs):
|
|
95
|
-
"""
|
|
94
|
+
"""
|
|
95
|
+
Create an Account wrapper for a blockchain account.
|
|
96
|
+
|
|
97
|
+
Parameters:
|
|
98
|
+
account (str | dict): Account name or raw account object/dict. If a dict is provided it will be parsed into the internal account representation.
|
|
99
|
+
full (bool): If True, load complete account data (includes extended fields); if False use a lighter representation.
|
|
100
|
+
lazy (bool): If True, defer fetching/processing of some fields until needed.
|
|
96
101
|
|
|
97
|
-
:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
:
|
|
101
|
-
|
|
102
|
-
etc.
|
|
102
|
+
Description:
|
|
103
|
+
Optionally accepts an explicit blockchain instance via the `blockchain_instance` argument; if not provided a shared instance is used. For backward compatibility the deprecated kwargs `steem_instance` and `hive_instance` are accepted (they emit a DeprecationWarning and are mapped to `blockchain_instance`), but specifying more than one legacy instance raises ValueError.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
None
|
|
103
107
|
"""
|
|
108
|
+
# Handle legacy parameters
|
|
109
|
+
legacy_keys = {"steem_instance", "hive_instance"}
|
|
110
|
+
legacy_instance = None
|
|
111
|
+
for key in legacy_keys:
|
|
112
|
+
if key in kwargs:
|
|
113
|
+
if legacy_instance is not None:
|
|
114
|
+
raise ValueError(
|
|
115
|
+
f"Cannot specify both {key} and another legacy instance parameter"
|
|
116
|
+
)
|
|
117
|
+
legacy_instance = kwargs.pop(key)
|
|
118
|
+
warnings.warn(
|
|
119
|
+
f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
|
|
120
|
+
DeprecationWarning,
|
|
121
|
+
stacklevel=2,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# Prefer explicit blockchain_instance, then legacy
|
|
125
|
+
if blockchain_instance is None and legacy_instance is not None:
|
|
126
|
+
blockchain_instance = legacy_instance
|
|
127
|
+
|
|
104
128
|
self.full = full
|
|
105
129
|
self.lazy = lazy
|
|
106
|
-
if blockchain_instance is None:
|
|
107
|
-
if kwargs.get("steem_instance"):
|
|
108
|
-
blockchain_instance = kwargs["steem_instance"]
|
|
109
|
-
elif kwargs.get("hive_instance"):
|
|
110
|
-
blockchain_instance = kwargs["hive_instance"]
|
|
111
130
|
self.blockchain = blockchain_instance or shared_blockchain_instance()
|
|
112
131
|
if isinstance(account, dict):
|
|
113
132
|
account = self._parse_json_data(account)
|
|
114
133
|
super(Account, self).__init__(
|
|
115
|
-
account, lazy=lazy, full=full, id_item="name", blockchain_instance=
|
|
134
|
+
account, lazy=lazy, full=full, id_item="name", blockchain_instance=self.blockchain
|
|
116
135
|
)
|
|
117
136
|
|
|
118
137
|
def refresh(self):
|
|
@@ -150,6 +169,17 @@ class Account(BlockchainObject):
|
|
|
150
169
|
)
|
|
151
170
|
|
|
152
171
|
def _parse_json_data(self, account):
|
|
172
|
+
"""
|
|
173
|
+
Normalize and convert raw account JSON fields into proper Python types.
|
|
174
|
+
|
|
175
|
+
Converts certain string-encoded integer fields to int, parses timestamp strings to datetime via formatTimeString, converts proxied_vsf_votes entries to ints, and wraps balance/vesting fields in Amount objects using the instance's blockchain. The input dict is modified in-place and also returned.
|
|
176
|
+
|
|
177
|
+
Parameters:
|
|
178
|
+
account (dict): Raw account JSON as returned by the node; keys like balances, timestamps, and counters will be normalized.
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
dict: The same account dict after in-place normalization.
|
|
182
|
+
"""
|
|
153
183
|
parse_int = [
|
|
154
184
|
"sbd_seconds",
|
|
155
185
|
"savings_sbd_seconds",
|
|
@@ -181,10 +211,6 @@ class Account(BlockchainObject):
|
|
|
181
211
|
"last_active_proved",
|
|
182
212
|
"last_account_recovery",
|
|
183
213
|
"last_vote_time",
|
|
184
|
-
"sbd_seconds_last_update",
|
|
185
|
-
"sbd_last_interest_payment",
|
|
186
|
-
"savings_sbd_seconds_last_update",
|
|
187
|
-
"savings_sbd_last_interest_payment",
|
|
188
214
|
"next_vesting_withdrawal",
|
|
189
215
|
"last_market_bandwidth_update",
|
|
190
216
|
"last_post",
|
|
@@ -202,16 +228,11 @@ class Account(BlockchainObject):
|
|
|
202
228
|
amounts = [
|
|
203
229
|
"balance",
|
|
204
230
|
"savings_balance",
|
|
205
|
-
"sbd_balance",
|
|
206
|
-
"savings_sbd_balance",
|
|
207
|
-
"reward_sbd_balance",
|
|
208
231
|
"hbd_balance",
|
|
209
232
|
"savings_hbd_balance",
|
|
210
233
|
"reward_hbd_balance",
|
|
211
|
-
"reward_steem_balance",
|
|
212
234
|
"reward_hive_balance",
|
|
213
235
|
"reward_vesting_balance",
|
|
214
|
-
"reward_vesting_steem",
|
|
215
236
|
"vesting_shares",
|
|
216
237
|
"delegated_vesting_shares",
|
|
217
238
|
"received_vesting_shares",
|
|
@@ -224,6 +245,18 @@ class Account(BlockchainObject):
|
|
|
224
245
|
return account
|
|
225
246
|
|
|
226
247
|
def json(self):
|
|
248
|
+
"""
|
|
249
|
+
Return a JSON-serializable representation of the account data with normalized field types.
|
|
250
|
+
|
|
251
|
+
Converts internal Python objects to plain JSON-friendly types:
|
|
252
|
+
- Specific integer fields are converted to strings (to preserve large integers) or to strings only when non-zero.
|
|
253
|
+
- Elements of `proxied_vsf_votes` are converted to strings when they are non-zero integers; other elements are left unchanged.
|
|
254
|
+
- Datetime, date, and time objects listed in time fields are converted to ISO-like strings via `formatTimeString`; non-datetime values are passed through.
|
|
255
|
+
- Amount-like fields (e.g., balances, vesting shares) are converted by calling their `.json()` method.
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
dict: A JSON-serializable dictionary representing the account suitable for serialization.
|
|
259
|
+
"""
|
|
227
260
|
output = self.copy()
|
|
228
261
|
parse_int = [
|
|
229
262
|
"sbd_seconds",
|
|
@@ -259,10 +292,6 @@ class Account(BlockchainObject):
|
|
|
259
292
|
"last_active_proved",
|
|
260
293
|
"last_account_recovery",
|
|
261
294
|
"last_vote_time",
|
|
262
|
-
"sbd_seconds_last_update",
|
|
263
|
-
"sbd_last_interest_payment",
|
|
264
|
-
"savings_sbd_seconds_last_update",
|
|
265
|
-
"savings_sbd_last_interest_payment",
|
|
266
295
|
"next_vesting_withdrawal",
|
|
267
296
|
"last_market_bandwidth_update",
|
|
268
297
|
"last_post",
|
|
@@ -283,16 +312,11 @@ class Account(BlockchainObject):
|
|
|
283
312
|
amounts = [
|
|
284
313
|
"balance",
|
|
285
314
|
"savings_balance",
|
|
286
|
-
"sbd_balance",
|
|
287
|
-
"savings_sbd_balance",
|
|
288
|
-
"reward_sbd_balance",
|
|
289
|
-
"reward_steem_balance",
|
|
290
315
|
"hbd_balance",
|
|
291
316
|
"savings_hbd_balance",
|
|
292
317
|
"reward_hbd_balance",
|
|
293
318
|
"reward_hive_balance",
|
|
294
319
|
"reward_vesting_balance",
|
|
295
|
-
"reward_vesting_steem",
|
|
296
320
|
"vesting_shares",
|
|
297
321
|
"delegated_vesting_shares",
|
|
298
322
|
"received_vesting_shares",
|
|
@@ -315,7 +339,22 @@ class Account(BlockchainObject):
|
|
|
315
339
|
return b.find_rc_accounts(self["name"])
|
|
316
340
|
|
|
317
341
|
def get_rc_manabar(self):
|
|
318
|
-
"""
|
|
342
|
+
"""
|
|
343
|
+
Return the account's current and maximum Resource Credit (RC) mana.
|
|
344
|
+
|
|
345
|
+
Calculates RC mana regeneration since the stored `rc_manabar.last_update_time` and returns
|
|
346
|
+
both raw and computed values.
|
|
347
|
+
|
|
348
|
+
Returns:
|
|
349
|
+
dict: {
|
|
350
|
+
"last_mana" (int): stored mana at the last update (raw value from account data),
|
|
351
|
+
"last_update_time" (int): UNIX timestamp (seconds) of the last manabar update,
|
|
352
|
+
"current_mana" (int): estimated current mana after regeneration (capped at max_mana),
|
|
353
|
+
"max_mana" (int): maximum possible mana (from `max_rc`),
|
|
354
|
+
"current_pct" (float): current_mana / max_mana * 100 (0 if max_mana == 0),
|
|
355
|
+
"max_rc_creation_adjustment" (Amount): Amount object representing max RC creation adjustment
|
|
356
|
+
}
|
|
357
|
+
"""
|
|
319
358
|
rc_param = self.get_rc()
|
|
320
359
|
max_mana = int(rc_param["max_rc"])
|
|
321
360
|
last_mana = int(rc_param["rc_manabar"]["current_mana"])
|
|
@@ -323,7 +362,7 @@ class Account(BlockchainObject):
|
|
|
323
362
|
last_update = datetime.fromtimestamp(last_update_time, tz=timezone.utc)
|
|
324
363
|
diff_in_seconds = (datetime.now(timezone.utc) - last_update).total_seconds()
|
|
325
364
|
current_mana = int(
|
|
326
|
-
last_mana + diff_in_seconds * max_mana /
|
|
365
|
+
last_mana + diff_in_seconds * max_mana / HIVE_VOTING_MANA_REGENERATION_SECONDS
|
|
327
366
|
)
|
|
328
367
|
if current_mana > max_mana:
|
|
329
368
|
current_mana = max_mana
|
|
@@ -380,12 +419,16 @@ class Account(BlockchainObject):
|
|
|
380
419
|
|
|
381
420
|
@property
|
|
382
421
|
def sp(self):
|
|
383
|
-
"""
|
|
422
|
+
"""
|
|
423
|
+
Return the account's Hive Power (HP).
|
|
424
|
+
|
|
425
|
+
This is a compatibility alias that delegates to `get_token_power()` and returns the account's effective Hive Power as computed by that method.
|
|
426
|
+
"""
|
|
384
427
|
return self.get_token_power()
|
|
385
428
|
|
|
386
429
|
@property
|
|
387
430
|
def tp(self):
|
|
388
|
-
"""Returns the
|
|
431
|
+
"""Returns the account Hive Power"""
|
|
389
432
|
return self.get_token_power()
|
|
390
433
|
|
|
391
434
|
@property
|
|
@@ -406,7 +449,22 @@ class Account(BlockchainObject):
|
|
|
406
449
|
return json.loads(self["posting_json_metadata"])
|
|
407
450
|
|
|
408
451
|
def print_info(self, force_refresh=False, return_str=False, use_table=False, **kwargs):
|
|
409
|
-
"""
|
|
452
|
+
"""
|
|
453
|
+
Print account summary information, either printed or returned as a string.
|
|
454
|
+
|
|
455
|
+
If force_refresh is True the account data and shared blockchain data are refreshed before computing values.
|
|
456
|
+
The summary includes reputation, voting/downvoting power and recharge times, estimated vote value (HBD),
|
|
457
|
+
token power (HP), balances, and (when available) RC manabar estimates and approximate RC costs for common ops.
|
|
458
|
+
|
|
459
|
+
Parameters:
|
|
460
|
+
force_refresh (bool): If True, refresh account and blockchain data before generating the summary.
|
|
461
|
+
return_str (bool): If True, return the formatted summary string instead of printing it.
|
|
462
|
+
use_table (bool): If True, format the output as a two-column PrettyTable; otherwise produce a plain text block.
|
|
463
|
+
**kwargs: Forwarded to PrettyTable.get_string when use_table is True (e.g., sortby, border). These are ignored for plain text output.
|
|
464
|
+
|
|
465
|
+
Returns:
|
|
466
|
+
str | None: The formatted summary string when return_str is True; otherwise None (the summary is printed).
|
|
467
|
+
"""
|
|
410
468
|
if force_refresh:
|
|
411
469
|
self.refresh()
|
|
412
470
|
self.blockchain.refresh_data(True)
|
|
@@ -436,7 +494,7 @@ class Account(BlockchainObject):
|
|
|
436
494
|
t.add_row(["Name (rep)", self.name + " (%.2f)" % (self.rep)])
|
|
437
495
|
t.add_row(["Voting Power", "%.2f %%, " % (self.get_voting_power())])
|
|
438
496
|
t.add_row(["Downvoting Power", "%.2f %%, " % (self.get_downvoting_power())])
|
|
439
|
-
t.add_row(["Vote Value", "%.2f $" % (self.
|
|
497
|
+
t.add_row(["Vote Value (HBD)", "%.2f $" % (self.get_voting_value_HBD())])
|
|
440
498
|
t.add_row(["Last vote", "%s ago" % last_vote_time_str])
|
|
441
499
|
t.add_row(["Full in ", "%s" % (self.get_recharge_time_str())])
|
|
442
500
|
t.add_row(
|
|
@@ -507,12 +565,12 @@ class Account(BlockchainObject):
|
|
|
507
565
|
ret = self.name + " (%.2f) \n" % (self.rep)
|
|
508
566
|
ret += "--- Voting Power ---\n"
|
|
509
567
|
ret += "%.2f %%, " % (self.get_voting_power())
|
|
510
|
-
ret += " %.2f $\n" % (self.
|
|
568
|
+
ret += " %.2f $\n" % (self.get_voting_value_HBD())
|
|
511
569
|
ret += "full in %s \n" % (self.get_recharge_time_str())
|
|
512
570
|
ret += "--- Downvoting Power ---\n"
|
|
513
571
|
ret += "%.2f %% \n" % (self.get_downvoting_power())
|
|
514
572
|
ret += "--- Balance ---\n"
|
|
515
|
-
ret += "%.2f
|
|
573
|
+
ret += "%.2f HP, " % (self.get_token_power())
|
|
516
574
|
ret += "%s, %s\n" % (
|
|
517
575
|
str(self.balances["available"][0]),
|
|
518
576
|
str(self.balances["available"][1]),
|
|
@@ -552,7 +610,11 @@ class Account(BlockchainObject):
|
|
|
552
610
|
print(ret)
|
|
553
611
|
|
|
554
612
|
def get_reputation(self):
|
|
555
|
-
"""
|
|
613
|
+
"""
|
|
614
|
+
Return the account's normalized reputation score.
|
|
615
|
+
|
|
616
|
+
If the node is offline, returns None. When connected, prefers the appbase `reputation` API to fetch the latest reputation; if that call fails or is unavailable, falls back to the account's cached `reputation` field. The returned value is the normalized reputation computed by `reputation_to_score`.
|
|
617
|
+
"""
|
|
556
618
|
if not self.blockchain.is_connected():
|
|
557
619
|
return None
|
|
558
620
|
self.blockchain.rpc.set_next_node_on_empty_reply(False)
|
|
@@ -573,7 +635,25 @@ class Account(BlockchainObject):
|
|
|
573
635
|
return reputation_to_score(rep)
|
|
574
636
|
|
|
575
637
|
def get_manabar(self):
|
|
576
|
-
"""
|
|
638
|
+
"""
|
|
639
|
+
Return the account's voting manabar state.
|
|
640
|
+
|
|
641
|
+
Calculates current voting mana from the stored voting_manabar using the account's
|
|
642
|
+
effective vesting shares as `max_mana`. If effective vesting shares are zero,
|
|
643
|
+
a fallback is computed from the chain's account creation fee converted to vests.
|
|
644
|
+
|
|
645
|
+
Returns:
|
|
646
|
+
dict: Manabar values with the following keys:
|
|
647
|
+
- last_mana (int): Stored `current_mana` at the last update.
|
|
648
|
+
- last_update_time (int): Unix timestamp (seconds) of the last manabar update.
|
|
649
|
+
- current_mana (int): Estimated current mana (capped at `max_mana`).
|
|
650
|
+
- max_mana (int): Maximum mana derived from effective vesting shares.
|
|
651
|
+
- current_mana_pct (float): Current mana as a percentage of `max_mana`.
|
|
652
|
+
|
|
653
|
+
Notes:
|
|
654
|
+
- Regeneration uses HIVE_VOTING_MANA_REGENERATION_SECONDS to convert elapsed
|
|
655
|
+
seconds since `last_update_time` into regenerated mana.
|
|
656
|
+
"""
|
|
577
657
|
max_mana = self.get_effective_vesting_shares()
|
|
578
658
|
if max_mana == 0:
|
|
579
659
|
props = self.blockchain.get_chain_properties()
|
|
@@ -589,7 +669,7 @@ class Account(BlockchainObject):
|
|
|
589
669
|
addTzInfo(datetime.now(timezone.utc)) - addTzInfo(last_update)
|
|
590
670
|
).total_seconds()
|
|
591
671
|
current_mana = int(
|
|
592
|
-
last_mana + diff_in_seconds * max_mana /
|
|
672
|
+
last_mana + diff_in_seconds * max_mana / HIVE_VOTING_MANA_REGENERATION_SECONDS
|
|
593
673
|
)
|
|
594
674
|
if current_mana > max_mana:
|
|
595
675
|
current_mana = max_mana
|
|
@@ -606,7 +686,18 @@ class Account(BlockchainObject):
|
|
|
606
686
|
}
|
|
607
687
|
|
|
608
688
|
def get_downvote_manabar(self):
|
|
609
|
-
"""
|
|
689
|
+
"""
|
|
690
|
+
Return the account's downvote manabar state and regeneration progress.
|
|
691
|
+
|
|
692
|
+
If the account has no 'downvote_manabar' field returns None.
|
|
693
|
+
|
|
694
|
+
Returns a dict with:
|
|
695
|
+
- last_mana (int): stored mana at last update.
|
|
696
|
+
- last_update_time (int): POSIX timestamp of the last update.
|
|
697
|
+
- current_mana (int): estimated current mana after regeneration (clamped to max_mana).
|
|
698
|
+
- max_mana (int): maximum possible downvote mana (derived from effective vesting shares or account creation fee fallback).
|
|
699
|
+
- current_mana_pct (float): current_mana expressed as a percentage of max_mana (0–100).
|
|
700
|
+
"""
|
|
610
701
|
if "downvote_manabar" not in self:
|
|
611
702
|
return None
|
|
612
703
|
max_mana = self.get_effective_vesting_shares() / 4
|
|
@@ -624,7 +715,7 @@ class Account(BlockchainObject):
|
|
|
624
715
|
addTzInfo(datetime.now(timezone.utc)) - addTzInfo(last_update)
|
|
625
716
|
).total_seconds()
|
|
626
717
|
current_mana = int(
|
|
627
|
-
last_mana + diff_in_seconds * max_mana /
|
|
718
|
+
last_mana + diff_in_seconds * max_mana / HIVE_VOTING_MANA_REGENERATION_SECONDS
|
|
628
719
|
)
|
|
629
720
|
if current_mana > max_mana:
|
|
630
721
|
current_mana = max_mana
|
|
@@ -641,10 +732,16 @@ class Account(BlockchainObject):
|
|
|
641
732
|
}
|
|
642
733
|
|
|
643
734
|
def get_voting_power(self, with_regeneration=True):
|
|
644
|
-
"""
|
|
735
|
+
"""
|
|
736
|
+
Return the account's current voting power as a percentage (0–100).
|
|
645
737
|
|
|
646
|
-
|
|
647
|
-
|
|
738
|
+
If the account stores a `voting_manabar`, the result is derived from that manabar and optionally includes regeneration. If the legacy `voting_power` field is present, the method uses that value and, when `with_regeneration` is True, adds the amount regenerated since `last_vote_time`.
|
|
739
|
+
|
|
740
|
+
Parameters:
|
|
741
|
+
with_regeneration (bool): If True (default), include regenerated voting power since the last update.
|
|
742
|
+
|
|
743
|
+
Returns:
|
|
744
|
+
float: Voting power percentage in the range 0 to 100 (clamped).
|
|
648
745
|
"""
|
|
649
746
|
if "voting_manabar" in self:
|
|
650
747
|
manabar = self.get_manabar()
|
|
@@ -662,7 +759,7 @@ class Account(BlockchainObject):
|
|
|
662
759
|
addTzInfo(datetime.now(timezone.utc)) - (last_vote_time)
|
|
663
760
|
).total_seconds()
|
|
664
761
|
regenerated_vp = (
|
|
665
|
-
diff_in_seconds *
|
|
762
|
+
diff_in_seconds * HIVE_100_PERCENT / HIVE_VOTE_REGENERATION_SECONDS / 100
|
|
666
763
|
)
|
|
667
764
|
else:
|
|
668
765
|
regenerated_vp = 0
|
|
@@ -713,7 +810,18 @@ class Account(BlockchainObject):
|
|
|
713
810
|
return vests
|
|
714
811
|
|
|
715
812
|
def get_effective_vesting_shares(self):
|
|
716
|
-
"""
|
|
813
|
+
"""
|
|
814
|
+
Return the account's effective vesting shares as an integer.
|
|
815
|
+
|
|
816
|
+
Calculates vesting shares adjusted for active delegations and pending withdrawals:
|
|
817
|
+
- Starts from `vesting_shares`.
|
|
818
|
+
- Subtracts `delegated_vesting_shares` and adds `received_vesting_shares` when present.
|
|
819
|
+
- If a future `next_vesting_withdrawal` exists and withdrawal fields are present,
|
|
820
|
+
subtracts the remaining amount that will be withdrawn (bounded by `vesting_withdraw_rate`).
|
|
821
|
+
|
|
822
|
+
Returns:
|
|
823
|
+
int: Effective vesting shares in the same internal units stored on the account.
|
|
824
|
+
"""
|
|
717
825
|
vesting_shares = int(self["vesting_shares"])
|
|
718
826
|
if "delegated_vesting_shares" in self and "received_vesting_shares" in self:
|
|
719
827
|
vesting_shares = (
|
|
@@ -737,22 +845,20 @@ class Account(BlockchainObject):
|
|
|
737
845
|
return vesting_shares
|
|
738
846
|
|
|
739
847
|
def get_token_power(self, only_own_vests=False, use_stored_data=True):
|
|
740
|
-
"""
|
|
848
|
+
"""
|
|
849
|
+
Return the account's Hive Power (HP), including staked tokens and delegated amounts.
|
|
741
850
|
|
|
742
|
-
:
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
vests_to_token_power ratio everytime (default True)
|
|
851
|
+
Parameters:
|
|
852
|
+
only_own_vests (bool): If True, only the account's owned vesting shares are considered (delegations excluded).
|
|
853
|
+
use_stored_data (bool): If False, fetch the current vests-to-token-power conversion from the chain; if True, use cached conversion values.
|
|
746
854
|
|
|
855
|
+
Returns:
|
|
856
|
+
float: Hive Power (HP) equivalent for the account's vesting shares.
|
|
747
857
|
"""
|
|
748
858
|
return self.blockchain.vests_to_token_power(
|
|
749
859
|
self.get_vests(only_own_vests=only_own_vests), use_stored_data=use_stored_data
|
|
750
860
|
)
|
|
751
861
|
|
|
752
|
-
def get_steem_power(self, onlyOwnSP=False):
|
|
753
|
-
"""Returns the account steem power"""
|
|
754
|
-
return self.get_token_power(only_own_vests=onlyOwnSP)
|
|
755
|
-
|
|
756
862
|
def get_voting_value(
|
|
757
863
|
self,
|
|
758
864
|
post_rshares=0,
|
|
@@ -761,7 +867,23 @@ class Account(BlockchainObject):
|
|
|
761
867
|
token_power=None,
|
|
762
868
|
not_broadcasted_vote=True,
|
|
763
869
|
):
|
|
764
|
-
"""
|
|
870
|
+
"""
|
|
871
|
+
Estimate the vote value expressed in HBD for a potential vote by this account.
|
|
872
|
+
|
|
873
|
+
Detailed description:
|
|
874
|
+
Computes the HBD value that a vote would produce given post rshares and voting settings. Uses the account's token power (HP) by default and delegates the numeric conversion to the blockchain instance.
|
|
875
|
+
|
|
876
|
+
Parameters:
|
|
877
|
+
post_rshares (int): The post's rshares contribution (can be 0 for an upvote-only estimate).
|
|
878
|
+
voting_weight (float|int, optional): The vote weight as a percentage in the range 0–100 (default 100).
|
|
879
|
+
voting_power (float|int, optional): The account's current voting power as a percentage in the range 0–100.
|
|
880
|
+
If omitted, the account's current voting power is used.
|
|
881
|
+
token_power (float|int, optional): Token power (HP) to use for the calculation. If omitted, the account's current HP is used.
|
|
882
|
+
not_broadcasted_vote (bool, optional): If True, treat the vote as not yet broadcast when estimating (affects regeneration logic).
|
|
883
|
+
|
|
884
|
+
Returns:
|
|
885
|
+
Amount: Estimated vote value denominated in HBD.
|
|
886
|
+
"""
|
|
765
887
|
if voting_power is None:
|
|
766
888
|
voting_power = self.get_voting_power()
|
|
767
889
|
if token_power is None:
|
|
@@ -777,40 +899,58 @@ class Account(BlockchainObject):
|
|
|
777
899
|
)
|
|
778
900
|
return voteValue
|
|
779
901
|
|
|
780
|
-
def
|
|
902
|
+
def get_voting_value_HBD(
|
|
781
903
|
self,
|
|
782
904
|
post_rshares=0,
|
|
783
905
|
voting_weight=100,
|
|
784
906
|
voting_power=None,
|
|
785
|
-
|
|
907
|
+
hive_power=None,
|
|
786
908
|
not_broadcasted_vote=True,
|
|
787
909
|
):
|
|
788
|
-
"""
|
|
910
|
+
"""
|
|
911
|
+
Return the estimated voting value expressed in HBD for the account.
|
|
912
|
+
|
|
913
|
+
This is a thin wrapper around `get_voting_value` that maps `hive_power` to the underlying `token_power` parameter.
|
|
914
|
+
|
|
915
|
+
Parameters:
|
|
916
|
+
post_rshares (int): Total rshares for the target post (default 0).
|
|
917
|
+
voting_weight (int): Weight of the vote as a percentage (0-100, default 100).
|
|
918
|
+
voting_power (int | None): Current voting power percentage to use; if None the account's current power is used.
|
|
919
|
+
hive_power (float | None): Token power (Hive Power / HP) to use for the calculation; if None the account's current token power is used.
|
|
920
|
+
not_broadcasted_vote (bool): If True, calculate value as if the vote is not yet broadcast (default True).
|
|
921
|
+
|
|
922
|
+
Returns:
|
|
923
|
+
Estimated vote value expressed in HBD.
|
|
924
|
+
"""
|
|
789
925
|
return self.get_voting_value(
|
|
790
926
|
post_rshares=post_rshares,
|
|
791
927
|
voting_weight=voting_weight,
|
|
792
928
|
voting_power=voting_power,
|
|
793
|
-
token_power=
|
|
929
|
+
token_power=hive_power,
|
|
794
930
|
not_broadcasted_vote=not_broadcasted_vote,
|
|
795
931
|
)
|
|
796
932
|
|
|
797
|
-
def
|
|
798
|
-
self,
|
|
933
|
+
def get_vote_pct_for_HBD(
|
|
934
|
+
self, hbd, post_rshares=0, voting_power=None, hive_power=None, not_broadcasted_vote=True
|
|
799
935
|
):
|
|
800
|
-
"""
|
|
801
|
-
|
|
802
|
-
If the returned number is bigger than 10000 or smaller than -10000,
|
|
803
|
-
the given SBD value is too high for that account
|
|
936
|
+
"""
|
|
937
|
+
Return the voting percentage (weight) required for this account to produce a vote worth the given HBD amount.
|
|
804
938
|
|
|
805
|
-
:
|
|
806
|
-
|
|
939
|
+
Parameters:
|
|
940
|
+
hbd (str | int | Amount): Desired vote value in HBD (can be numeric, string, or an Amount).
|
|
941
|
+
post_rshares (int): Current rshares of the post; used in the vote value calculation. Defaults to 0.
|
|
942
|
+
voting_power (int | None): Current voting power to use (in internal units). If None, the account's current voting power is used.
|
|
943
|
+
hive_power (Amount | None): Token power (HP) to use for the calculation. If None, the account's current HP is used.
|
|
944
|
+
not_broadcasted_vote (bool): If True, accounts for a non-broadcasted (simulated) vote when estimating required percentage.
|
|
807
945
|
|
|
946
|
+
Returns:
|
|
947
|
+
int: Vote weight as an integer in the range -10000..10000 (where 10000 == 100%). Values outside that range indicate the requested HBD value is unattainable with this account (e.g., greater than 10000 or less than -10000).
|
|
808
948
|
"""
|
|
809
949
|
return self.get_vote_pct_for_vote_value(
|
|
810
|
-
|
|
950
|
+
hbd,
|
|
811
951
|
post_rshares=post_rshares,
|
|
812
952
|
voting_power=voting_power,
|
|
813
|
-
token_power=
|
|
953
|
+
token_power=hive_power,
|
|
814
954
|
not_broadcasted_vote=not_broadcasted_vote,
|
|
815
955
|
)
|
|
816
956
|
|
|
@@ -822,14 +962,23 @@ class Account(BlockchainObject):
|
|
|
822
962
|
token_power=None,
|
|
823
963
|
not_broadcasted_vote=True,
|
|
824
964
|
):
|
|
825
|
-
"""
|
|
965
|
+
"""
|
|
966
|
+
Return the voting percentage required to produce a specified vote value in the blockchain's backed token (HBD).
|
|
967
|
+
|
|
968
|
+
Given a desired token-backed amount (token_units), compute the internal vote percentage (in the same scale used by the chain, e.g. 10000 == 100%) required to yield that payout for a post with post_rshares. If the returned value is larger than 10000 or smaller than -10000, the requested value is outside what the account can reasonably produce.
|
|
826
969
|
|
|
827
|
-
|
|
828
|
-
|
|
970
|
+
Parameters:
|
|
971
|
+
token_units (str|int|Amount): Desired vote value expressed in the blockchain's backed token (HBD). Strings and numbers will be converted to an Amount using the account's blockchain context.
|
|
972
|
+
post_rshares (int, optional): Current rshares for the post; used when converting rshares to a percentage. Default 0.
|
|
973
|
+
voting_power (float|int, optional): Account voting power as returned by get_voting_power (expected on a 0–100 scale). If omitted, the account's current voting power is used.
|
|
974
|
+
token_power (float|int, optional): Account token power (HP). If omitted, the account's current token power is used.
|
|
975
|
+
not_broadcasted_vote (bool, optional): Passed to the conversion routine when estimating rshares from HBD; controls whether broadcast-specific adjustments are applied. Default True.
|
|
829
976
|
|
|
830
|
-
:
|
|
831
|
-
|
|
977
|
+
Returns:
|
|
978
|
+
int: The vote percentage in chain units (e.g., 10000 == 100%). May exceed ±10000 when the requested value is unattainable.
|
|
832
979
|
|
|
980
|
+
Raises:
|
|
981
|
+
AssertionError: If token_units is not expressed in the blockchain's backed token symbol (HBD).
|
|
833
982
|
"""
|
|
834
983
|
if voting_power is None:
|
|
835
984
|
voting_power = self.get_voting_power()
|
|
@@ -850,18 +999,6 @@ class Account(BlockchainObject):
|
|
|
850
999
|
raise AssertionError(
|
|
851
1000
|
"Should input %s, not any other asset!" % self.blockchain.backed_token_symbol
|
|
852
1001
|
)
|
|
853
|
-
from nectar import Steem
|
|
854
|
-
|
|
855
|
-
if isinstance(self.blockchain, Steem):
|
|
856
|
-
vote_pct = self.blockchain.rshares_to_vote_pct(
|
|
857
|
-
self.blockchain.sbd_to_rshares(
|
|
858
|
-
token_units, not_broadcasted_vote=not_broadcasted_vote
|
|
859
|
-
),
|
|
860
|
-
post_rshares=post_rshares,
|
|
861
|
-
voting_power=voting_power * 100,
|
|
862
|
-
steem_power=token_power,
|
|
863
|
-
)
|
|
864
|
-
else:
|
|
865
1002
|
vote_pct = self.blockchain.rshares_to_vote_pct(
|
|
866
1003
|
self.blockchain.hbd_to_rshares(
|
|
867
1004
|
token_units, not_broadcasted_vote=not_broadcasted_vote
|
|
@@ -895,12 +1032,24 @@ class Account(BlockchainObject):
|
|
|
895
1032
|
return formatTimedelta(remainingTime)
|
|
896
1033
|
|
|
897
1034
|
def get_recharge_timedelta(self, voting_power_goal=100, starting_voting_power=None):
|
|
898
|
-
"""
|
|
1035
|
+
"""
|
|
1036
|
+
Return the timedelta required to recharge the account's voting power to a target percentage.
|
|
899
1037
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1038
|
+
If `starting_voting_power` is omitted, the current voting power is used. `voting_power_goal`
|
|
1039
|
+
and `starting_voting_power` are percentages (e.g., 100 for full power). If the starting
|
|
1040
|
+
power already meets or exceeds the goal, the function returns 0.
|
|
1041
|
+
|
|
1042
|
+
Parameters:
|
|
1043
|
+
voting_power_goal (float): Target voting power percentage (default 100).
|
|
1044
|
+
starting_voting_power (float | int | None): Optional starting voting power percentage to
|
|
1045
|
+
use instead of the account's current voting power.
|
|
1046
|
+
|
|
1047
|
+
Returns:
|
|
1048
|
+
datetime.timedelta | int: Time required to recharge to the goal as a timedelta, or 0 if
|
|
1049
|
+
the starting power is already at or above the goal.
|
|
903
1050
|
|
|
1051
|
+
Raises:
|
|
1052
|
+
ValueError: If `starting_voting_power` is provided but is not a number.
|
|
904
1053
|
"""
|
|
905
1054
|
if starting_voting_power is None:
|
|
906
1055
|
missing_vp = voting_power_goal - self.get_voting_power()
|
|
@@ -911,7 +1060,7 @@ class Account(BlockchainObject):
|
|
|
911
1060
|
if missing_vp < 0:
|
|
912
1061
|
return 0
|
|
913
1062
|
recharge_seconds = (
|
|
914
|
-
missing_vp * 100 *
|
|
1063
|
+
missing_vp * 100 * HIVE_VOTING_MANA_REGENERATION_SECONDS / HIVE_100_PERCENT
|
|
915
1064
|
)
|
|
916
1065
|
return timedelta(seconds=recharge_seconds)
|
|
917
1066
|
|
|
@@ -940,11 +1089,17 @@ class Account(BlockchainObject):
|
|
|
940
1089
|
return formatTimedelta(remainingTime)
|
|
941
1090
|
|
|
942
1091
|
def get_manabar_recharge_timedelta(self, manabar, recharge_pct_goal=100):
|
|
943
|
-
"""
|
|
1092
|
+
"""
|
|
1093
|
+
Return the time remaining for a manabar to recharge to a target percentage.
|
|
944
1094
|
|
|
945
|
-
:
|
|
946
|
-
|
|
1095
|
+
Parameters:
|
|
1096
|
+
manabar (dict): Manabar structure returned by get_manabar() or get_rc_manabar().
|
|
1097
|
+
Expected to contain either 'current_mana_pct' or 'current_pct' (value in percent).
|
|
1098
|
+
recharge_pct_goal (float): Target recharge percentage (0–100). Defaults to 100.
|
|
947
1099
|
|
|
1100
|
+
Returns:
|
|
1101
|
+
datetime.timedelta or int: Time required to reach the target as a timedelta. If the
|
|
1102
|
+
manabar is already at or above the target, returns 0.
|
|
948
1103
|
"""
|
|
949
1104
|
if "current_mana_pct" in manabar:
|
|
950
1105
|
missing_rc_pct = recharge_pct_goal - manabar["current_mana_pct"]
|
|
@@ -953,85 +1108,40 @@ class Account(BlockchainObject):
|
|
|
953
1108
|
if missing_rc_pct < 0:
|
|
954
1109
|
return 0
|
|
955
1110
|
recharge_seconds = (
|
|
956
|
-
missing_rc_pct * 100 *
|
|
1111
|
+
missing_rc_pct * 100 * HIVE_VOTING_MANA_REGENERATION_SECONDS / HIVE_100_PERCENT
|
|
957
1112
|
)
|
|
958
1113
|
return timedelta(seconds=recharge_seconds)
|
|
959
1114
|
|
|
960
1115
|
def get_manabar_recharge_time(self, manabar, recharge_pct_goal=100):
|
|
961
|
-
"""
|
|
1116
|
+
"""
|
|
1117
|
+
Return the UTC datetime when the given manabar will reach the specified recovery percentage.
|
|
962
1118
|
|
|
963
|
-
:
|
|
964
|
-
|
|
1119
|
+
Parameters:
|
|
1120
|
+
manabar (dict): Manabar state as returned by get_manabar() or get_rc_manabar().
|
|
1121
|
+
Expected keys include 'current_mana' (int), 'max_mana' (int) and 'last_update_time' (datetime or ISO string).
|
|
1122
|
+
recharge_pct_goal (float): Target recovery level as a percentage (0–100). Defaults to 100.
|
|
965
1123
|
|
|
1124
|
+
Returns:
|
|
1125
|
+
datetime: Timezone-aware UTC datetime when the manabar is expected to reach the target percentage.
|
|
966
1126
|
"""
|
|
967
1127
|
return addTzInfo(datetime.now(timezone.utc)) + self.get_manabar_recharge_timedelta(
|
|
968
1128
|
manabar, recharge_pct_goal
|
|
969
1129
|
)
|
|
970
1130
|
|
|
971
|
-
def get_feed(
|
|
972
|
-
self, start_entry_id=0, limit=100, raw_data=False, short_entries=False, account=None
|
|
973
|
-
):
|
|
974
|
-
"""Returns a list of items in an account’s feed
|
|
975
|
-
|
|
976
|
-
:param int start_entry_id: default is 0
|
|
977
|
-
:param int limit: default is 100
|
|
978
|
-
:param bool raw_data: default is False
|
|
979
|
-
:param bool short_entries: when set to True and raw_data is True, get_feed_entries is used istead of get_feed
|
|
980
|
-
:param str account: When set, a different account name is used (Default is object account name)
|
|
981
|
-
|
|
982
|
-
:rtype: list
|
|
983
|
-
|
|
984
|
-
.. code-block:: python
|
|
985
|
-
|
|
986
|
-
>>> from nectar.account import Account
|
|
987
|
-
>>> from nectar import Hive
|
|
988
|
-
>>> from nectar.nodelist import NodeList
|
|
989
|
-
>>> nodelist = NodeList()
|
|
990
|
-
>>> nodelist.update_nodes()
|
|
991
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
992
|
-
>>> account = Account("steemit", blockchain_instance=stm)
|
|
993
|
-
>>> account.get_feed(0, 1, raw_data=True)
|
|
994
|
-
[]
|
|
995
|
-
|
|
996
|
-
"""
|
|
997
|
-
if account is None:
|
|
998
|
-
account = self["name"]
|
|
999
|
-
account = extract_account_name(account)
|
|
1000
|
-
if not self.blockchain.is_connected():
|
|
1001
|
-
return None
|
|
1002
|
-
from nectar.discussions import Discussions, Query
|
|
1003
|
-
|
|
1004
|
-
d = Discussions(blockchain_instance=self.blockchain)
|
|
1005
|
-
if short_entries:
|
|
1006
|
-
truncate_body = 1
|
|
1007
|
-
else:
|
|
1008
|
-
truncate_body = 0
|
|
1009
|
-
q = Query(limit=limit, tag=account, truncate_body=truncate_body)
|
|
1010
|
-
return [c for c in d.get_discussions("feed", q, limit=limit, raw_data=raw_data)]
|
|
1011
|
-
|
|
1012
1131
|
def get_feed_entries(self, start_entry_id=0, limit=100, raw_data=True, account=None):
|
|
1013
|
-
"""
|
|
1014
|
-
|
|
1015
|
-
:param int start_entry_id: default is 0
|
|
1016
|
-
:param int limit: default is 100
|
|
1017
|
-
:param bool raw_data: default is False
|
|
1018
|
-
:param bool short_entries: when set to True and raw_data is True, get_feed_entries is used istead of get_feed
|
|
1019
|
-
:param str account: When set, a different account name is used (Default is object account name)
|
|
1020
|
-
|
|
1021
|
-
:rtype: list
|
|
1132
|
+
"""
|
|
1133
|
+
Return a list of feed entries for the account.
|
|
1022
1134
|
|
|
1023
|
-
|
|
1135
|
+
If `account` is provided, entries for that account are returned; otherwise uses this Account's name. This method delegates to the internal feed retrieval implementation and requests short-form entries.
|
|
1024
1136
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1031
|
-
>>> account = Account("steemit", blockchain_instance=stm)
|
|
1032
|
-
>>> account.get_feed_entries(0, 1)
|
|
1033
|
-
[]
|
|
1137
|
+
Parameters:
|
|
1138
|
+
start_entry_id (int): Entry index to start from (default 0).
|
|
1139
|
+
limit (int): Maximum number of entries to return (default 100).
|
|
1140
|
+
raw_data (bool): If True, return raw API dictionaries; if False, return wrapped objects (default True).
|
|
1141
|
+
account (str, optional): Override account name to fetch feed for (default uses this Account).
|
|
1034
1142
|
|
|
1143
|
+
Returns:
|
|
1144
|
+
list: A list of feed entries (raw dicts or wrapped objects depending on `raw_data`).
|
|
1035
1145
|
"""
|
|
1036
1146
|
return self.get_feed(
|
|
1037
1147
|
start_entry_id=start_entry_id,
|
|
@@ -1042,28 +1152,19 @@ class Account(BlockchainObject):
|
|
|
1042
1152
|
)
|
|
1043
1153
|
|
|
1044
1154
|
def get_blog_entries(self, start_entry_id=0, limit=100, raw_data=True, account=None):
|
|
1045
|
-
"""
|
|
1046
|
-
|
|
1047
|
-
:param int start_entry_id: default is 0
|
|
1048
|
-
:param int limit: default is 100
|
|
1049
|
-
:param bool raw_data: default is False
|
|
1050
|
-
:param str account: When set, a different account name is used (Default is object account name)
|
|
1051
|
-
|
|
1052
|
-
:rtype: list
|
|
1155
|
+
"""
|
|
1156
|
+
Return the account's blog entries.
|
|
1053
1157
|
|
|
1054
|
-
|
|
1158
|
+
By default returns up to `limit` entries starting at `start_entry_id` for this account. When `raw_data` is True the entries are returned as raw dictionaries from the RPC; when False they are returned as processed Comment objects.
|
|
1055
1159
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1062
|
-
>>> account = Account("steemit", blockchain_instance=stm)
|
|
1063
|
-
>>> entry = account.get_blog_entries(0, 1, raw_data=True)[0]
|
|
1064
|
-
>>> print("%s - %s - %s" % (entry["author"], entry["permlink"], entry["blog"]))
|
|
1065
|
-
steemit - firstpost - steemit
|
|
1160
|
+
Parameters:
|
|
1161
|
+
start_entry_id (int): Entry index to start from (default 0).
|
|
1162
|
+
limit (int): Maximum number of entries to return (default 100).
|
|
1163
|
+
raw_data (bool): If True return raw RPC dicts; if False return Comment objects (default True).
|
|
1164
|
+
account (str): Optional account name to fetch entries for (default is this Account's name).
|
|
1066
1165
|
|
|
1166
|
+
Returns:
|
|
1167
|
+
list: A list of entries (dicts when `raw_data` is True, Comment objects when False).
|
|
1067
1168
|
"""
|
|
1068
1169
|
return self.get_blog(
|
|
1069
1170
|
start_entry_id=start_entry_id,
|
|
@@ -1076,28 +1177,23 @@ class Account(BlockchainObject):
|
|
|
1076
1177
|
def get_blog(
|
|
1077
1178
|
self, start_entry_id=0, limit=100, raw_data=False, short_entries=False, account=None
|
|
1078
1179
|
):
|
|
1079
|
-
"""
|
|
1180
|
+
"""
|
|
1181
|
+
Return the blog entries for an account.
|
|
1080
1182
|
|
|
1081
|
-
|
|
1082
|
-
:param int limit: default is 100
|
|
1083
|
-
:param bool raw_data: default is False
|
|
1084
|
-
:param bool short_entries: when set to True and raw_data is True, get_blog_entries is used istead of get_blog
|
|
1085
|
-
:param str account: When set, a different account name is used (Default is object account name)
|
|
1183
|
+
By default this returns a list of Comment objects for the account's blog. If raw_data=True the raw API dicts are returned instead. When both raw_data and short_entries are True the `get_blog_entries` API is used (returns shorter entry objects). If account is None the current Account's name is used.
|
|
1086
1184
|
|
|
1087
|
-
:
|
|
1185
|
+
Parameters:
|
|
1186
|
+
start_entry_id (int): ID offset to start from (default 0).
|
|
1187
|
+
limit (int): Maximum number of entries to return (default 100).
|
|
1188
|
+
raw_data (bool): If True, return raw API dictionaries instead of Comment objects.
|
|
1189
|
+
short_entries (bool): When True and raw_data is True, use the shorter `get_blog_entries` API.
|
|
1190
|
+
account (str|Account|dict|None): Account to query; if None uses this Account.
|
|
1088
1191
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
>>> from nectar.account import Account
|
|
1092
|
-
>>> from nectar import Hive
|
|
1093
|
-
>>> from nectar.nodelist import NodeList
|
|
1094
|
-
>>> nodelist = NodeList()
|
|
1095
|
-
>>> nodelist.update_nodes()
|
|
1096
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1097
|
-
>>> account = Account("steemit", blockchain_instance=stm)
|
|
1098
|
-
>>> account.get_blog(0, 1)
|
|
1099
|
-
[<Comment @steemit/firstpost>]
|
|
1192
|
+
Returns:
|
|
1193
|
+
list: A list of Comment objects (when raw_data is False) or raw entry dictionaries (when raw_data is True).
|
|
1100
1194
|
|
|
1195
|
+
Raises:
|
|
1196
|
+
OfflineHasNoRPCException: If called while offline (no RPC available).
|
|
1101
1197
|
"""
|
|
1102
1198
|
if account is None:
|
|
1103
1199
|
account = self["name"]
|
|
@@ -1232,23 +1328,10 @@ class Account(BlockchainObject):
|
|
|
1232
1328
|
return self.blockchain.custom_json("notify", json_body, required_posting_auths=[account])
|
|
1233
1329
|
|
|
1234
1330
|
def get_blog_authors(self, account=None):
|
|
1235
|
-
"""
|
|
1236
|
-
|
|
1237
|
-
:param str account: When set, a different account name is used (Default is object account name)
|
|
1238
|
-
|
|
1239
|
-
:rtype: list
|
|
1240
|
-
|
|
1241
|
-
.. code-block:: python
|
|
1242
|
-
|
|
1243
|
-
>>> from nectar.account import Account
|
|
1244
|
-
>>> from nectar import Hive
|
|
1245
|
-
>>> from nectar.nodelist import NodeList
|
|
1246
|
-
>>> nodelist = NodeList()
|
|
1247
|
-
>>> nodelist.update_nodes()
|
|
1248
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1249
|
-
>>> account = Account("gtg", blockchain_instance=stm)
|
|
1250
|
-
>>> account.get_blog_authors() # doctest: +SKIP
|
|
1331
|
+
"""
|
|
1332
|
+
Return a list of author account names whose posts have been reblogged on the specified blog account.
|
|
1251
1333
|
|
|
1334
|
+
If `account` is omitted, uses this Account object's name. Raises OfflineHasNoRPCException if called while offline. Returns a list of strings (author account names).
|
|
1252
1335
|
"""
|
|
1253
1336
|
if account is None:
|
|
1254
1337
|
account = self["name"]
|
|
@@ -1312,7 +1395,16 @@ class Account(BlockchainObject):
|
|
|
1312
1395
|
return Accounts(name_list, blockchain_instance=self.blockchain)
|
|
1313
1396
|
|
|
1314
1397
|
def get_mutings(self, raw_name_list=True, limit=100):
|
|
1315
|
-
"""
|
|
1398
|
+
"""
|
|
1399
|
+
Return the list of accounts this account has muted.
|
|
1400
|
+
|
|
1401
|
+
Parameters:
|
|
1402
|
+
raw_name_list (bool): If True (default), return a list of account names (str). If False, return an Accounts collection of Account objects.
|
|
1403
|
+
limit (int): Maximum number of muted accounts to fetch (default 100).
|
|
1404
|
+
|
|
1405
|
+
Returns:
|
|
1406
|
+
list[str] | Accounts: Either a list of account names or an Accounts object containing the muted accounts.
|
|
1407
|
+
"""
|
|
1316
1408
|
name_list = [
|
|
1317
1409
|
x["following"]
|
|
1318
1410
|
for x in self._get_followers(direction="following", what="ignore", limit=limit)
|
|
@@ -1322,41 +1414,83 @@ class Account(BlockchainObject):
|
|
|
1322
1414
|
else:
|
|
1323
1415
|
return Accounts(name_list, blockchain_instance=self.blockchain)
|
|
1324
1416
|
|
|
1325
|
-
def get_follow_list(
|
|
1326
|
-
|
|
1417
|
+
def get_follow_list(
|
|
1418
|
+
self,
|
|
1419
|
+
follow_type: str,
|
|
1420
|
+
starting_account: Optional[str] = None,
|
|
1421
|
+
raw_name_list: bool = True,
|
|
1422
|
+
) -> Union[List[Dict[str, Any]], "Accounts"]:
|
|
1423
|
+
"""
|
|
1424
|
+
Return the account follow list for a given follow_type (requires Hive HF >= 24).
|
|
1425
|
+
|
|
1426
|
+
Normalizes legacy aliases ('blacklisted' -> 'follow_blacklist', 'muted' -> 'follow_muted')
|
|
1427
|
+
and queries the blockchain bridge API for the observer's follow list. Supports pagination
|
|
1428
|
+
via an optional starting_account cursor.
|
|
1327
1429
|
|
|
1328
|
-
:
|
|
1430
|
+
Parameters:
|
|
1431
|
+
follow_type (str): One of 'follow_blacklist' or 'follow_muted' (aliases 'blacklisted' and 'muted' accepted).
|
|
1432
|
+
starting_account (Optional[str]): Optional pagination start cursor (name of the account to start from).
|
|
1433
|
+
raw_name_list (bool): If True, return the raw list of dicts from the bridge API (each dict typically contains a 'name' key).
|
|
1434
|
+
If False, return an Accounts collection built from the returned names.
|
|
1435
|
+
|
|
1436
|
+
Returns:
|
|
1437
|
+
Union[List[Dict[str, Any]], Accounts]: Raw list of follow entries (dicts) when raw_name_list is True,
|
|
1438
|
+
otherwise an Accounts instance containing the followed account names.
|
|
1439
|
+
|
|
1440
|
+
Raises:
|
|
1441
|
+
OfflineHasNoRPCException: If called while the blockchain instance is in offline mode (no RPC available).
|
|
1442
|
+
ValueError: If follow_type is not one of the supported values or aliases.
|
|
1329
1443
|
"""
|
|
1330
1444
|
if not self.blockchain.is_connected():
|
|
1331
1445
|
raise OfflineHasNoRPCException("No RPC available in offline mode!")
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1446
|
+
# Normalize follow_type to canonical values accepted by all nodes
|
|
1447
|
+
alias_map = {
|
|
1448
|
+
"blacklisted": "follow_blacklist",
|
|
1449
|
+
"muted": "follow_muted",
|
|
1450
|
+
}
|
|
1451
|
+
normalized_follow_type = alias_map.get(follow_type, follow_type)
|
|
1452
|
+
valid_types = {"follow_blacklist", "follow_muted"}
|
|
1453
|
+
if normalized_follow_type not in valid_types:
|
|
1454
|
+
raise ValueError(
|
|
1455
|
+
"Invalid follow_type. Use one of: 'blacklisted', 'muted', 'follow_blacklist', 'follow_muted'"
|
|
1456
|
+
)
|
|
1457
|
+
|
|
1458
|
+
self.blockchain.rpc.set_next_node_on_empty_reply(False)
|
|
1459
|
+
query = {
|
|
1460
|
+
"observer": self.name,
|
|
1461
|
+
"follow_type": normalized_follow_type,
|
|
1462
|
+
}
|
|
1463
|
+
if starting_account is not None:
|
|
1464
|
+
query["start"] = starting_account
|
|
1465
|
+
|
|
1466
|
+
followers = self.blockchain.rpc.get_follow_list(query, api="bridge")
|
|
1467
|
+
|
|
1468
|
+
name_list: List[Dict[str, Any]] = followers or []
|
|
1353
1469
|
if raw_name_list:
|
|
1354
1470
|
return name_list
|
|
1355
1471
|
else:
|
|
1356
|
-
|
|
1472
|
+
# Convert list of dicts to list of account names for Accounts initializer
|
|
1473
|
+
account_names: List[str] = [x["name"] for x in name_list if "name" in x]
|
|
1474
|
+
return Accounts(account_names, blockchain_instance=self.blockchain)
|
|
1357
1475
|
|
|
1358
1476
|
def _get_followers(self, direction="follower", last_user="", what="blog", limit=100):
|
|
1359
|
-
"""
|
|
1477
|
+
"""
|
|
1478
|
+
Fetch and return the full list of follower or following entries for this account by repeatedly calling the condenser follow APIs.
|
|
1479
|
+
|
|
1480
|
+
This helper paginates through get_followers/get_following RPC calls (appbase and legacy modes supported) until no more pages are returned, concatenating results into a single list. When batching, duplicate leading entries from subsequent pages are skipped so entries are not repeated.
|
|
1481
|
+
|
|
1482
|
+
Parameters:
|
|
1483
|
+
direction (str): "follower" to fetch followers, "following" to fetch accounts this account follows.
|
|
1484
|
+
last_user (str): Starting username for pagination (inclusive start for the first call); subsequent pages are continued internally.
|
|
1485
|
+
what (str): Relationship type filter passed to the RPC (commonly "blog" or "ignore").
|
|
1486
|
+
limit (int): Maximum number of entries to request per RPC call (page size).
|
|
1487
|
+
|
|
1488
|
+
Returns:
|
|
1489
|
+
list: A list of follower/following records as returned by the condenser API.
|
|
1490
|
+
|
|
1491
|
+
Raises:
|
|
1492
|
+
OfflineHasNoRPCException: If called while the blockchain instance is offline.
|
|
1493
|
+
"""
|
|
1360
1494
|
if not self.blockchain.is_connected():
|
|
1361
1495
|
raise OfflineHasNoRPCException("No RPC available in offline mode!")
|
|
1362
1496
|
followers_list = []
|
|
@@ -1441,12 +1575,13 @@ class Account(BlockchainObject):
|
|
|
1441
1575
|
|
|
1442
1576
|
@property
|
|
1443
1577
|
def available_balances(self):
|
|
1444
|
-
"""List balances of an account. This call returns instances of
|
|
1445
|
-
:class:`nectar.amount.Amount`.
|
|
1446
1578
|
"""
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1579
|
+
Return a list of the account's available balances as Amount objects.
|
|
1580
|
+
|
|
1581
|
+
Includes liquid HIVE ("balance"), HBD ("hbd_balance") when present, and vesting shares ("vesting_shares").
|
|
1582
|
+
Balances are returned in that order when available and are shallow copies of the stored Amount objects.
|
|
1583
|
+
"""
|
|
1584
|
+
if "hbd_balance" in self:
|
|
1450
1585
|
amount_list = ["balance", "hbd_balance", "vesting_shares"]
|
|
1451
1586
|
else:
|
|
1452
1587
|
amount_list = ["balance", "vesting_shares"]
|
|
@@ -1458,10 +1593,15 @@ class Account(BlockchainObject):
|
|
|
1458
1593
|
|
|
1459
1594
|
@property
|
|
1460
1595
|
def saving_balances(self):
|
|
1596
|
+
"""
|
|
1597
|
+
Return the account's savings balances.
|
|
1598
|
+
|
|
1599
|
+
Returns a list of Amount objects representing savings balances present on the account.
|
|
1600
|
+
Includes "savings_balance" and, if present, "savings_hbd_balance". Returns an empty list if no
|
|
1601
|
+
savings balances are available.
|
|
1602
|
+
"""
|
|
1461
1603
|
savings_amount = []
|
|
1462
|
-
if "
|
|
1463
|
-
amount_list = ["savings_balance", "savings_sbd_balance"]
|
|
1464
|
-
elif "savings_hbd_balance" in self:
|
|
1604
|
+
if "savings_hbd_balance" in self:
|
|
1465
1605
|
amount_list = ["savings_balance", "savings_hbd_balance"]
|
|
1466
1606
|
else:
|
|
1467
1607
|
amount_list = ["savings_balance"]
|
|
@@ -1472,9 +1612,15 @@ class Account(BlockchainObject):
|
|
|
1472
1612
|
|
|
1473
1613
|
@property
|
|
1474
1614
|
def reward_balances(self):
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1615
|
+
"""
|
|
1616
|
+
Return the account's reward balances as a list of Amount objects.
|
|
1617
|
+
|
|
1618
|
+
Checks for reward-related fields ('reward_hive_balance', 'reward_hbd_balance', 'reward_vesting_balance') on the account and returns copies of any that exist, preserving the original stored Amount objects. The list order is: reward_hive_balance, reward_hbd_balance, reward_vesting_balance (when present).
|
|
1619
|
+
|
|
1620
|
+
Returns:
|
|
1621
|
+
list: A list of Amount instances (copies) for each available reward balance.
|
|
1622
|
+
"""
|
|
1623
|
+
if "reward_hive_balance" in self and "reward_hbd_balance" in self:
|
|
1478
1624
|
amount_list = ["reward_hive_balance", "reward_hbd_balance", "reward_vesting_balance"]
|
|
1479
1625
|
else:
|
|
1480
1626
|
amount_list = []
|
|
@@ -1503,22 +1649,17 @@ class Account(BlockchainObject):
|
|
|
1503
1649
|
return self.get_balances()
|
|
1504
1650
|
|
|
1505
1651
|
def get_balances(self):
|
|
1506
|
-
"""
|
|
1507
|
-
|
|
1508
|
-
:returns: Account balances
|
|
1509
|
-
:rtype: dictionary
|
|
1510
|
-
|
|
1511
|
-
Sample output:
|
|
1652
|
+
"""
|
|
1653
|
+
Return the account's balances grouped by category.
|
|
1512
1654
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
'rewards': [0.000 STEEM, 0.000 SBD, 0.000000 VESTS],
|
|
1519
|
-
'total': [102.985 STEEM, 0.008 SBD, 146273.695970 VESTS]
|
|
1520
|
-
}
|
|
1655
|
+
Returns a dictionary with keys:
|
|
1656
|
+
- "available": list of Amounts currently spendable (e.g., HIVE, HBD, VESTS)
|
|
1657
|
+
- "savings": list of Amounts held in savings
|
|
1658
|
+
- "rewards": list of pending reward Amounts
|
|
1659
|
+
- "total": list of total Amounts combining available, savings, and rewards
|
|
1521
1660
|
|
|
1661
|
+
Returns:
|
|
1662
|
+
dict: Mapping of balance category to a list of Amount objects (or empty list for absent symbols).
|
|
1522
1663
|
"""
|
|
1523
1664
|
return {
|
|
1524
1665
|
"available": self.available_balances,
|
|
@@ -1528,30 +1669,17 @@ class Account(BlockchainObject):
|
|
|
1528
1669
|
}
|
|
1529
1670
|
|
|
1530
1671
|
def get_balance(self, balances, symbol):
|
|
1531
|
-
"""
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
* "available"
|
|
1535
|
-
* "saving"
|
|
1536
|
-
* "reward"
|
|
1537
|
-
* "total"
|
|
1538
|
-
|
|
1539
|
-
:param str balances: Defines the balance type
|
|
1540
|
-
:param symbol: Can be "SBD", "STEEM" or "VESTS
|
|
1541
|
-
:type symbol: str, dict
|
|
1672
|
+
"""
|
|
1673
|
+
Return a specific balance Amount for this account.
|
|
1542
1674
|
|
|
1543
|
-
|
|
1675
|
+
Accepts either a list of balance dicts or a balance category name and returns the Amount for the requested symbol. Valid balance category names are "available", "savings", "rewards", and "total". The symbol may be a string (e.g., "HBD", "HIVE", "VESTS") or a dict containing a "symbol" key.
|
|
1544
1676
|
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
>>> nodelist = NodeList()
|
|
1549
|
-
>>> nodelist.update_nodes()
|
|
1550
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1551
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
1552
|
-
>>> account.get_balance("rewards", "HBD")
|
|
1553
|
-
0.000 HBD
|
|
1677
|
+
Parameters:
|
|
1678
|
+
balances (str | list[dict]): A balance category name or a list of balance dicts (each with keys "amount" and "symbol").
|
|
1679
|
+
symbol (str | dict): The asset symbol to look up, or a dict containing {"symbol": <str>}.
|
|
1554
1680
|
|
|
1681
|
+
Returns:
|
|
1682
|
+
nectar.amount.Amount: The matching Amount from the provided balances, or Amount(0, symbol) if no matching entry is found.
|
|
1555
1683
|
"""
|
|
1556
1684
|
if isinstance(balances, str):
|
|
1557
1685
|
if balances == "available":
|
|
@@ -1719,24 +1847,20 @@ class Account(BlockchainObject):
|
|
|
1719
1847
|
# print("bandwidth percent remaining: " + str(100 - (100 * used_bandwidth / allocated_bandwidth)))
|
|
1720
1848
|
|
|
1721
1849
|
def get_owner_history(self, account=None):
|
|
1722
|
-
"""
|
|
1850
|
+
"""
|
|
1851
|
+
Return the owner authority history for an account.
|
|
1723
1852
|
|
|
1724
|
-
|
|
1853
|
+
If `account` is provided, fetches the owner history for that account; otherwise uses this Account's name.
|
|
1854
|
+
Returns a list of owner-authority history entries (RPC dicts, typically those under the `owner_auths` key).
|
|
1725
1855
|
|
|
1726
|
-
:
|
|
1856
|
+
Parameters:
|
|
1857
|
+
account (str, optional): Account name or Account-like object to query. Defaults to this Account's name.
|
|
1727
1858
|
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
>>> from nectar.account import Account
|
|
1731
|
-
>>> from nectar import Hive
|
|
1732
|
-
>>> from nectar.nodelist import NodeList
|
|
1733
|
-
>>> nodelist = NodeList()
|
|
1734
|
-
>>> nodelist.update_nodes()
|
|
1735
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1736
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
1737
|
-
>>> account.get_owner_history()
|
|
1738
|
-
[]
|
|
1859
|
+
Returns:
|
|
1860
|
+
list: Owner history entries as returned by the node RPC.
|
|
1739
1861
|
|
|
1862
|
+
Raises:
|
|
1863
|
+
OfflineHasNoRPCException: If called while the blockchain is in offline mode (no RPC available).
|
|
1740
1864
|
"""
|
|
1741
1865
|
if account is None:
|
|
1742
1866
|
account = self["name"]
|
|
@@ -1752,24 +1876,19 @@ class Account(BlockchainObject):
|
|
|
1752
1876
|
return self.blockchain.rpc.get_owner_history(account)
|
|
1753
1877
|
|
|
1754
1878
|
def get_conversion_requests(self, account=None):
|
|
1755
|
-
"""
|
|
1756
|
-
|
|
1757
|
-
:param str account: When set, a different account is used for the request (Default is object account name)
|
|
1879
|
+
"""
|
|
1880
|
+
Return the list of pending HBD conversion requests for an account.
|
|
1758
1881
|
|
|
1759
|
-
|
|
1882
|
+
If `account` is omitted, the method queries conversion requests for this Account instance.
|
|
1760
1883
|
|
|
1761
|
-
|
|
1884
|
+
Parameters:
|
|
1885
|
+
account (str, optional): Account name or Account-like object. Defaults to this account's name.
|
|
1762
1886
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
>>> from nectar.nodelist import NodeList
|
|
1766
|
-
>>> nodelist = NodeList()
|
|
1767
|
-
>>> nodelist.update_nodes()
|
|
1768
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1769
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
1770
|
-
>>> account.get_conversion_requests()
|
|
1771
|
-
[]
|
|
1887
|
+
Returns:
|
|
1888
|
+
list: A list of conversion request dictionaries (empty list if none).
|
|
1772
1889
|
|
|
1890
|
+
Raises:
|
|
1891
|
+
OfflineHasNoRPCException: If called while the blockchain is in offline mode (no RPC available).
|
|
1773
1892
|
"""
|
|
1774
1893
|
if account is None:
|
|
1775
1894
|
account = self["name"]
|
|
@@ -1789,25 +1908,21 @@ class Account(BlockchainObject):
|
|
|
1789
1908
|
return self.blockchain.rpc.get_conversion_requests(account)
|
|
1790
1909
|
|
|
1791
1910
|
def get_vesting_delegations(self, start_account="", limit=100, account=None):
|
|
1792
|
-
"""
|
|
1911
|
+
"""
|
|
1912
|
+
Return the list of vesting delegations made by an account.
|
|
1793
1913
|
|
|
1794
|
-
|
|
1795
|
-
:param str start_account: delegatee to start with, leave empty to start from the first by name
|
|
1796
|
-
:param int limit: maximum number of results to return
|
|
1797
|
-
:rtype: list
|
|
1914
|
+
If `account` is omitted, the method uses this Account object's name. Results can be paginated by specifying `start_account` (delegatee name to start from) and `limit` (maximum number of entries returned). In appbase mode the call filters returned delegations to those where the delegator matches `account`.
|
|
1798
1915
|
|
|
1799
|
-
|
|
1916
|
+
Parameters:
|
|
1917
|
+
start_account (str): Delegatee name to start listing from (for pagination). Default is empty string (start from first).
|
|
1918
|
+
limit (int): Maximum number of results to return. Default is 100.
|
|
1919
|
+
account (str | Account, optional): Account to query; accepts an account name or Account-like object. If None, uses this Account.
|
|
1800
1920
|
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
>>> from nectar.nodelist import NodeList
|
|
1804
|
-
>>> nodelist = NodeList()
|
|
1805
|
-
>>> nodelist.update_nodes()
|
|
1806
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1807
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
1808
|
-
>>> account.get_vesting_delegations()
|
|
1809
|
-
[]
|
|
1921
|
+
Returns:
|
|
1922
|
+
list: A list of delegation dictionaries as returned by the node RPC.
|
|
1810
1923
|
|
|
1924
|
+
Raises:
|
|
1925
|
+
OfflineHasNoRPCException: If called while the blockchain instance is offline (no RPC available).
|
|
1811
1926
|
"""
|
|
1812
1927
|
if account is None:
|
|
1813
1928
|
account = self["name"]
|
|
@@ -1825,24 +1940,20 @@ class Account(BlockchainObject):
|
|
|
1825
1940
|
return self.blockchain.rpc.get_vesting_delegations(account, start_account, limit)
|
|
1826
1941
|
|
|
1827
1942
|
def get_withdraw_routes(self, account=None):
|
|
1828
|
-
"""
|
|
1829
|
-
|
|
1830
|
-
:param str account: When set, a different account is used for the request (Default is object account name)
|
|
1943
|
+
"""
|
|
1944
|
+
Return the account's withdraw vesting routes.
|
|
1831
1945
|
|
|
1832
|
-
|
|
1946
|
+
If `account` is omitted, uses this Account object's name. Each route is returned as a dict
|
|
1947
|
+
in the format provided by the node RPC (fields include destination account, percentage, auto_vest, etc.).
|
|
1833
1948
|
|
|
1834
|
-
|
|
1949
|
+
Parameters:
|
|
1950
|
+
account (str, optional): Account name to query. Defaults to this Account's name.
|
|
1835
1951
|
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
>>> from nectar.nodelist import NodeList
|
|
1839
|
-
>>> nodelist = NodeList()
|
|
1840
|
-
>>> nodelist.update_nodes()
|
|
1841
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1842
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
1843
|
-
>>> account.get_withdraw_routes()
|
|
1844
|
-
[]
|
|
1952
|
+
Returns:
|
|
1953
|
+
list: A list of withdraw-route dictionaries as returned by the node RPC.
|
|
1845
1954
|
|
|
1955
|
+
Raises:
|
|
1956
|
+
OfflineHasNoRPCException: If called while the blockchain instance is in offline mode.
|
|
1846
1957
|
"""
|
|
1847
1958
|
if account is None:
|
|
1848
1959
|
account = self["name"]
|
|
@@ -1858,25 +1969,20 @@ class Account(BlockchainObject):
|
|
|
1858
1969
|
return self.blockchain.rpc.get_withdraw_routes(account, "all")
|
|
1859
1970
|
|
|
1860
1971
|
def get_savings_withdrawals(self, direction="from", account=None):
|
|
1861
|
-
"""
|
|
1972
|
+
"""
|
|
1973
|
+
Return the list of savings withdrawal requests for an account.
|
|
1862
1974
|
|
|
1863
|
-
|
|
1864
|
-
:param str direction: Can be either from or to (only non appbase nodes)
|
|
1975
|
+
If no account is provided, uses this Account's name. On nodes using the appbase/database API the node determines which withdrawals are returned; on legacy (non-appbase) nodes the `direction` parameter selects between withdrawals originating "from" the account or destined "to" the account.
|
|
1865
1976
|
|
|
1866
|
-
:
|
|
1977
|
+
Parameters:
|
|
1978
|
+
account (str, optional): Account name to query. Defaults to this account.
|
|
1979
|
+
direction (str, optional): "from" or "to" (default "from"). Only used on non-appbase RPC nodes.
|
|
1867
1980
|
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
>>> from nectar.account import Account
|
|
1871
|
-
>>> from nectar import Hive
|
|
1872
|
-
>>> from nectar.nodelist import NodeList
|
|
1873
|
-
>>> nodelist = NodeList()
|
|
1874
|
-
>>> nodelist.update_nodes()
|
|
1875
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1876
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
1877
|
-
>>> account.get_savings_withdrawals()
|
|
1878
|
-
[]
|
|
1981
|
+
Returns:
|
|
1982
|
+
list: A list of savings withdrawal records (each record is a dict as returned by the node).
|
|
1879
1983
|
|
|
1984
|
+
Raises:
|
|
1985
|
+
OfflineHasNoRPCException: If called while in offline mode (no RPC available).
|
|
1880
1986
|
"""
|
|
1881
1987
|
if account is None:
|
|
1882
1988
|
account = self["name"]
|
|
@@ -1907,8 +2013,8 @@ class Account(BlockchainObject):
|
|
|
1907
2013
|
>>> from nectar.nodelist import NodeList
|
|
1908
2014
|
>>> nodelist = NodeList()
|
|
1909
2015
|
>>> nodelist.update_nodes()
|
|
1910
|
-
>>>
|
|
1911
|
-
>>> account = Account("nectarflower", blockchain_instance=
|
|
2016
|
+
>>> hv = Hive(node=nodelist.get_hive_nodes())
|
|
2017
|
+
>>> account = Account("nectarflower", blockchain_instance=hv)
|
|
1912
2018
|
>>> account.get_recovery_request()
|
|
1913
2019
|
[]
|
|
1914
2020
|
|
|
@@ -1927,25 +2033,22 @@ class Account(BlockchainObject):
|
|
|
1927
2033
|
return self.blockchain.rpc.get_recovery_request(account)
|
|
1928
2034
|
|
|
1929
2035
|
def get_escrow(self, escrow_id=0, account=None):
|
|
1930
|
-
"""
|
|
1931
|
-
|
|
1932
|
-
:param int escrow_id: Id (only pre appbase)
|
|
1933
|
-
:param str account: When set, a different account is used for the request (Default is object account name)
|
|
2036
|
+
"""
|
|
2037
|
+
Return escrow(s) related to this account.
|
|
1934
2038
|
|
|
1935
|
-
|
|
2039
|
+
If called in appbase mode, returns all escrows for the given account (the
|
|
2040
|
+
legacy escrow_id parameter is ignored). In legacy (pre-appbase) mode,
|
|
2041
|
+
returns the escrow with the specified escrow_id for the account.
|
|
1936
2042
|
|
|
1937
|
-
|
|
2043
|
+
Parameters:
|
|
2044
|
+
escrow_id (int): Escrow identifier used by legacy RPC (pre-appbase). Default 0.
|
|
2045
|
+
account (str | Account, optional): Account to query; defaults to this account's name.
|
|
1938
2046
|
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
>>> from nectar.nodelist import NodeList
|
|
1942
|
-
>>> nodelist = NodeList()
|
|
1943
|
-
>>> nodelist.update_nodes()
|
|
1944
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1945
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
1946
|
-
>>> account.get_escrow(1234)
|
|
1947
|
-
[]
|
|
2047
|
+
Returns:
|
|
2048
|
+
list[dict]: A list of escrow objects (empty if none found).
|
|
1948
2049
|
|
|
2050
|
+
Raises:
|
|
2051
|
+
OfflineHasNoRPCException: If called while the blockchain client is offline.
|
|
1949
2052
|
"""
|
|
1950
2053
|
if account is None:
|
|
1951
2054
|
account = self["name"]
|
|
@@ -1959,25 +2062,13 @@ class Account(BlockchainObject):
|
|
|
1959
2062
|
return self.blockchain.rpc.get_escrow(account, escrow_id)
|
|
1960
2063
|
|
|
1961
2064
|
def verify_account_authority(self, keys, account=None):
|
|
1962
|
-
"""
|
|
1963
|
-
|
|
1964
|
-
:param list keys: public key
|
|
1965
|
-
:param str account: When set, a different account is used for the request (Default is object account name)
|
|
1966
|
-
|
|
1967
|
-
:rtype: dictionary
|
|
1968
|
-
|
|
1969
|
-
.. code-block:: python
|
|
1970
|
-
|
|
1971
|
-
>>> from nectar.account import Account
|
|
1972
|
-
>>> from nectar import Hive
|
|
1973
|
-
>>> from nectar.nodelist import NodeList
|
|
1974
|
-
>>> nodelist = NodeList()
|
|
1975
|
-
>>> nodelist.update_nodes()
|
|
1976
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
1977
|
-
>>> account = Account("steemit", blockchain_instance=stm)
|
|
1978
|
-
>>> print(account.verify_account_authority(["STM7Q2rLBqzPzFeteQZewv9Lu3NLE69fZoLeL6YK59t7UmssCBNTU"])["valid"])
|
|
1979
|
-
False
|
|
2065
|
+
"""
|
|
2066
|
+
Return whether the provided signers (public keys) are sufficient to authorize the specified account.
|
|
1980
2067
|
|
|
2068
|
+
If `account` is omitted, uses this Account object's name. `keys` may be a single key or a list of public keys.
|
|
2069
|
+
Returns a dictionary as returned by the node RPC (e.g., {"valid": True} or {"valid": False}).
|
|
2070
|
+
Raises OfflineHasNoRPCException when the instance is offline. If the RPC raises MissingRequiredActiveAuthority
|
|
2071
|
+
during verification, the method returns {"valid": False}.
|
|
1981
2072
|
"""
|
|
1982
2073
|
if account is None:
|
|
1983
2074
|
account = self["name"]
|
|
@@ -2019,26 +2110,23 @@ class Account(BlockchainObject):
|
|
|
2019
2110
|
return self.blockchain.rpc.get_tags_used_by_author(account, api="condenser")
|
|
2020
2111
|
|
|
2021
2112
|
def get_expiring_vesting_delegations(self, after=None, limit=1000, account=None):
|
|
2022
|
-
"""
|
|
2113
|
+
"""
|
|
2114
|
+
Return upcoming vesting-delegation expirations for an account.
|
|
2023
2115
|
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2116
|
+
If `account` is None the current Account's name is used. On appbase-compatible nodes this queries the
|
|
2117
|
+
database API and returns the list under the "delegations" key; on legacy nodes it calls the
|
|
2118
|
+
legacy RPC which accepts `after` (a datetime) and `limit`.
|
|
2027
2119
|
|
|
2028
|
-
:
|
|
2120
|
+
Parameters:
|
|
2121
|
+
after (datetime, optional): Only used on pre-appbase nodes — include expirations after this time.
|
|
2122
|
+
limit (int, optional): Only used on pre-appbase nodes — maximum number of entries to return.
|
|
2123
|
+
account (str or object, optional): Account name or object to query. Defaults to the current account.
|
|
2029
2124
|
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
>>> from nectar.account import Account
|
|
2033
|
-
>>> from nectar import Hive
|
|
2034
|
-
>>> from nectar.nodelist import NodeList
|
|
2035
|
-
>>> nodelist = NodeList()
|
|
2036
|
-
>>> nodelist.update_nodes()
|
|
2037
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
2038
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
2039
|
-
>>> account.get_expiring_vesting_delegations()
|
|
2040
|
-
[]
|
|
2125
|
+
Returns:
|
|
2126
|
+
list: A list of vesting delegation expiration records.
|
|
2041
2127
|
|
|
2128
|
+
Raises:
|
|
2129
|
+
OfflineHasNoRPCException: If called while the blockchain instance is offline.
|
|
2042
2130
|
"""
|
|
2043
2131
|
if account is None:
|
|
2044
2132
|
account = self["name"]
|
|
@@ -2060,21 +2148,23 @@ class Account(BlockchainObject):
|
|
|
2060
2148
|
def get_account_votes(
|
|
2061
2149
|
self, account=None, start_author="", start_permlink="", limit=1000, start_date=None
|
|
2062
2150
|
):
|
|
2063
|
-
"""
|
|
2151
|
+
"""
|
|
2152
|
+
Return a list of vote operations made by an account.
|
|
2064
2153
|
|
|
2065
|
-
|
|
2154
|
+
Retrieves votes by paging through the node's `list_votes` (database) API ordered by voter+comment. Returns vote objects (dicts) that include fields such as `voter`, `author`, `permlink`, `weight`, and `last_update`. Results are filtered so only votes cast by `account` are included and, if `start_date` is provided, only votes with `last_update >= start_date` are returned. Pagination state is advanced using `start_author` / `start_permlink`.
|
|
2066
2155
|
|
|
2067
|
-
|
|
2156
|
+
Parameters:
|
|
2157
|
+
account (str|dict|Account, optional): Account to query. If None, uses this Account's name.
|
|
2158
|
+
start_author (str, optional): Author permlink paging start key (used to continue from a previous page).
|
|
2159
|
+
start_permlink (str, optional): Permlink paging start key paired with `start_author`.
|
|
2160
|
+
limit (int, optional): Maximum number of votes to request per RPC call (page size).
|
|
2161
|
+
start_date (datetime.datetime, optional): If provided, stop and exclude votes older than this datetime.
|
|
2068
2162
|
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
>>> from nectar.nodelist import NodeList
|
|
2072
|
-
>>> nodelist = NodeList()
|
|
2073
|
-
>>> nodelist.update_nodes()
|
|
2074
|
-
>>> stm = Hive(node=nodelist.get_hive_nodes())
|
|
2075
|
-
>>> account = Account("nectarflower", blockchain_instance=stm)
|
|
2076
|
-
>>> account.get_account_votes() # doctest: +SKIP
|
|
2163
|
+
Returns:
|
|
2164
|
+
list[dict]: List of vote dictionaries in descending retrieval order (newest first as returned by the node).
|
|
2077
2165
|
|
|
2166
|
+
Raises:
|
|
2167
|
+
OfflineHasNoRPCException: If called while the blockchain instance is offline (no RPC available).
|
|
2078
2168
|
"""
|
|
2079
2169
|
if account is None:
|
|
2080
2170
|
account = self["name"]
|
|
@@ -2455,34 +2545,30 @@ class Account(BlockchainObject):
|
|
|
2455
2545
|
exclude_ops=[],
|
|
2456
2546
|
raw_output=False,
|
|
2457
2547
|
):
|
|
2458
|
-
"""
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
:
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
The full list of operation ID's can be found in
|
|
2483
|
-
nectarbase.operationids.ops.
|
|
2484
|
-
Example: ['transfer', 'vote']
|
|
2485
|
-
|
|
2548
|
+
"""
|
|
2549
|
+
Yield account history operations for a single account.
|
|
2550
|
+
|
|
2551
|
+
Generates account history entries (one at a time) between a starting index and limit, optionally filtered
|
|
2552
|
+
and ordered. Each yielded item is either the raw RPC (index, event) tuple when raw_output is True,
|
|
2553
|
+
or an enriched dict containing operation fields plus metadata (account, type, index, _id).
|
|
2554
|
+
|
|
2555
|
+
Parameters:
|
|
2556
|
+
index (int): starting index for history retrieval (passed to underlying fetch).
|
|
2557
|
+
limit (int): maximum number of entries to request from the node.
|
|
2558
|
+
order (int): 1 for chronological, -1 for reverse chronological (default -1).
|
|
2559
|
+
start (int | datetime | date | time | None): inclusive start boundary. Interpreted as a block number
|
|
2560
|
+
when use_block_num is True, otherwise as an operation index; a datetime/value restricts by timestamp.
|
|
2561
|
+
stop (int | datetime | date | time | None): inclusive stop boundary, interpreted like `start`.
|
|
2562
|
+
use_block_num (bool): when True, treat numeric start/stop as blockchain block numbers; otherwise as op indices.
|
|
2563
|
+
only_ops (list[str]): if non-empty, only yield operations whose type is in this list.
|
|
2564
|
+
exclude_ops (list[str]): skip operations whose type is in this list.
|
|
2565
|
+
raw_output (bool): when True yield the raw (index, event) tuple from the RPC; when False yield an enriched dict.
|
|
2566
|
+
|
|
2567
|
+
Returns:
|
|
2568
|
+
generator: yields history entries as described above.
|
|
2569
|
+
|
|
2570
|
+
Raises:
|
|
2571
|
+
ValueError: if `order` is not 1 or -1.
|
|
2486
2572
|
"""
|
|
2487
2573
|
if order != -1 and order != 1:
|
|
2488
2574
|
raise ValueError("order must be -1 or 1!")
|
|
@@ -2548,7 +2634,22 @@ class Account(BlockchainObject):
|
|
|
2548
2634
|
block_props = remove_from_dict(event, keys=["op"], keep_keys=False)
|
|
2549
2635
|
|
|
2550
2636
|
def construct_op(account_name):
|
|
2551
|
-
# verbatim output from
|
|
2637
|
+
# verbatim output from RPC node
|
|
2638
|
+
"""
|
|
2639
|
+
Construct a normalized, immutable operation dictionary for an account.
|
|
2640
|
+
|
|
2641
|
+
If `raw_output` is true (from outer scope), returns the original RPC `item` unchanged. Otherwise returns a copy of `op` merged with `block_props` and the following fields:
|
|
2642
|
+
- "account": the provided account_name
|
|
2643
|
+
- "type": operation type (from outer scope `op_type`)
|
|
2644
|
+
- "_id": a deterministic hash computed via Blockchain.hash_op(immutable)
|
|
2645
|
+
- "index": the operation index (from outer scope `item_index`)
|
|
2646
|
+
|
|
2647
|
+
Parameters:
|
|
2648
|
+
account_name (str): Account name to attach to the constructed operation.
|
|
2649
|
+
|
|
2650
|
+
Returns:
|
|
2651
|
+
dict: Either the raw RPC item (if `raw_output`) or an immutable operation dict augmented with account, type, _id, and index.
|
|
2652
|
+
"""
|
|
2552
2653
|
if raw_output:
|
|
2553
2654
|
return item
|
|
2554
2655
|
|
|
@@ -3318,30 +3419,22 @@ class Account(BlockchainObject):
|
|
|
3318
3419
|
def transfer(
|
|
3319
3420
|
self, to, amount, asset, memo="", skip_account_check=False, account=None, **kwargs
|
|
3320
3421
|
):
|
|
3321
|
-
"""
|
|
3322
|
-
|
|
3323
|
-
:param str to: Recipient
|
|
3324
|
-
:param float amount: Amount to transfer
|
|
3325
|
-
:param str asset: Asset to transfer
|
|
3326
|
-
:param str memo: (optional) Memo, may begin with `#` for encrypted
|
|
3327
|
-
messaging
|
|
3328
|
-
:param bool skip_account_check: (optional) When True, the receiver
|
|
3329
|
-
account name is not checked to speed up sending multiple transfers in a row
|
|
3330
|
-
:param str account: (optional) the source account for the transfer
|
|
3331
|
-
if not ``default_account``
|
|
3332
|
-
|
|
3422
|
+
"""
|
|
3423
|
+
Transfer an asset from this account to another account.
|
|
3333
3424
|
|
|
3334
|
-
Transfer
|
|
3425
|
+
Creates and broadcasts a Transfer operation using the account's active authority.
|
|
3335
3426
|
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3427
|
+
Parameters:
|
|
3428
|
+
to (str | Account): Recipient account name or Account object.
|
|
3429
|
+
amount (int | float | str | Amount): Amount to transfer; will be normalized to an Amount with the given asset.
|
|
3430
|
+
asset (str): Asset symbol (e.g., "HIVE", "HBD").
|
|
3431
|
+
memo (str, optional): Optional memo; if it starts with '#', the remainder is encrypted with the sender's and receiver's memo keys.
|
|
3432
|
+
skip_account_check (bool, optional): If True, skip resolving the `to` and `account` parameters to Account objects (faster for repeated transfers).
|
|
3433
|
+
account (str | Account, optional): Source account name or Account object; defaults to this Account instance.
|
|
3434
|
+
**kwargs: Passed through to finalizeOp (e.g., broadcast options).
|
|
3344
3435
|
|
|
3436
|
+
Returns:
|
|
3437
|
+
dict: Result from blockchain.finalizeOp (signed/broadcast transaction response).
|
|
3345
3438
|
"""
|
|
3346
3439
|
|
|
3347
3440
|
if account is None:
|
|
@@ -3387,32 +3480,23 @@ class Account(BlockchainObject):
|
|
|
3387
3480
|
account=None,
|
|
3388
3481
|
**kwargs,
|
|
3389
3482
|
):
|
|
3390
|
-
"""
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
:
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
.. code-block:: python
|
|
3408
|
-
|
|
3409
|
-
from nectar.account import Account
|
|
3410
|
-
from nectar import Hive
|
|
3411
|
-
active_wif = "5xxxx"
|
|
3412
|
-
stm = Hive(keys=[active_wif])
|
|
3413
|
-
acc = Account("test", blockchain_instance=stm)
|
|
3414
|
-
acc.transfer("test1", 1, "HIVE", 48, 5, "test")
|
|
3415
|
-
|
|
3483
|
+
"""
|
|
3484
|
+
Schedule a recurring transfer of a token from this account to another.
|
|
3485
|
+
|
|
3486
|
+
Schedules a recurring on-chain transfer operation that will execute `executions` times every `recurrence` hours.
|
|
3487
|
+
|
|
3488
|
+
Parameters:
|
|
3489
|
+
to (str | Account): Recipient account name or Account object.
|
|
3490
|
+
amount (int | float | str | Amount): Amount to transfer each occurrence. Must match the asset's precision (commonly 3 decimals).
|
|
3491
|
+
asset (str): Asset symbol (e.g., "HIVE", "HBD").
|
|
3492
|
+
recurrence (int): Interval between executions in hours.
|
|
3493
|
+
executions (int): Number of times the transfer will be executed.
|
|
3494
|
+
memo (str, optional): Memo for the transfer. If it starts with '#', the remainder is encrypted to the recipient.
|
|
3495
|
+
skip_account_check (bool, optional): If True, skip resolving/checking Account objects for `to` and `account` (faster when making many calls).
|
|
3496
|
+
account (str | Account, optional): Source account name or Account object; defaults to this Account.
|
|
3497
|
+
|
|
3498
|
+
Returns:
|
|
3499
|
+
dict: The broadcasted transaction result returned by finalizeOp.
|
|
3416
3500
|
"""
|
|
3417
3501
|
|
|
3418
3502
|
if account is None:
|
|
@@ -3448,14 +3532,19 @@ class Account(BlockchainObject):
|
|
|
3448
3532
|
def transfer_to_vesting(
|
|
3449
3533
|
self, amount, to=None, account=None, skip_account_check=False, **kwargs
|
|
3450
3534
|
):
|
|
3451
|
-
"""
|
|
3535
|
+
"""
|
|
3536
|
+
Power up HIVE by converting liquid HIVE into vesting shares (VESTS).
|
|
3452
3537
|
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
:
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
account
|
|
3538
|
+
Performs a Transfer_to_vesting operation from the source account to the recipient (defaults to the account itself). The `amount` is normalized to the chain token symbol before broadcasting. Use `skip_account_check=True` to avoid resolving/validating Account objects for `to` or `account` when sending many transfers in a loop (faster but skips existence checks).
|
|
3539
|
+
|
|
3540
|
+
Parameters:
|
|
3541
|
+
amount: Amount to transfer; accepts numeric, string, or Amount-like inputs and will be normalized to the blockchain token symbol.
|
|
3542
|
+
to (str|Account, optional): Recipient account name or Account object. Defaults to the calling account.
|
|
3543
|
+
account (str|Account, optional): Source account name or Account object. If omitted, the caller account is used.
|
|
3544
|
+
skip_account_check (bool, optional): If True, do not resolve/validate account names to Account objects (speeds up bulk transfers).
|
|
3545
|
+
|
|
3546
|
+
Returns:
|
|
3547
|
+
The result of finalizeOp (broadcast/transaction result) for the Transfer_to_vesting operation.
|
|
3459
3548
|
"""
|
|
3460
3549
|
if account is None:
|
|
3461
3550
|
account = self
|
|
@@ -3483,14 +3572,16 @@ class Account(BlockchainObject):
|
|
|
3483
3572
|
return self.blockchain.finalizeOp(op, account, "active", **kwargs)
|
|
3484
3573
|
|
|
3485
3574
|
def convert(self, amount, account=None, request_id=None):
|
|
3486
|
-
"""
|
|
3575
|
+
"""
|
|
3576
|
+
Convert HBD to HIVE (takes ~3.5 days to settle).
|
|
3487
3577
|
|
|
3488
|
-
:
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
conversion`
|
|
3578
|
+
Parameters:
|
|
3579
|
+
amount: HBD amount to convert — accepts numeric, string, or Amount-compatible input; will be normalized to the chain's backed token symbol.
|
|
3580
|
+
account (str | Account, optional): Source account performing the conversion. If omitted, uses this account.
|
|
3581
|
+
request_id (int | str, optional): Numeric identifier for the conversion request. If omitted, a random request id is generated.
|
|
3493
3582
|
|
|
3583
|
+
Returns:
|
|
3584
|
+
The result of broadcasting the Convert operation (as returned by blockchain.finalizeOp).
|
|
3494
3585
|
"""
|
|
3495
3586
|
if account is None:
|
|
3496
3587
|
account = self
|
|
@@ -3515,15 +3606,22 @@ class Account(BlockchainObject):
|
|
|
3515
3606
|
|
|
3516
3607
|
# Added to differentiate and match the addition of the HF25 convert operation
|
|
3517
3608
|
def collateralized_convert(self, amount, account=None, request_id=None, **kwargs):
|
|
3518
|
-
"""
|
|
3519
|
-
|
|
3609
|
+
"""
|
|
3610
|
+
Convert HBD to HIVE using the HF25 collateralized convert operation and broadcast the resulting transaction.
|
|
3520
3611
|
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3612
|
+
This builds a Collateralized_convert operation for the specified HBD amount and finalizes it with the account's active authority. If `account` is omitted, the method uses the current Account object. If `request_id` is not provided, a random 32-bit id is generated.
|
|
3613
|
+
|
|
3614
|
+
Parameters:
|
|
3615
|
+
amount: Amount, str, int, or float
|
|
3616
|
+
Amount of HBD to convert (symbol must match the chain's backed token symbol).
|
|
3617
|
+
account: str or Account, optional
|
|
3618
|
+
Source account name or Account instance; defaults to the calling account.
|
|
3619
|
+
request_id: int, optional
|
|
3620
|
+
Numeric identifier for the conversion request; if omitted a random id is used.
|
|
3526
3621
|
|
|
3622
|
+
Returns:
|
|
3623
|
+
dict
|
|
3624
|
+
Result of finalizeOp (the broadcasted operation response).
|
|
3527
3625
|
"""
|
|
3528
3626
|
if account is None:
|
|
3529
3627
|
account = self
|
|
@@ -3547,16 +3645,24 @@ class Account(BlockchainObject):
|
|
|
3547
3645
|
return self.blockchain.finalizeOp(op, account, "active", **kwargs)
|
|
3548
3646
|
|
|
3549
3647
|
def transfer_to_savings(self, amount, asset, memo, to=None, account=None, **kwargs):
|
|
3550
|
-
"""
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
:
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3648
|
+
"""
|
|
3649
|
+
Transfer HBD or HIVE from an account into its savings balance (or into another account's savings) and broadcast the transfer_to_savings operation.
|
|
3650
|
+
|
|
3651
|
+
Parameters:
|
|
3652
|
+
amount (float | str | Amount): Amount to transfer; may be numeric, string, or an Amount instance.
|
|
3653
|
+
asset (str): Asset symbol, must be the chain token or its backed token (e.g. "HIVE" or "HBD").
|
|
3654
|
+
memo (str): Memo to include with the transfer (may be empty).
|
|
3655
|
+
to (str | Account, optional): Destination account name or Account whose savings will receive the funds.
|
|
3656
|
+
If omitted, the source account's own savings is used.
|
|
3657
|
+
account (str | Account, optional): Source account name or Account performing the transfer.
|
|
3658
|
+
If omitted, `self` is used.
|
|
3659
|
+
**kwargs: Additional keyword arguments passed to the underlying finalizeOp call.
|
|
3660
|
+
|
|
3661
|
+
Returns:
|
|
3662
|
+
dict: Result of finalizeOp (the broadcast/transaction result).
|
|
3663
|
+
|
|
3664
|
+
Raises:
|
|
3665
|
+
AssertionError: If `asset` is not one of the allowed symbols.
|
|
3560
3666
|
"""
|
|
3561
3667
|
if asset not in [self.blockchain.token_symbol, self.blockchain.backed_token_symbol]:
|
|
3562
3668
|
raise AssertionError()
|
|
@@ -3586,18 +3692,27 @@ class Account(BlockchainObject):
|
|
|
3586
3692
|
def transfer_from_savings(
|
|
3587
3693
|
self, amount, asset, memo, request_id=None, to=None, account=None, **kwargs
|
|
3588
3694
|
):
|
|
3589
|
-
"""
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3695
|
+
"""
|
|
3696
|
+
Withdraw an amount from the account's savings into a liquid balance (HIVE or HBD).
|
|
3697
|
+
|
|
3698
|
+
Creates and broadcasts a `transfer_from_savings` operation. If `request_id` is not
|
|
3699
|
+
provided a random 32-bit id will be generated. If `account` is omitted the
|
|
3700
|
+
operation will be created for the current account; if `to` is omitted the funds
|
|
3701
|
+
are transferred back to the same account.
|
|
3702
|
+
|
|
3703
|
+
Parameters:
|
|
3704
|
+
amount (float|str|Amount): Amount to withdraw.
|
|
3705
|
+
asset (str): Symbol of the asset to withdraw, must be the chain token or its backed token (e.g., "HIVE" or "HBD").
|
|
3706
|
+
memo (str): Memo for the transfer (may be empty).
|
|
3707
|
+
request_id (int, optional): Identifier for this withdrawal request; used to cancel or track the withdrawal. If omitted one is generated.
|
|
3708
|
+
to (str|Account, optional): Destination account name or Account; defaults to the source account.
|
|
3709
|
+
account (str|Account, optional): Source account name or Account; defaults to the current account.
|
|
3710
|
+
|
|
3711
|
+
Returns:
|
|
3712
|
+
dict: Result of finalizeOp / broadcast (operation confirmation).
|
|
3713
|
+
|
|
3714
|
+
Raises:
|
|
3715
|
+
AssertionError: If `asset` is not a supported token symbol for this chain.
|
|
3601
3716
|
"""
|
|
3602
3717
|
if asset not in [self.blockchain.token_symbol, self.blockchain.backed_token_symbol]:
|
|
3603
3718
|
raise AssertionError()
|
|
@@ -3664,27 +3779,28 @@ class Account(BlockchainObject):
|
|
|
3664
3779
|
|
|
3665
3780
|
def claim_reward_balance(
|
|
3666
3781
|
self,
|
|
3667
|
-
reward_steem=0,
|
|
3668
|
-
reward_sbd=0,
|
|
3669
3782
|
reward_hive=0,
|
|
3670
3783
|
reward_hbd=0,
|
|
3671
3784
|
reward_vests=0,
|
|
3672
3785
|
account=None,
|
|
3673
3786
|
**kwargs,
|
|
3674
3787
|
):
|
|
3675
|
-
"""
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3788
|
+
"""
|
|
3789
|
+
Claim the account's pending reward balances (HIVE, HBD, and/or VESTS).
|
|
3790
|
+
|
|
3791
|
+
If all reward amounts are left at their default (0), this will claim all outstanding rewards for the target account. Otherwise only the nonzero amounts will be claimed.
|
|
3679
3792
|
|
|
3680
|
-
:
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
:param str account: The source account for the claim if not
|
|
3686
|
-
``default_account`` is used.
|
|
3793
|
+
Parameters:
|
|
3794
|
+
reward_hive (str|float|Amount, optional): Amount of HIVE to claim (default: 0).
|
|
3795
|
+
reward_hbd (str|float|Amount, optional): Amount of HBD to claim (default: 0).
|
|
3796
|
+
reward_vests (str|float|Amount, optional): Amount of VESTS to claim (default: 0).
|
|
3797
|
+
account (str|Account, optional): Account to claim rewards for; if None, uses self. Must be a valid account.
|
|
3687
3798
|
|
|
3799
|
+
Returns:
|
|
3800
|
+
dict: The broadcast/finalization result returned by the blockchain finalizeOp call.
|
|
3801
|
+
|
|
3802
|
+
Raises:
|
|
3803
|
+
ValueError: If no account is provided or the resolved account is falsy.
|
|
3688
3804
|
"""
|
|
3689
3805
|
if account is None:
|
|
3690
3806
|
account = self
|
|
@@ -3696,20 +3812,14 @@ class Account(BlockchainObject):
|
|
|
3696
3812
|
# if no values were set by user, claim all outstanding balances on
|
|
3697
3813
|
# account
|
|
3698
3814
|
|
|
3699
|
-
reward_token_amount = self._check_amount(
|
|
3700
|
-
reward_steem + reward_hive, self.blockchain.token_symbol
|
|
3701
|
-
)
|
|
3815
|
+
reward_token_amount = self._check_amount(reward_hive, self.blockchain.token_symbol)
|
|
3702
3816
|
reward_backed_token_amount = self._check_amount(
|
|
3703
|
-
|
|
3817
|
+
reward_hbd, self.blockchain.backed_token_symbol
|
|
3704
3818
|
)
|
|
3705
3819
|
reward_vests_amount = self._check_amount(reward_vests, self.blockchain.vest_token_symbol)
|
|
3706
3820
|
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
reward_backed_token = "reward_hbd"
|
|
3710
|
-
else:
|
|
3711
|
-
reward_token = "reward_steem"
|
|
3712
|
-
reward_backed_token = "reward_sbd"
|
|
3821
|
+
reward_token = "reward_hive"
|
|
3822
|
+
reward_backed_token = "reward_hbd"
|
|
3713
3823
|
|
|
3714
3824
|
if (
|
|
3715
3825
|
reward_token_amount.amount == 0
|
|
@@ -3746,14 +3856,19 @@ class Account(BlockchainObject):
|
|
|
3746
3856
|
return self.blockchain.finalizeOp(op, account, "posting", **kwargs)
|
|
3747
3857
|
|
|
3748
3858
|
def delegate_vesting_shares(self, to_account, vesting_shares, account=None, **kwargs):
|
|
3749
|
-
"""
|
|
3859
|
+
"""
|
|
3860
|
+
Delegate vesting shares (Hive Power) from one account to another.
|
|
3861
|
+
|
|
3862
|
+
Parameters:
|
|
3863
|
+
to_account (str or Account): Receiver of the delegated vesting shares (delegatee).
|
|
3864
|
+
vesting_shares (str|Amount): Amount to delegate, e.g. "10000 VESTS" or an Amount-like object.
|
|
3865
|
+
account (str or Account, optional): Source account (delegator). If omitted, uses this Account instance.
|
|
3750
3866
|
|
|
3751
|
-
:
|
|
3752
|
-
(
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
``default_account`` is used.
|
|
3867
|
+
Returns:
|
|
3868
|
+
dict: Result of broadcasting the Delegate_vesting_shares operation (transaction/result object).
|
|
3869
|
+
|
|
3870
|
+
Raises:
|
|
3871
|
+
ValueError: If `to_account` is not provided or cannot be resolved.
|
|
3757
3872
|
"""
|
|
3758
3873
|
if account is None:
|
|
3759
3874
|
account = self
|
|
@@ -3802,18 +3917,22 @@ class Account(BlockchainObject):
|
|
|
3802
3917
|
def set_withdraw_vesting_route(
|
|
3803
3918
|
self, to, percentage=100, account=None, auto_vest=False, **kwargs
|
|
3804
3919
|
):
|
|
3805
|
-
"""
|
|
3806
|
-
|
|
3807
|
-
|
|
3920
|
+
"""
|
|
3921
|
+
Set or update a vesting withdraw route for an account.
|
|
3922
|
+
|
|
3923
|
+
When the source account withdraws vesting shares, a portion of the withdrawn amount is routed to `to` according to `percentage`. If `auto_vest` is True the recipient receives VESTS; otherwise the recipient receives liquid HIVE.
|
|
3808
3924
|
|
|
3809
|
-
:
|
|
3810
|
-
|
|
3811
|
-
to
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
should receive the VESTS as VESTS, or false if it should
|
|
3815
|
-
receive them as STEEM. (defaults to ``False``)
|
|
3925
|
+
Parameters:
|
|
3926
|
+
to (str): Recipient account name.
|
|
3927
|
+
percentage (float): Percentage of each withdraw to route to `to` (0.0–100.0). Internally converted to protocol units (multiplied by HIVE_1_PERCENT).
|
|
3928
|
+
account (str|Account, optional): Source account performing the route change. If omitted, `self` is used.
|
|
3929
|
+
auto_vest (bool): If True route is added as VESTS; if False route is converted to HIVE.
|
|
3816
3930
|
|
|
3931
|
+
Returns:
|
|
3932
|
+
dict: Result of broadcasting the `set_withdraw_vesting_route` operation (as returned by finalizeOp).
|
|
3933
|
+
|
|
3934
|
+
Notes:
|
|
3935
|
+
- Operation is broadcast with the source account's active authority.
|
|
3817
3936
|
"""
|
|
3818
3937
|
if account is None:
|
|
3819
3938
|
account = self
|
|
@@ -3823,7 +3942,7 @@ class Account(BlockchainObject):
|
|
|
3823
3942
|
**{
|
|
3824
3943
|
"from_account": account["name"],
|
|
3825
3944
|
"to_account": to,
|
|
3826
|
-
"percent": int(percentage *
|
|
3945
|
+
"percent": int(percentage * HIVE_1_PERCENT),
|
|
3827
3946
|
"auto_vest": auto_vest,
|
|
3828
3947
|
}
|
|
3829
3948
|
)
|
|
@@ -3970,40 +4089,22 @@ class Account(BlockchainObject):
|
|
|
3970
4089
|
return self.blockchain.finalizeOp(op, account, "active", **kwargs)
|
|
3971
4090
|
|
|
3972
4091
|
def feed_history(self, limit=None, start_author=None, start_permlink=None, account=None):
|
|
3973
|
-
"""
|
|
3974
|
-
|
|
3975
|
-
.. note:: RPC nodes keep a limited history of entries for the
|
|
3976
|
-
user feed. Older entries may not be available via this
|
|
3977
|
-
call due to these node limitations.
|
|
3978
|
-
|
|
3979
|
-
:param int limit: (optional) stream the latest `limit`
|
|
3980
|
-
feed entries. If unset (default), all available entries
|
|
3981
|
-
are streamed.
|
|
3982
|
-
:param str start_author: (optional) start streaming the
|
|
3983
|
-
replies from this author. `start_permlink=None`
|
|
3984
|
-
(default) starts with the latest available entry.
|
|
3985
|
-
If set, `start_permlink` has to be set as well.
|
|
3986
|
-
:param str start_permlink: (optional) start streaming the
|
|
3987
|
-
replies from this permlink. `start_permlink=None`
|
|
3988
|
-
(default) starts with the latest available entry.
|
|
3989
|
-
If set, `start_author` has to be set as well.
|
|
3990
|
-
:param str account: (optional) the account to get replies
|
|
3991
|
-
to (defaults to ``default_account``)
|
|
4092
|
+
"""
|
|
4093
|
+
Yield feed entries for an account in reverse chronological order.
|
|
3992
4094
|
|
|
3993
|
-
|
|
4095
|
+
Streams discussion entries from the account's feed using paginated calls to the discussions API. Entries are yielded one at a time until the optional limit is reached or no more entries are available. Note that RPC nodes keep only a limited feed history, so older entries may be unavailable.
|
|
3994
4096
|
|
|
3995
|
-
|
|
4097
|
+
Parameters:
|
|
4098
|
+
limit (int, optional): Maximum number of entries to yield. If omitted, yields all available entries.
|
|
4099
|
+
start_author (str, optional): Author name to start from. Must be provided together with `start_permlink` to page from a specific position.
|
|
4100
|
+
start_permlink (str, optional): Permlink to start from. Must be provided together with `start_author`.
|
|
4101
|
+
account (str|Account, optional): Account whose feed to stream. If omitted, uses this Account instance.
|
|
3996
4102
|
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
from nectar.nodelist import NodeList
|
|
4000
|
-
nodelist = NodeList()
|
|
4001
|
-
nodelist.update_nodes()
|
|
4002
|
-
stm = Steem(node=nodelist.get_hive_nodes())
|
|
4003
|
-
acc = Account("ned", blockchain_instance=stm)
|
|
4004
|
-
for reply in acc.feed_history(limit=10):
|
|
4005
|
-
print(reply)
|
|
4103
|
+
Raises:
|
|
4104
|
+
AssertionError: If `limit` is not a positive integer, or if only one of `start_author` / `start_permlink` is provided.
|
|
4006
4105
|
|
|
4106
|
+
Yields:
|
|
4107
|
+
dict or Comment-like object: Discussion/feed entries returned by the discussions API, in reverse time order.
|
|
4007
4108
|
"""
|
|
4008
4109
|
if limit is not None:
|
|
4009
4110
|
if not isinstance(limit, int) or limit <= 0:
|
|
@@ -4046,38 +4147,22 @@ class Account(BlockchainObject):
|
|
|
4046
4147
|
return
|
|
4047
4148
|
|
|
4048
4149
|
def blog_history(self, limit=None, start=-1, reblogs=True, account=None):
|
|
4049
|
-
"""
|
|
4050
|
-
|
|
4051
|
-
.. note:: RPC nodes keep a limited history of entries for the
|
|
4052
|
-
user blog. Older blog posts of an account may not be available
|
|
4053
|
-
via this call due to these node limitations.
|
|
4150
|
+
"""
|
|
4151
|
+
Yield blog entries for an account in reverse chronological order.
|
|
4054
4152
|
|
|
4055
|
-
|
|
4056
|
-
blog entries. If unset (default), all available blog
|
|
4057
|
-
entries are streamed.
|
|
4058
|
-
:param int start: (optional) start streaming the blog
|
|
4059
|
-
entries from this index. `start=-1` (default) starts
|
|
4060
|
-
with the latest available entry.
|
|
4061
|
-
:param bool reblogs: (optional) if set `True` (default)
|
|
4062
|
-
reblogs / resteems are included. If set `False`,
|
|
4063
|
-
reblogs/resteems are omitted.
|
|
4064
|
-
:param str account: (optional) the account to stream blog
|
|
4065
|
-
entries for (defaults to ``default_account``)
|
|
4066
|
-
|
|
4067
|
-
blog_history_reverse example:
|
|
4153
|
+
Streams Discussion entries from the account's blog (newest first). Results are limited by RPC node history and may not include very old posts.
|
|
4068
4154
|
|
|
4069
|
-
|
|
4155
|
+
Parameters:
|
|
4156
|
+
limit (int, optional): Maximum number of entries to yield. Must be > 0 if provided; otherwise all available entries are streamed.
|
|
4157
|
+
start (int, optional): (Currently ignored) kept for backward compatibility.
|
|
4158
|
+
reblogs (bool, optional): If True (default), include reblogs; if False, only original posts by the account are yielded.
|
|
4159
|
+
account (str|Account, optional): Account name or Account object to stream; defaults to this Account instance.
|
|
4070
4160
|
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
from nectar.nodelist import NodeList
|
|
4074
|
-
nodelist = NodeList()
|
|
4075
|
-
nodelist.update_nodes()
|
|
4076
|
-
stm = Steem(node=nodelist.get_hive_nodes())
|
|
4077
|
-
acc = Account("steemitblog", blockchain_instance=stm)
|
|
4078
|
-
for post in acc.blog_history(limit=10):
|
|
4079
|
-
print(post)
|
|
4161
|
+
Returns:
|
|
4162
|
+
generator: Yields discussion dicts (post objects) as returned by Discussions_by_blog.
|
|
4080
4163
|
|
|
4164
|
+
Raises:
|
|
4165
|
+
AssertionError: If limit is provided but is not an int > 0.
|
|
4081
4166
|
"""
|
|
4082
4167
|
if limit is not None:
|
|
4083
4168
|
if not isinstance(limit, int) or limit <= 0:
|
|
@@ -4121,35 +4206,21 @@ class Account(BlockchainObject):
|
|
|
4121
4206
|
return
|
|
4122
4207
|
|
|
4123
4208
|
def comment_history(self, limit=None, start_permlink=None, account=None):
|
|
4124
|
-
"""
|
|
4125
|
-
|
|
4126
|
-
.. note:: RPC nodes keep a limited history of user comments for the
|
|
4127
|
-
user feed. Older comments may not be available via this
|
|
4128
|
-
call due to these node limitations.
|
|
4129
|
-
|
|
4130
|
-
:param int limit: (optional) stream the latest `limit`
|
|
4131
|
-
comments. If unset (default), all available comments
|
|
4132
|
-
are streamed.
|
|
4133
|
-
:param str start_permlink: (optional) start streaming the
|
|
4134
|
-
comments from this permlink. `start_permlink=None`
|
|
4135
|
-
(default) starts with the latest available entry.
|
|
4136
|
-
:param str account: (optional) the account to stream
|
|
4137
|
-
comments for (defaults to ``default_account``)
|
|
4209
|
+
"""
|
|
4210
|
+
Yield comments authored by an account in reverse chronological order.
|
|
4138
4211
|
|
|
4139
|
-
|
|
4212
|
+
Streams available comment entries from the node's discussions_by_comments index. Results are returned newest-first and may be truncated by RPC node history limits; older comments might not be available.
|
|
4140
4213
|
|
|
4141
|
-
|
|
4214
|
+
Parameters:
|
|
4215
|
+
limit (int, optional): Maximum number of comments to yield. If None, yields all available comments.
|
|
4216
|
+
start_permlink (str, optional): If set, start streaming from this permlink (inclusive). If None, starts from the latest available entry.
|
|
4217
|
+
account (str or Account, optional): Account name or Account instance to stream comments for. Defaults to the Account instance this method is called on.
|
|
4142
4218
|
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
from nectar.nodelist import NodeList
|
|
4146
|
-
nodelist = NodeList()
|
|
4147
|
-
nodelist.update_nodes()
|
|
4148
|
-
stm = Steem(node=nodelist.get_hive_nodes())
|
|
4149
|
-
acc = Account("ned", blockchain_instance=stm)
|
|
4150
|
-
for comment in acc.comment_history(limit=10):
|
|
4151
|
-
print(comment)
|
|
4219
|
+
Yields:
|
|
4220
|
+
dict: Discussion/comment dictionaries as returned by the Discussions_by_comments helper.
|
|
4152
4221
|
|
|
4222
|
+
Raises:
|
|
4223
|
+
AssertionError: If `limit` is provided and is not a positive integer.
|
|
4153
4224
|
"""
|
|
4154
4225
|
if limit is not None:
|
|
4155
4226
|
if not isinstance(limit, int) or limit <= 0:
|
|
@@ -4273,6 +4344,25 @@ class AccountsObject(list):
|
|
|
4273
4344
|
print(t)
|
|
4274
4345
|
|
|
4275
4346
|
def print_summarize_table(self, tag_type="Follower", return_str=False, **kwargs):
|
|
4347
|
+
"""
|
|
4348
|
+
Print or return a one-line summary table aggregating metrics for the accounts in this collection.
|
|
4349
|
+
|
|
4350
|
+
Calculates and reports:
|
|
4351
|
+
- total count of accounts,
|
|
4352
|
+
- summed MVest value (own vesting shares / 1e6),
|
|
4353
|
+
- mean and max reputation (if available),
|
|
4354
|
+
- summed, mean, and max effective HP (Hive Power) (if available),
|
|
4355
|
+
- mean time since last vote (hours) and mean time since last post (days) excluding accounts inactive >= 365 days,
|
|
4356
|
+
- counts of accounts without a vote or a post in the last 365 days.
|
|
4357
|
+
|
|
4358
|
+
Parameters:
|
|
4359
|
+
tag_type (str): Label used for counting rows (default "Follower").
|
|
4360
|
+
return_str (bool): If True, return the formatted table as a string; if False, print it.
|
|
4361
|
+
**kwargs: Passed through to PrettyTable.get_string (formatting options).
|
|
4362
|
+
|
|
4363
|
+
Returns:
|
|
4364
|
+
Optional[str]: The table string when return_str is True; otherwise None.
|
|
4365
|
+
"""
|
|
4276
4366
|
t = PrettyTable(["Key", "Value"])
|
|
4277
4367
|
t.align = "r"
|
|
4278
4368
|
t.add_row([tag_type + " count", str(len(self))])
|
|
@@ -4303,9 +4393,9 @@ class AccountsObject(list):
|
|
|
4303
4393
|
t.add_row(["Mean Rep.", "%.2f" % (sum(rep) / len(rep))])
|
|
4304
4394
|
t.add_row(["Max Rep.", "%.2f" % (max(rep))])
|
|
4305
4395
|
if len(eff_sp) > 0:
|
|
4306
|
-
t.add_row(["Summed eff.
|
|
4307
|
-
t.add_row(["Mean eff.
|
|
4308
|
-
t.add_row(["Max eff.
|
|
4396
|
+
t.add_row(["Summed eff. HP", "%.2f" % sum(eff_sp)])
|
|
4397
|
+
t.add_row(["Mean eff. HP", "%.2f" % (sum(eff_sp) / len(eff_sp))])
|
|
4398
|
+
t.add_row(["Max eff. HP", "%.2f" % max(eff_sp)])
|
|
4309
4399
|
if len(last_vote_h) > 0:
|
|
4310
4400
|
t.add_row(
|
|
4311
4401
|
["Mean last vote diff in hours", "%.2f" % (sum(last_vote_h) / len(last_vote_h))]
|
|
@@ -4328,18 +4418,34 @@ class Accounts(AccountsObject):
|
|
|
4328
4418
|
:param list name_list: list of accounts to fetch
|
|
4329
4419
|
:param int batch_limit: (optional) maximum number of accounts
|
|
4330
4420
|
to fetch per call, defaults to 100
|
|
4331
|
-
:param
|
|
4332
|
-
accessing
|
|
4421
|
+
:param Blockchain blockchain_instance: Blockchain instance to use when
|
|
4422
|
+
accessing the RPC
|
|
4333
4423
|
"""
|
|
4334
4424
|
|
|
4335
4425
|
def __init__(
|
|
4336
|
-
self,
|
|
4426
|
+
self,
|
|
4427
|
+
name_list,
|
|
4428
|
+
batch_limit=100,
|
|
4429
|
+
lazy=False,
|
|
4430
|
+
full=True,
|
|
4431
|
+
blockchain_instance=None,
|
|
4337
4432
|
):
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4433
|
+
"""
|
|
4434
|
+
Initialize an Accounts collection by batch-fetching account data and wrapping each result in an Account object.
|
|
4435
|
+
|
|
4436
|
+
Parameters:
|
|
4437
|
+
name_list (Iterable[str]): Sequence of account names to load.
|
|
4438
|
+
batch_limit (int): Maximum number of accounts fetched per RPC call (default 100).
|
|
4439
|
+
lazy (bool): Passed to each Account; if True, create lightweight Account objects (default False).
|
|
4440
|
+
full (bool): Passed to each Account; if True, request full account data when available (default True).
|
|
4441
|
+
blockchain_instance: Optional blockchain client; when omitted, a shared instance is used.
|
|
4442
|
+
|
|
4443
|
+
Behavior:
|
|
4444
|
+
- If the blockchain client is not connected, initialization returns early (creates an empty collection).
|
|
4445
|
+
- Accounts are fetched in batches via the blockchain RPC. When appbase is enabled the
|
|
4446
|
+
`find_accounts` (database) endpoint is used; otherwise `get_accounts` is used.
|
|
4447
|
+
- Each fetched account JSON is converted into an Account(name_or_dict, lazy=..., full=..., blockchain_instance=...).
|
|
4448
|
+
"""
|
|
4343
4449
|
self.blockchain = blockchain_instance or shared_blockchain_instance()
|
|
4344
4450
|
|
|
4345
4451
|
if not self.blockchain.is_connected():
|