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/cli.py
CHANGED
|
@@ -24,10 +24,8 @@ from nectar.asciichart import AsciiChart
|
|
|
24
24
|
from nectar.asset import Asset
|
|
25
25
|
from nectar.block import Block
|
|
26
26
|
from nectar.blockchain import Blockchain
|
|
27
|
-
from nectar.blurt import Blurt
|
|
28
27
|
from nectar.comment import Comment
|
|
29
28
|
from nectar.community import Communities, Community
|
|
30
|
-
from nectar.conveyor import Conveyor
|
|
31
29
|
from nectar.hive import Hive
|
|
32
30
|
from nectar.hivesigner import HiveSigner
|
|
33
31
|
from nectar.imageuploader import ImageUploader
|
|
@@ -39,8 +37,6 @@ from nectar.nodelist import NodeList, node_answer_time
|
|
|
39
37
|
from nectar.price import Price
|
|
40
38
|
from nectar.profile import Profile
|
|
41
39
|
from nectar.rc import RC
|
|
42
|
-
from nectar.steem import Steem
|
|
43
|
-
from nectar.storage import get_default_config_store
|
|
44
40
|
from nectar.transactionbuilder import TransactionBuilder
|
|
45
41
|
from nectar.utils import (
|
|
46
42
|
construct_authorperm,
|
|
@@ -93,8 +89,8 @@ def prompt_callback(ctx, param, value):
|
|
|
93
89
|
|
|
94
90
|
|
|
95
91
|
def asset_callback(ctx, param, value):
|
|
96
|
-
if value not in ["
|
|
97
|
-
print("Please
|
|
92
|
+
if value not in ["HIVE", "HBD", "TBD", "TESTS"]:
|
|
93
|
+
print("Please choose HIVE/HBD (or TESTS/TBD for test assets) as asset!")
|
|
98
94
|
ctx.abort()
|
|
99
95
|
else:
|
|
100
96
|
return value
|
|
@@ -119,16 +115,16 @@ def is_keyring_available():
|
|
|
119
115
|
return KEYRING_AVAILABLE
|
|
120
116
|
|
|
121
117
|
|
|
122
|
-
def unlock_wallet(
|
|
123
|
-
if
|
|
118
|
+
def unlock_wallet(hv, password=None, allow_wif=True):
|
|
119
|
+
if hv.unsigned and hv.nobroadcast:
|
|
124
120
|
return True
|
|
125
|
-
if
|
|
121
|
+
if hv.use_ledger:
|
|
126
122
|
return True
|
|
127
|
-
if not
|
|
123
|
+
if not hv.wallet.locked():
|
|
128
124
|
return True
|
|
129
|
-
if not
|
|
125
|
+
if not hv.wallet.store.is_encrypted():
|
|
130
126
|
return True
|
|
131
|
-
password_storage =
|
|
127
|
+
password_storage = hv.config["password_storage"]
|
|
132
128
|
if not password and password_storage == "keyring" and is_keyring_available():
|
|
133
129
|
import keyring
|
|
134
130
|
|
|
@@ -136,7 +132,7 @@ def unlock_wallet(stm, password=None, allow_wif=True):
|
|
|
136
132
|
if not password and password_storage == "environment" and "UNLOCK" in os.environ:
|
|
137
133
|
password = os.environ.get("UNLOCK")
|
|
138
134
|
if bool(password):
|
|
139
|
-
|
|
135
|
+
hv.wallet.unlock(password)
|
|
140
136
|
else:
|
|
141
137
|
if allow_wif:
|
|
142
138
|
password = click.prompt(
|
|
@@ -148,15 +144,15 @@ def unlock_wallet(stm, password=None, allow_wif=True):
|
|
|
148
144
|
password = click.prompt(
|
|
149
145
|
"Password to unlock wallet", confirmation_prompt=False, hide_input=True
|
|
150
146
|
)
|
|
151
|
-
if
|
|
147
|
+
if hv.wallet.is_encrypted():
|
|
152
148
|
try:
|
|
153
|
-
|
|
149
|
+
hv.wallet.unlock(password)
|
|
154
150
|
except Exception:
|
|
155
151
|
try:
|
|
156
152
|
from nectarstorage import InRamPlainKeyStore
|
|
157
153
|
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
hv.wallet.store = InRamPlainKeyStore()
|
|
155
|
+
hv.wallet.setKeys([password])
|
|
160
156
|
print("Wif accepted!")
|
|
161
157
|
return True
|
|
162
158
|
except Exception:
|
|
@@ -170,15 +166,15 @@ def unlock_wallet(stm, password=None, allow_wif=True):
|
|
|
170
166
|
)
|
|
171
167
|
else:
|
|
172
168
|
try:
|
|
173
|
-
|
|
169
|
+
hv.wallet.setKeys([password])
|
|
174
170
|
print("Wif accepted!")
|
|
175
171
|
return True
|
|
176
172
|
except Exception:
|
|
177
173
|
try:
|
|
178
174
|
from nectarstorage import SqliteEncryptedKeyStore
|
|
179
175
|
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
hv.wallet.store = SqliteEncryptedKeyStore(config=hv.config)
|
|
177
|
+
hv.wallet.unlock(password)
|
|
182
178
|
except Exception:
|
|
183
179
|
if allow_wif:
|
|
184
180
|
raise exceptions.WrongMasterPasswordException(
|
|
@@ -189,15 +185,15 @@ def unlock_wallet(stm, password=None, allow_wif=True):
|
|
|
189
185
|
"entered password is not a valid password"
|
|
190
186
|
)
|
|
191
187
|
|
|
192
|
-
if
|
|
188
|
+
if hv.wallet.locked():
|
|
193
189
|
if password_storage == "keyring" or password_storage == "environment":
|
|
194
190
|
print("Wallet could not be unlocked with %s!" % password_storage)
|
|
195
191
|
password = click.prompt(
|
|
196
192
|
"Password to unlock wallet", confirmation_prompt=False, hide_input=True
|
|
197
193
|
)
|
|
198
194
|
if bool(password):
|
|
199
|
-
unlock_wallet(
|
|
200
|
-
if not
|
|
195
|
+
unlock_wallet(hv, password=password)
|
|
196
|
+
if not hv.wallet.locked():
|
|
201
197
|
return True
|
|
202
198
|
else:
|
|
203
199
|
print("Wallet could not be unlocked!")
|
|
@@ -207,16 +203,16 @@ def unlock_wallet(stm, password=None, allow_wif=True):
|
|
|
207
203
|
return True
|
|
208
204
|
|
|
209
205
|
|
|
210
|
-
def unlock_token_wallet(
|
|
211
|
-
if
|
|
206
|
+
def unlock_token_wallet(hv, hs, password=None):
|
|
207
|
+
if hv.unsigned and hv.nobroadcast:
|
|
212
208
|
return True
|
|
213
|
-
if
|
|
209
|
+
if hv.use_ledger:
|
|
214
210
|
return True
|
|
215
|
-
if not
|
|
211
|
+
if not hs.locked():
|
|
216
212
|
return True
|
|
217
|
-
if not
|
|
213
|
+
if not hs.store.is_encrypted():
|
|
218
214
|
return True
|
|
219
|
-
password_storage =
|
|
215
|
+
password_storage = hv.config["password_storage"]
|
|
220
216
|
if not password and password_storage == "keyring" and is_keyring_available():
|
|
221
217
|
import keyring
|
|
222
218
|
|
|
@@ -224,27 +220,27 @@ def unlock_token_wallet(stm, sc2, password=None):
|
|
|
224
220
|
if not password and password_storage == "environment" and "UNLOCK" in os.environ:
|
|
225
221
|
password = os.environ.get("UNLOCK")
|
|
226
222
|
if bool(password):
|
|
227
|
-
|
|
223
|
+
hs.unlock(password)
|
|
228
224
|
else:
|
|
229
225
|
password = click.prompt(
|
|
230
226
|
"Password to unlock wallet", confirmation_prompt=False, hide_input=True
|
|
231
227
|
)
|
|
232
228
|
try:
|
|
233
|
-
|
|
229
|
+
hs.unlock(password)
|
|
234
230
|
except Exception:
|
|
235
231
|
raise exceptions.WrongMasterPasswordException(
|
|
236
232
|
"entered password is not a valid password"
|
|
237
233
|
)
|
|
238
234
|
|
|
239
|
-
if
|
|
235
|
+
if hs.locked():
|
|
240
236
|
if password_storage == "keyring" or password_storage == "environment":
|
|
241
237
|
print("Wallet could not be unlocked with %s!" % password_storage)
|
|
242
238
|
password = click.prompt(
|
|
243
239
|
"Password to unlock wallet", confirmation_prompt=False, hide_input=True
|
|
244
240
|
)
|
|
245
241
|
if bool(password):
|
|
246
|
-
unlock_token_wallet(
|
|
247
|
-
if not
|
|
242
|
+
unlock_token_wallet(hv, hs, password=password)
|
|
243
|
+
if not hs.locked():
|
|
248
244
|
return True
|
|
249
245
|
else:
|
|
250
246
|
print("Wallet could not be unlocked!")
|
|
@@ -286,8 +282,7 @@ def export_trx(tx, export):
|
|
|
286
282
|
default=False,
|
|
287
283
|
help="Creates hivesigner links from all broadcast operations",
|
|
288
284
|
)
|
|
289
|
-
|
|
290
|
-
@click.option("--hive", "-h", is_flag=True, default=False, help="Connect to the Hive blockchain")
|
|
285
|
+
# Hive is the only supported chain; no chain selection flags
|
|
291
286
|
@click.option(
|
|
292
287
|
"--keys",
|
|
293
288
|
"-k",
|
|
@@ -325,8 +320,6 @@ def cli(
|
|
|
325
320
|
no_wallet,
|
|
326
321
|
unsigned,
|
|
327
322
|
create_link,
|
|
328
|
-
steem,
|
|
329
|
-
hive,
|
|
330
323
|
keys,
|
|
331
324
|
use_ledger,
|
|
332
325
|
path,
|
|
@@ -368,78 +361,31 @@ def cli(
|
|
|
368
361
|
if create_link:
|
|
369
362
|
no_broadcast = True
|
|
370
363
|
unsigned = True
|
|
371
|
-
|
|
364
|
+
hs = HiveSigner()
|
|
372
365
|
else:
|
|
373
|
-
|
|
366
|
+
hs = None
|
|
374
367
|
debug = verbose > 0
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
hivesigner=sc2,
|
|
395
|
-
use_ledger=use_ledger,
|
|
396
|
-
path=path,
|
|
397
|
-
debug=debug,
|
|
398
|
-
num_retries=10,
|
|
399
|
-
num_retries_call=5,
|
|
400
|
-
timeout=30,
|
|
401
|
-
autoconnect=autoconnect,
|
|
402
|
-
)
|
|
403
|
-
elif steem:
|
|
404
|
-
stm = Steem(
|
|
405
|
-
node=node,
|
|
406
|
-
nobroadcast=no_broadcast,
|
|
407
|
-
offline=offline,
|
|
408
|
-
keys=keys_list,
|
|
409
|
-
nowallet=no_wallet,
|
|
410
|
-
unsigned=unsigned,
|
|
411
|
-
use_sc2=token,
|
|
412
|
-
expiration=expires,
|
|
413
|
-
steemconnect=sc2,
|
|
414
|
-
use_ledger=use_ledger,
|
|
415
|
-
path=path,
|
|
416
|
-
debug=debug,
|
|
417
|
-
num_retries=10,
|
|
418
|
-
num_retries_call=5,
|
|
419
|
-
timeout=30,
|
|
420
|
-
autoconnect=autoconnect,
|
|
421
|
-
)
|
|
422
|
-
else:
|
|
423
|
-
stm = Blurt(
|
|
424
|
-
node=node,
|
|
425
|
-
nobroadcast=no_broadcast,
|
|
426
|
-
offline=offline,
|
|
427
|
-
keys=keys_list,
|
|
428
|
-
nowallet=no_wallet,
|
|
429
|
-
unsigned=unsigned,
|
|
430
|
-
use_sc2=token,
|
|
431
|
-
expiration=expires,
|
|
432
|
-
steemconnect=sc2,
|
|
433
|
-
use_ledger=use_ledger,
|
|
434
|
-
path=path,
|
|
435
|
-
debug=debug,
|
|
436
|
-
num_retries=10,
|
|
437
|
-
num_retries_call=5,
|
|
438
|
-
timeout=30,
|
|
439
|
-
autoconnect=autoconnect,
|
|
440
|
-
)
|
|
368
|
+
# Hive-only instance
|
|
369
|
+
hv = Hive(
|
|
370
|
+
node=node,
|
|
371
|
+
nobroadcast=no_broadcast,
|
|
372
|
+
keys=keys_list,
|
|
373
|
+
offline=offline,
|
|
374
|
+
nowallet=no_wallet,
|
|
375
|
+
unsigned=unsigned,
|
|
376
|
+
use_hs=token,
|
|
377
|
+
expiration=expires,
|
|
378
|
+
hivesigner=hs,
|
|
379
|
+
use_ledger=use_ledger,
|
|
380
|
+
path=path,
|
|
381
|
+
debug=debug,
|
|
382
|
+
num_retries=10,
|
|
383
|
+
num_retries_call=5,
|
|
384
|
+
timeout=30,
|
|
385
|
+
autoconnect=autoconnect,
|
|
386
|
+
)
|
|
441
387
|
|
|
442
|
-
set_shared_blockchain_instance(
|
|
388
|
+
set_shared_blockchain_instance(hv)
|
|
443
389
|
|
|
444
390
|
pass
|
|
445
391
|
|
|
@@ -457,22 +403,22 @@ def set(key, value):
|
|
|
457
403
|
Set the default vote weight to 50 %:
|
|
458
404
|
set default_vote_weight 50
|
|
459
405
|
"""
|
|
460
|
-
|
|
406
|
+
hv = shared_blockchain_instance()
|
|
461
407
|
if key == "default_account":
|
|
462
|
-
if
|
|
463
|
-
|
|
464
|
-
|
|
408
|
+
if hv.rpc is not None:
|
|
409
|
+
hv.rpc.rpcconnect()
|
|
410
|
+
hv.set_default_account(value)
|
|
465
411
|
elif key == "default_vote_weight":
|
|
466
|
-
|
|
412
|
+
hv.set_default_vote_weight(value)
|
|
467
413
|
elif key == "nodes" or key == "node":
|
|
468
414
|
if bool(value) or value != "default":
|
|
469
|
-
|
|
415
|
+
hv.set_default_nodes(value)
|
|
470
416
|
else:
|
|
471
|
-
|
|
417
|
+
hv.set_default_nodes("")
|
|
472
418
|
elif key == "default_chain":
|
|
473
|
-
|
|
419
|
+
hv.config["default_chain"] = value
|
|
474
420
|
elif key == "password_storage":
|
|
475
|
-
|
|
421
|
+
hv.config["password_storage"] = value
|
|
476
422
|
if is_keyring_available() and value == "keyring":
|
|
477
423
|
import keyring
|
|
478
424
|
|
|
@@ -494,23 +440,23 @@ def set(key, value):
|
|
|
494
440
|
"The wallet password can be stored in the UNLOCK environment variable to skip password prompt!"
|
|
495
441
|
)
|
|
496
442
|
elif key == "client_id":
|
|
497
|
-
|
|
443
|
+
hv.config["client_id"] = value
|
|
498
444
|
elif key == "hot_sign_redirect_uri":
|
|
499
|
-
|
|
500
|
-
elif key == "sc2_api_url":
|
|
501
|
-
stm.config["sc2_api_url"] = value
|
|
445
|
+
hv.config["hot_sign_redirect_uri"] = value
|
|
502
446
|
elif key == "hs_api_url":
|
|
503
|
-
|
|
447
|
+
hv.config["hs_api_url"] = value
|
|
504
448
|
elif key == "oauth_base_url":
|
|
505
|
-
|
|
449
|
+
# Keep generic key and also update HiveSigner oauth base for consistency
|
|
450
|
+
hv.config["oauth_base_url"] = value
|
|
451
|
+
hv.config["hs_oauth_base_url"] = value
|
|
506
452
|
elif key == "default_path":
|
|
507
|
-
|
|
453
|
+
hv.config["default_path"] = value
|
|
508
454
|
elif key == "default_canonical_url":
|
|
509
|
-
|
|
455
|
+
hv.config["default_canonical_url"] = value
|
|
510
456
|
elif key == "use_condenser":
|
|
511
|
-
|
|
457
|
+
hv.config["use_condenser"] = value in ["true", "True"]
|
|
512
458
|
elif key == "use_tor":
|
|
513
|
-
|
|
459
|
+
hv.config["use_tor"] = value in ["true", "True"]
|
|
514
460
|
else:
|
|
515
461
|
print("wrong key")
|
|
516
462
|
|
|
@@ -519,34 +465,34 @@ def set(key, value):
|
|
|
519
465
|
@click.option("--results", is_flag=True, default=False, help="Shows result of changing the node.")
|
|
520
466
|
def nextnode(results):
|
|
521
467
|
"""Uses the next node in list"""
|
|
522
|
-
|
|
523
|
-
if
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
node =
|
|
527
|
-
offline =
|
|
468
|
+
hv = shared_blockchain_instance()
|
|
469
|
+
if hv.rpc is not None:
|
|
470
|
+
hv.rpc.rpcconnect()
|
|
471
|
+
hv.move_current_node_to_front()
|
|
472
|
+
node = hv.get_default_nodes()
|
|
473
|
+
offline = hv.offline
|
|
528
474
|
if len(node) < 2 or isinstance(node, str):
|
|
529
475
|
print("At least two nodes are needed!")
|
|
530
476
|
return
|
|
531
477
|
node = node[1:] + [node[0]]
|
|
532
478
|
if not offline:
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
while not offline and node[0] !=
|
|
479
|
+
hv.rpc.next()
|
|
480
|
+
hv.get_blockchain_version()
|
|
481
|
+
while not offline and node[0] != hv.rpc.url and len(node) > 1:
|
|
536
482
|
node = node[1:] + [node[0]]
|
|
537
|
-
|
|
483
|
+
hv.set_default_nodes(node)
|
|
538
484
|
if not results:
|
|
539
485
|
return
|
|
540
486
|
|
|
541
487
|
t = PrettyTable(["Key", "Value"])
|
|
542
488
|
t.align = "l"
|
|
543
489
|
if not offline:
|
|
544
|
-
t.add_row(["Node-Url",
|
|
490
|
+
t.add_row(["Node-Url", hv.rpc.url])
|
|
545
491
|
else:
|
|
546
492
|
t.add_row(["Node-Url", node[0]])
|
|
547
493
|
if not offline:
|
|
548
|
-
t.add_row(["Version",
|
|
549
|
-
t.add_row(["HIVE",
|
|
494
|
+
t.add_row(["Version", hv.get_blockchain_version()])
|
|
495
|
+
t.add_row(["HIVE", hv.is_hive])
|
|
550
496
|
else:
|
|
551
497
|
t.add_row(["Version", "hive-nectar is in offline mode..."])
|
|
552
498
|
print(t)
|
|
@@ -559,10 +505,10 @@ def nextnode(results):
|
|
|
559
505
|
)
|
|
560
506
|
def pingnode(sort, remove):
|
|
561
507
|
"""Returns the answer time in milliseconds"""
|
|
562
|
-
|
|
563
|
-
if
|
|
564
|
-
|
|
565
|
-
nodes =
|
|
508
|
+
hv = shared_blockchain_instance()
|
|
509
|
+
if hv.rpc is not None:
|
|
510
|
+
hv.rpc.rpcconnect()
|
|
511
|
+
nodes = hv.get_default_nodes()
|
|
566
512
|
|
|
567
513
|
t = PrettyTable(["Node", "Answer time [ms]"])
|
|
568
514
|
t.align = "l"
|
|
@@ -574,9 +520,9 @@ def pingnode(sort, remove):
|
|
|
574
520
|
t.add_row([node["url"], "%.2f" % (node["delay_ms"])])
|
|
575
521
|
sorted_node_list.append(node["url"])
|
|
576
522
|
print(t)
|
|
577
|
-
|
|
523
|
+
hv.set_default_nodes(sorted_node_list)
|
|
578
524
|
else:
|
|
579
|
-
node =
|
|
525
|
+
node = hv.rpc.url
|
|
580
526
|
rpc_answer_time = node_answer_time(node)
|
|
581
527
|
rpc_time_str = "%.2f" % (rpc_answer_time * 1000)
|
|
582
528
|
t.add_row([node, rpc_time_str])
|
|
@@ -598,46 +544,38 @@ def about():
|
|
|
598
544
|
@click.option("--url", is_flag=True, default=False, help="Returns only the raw url value")
|
|
599
545
|
def currentnode(version, url):
|
|
600
546
|
"""Sets the currently working node at the first place in the list"""
|
|
601
|
-
|
|
602
|
-
if
|
|
603
|
-
|
|
604
|
-
offline =
|
|
605
|
-
|
|
606
|
-
node =
|
|
547
|
+
hv = shared_blockchain_instance()
|
|
548
|
+
if hv.rpc is not None:
|
|
549
|
+
hv.rpc.rpcconnect()
|
|
550
|
+
offline = hv.offline
|
|
551
|
+
hv.move_current_node_to_front()
|
|
552
|
+
node = hv.get_default_nodes()
|
|
607
553
|
if version and not offline:
|
|
608
|
-
print(
|
|
554
|
+
print(hv.get_blockchain_version())
|
|
609
555
|
return
|
|
610
556
|
elif version and offline:
|
|
611
557
|
print("Node is offline")
|
|
612
558
|
return
|
|
613
559
|
if url and not offline:
|
|
614
|
-
print(
|
|
560
|
+
print(hv.rpc.url)
|
|
615
561
|
return
|
|
616
562
|
t = PrettyTable(["Key", "Value"])
|
|
617
563
|
t.align = "l"
|
|
618
564
|
if not offline:
|
|
619
|
-
t.add_row(["Node-Url",
|
|
565
|
+
t.add_row(["Node-Url", hv.rpc.url])
|
|
620
566
|
else:
|
|
621
567
|
t.add_row(["Node-Url", node[0]])
|
|
622
568
|
if not offline:
|
|
623
|
-
t.add_row(["Version",
|
|
624
|
-
t.add_row(["Chain",
|
|
569
|
+
t.add_row(["Version", hv.get_blockchain_version()])
|
|
570
|
+
t.add_row(["Chain", hv.get_blockchain_name()])
|
|
625
571
|
else:
|
|
626
|
-
t.add_row(["Version", "
|
|
572
|
+
t.add_row(["Version", "hive-nectar is in offline mode..."])
|
|
627
573
|
print(t)
|
|
628
574
|
|
|
629
575
|
|
|
630
576
|
@cli.command()
|
|
631
577
|
@click.option("--show", "-s", is_flag=True, default=False, help="Prints the updated nodes")
|
|
632
|
-
|
|
633
|
-
"--hive", "-h", is_flag=True, default=False, help="Switch to HIVE blockchain, when set to true."
|
|
634
|
-
)
|
|
635
|
-
@click.option(
|
|
636
|
-
"--steem", "-e", is_flag=True, default=False, help="Switch to STEEM nodes, when set to true."
|
|
637
|
-
)
|
|
638
|
-
@click.option(
|
|
639
|
-
"--blurt", "-b", is_flag=True, default=False, help="Switch to BLURT nodes, when set to true."
|
|
640
|
-
)
|
|
578
|
+
# Hive-only node updates
|
|
641
579
|
@click.option(
|
|
642
580
|
"--test",
|
|
643
581
|
"-t",
|
|
@@ -647,44 +585,18 @@ def currentnode(version, url):
|
|
|
647
585
|
)
|
|
648
586
|
@click.option("--only-https", is_flag=True, default=False, help="Use only https nodes.")
|
|
649
587
|
@click.option("--only-wss", is_flag=True, default=False, help="Use only websocket nodes.")
|
|
650
|
-
def updatenodes(show,
|
|
588
|
+
def updatenodes(show, test, only_https, only_wss):
|
|
651
589
|
"""Update the nodelist from @fullnodeupdate"""
|
|
652
|
-
|
|
653
|
-
if
|
|
654
|
-
|
|
655
|
-
if steem and hive:
|
|
656
|
-
print("hive and steem cannot be active both")
|
|
657
|
-
return
|
|
590
|
+
hv = shared_blockchain_instance()
|
|
591
|
+
if hv.rpc is not None:
|
|
592
|
+
hv.rpc.rpcconnect()
|
|
658
593
|
t = PrettyTable(["node", "Version", "score"])
|
|
659
594
|
t.align = "l"
|
|
660
|
-
if steem:
|
|
661
|
-
blockchain = "steem"
|
|
662
|
-
elif hive:
|
|
663
|
-
blockchain = "hive"
|
|
664
|
-
elif blurt:
|
|
665
|
-
blockchain = "blurt"
|
|
666
|
-
else:
|
|
667
|
-
blockchain = stm.config["default_chain"]
|
|
668
595
|
nodelist = NodeList()
|
|
669
|
-
nodelist.update_nodes(blockchain_instance=
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
stm.config["default_chain"] = "hive"
|
|
674
|
-
elif steem:
|
|
675
|
-
nodes = nodelist.get_steem_nodes(wss=not only_https, https=not only_wss)
|
|
676
|
-
if stm.config["default_chain"] != "steem":
|
|
677
|
-
stm.config["default_chain"] = "steem"
|
|
678
|
-
elif blurt:
|
|
679
|
-
nodes = ["https://rpc.blurt.world", "https://blurt-rpc.steem.buzz"]
|
|
680
|
-
if stm.config["default_chain"] != "blurt":
|
|
681
|
-
stm.config["default_chain"] = "blurt"
|
|
682
|
-
elif stm.config["default_chain"] == "steem":
|
|
683
|
-
nodes = nodelist.get_steem_nodes(wss=not only_https, https=not only_wss)
|
|
684
|
-
elif stm.config["default_chain"] == "blurt":
|
|
685
|
-
nodes = ["https://rpc.blurt.world", "https://blurt-rpc.steem.buzz"]
|
|
686
|
-
else:
|
|
687
|
-
nodes = nodelist.get_hive_nodes(wss=not only_https, https=not only_wss)
|
|
596
|
+
nodelist.update_nodes(blockchain_instance=hv)
|
|
597
|
+
nodes = nodelist.get_hive_nodes(wss=not only_https, https=not only_wss)
|
|
598
|
+
if hv.config["default_chain"] != "hive":
|
|
599
|
+
hv.config["default_chain"] = "hive"
|
|
688
600
|
if show or test:
|
|
689
601
|
sorted_nodes = sorted(nodelist, key=lambda node: node["score"], reverse=True)
|
|
690
602
|
for node in sorted_nodes:
|
|
@@ -693,20 +605,20 @@ def updatenodes(show, hive, steem, blurt, test, only_https, only_wss):
|
|
|
693
605
|
t.add_row([node["url"], node["version"], score])
|
|
694
606
|
print(t)
|
|
695
607
|
if not test:
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
608
|
+
hv.set_default_nodes(nodes)
|
|
609
|
+
hv.rpc.nodes.set_node_urls(nodes)
|
|
610
|
+
hv.rpc.current_rpc = 0
|
|
611
|
+
hv.rpc.rpcclose()
|
|
612
|
+
hv.rpc.rpcconnect()
|
|
701
613
|
|
|
702
614
|
|
|
703
615
|
@cli.command()
|
|
704
616
|
def config():
|
|
705
617
|
"""Shows local configuration"""
|
|
706
|
-
|
|
618
|
+
hv = shared_blockchain_instance()
|
|
707
619
|
t = PrettyTable(["Key", "Value"])
|
|
708
620
|
t.align = "l"
|
|
709
|
-
for key in
|
|
621
|
+
for key in hv.config:
|
|
710
622
|
# hide internal config data
|
|
711
623
|
if (
|
|
712
624
|
key in availableConfigurationKeys
|
|
@@ -714,18 +626,18 @@ def config():
|
|
|
714
626
|
and key != "node"
|
|
715
627
|
and key != "use_tor"
|
|
716
628
|
):
|
|
717
|
-
t.add_row([key,
|
|
718
|
-
node =
|
|
719
|
-
blockchain =
|
|
629
|
+
t.add_row([key, hv.config[key]])
|
|
630
|
+
node = hv.get_default_nodes()
|
|
631
|
+
blockchain = hv.config["default_chain"]
|
|
720
632
|
nodes = json.dumps(node, indent=4)
|
|
721
633
|
t.add_row(["default_chain", blockchain])
|
|
722
634
|
t.add_row(["nodes", nodes])
|
|
723
635
|
if "password_storage" not in availableConfigurationKeys:
|
|
724
|
-
t.add_row(["password_storage",
|
|
725
|
-
if not
|
|
726
|
-
t.add_row(["use_condenser",
|
|
727
|
-
t.add_row(["data_dir",
|
|
728
|
-
t.add_row(["use_tor", bool(
|
|
636
|
+
t.add_row(["password_storage", hv.config["password_storage"]])
|
|
637
|
+
if not hv.config["use_condenser"]:
|
|
638
|
+
t.add_row(["use_condenser", hv.config["use_condenser"]])
|
|
639
|
+
t.add_row(["data_dir", hv.config.data_dir])
|
|
640
|
+
t.add_row(["use_tor", bool(hv.config["use_tor"])])
|
|
729
641
|
print(t)
|
|
730
642
|
|
|
731
643
|
|
|
@@ -733,26 +645,26 @@ def config():
|
|
|
733
645
|
@click.option("--wipe", is_flag=True, default=False, help="Wipe old wallet without prompt.")
|
|
734
646
|
def createwallet(wipe):
|
|
735
647
|
"""Create new wallet with a new password"""
|
|
736
|
-
|
|
737
|
-
if
|
|
738
|
-
|
|
739
|
-
if
|
|
648
|
+
hv = shared_blockchain_instance()
|
|
649
|
+
if hv.rpc is not None:
|
|
650
|
+
hv.rpc.rpcconnect()
|
|
651
|
+
if hv.wallet.created() and not wipe:
|
|
740
652
|
wipe_answer = click.prompt(
|
|
741
653
|
"'Do you want to wipe your wallet? Are your sure? This is IRREVERSIBLE! If you dont have a backup you may lose access to your account! [y/n]",
|
|
742
654
|
default="n",
|
|
743
655
|
)
|
|
744
656
|
if wipe_answer in ["y", "ye", "yes"]:
|
|
745
|
-
|
|
657
|
+
hv.wallet.wipe(True)
|
|
746
658
|
else:
|
|
747
659
|
return
|
|
748
660
|
elif wipe:
|
|
749
|
-
|
|
661
|
+
hv.wallet.wipe(True)
|
|
750
662
|
password = None
|
|
751
663
|
password = click.prompt("New wallet password", confirmation_prompt=True, hide_input=True)
|
|
752
664
|
if not bool(password):
|
|
753
665
|
print("Password cannot be empty! Quitting...")
|
|
754
666
|
return
|
|
755
|
-
password_storage =
|
|
667
|
+
password_storage = hv.config["password_storage"]
|
|
756
668
|
if password_storage == "keyring" and is_keyring_available():
|
|
757
669
|
import keyring
|
|
758
670
|
|
|
@@ -761,9 +673,9 @@ def createwallet(wipe):
|
|
|
761
673
|
print(
|
|
762
674
|
"The new wallet password can be stored in the UNLOCK environment variable to skip password prompt!"
|
|
763
675
|
)
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
set_shared_blockchain_instance(
|
|
676
|
+
hv.wallet.wipe(True)
|
|
677
|
+
hv.wallet.create(password)
|
|
678
|
+
set_shared_blockchain_instance(hv)
|
|
767
679
|
|
|
768
680
|
|
|
769
681
|
@cli.command()
|
|
@@ -771,21 +683,21 @@ def createwallet(wipe):
|
|
|
771
683
|
@click.option("--lock", "-l", is_flag=True, default=False, help="Lock wallet")
|
|
772
684
|
def walletinfo(unlock, lock):
|
|
773
685
|
"""Show info about wallet"""
|
|
774
|
-
|
|
775
|
-
if
|
|
776
|
-
|
|
686
|
+
hv = shared_blockchain_instance()
|
|
687
|
+
if hv.rpc is not None:
|
|
688
|
+
hv.rpc.rpcconnect()
|
|
777
689
|
if lock:
|
|
778
|
-
|
|
690
|
+
hv.wallet.lock()
|
|
779
691
|
elif unlock:
|
|
780
|
-
unlock_wallet(
|
|
692
|
+
unlock_wallet(hv, allow_wif=False)
|
|
781
693
|
|
|
782
694
|
t = PrettyTable(["Key", "Value"])
|
|
783
695
|
t.align = "l"
|
|
784
|
-
t.add_row(["created",
|
|
785
|
-
t.add_row(["locked",
|
|
786
|
-
t.add_row(["Number of stored keys", len(
|
|
787
|
-
t.add_row(["sql-file",
|
|
788
|
-
password_storage =
|
|
696
|
+
t.add_row(["created", hv.wallet.created()])
|
|
697
|
+
t.add_row(["locked", hv.wallet.locked()])
|
|
698
|
+
t.add_row(["Number of stored keys", len(hv.wallet.getPublicKeys())])
|
|
699
|
+
t.add_row(["sql-file", hv.wallet.store.sqlite_file])
|
|
700
|
+
password_storage = hv.config["password_storage"]
|
|
789
701
|
t.add_row(["password_storage", password_storage])
|
|
790
702
|
password = os.environ.get("UNLOCK")
|
|
791
703
|
if password is not None:
|
|
@@ -798,11 +710,11 @@ def walletinfo(unlock, lock):
|
|
|
798
710
|
t.add_row(["keyring installed", "no"])
|
|
799
711
|
|
|
800
712
|
if unlock:
|
|
801
|
-
if unlock_wallet(
|
|
713
|
+
if unlock_wallet(hv, allow_wif=False):
|
|
802
714
|
t.add_row(["Wallet unlock", "successful"])
|
|
803
715
|
else:
|
|
804
716
|
t.add_row(["Wallet unlock", "not working"])
|
|
805
|
-
# t.add_row(["getPublicKeys", str(
|
|
717
|
+
# t.add_row(["getPublicKeys", str(hv.wallet.getPublicKeys())])
|
|
806
718
|
print(t)
|
|
807
719
|
|
|
808
720
|
|
|
@@ -814,17 +726,17 @@ def walletinfo(unlock, lock):
|
|
|
814
726
|
)
|
|
815
727
|
def parsewif(unsafe_import_key):
|
|
816
728
|
"""Parse a WIF private key without importing"""
|
|
817
|
-
|
|
818
|
-
if
|
|
819
|
-
|
|
729
|
+
hv = shared_blockchain_instance()
|
|
730
|
+
if hv.rpc is not None:
|
|
731
|
+
hv.rpc.rpcconnect()
|
|
820
732
|
if unsafe_import_key:
|
|
821
733
|
for key in unsafe_import_key:
|
|
822
734
|
try:
|
|
823
|
-
pubkey = PrivateKey(key, prefix=
|
|
735
|
+
pubkey = PrivateKey(key, prefix=hv.prefix).pubkey
|
|
824
736
|
print(pubkey)
|
|
825
|
-
account =
|
|
826
|
-
account = Account(account, blockchain_instance=
|
|
827
|
-
key_type =
|
|
737
|
+
account = hv.wallet.getAccountFromPublicKey(str(pubkey))
|
|
738
|
+
account = Account(account, blockchain_instance=hv)
|
|
739
|
+
key_type = hv.wallet.getKeyType(account, str(pubkey))
|
|
828
740
|
print("Account: %s - %s" % (account["name"], key_type))
|
|
829
741
|
except Exception as e:
|
|
830
742
|
print(str(e))
|
|
@@ -834,11 +746,11 @@ def parsewif(unsafe_import_key):
|
|
|
834
746
|
if not wifkey or wifkey == "quit" or wifkey == "exit":
|
|
835
747
|
break
|
|
836
748
|
try:
|
|
837
|
-
pubkey = PrivateKey(wifkey, prefix=
|
|
749
|
+
pubkey = PrivateKey(wifkey, prefix=hv.prefix).pubkey
|
|
838
750
|
print(pubkey)
|
|
839
|
-
account =
|
|
840
|
-
account = Account(account, blockchain_instance=
|
|
841
|
-
key_type =
|
|
751
|
+
account = hv.wallet.getAccountFromPublicKey(str(pubkey))
|
|
752
|
+
account = Account(account, blockchain_instance=hv)
|
|
753
|
+
key_type = hv.wallet.getKeyType(account, str(pubkey))
|
|
842
754
|
print("Account: %s - %s" % (account["name"], key_type))
|
|
843
755
|
except Exception as e:
|
|
844
756
|
print(str(e))
|
|
@@ -856,17 +768,17 @@ def addkey(unsafe_import_key):
|
|
|
856
768
|
When no [OPTION] is given, a password prompt for unlocking the wallet
|
|
857
769
|
and a prompt for entering the private key are shown.
|
|
858
770
|
"""
|
|
859
|
-
|
|
860
|
-
if
|
|
861
|
-
|
|
862
|
-
if not unlock_wallet(
|
|
771
|
+
hv = shared_blockchain_instance()
|
|
772
|
+
if hv.rpc is not None:
|
|
773
|
+
hv.rpc.rpcconnect()
|
|
774
|
+
if not unlock_wallet(hv, allow_wif=False):
|
|
863
775
|
return
|
|
864
776
|
if not unsafe_import_key:
|
|
865
777
|
unsafe_import_key = click.prompt(
|
|
866
778
|
"Enter private key", confirmation_prompt=False, hide_input=True
|
|
867
779
|
)
|
|
868
|
-
|
|
869
|
-
set_shared_blockchain_instance(
|
|
780
|
+
hv.wallet.addPrivateKey(unsafe_import_key)
|
|
781
|
+
set_shared_blockchain_instance(hv)
|
|
870
782
|
|
|
871
783
|
|
|
872
784
|
@cli.command()
|
|
@@ -886,13 +798,13 @@ def delkey(confirm, pub):
|
|
|
886
798
|
PUB is the public key from the private key
|
|
887
799
|
which will be deleted from the wallet
|
|
888
800
|
"""
|
|
889
|
-
|
|
890
|
-
if
|
|
891
|
-
|
|
892
|
-
if not unlock_wallet(
|
|
801
|
+
hv = shared_blockchain_instance()
|
|
802
|
+
if hv.rpc is not None:
|
|
803
|
+
hv.rpc.rpcconnect()
|
|
804
|
+
if not unlock_wallet(hv, allow_wif=False):
|
|
893
805
|
return
|
|
894
|
-
|
|
895
|
-
set_shared_blockchain_instance(
|
|
806
|
+
hv.wallet.removePrivateKeyFromPublicKey(pub)
|
|
807
|
+
set_shared_blockchain_instance(hv)
|
|
896
808
|
|
|
897
809
|
|
|
898
810
|
@cli.command()
|
|
@@ -913,7 +825,7 @@ def delkey(confirm, pub):
|
|
|
913
825
|
@click.option(
|
|
914
826
|
"--network",
|
|
915
827
|
"-n",
|
|
916
|
-
help="Network index
|
|
828
|
+
help="Network index for BIP39 (default is 13 for Hive)",
|
|
917
829
|
default=13,
|
|
918
830
|
)
|
|
919
831
|
@click.option(
|
|
@@ -962,7 +874,7 @@ def keygen(
|
|
|
962
874
|
The generated key is not stored. Can also be used to create new keys for an account.
|
|
963
875
|
Can also be used to derive account keys from a password or BIP39 wordlist.
|
|
964
876
|
"""
|
|
965
|
-
|
|
877
|
+
hv = shared_blockchain_instance()
|
|
966
878
|
pub_json = {"owner": "", "active": "", "posting": "", "memo": ""}
|
|
967
879
|
|
|
968
880
|
if not account_keys and len(role.split(",")) > 1:
|
|
@@ -975,10 +887,10 @@ def keygen(
|
|
|
975
887
|
else:
|
|
976
888
|
wif = 0
|
|
977
889
|
|
|
978
|
-
if
|
|
979
|
-
if
|
|
980
|
-
|
|
981
|
-
ledgertx =
|
|
890
|
+
if hv.use_ledger:
|
|
891
|
+
if hv.rpc is not None:
|
|
892
|
+
hv.rpc.rpcconnect()
|
|
893
|
+
ledgertx = hv.new_tx()
|
|
982
894
|
ledgertx.constructTx()
|
|
983
895
|
if account is None:
|
|
984
896
|
account = 0
|
|
@@ -1156,9 +1068,9 @@ def passwordgen(role, account, import_password, import_coldcard, wif, export_pub
|
|
|
1156
1068
|
"""Creates a new password based key and prints its derived private key and public key.
|
|
1157
1069
|
The generated key is not stored. The password is used to create new keys for an account.
|
|
1158
1070
|
"""
|
|
1159
|
-
|
|
1071
|
+
hv = shared_blockchain_instance()
|
|
1160
1072
|
if not account:
|
|
1161
|
-
account =
|
|
1073
|
+
account = hv.config["default_account"]
|
|
1162
1074
|
if import_password:
|
|
1163
1075
|
import_password = click.prompt("Enter password", confirmation_prompt=False, hide_input=True)
|
|
1164
1076
|
elif import_coldcard is not None:
|
|
@@ -1229,18 +1141,18 @@ def addtoken(name, unsafe_import_token):
|
|
|
1229
1141
|
When no [OPTION] is given, a password prompt for unlocking the wallet
|
|
1230
1142
|
and a prompt for entering the private key are shown.
|
|
1231
1143
|
"""
|
|
1232
|
-
|
|
1233
|
-
if
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
if not unlock_token_wallet(
|
|
1144
|
+
hv = shared_blockchain_instance()
|
|
1145
|
+
if hv.rpc is not None:
|
|
1146
|
+
hv.rpc.rpcconnect()
|
|
1147
|
+
hs = HiveSigner(blockchain_instance=hv)
|
|
1148
|
+
if not unlock_token_wallet(hv, hs):
|
|
1237
1149
|
return
|
|
1238
1150
|
if not unsafe_import_token:
|
|
1239
1151
|
unsafe_import_token = click.prompt(
|
|
1240
1152
|
"Enter private token", confirmation_prompt=False, hide_input=True
|
|
1241
1153
|
)
|
|
1242
|
-
|
|
1243
|
-
set_shared_blockchain_instance(
|
|
1154
|
+
hs.addToken(name, unsafe_import_token)
|
|
1155
|
+
set_shared_blockchain_instance(hv)
|
|
1244
1156
|
|
|
1245
1157
|
|
|
1246
1158
|
@cli.command()
|
|
@@ -1260,14 +1172,14 @@ def deltoken(confirm, name):
|
|
|
1260
1172
|
name is the public name from the private token
|
|
1261
1173
|
which will be deleted from the wallet
|
|
1262
1174
|
"""
|
|
1263
|
-
|
|
1264
|
-
if
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
if not unlock_token_wallet(
|
|
1175
|
+
hv = shared_blockchain_instance()
|
|
1176
|
+
if hv.rpc is not None:
|
|
1177
|
+
hv.rpc.rpcconnect()
|
|
1178
|
+
hs = HiveSigner(blockchain_instance=hv)
|
|
1179
|
+
if not unlock_token_wallet(hv, hs):
|
|
1268
1180
|
return
|
|
1269
|
-
|
|
1270
|
-
set_shared_blockchain_instance(
|
|
1181
|
+
hs.removeTokenFromPublicName(name)
|
|
1182
|
+
set_shared_blockchain_instance(hv)
|
|
1271
1183
|
|
|
1272
1184
|
|
|
1273
1185
|
@cli.command()
|
|
@@ -1284,16 +1196,16 @@ def listkeys(path, ledger_approval):
|
|
|
1284
1196
|
|
|
1285
1197
|
Can be used to receive and approve the pubkey obtained from the ledger
|
|
1286
1198
|
"""
|
|
1287
|
-
|
|
1288
|
-
if
|
|
1289
|
-
|
|
1199
|
+
hv = shared_blockchain_instance()
|
|
1200
|
+
if hv.rpc is not None:
|
|
1201
|
+
hv.rpc.rpcconnect()
|
|
1290
1202
|
|
|
1291
|
-
if
|
|
1203
|
+
if hv.use_ledger:
|
|
1292
1204
|
if path is None:
|
|
1293
|
-
path =
|
|
1205
|
+
path = hv.config["default_path"]
|
|
1294
1206
|
t = PrettyTable(["Available Key for %s" % path])
|
|
1295
1207
|
t.align = "l"
|
|
1296
|
-
ledgertx =
|
|
1208
|
+
ledgertx = hv.new_tx()
|
|
1297
1209
|
ledgertx.constructTx()
|
|
1298
1210
|
pubkey = ledgertx.ledgertx.get_pubkey(path, request_screen_approval=False)
|
|
1299
1211
|
t.add_row([str(pubkey)])
|
|
@@ -1303,7 +1215,7 @@ def listkeys(path, ledger_approval):
|
|
|
1303
1215
|
else:
|
|
1304
1216
|
t = PrettyTable(["Available Key"])
|
|
1305
1217
|
t.align = "l"
|
|
1306
|
-
for key in
|
|
1218
|
+
for key in hv.wallet.getPublicKeys():
|
|
1307
1219
|
t.add_row([key])
|
|
1308
1220
|
print(t)
|
|
1309
1221
|
|
|
@@ -1311,14 +1223,14 @@ def listkeys(path, ledger_approval):
|
|
|
1311
1223
|
@cli.command()
|
|
1312
1224
|
def listtoken():
|
|
1313
1225
|
"""Show stored token"""
|
|
1314
|
-
|
|
1226
|
+
hv = shared_blockchain_instance()
|
|
1315
1227
|
t = PrettyTable(["name", "scope", "status"])
|
|
1316
1228
|
t.align = "l"
|
|
1317
|
-
|
|
1318
|
-
if not unlock_token_wallet(
|
|
1229
|
+
hs = HiveSigner(blockchain_instance=hv)
|
|
1230
|
+
if not unlock_token_wallet(hv, hs):
|
|
1319
1231
|
return
|
|
1320
|
-
for name in
|
|
1321
|
-
ret =
|
|
1232
|
+
for name in hs.getPublicNames():
|
|
1233
|
+
ret = hs.me(username=name)
|
|
1322
1234
|
if "error" in ret:
|
|
1323
1235
|
t.add_row([name, "-", ret["error"]])
|
|
1324
1236
|
else:
|
|
@@ -1345,14 +1257,14 @@ def listaccounts(role, max_account_index, max_sequence):
|
|
|
1345
1257
|
|
|
1346
1258
|
Can be used with the ledger to obtain all accounts that uses pubkeys derived from this ledger
|
|
1347
1259
|
"""
|
|
1348
|
-
|
|
1349
|
-
if
|
|
1350
|
-
|
|
1260
|
+
hv = shared_blockchain_instance()
|
|
1261
|
+
if hv.rpc is not None:
|
|
1262
|
+
hv.rpc.rpcconnect()
|
|
1351
1263
|
|
|
1352
|
-
if
|
|
1264
|
+
if hv.use_ledger:
|
|
1353
1265
|
t = PrettyTable(["Name", "Type", "Available Key", "Path"])
|
|
1354
1266
|
t.align = "l"
|
|
1355
|
-
ledgertx =
|
|
1267
|
+
ledgertx = hv.new_tx()
|
|
1356
1268
|
ledgertx.constructTx()
|
|
1357
1269
|
key_found = False
|
|
1358
1270
|
path = None
|
|
@@ -1365,7 +1277,7 @@ def listaccounts(role, max_account_index, max_sequence):
|
|
|
1365
1277
|
for perm in role_list:
|
|
1366
1278
|
path = ledgertx.ledgertx.build_path(perm, current_account_index, current_key_index)
|
|
1367
1279
|
current_pubkey = ledgertx.ledgertx.get_pubkey(path)
|
|
1368
|
-
account =
|
|
1280
|
+
account = hv.wallet.getAccountFromPublicKey(str(current_pubkey))
|
|
1369
1281
|
if account is not None:
|
|
1370
1282
|
t.add_row([str(account), perm, str(current_pubkey), path])
|
|
1371
1283
|
if current_key_index < max_sequence:
|
|
@@ -1376,7 +1288,7 @@ def listaccounts(role, max_account_index, max_sequence):
|
|
|
1376
1288
|
else:
|
|
1377
1289
|
t = PrettyTable(["Name", "Type", "Available Key"])
|
|
1378
1290
|
t.align = "l"
|
|
1379
|
-
for account in
|
|
1291
|
+
for account in hv.wallet.getAccounts():
|
|
1380
1292
|
t.add_row([account["name"] or "n/a", account["type"] or "n/a", account["pubkey"]])
|
|
1381
1293
|
print(t)
|
|
1382
1294
|
|
|
@@ -1391,11 +1303,11 @@ def upvote(post, account, weight, export):
|
|
|
1391
1303
|
|
|
1392
1304
|
POST is @author/permlink
|
|
1393
1305
|
"""
|
|
1394
|
-
|
|
1395
|
-
if
|
|
1396
|
-
|
|
1306
|
+
hv = shared_blockchain_instance()
|
|
1307
|
+
if hv.rpc is not None:
|
|
1308
|
+
hv.rpc.rpcconnect()
|
|
1397
1309
|
if not weight:
|
|
1398
|
-
weight =
|
|
1310
|
+
weight = hv.config["default_vote_weight"]
|
|
1399
1311
|
else:
|
|
1400
1312
|
weight = float(weight)
|
|
1401
1313
|
if weight > 100:
|
|
@@ -1404,16 +1316,14 @@ def upvote(post, account, weight, export):
|
|
|
1404
1316
|
raise ValueError("Minimum vote weight is 0!")
|
|
1405
1317
|
|
|
1406
1318
|
if not account:
|
|
1407
|
-
account =
|
|
1408
|
-
if not unlock_wallet(
|
|
1319
|
+
account = hv.config["default_account"]
|
|
1320
|
+
if not unlock_wallet(hv):
|
|
1409
1321
|
return
|
|
1410
1322
|
try:
|
|
1411
|
-
post = Comment(post, blockchain_instance=
|
|
1323
|
+
post = Comment(post, blockchain_instance=hv)
|
|
1412
1324
|
tx = post.upvote(weight, voter=account)
|
|
1413
|
-
if
|
|
1414
|
-
tx =
|
|
1415
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1416
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1325
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1326
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1417
1327
|
except exceptions.VotingInvalidOnArchivedPost:
|
|
1418
1328
|
print("Post/Comment is older than 7 days! Did not upvote.")
|
|
1419
1329
|
tx = {}
|
|
@@ -1431,21 +1341,19 @@ def delete(post, account, export):
|
|
|
1431
1341
|
|
|
1432
1342
|
POST is @author/permlink
|
|
1433
1343
|
"""
|
|
1434
|
-
|
|
1435
|
-
if
|
|
1436
|
-
|
|
1344
|
+
hv = shared_blockchain_instance()
|
|
1345
|
+
if hv.rpc is not None:
|
|
1346
|
+
hv.rpc.rpcconnect()
|
|
1437
1347
|
|
|
1438
1348
|
if not account:
|
|
1439
|
-
account =
|
|
1440
|
-
if not unlock_wallet(
|
|
1349
|
+
account = hv.config["default_account"]
|
|
1350
|
+
if not unlock_wallet(hv):
|
|
1441
1351
|
return
|
|
1442
1352
|
try:
|
|
1443
|
-
post = Comment(post, blockchain_instance=
|
|
1353
|
+
post = Comment(post, blockchain_instance=hv)
|
|
1444
1354
|
tx = post.delete(account=account)
|
|
1445
|
-
if
|
|
1446
|
-
tx =
|
|
1447
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1448
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1355
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1356
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1449
1357
|
except exceptions.VotingInvalidOnArchivedPost:
|
|
1450
1358
|
print("Could not delete post.")
|
|
1451
1359
|
tx = {}
|
|
@@ -1464,9 +1372,9 @@ def downvote(post, account, weight, export):
|
|
|
1464
1372
|
|
|
1465
1373
|
POST is @author/permlink
|
|
1466
1374
|
"""
|
|
1467
|
-
|
|
1468
|
-
if
|
|
1469
|
-
|
|
1375
|
+
hv = shared_blockchain_instance()
|
|
1376
|
+
if hv.rpc is not None:
|
|
1377
|
+
hv.rpc.rpcconnect()
|
|
1470
1378
|
|
|
1471
1379
|
weight = float(weight)
|
|
1472
1380
|
if weight > 100:
|
|
@@ -1475,16 +1383,14 @@ def downvote(post, account, weight, export):
|
|
|
1475
1383
|
raise ValueError("Minimum downvote weight is 0!")
|
|
1476
1384
|
|
|
1477
1385
|
if not account:
|
|
1478
|
-
account =
|
|
1479
|
-
if not unlock_wallet(
|
|
1386
|
+
account = hv.config["default_account"]
|
|
1387
|
+
if not unlock_wallet(hv):
|
|
1480
1388
|
return
|
|
1481
1389
|
try:
|
|
1482
|
-
post = Comment(post, blockchain_instance=
|
|
1390
|
+
post = Comment(post, blockchain_instance=hv)
|
|
1483
1391
|
tx = post.downvote(weight, voter=account)
|
|
1484
|
-
if
|
|
1485
|
-
tx =
|
|
1486
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1487
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1392
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1393
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1488
1394
|
except exceptions.VotingInvalidOnArchivedPost:
|
|
1489
1395
|
print("Post/Comment is older than 7 days! Did not downvote.")
|
|
1490
1396
|
tx = {}
|
|
@@ -1501,22 +1407,20 @@ def downvote(post, account, weight, export):
|
|
|
1501
1407
|
@click.option("--account", "-a", help="Transfer from this account")
|
|
1502
1408
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
1503
1409
|
def transfer(to, amount, asset, memo, account, export):
|
|
1504
|
-
"""Transfer
|
|
1505
|
-
|
|
1506
|
-
if
|
|
1507
|
-
|
|
1410
|
+
"""Transfer HBD or HIVE"""
|
|
1411
|
+
hv = shared_blockchain_instance()
|
|
1412
|
+
if hv.rpc is not None:
|
|
1413
|
+
hv.rpc.rpcconnect()
|
|
1508
1414
|
if not account:
|
|
1509
|
-
account =
|
|
1415
|
+
account = hv.config["default_account"]
|
|
1510
1416
|
if not bool(memo):
|
|
1511
1417
|
memo = ""
|
|
1512
|
-
if not unlock_wallet(
|
|
1418
|
+
if not unlock_wallet(hv):
|
|
1513
1419
|
return
|
|
1514
|
-
acc = Account(account, blockchain_instance=
|
|
1420
|
+
acc = Account(account, blockchain_instance=hv)
|
|
1515
1421
|
tx = acc.transfer(to, amount, asset, memo)
|
|
1516
|
-
if
|
|
1517
|
-
tx =
|
|
1518
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1519
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1422
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1423
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1520
1424
|
export_trx(tx, export)
|
|
1521
1425
|
tx = json.dumps(tx, indent=4)
|
|
1522
1426
|
print(tx)
|
|
@@ -1528,24 +1432,22 @@ def transfer(to, amount, asset, memo, account, export):
|
|
|
1528
1432
|
@click.option("--to", "-t", help="Powerup this account", default=None)
|
|
1529
1433
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
1530
1434
|
def powerup(amount, account, to, export):
|
|
1531
|
-
"""Power up (vest
|
|
1532
|
-
|
|
1533
|
-
if
|
|
1534
|
-
|
|
1435
|
+
"""Power up (vest HIVE into Hive Power)"""
|
|
1436
|
+
hv = shared_blockchain_instance()
|
|
1437
|
+
if hv.rpc is not None:
|
|
1438
|
+
hv.rpc.rpcconnect()
|
|
1535
1439
|
if not account:
|
|
1536
|
-
account =
|
|
1537
|
-
if not unlock_wallet(
|
|
1440
|
+
account = hv.config["default_account"]
|
|
1441
|
+
if not unlock_wallet(hv):
|
|
1538
1442
|
return
|
|
1539
|
-
acc = Account(account, blockchain_instance=
|
|
1443
|
+
acc = Account(account, blockchain_instance=hv)
|
|
1540
1444
|
try:
|
|
1541
1445
|
amount = float(amount)
|
|
1542
1446
|
except Exception:
|
|
1543
1447
|
amount = str(amount)
|
|
1544
1448
|
tx = acc.transfer_to_vesting(amount, to=to)
|
|
1545
|
-
if
|
|
1546
|
-
tx =
|
|
1547
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1548
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1449
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1450
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1549
1451
|
export_trx(tx, export)
|
|
1550
1452
|
tx = json.dumps(tx, indent=4)
|
|
1551
1453
|
print(tx)
|
|
@@ -1556,27 +1458,25 @@ def powerup(amount, account, to, export):
|
|
|
1556
1458
|
@click.option("--account", "-a", help="Powerup from this account")
|
|
1557
1459
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
1558
1460
|
def powerdown(amount, account, export):
|
|
1559
|
-
"""Power down (start withdrawing VESTS from
|
|
1461
|
+
"""Power down (start withdrawing VESTS from Hive Power)
|
|
1560
1462
|
|
|
1561
1463
|
amount is in VESTS
|
|
1562
1464
|
"""
|
|
1563
|
-
|
|
1564
|
-
if
|
|
1565
|
-
|
|
1465
|
+
hv = shared_blockchain_instance()
|
|
1466
|
+
if hv.rpc is not None:
|
|
1467
|
+
hv.rpc.rpcconnect()
|
|
1566
1468
|
if not account:
|
|
1567
|
-
account =
|
|
1568
|
-
if not unlock_wallet(
|
|
1469
|
+
account = hv.config["default_account"]
|
|
1470
|
+
if not unlock_wallet(hv):
|
|
1569
1471
|
return
|
|
1570
|
-
acc = Account(account, blockchain_instance=
|
|
1472
|
+
acc = Account(account, blockchain_instance=hv)
|
|
1571
1473
|
try:
|
|
1572
1474
|
amount = float(amount)
|
|
1573
1475
|
except Exception:
|
|
1574
1476
|
amount = str(amount)
|
|
1575
1477
|
tx = acc.withdraw_vesting(amount)
|
|
1576
|
-
if
|
|
1577
|
-
tx =
|
|
1578
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1579
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1478
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1479
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1580
1480
|
export_trx(tx, export)
|
|
1581
1481
|
tx = json.dumps(tx, indent=4)
|
|
1582
1482
|
print(tx)
|
|
@@ -1590,30 +1490,27 @@ def powerdown(amount, account, export):
|
|
|
1590
1490
|
def delegate(amount, to_account, account, export):
|
|
1591
1491
|
"""Delegate (start delegating VESTS to another account)
|
|
1592
1492
|
|
|
1593
|
-
amount is in VESTS /
|
|
1493
|
+
amount is in VESTS / HIVE Power
|
|
1594
1494
|
"""
|
|
1595
|
-
|
|
1596
|
-
if
|
|
1597
|
-
|
|
1495
|
+
hv = shared_blockchain_instance()
|
|
1496
|
+
if hv.rpc is not None:
|
|
1497
|
+
hv.rpc.rpcconnect()
|
|
1598
1498
|
if not account:
|
|
1599
|
-
account =
|
|
1600
|
-
if not unlock_wallet(
|
|
1499
|
+
account = hv.config["default_account"]
|
|
1500
|
+
if not unlock_wallet(hv):
|
|
1601
1501
|
return
|
|
1602
|
-
acc = Account(account, blockchain_instance=
|
|
1603
|
-
|
|
1604
|
-
amount =
|
|
1605
|
-
|
|
1606
|
-
amount = Amount(
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
amount = stm.hp_to_vests(float(amount))
|
|
1502
|
+
acc = Account(account, blockchain_instance=hv)
|
|
1503
|
+
if hv.token_symbol is not None:
|
|
1504
|
+
amount = Amount(amount, blockchain_instance=hv)
|
|
1505
|
+
else:
|
|
1506
|
+
amount = Amount(amount, blockchain_instance=hv)
|
|
1507
|
+
if isinstance(amount, Amount):
|
|
1508
|
+
if amount.symbol == hv.token_symbol:
|
|
1509
|
+
amount = hv.hp_to_vests(float(amount))
|
|
1611
1510
|
|
|
1612
1511
|
tx = acc.delegate_vesting_shares(to_account, amount)
|
|
1613
|
-
if
|
|
1614
|
-
tx =
|
|
1615
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1616
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1512
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1513
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1617
1514
|
export_trx(tx, export)
|
|
1618
1515
|
tx = json.dumps(tx, indent=4)
|
|
1619
1516
|
print(tx)
|
|
@@ -1627,13 +1524,13 @@ def listdelegations(account):
|
|
|
1627
1524
|
The default account is used if no other account name is given as
|
|
1628
1525
|
option to this command.
|
|
1629
1526
|
"""
|
|
1630
|
-
|
|
1631
|
-
if
|
|
1632
|
-
|
|
1527
|
+
hv = shared_blockchain_instance()
|
|
1528
|
+
if hv.rpc is not None:
|
|
1529
|
+
hv.rpc.rpcconnect()
|
|
1633
1530
|
if not account:
|
|
1634
|
-
account =
|
|
1635
|
-
acc = Account(account, blockchain_instance=
|
|
1636
|
-
pt = PrettyTable(["Delegatee",
|
|
1531
|
+
account = hv.config["default_account"]
|
|
1532
|
+
acc = Account(account, blockchain_instance=hv)
|
|
1533
|
+
pt = PrettyTable(["Delegatee", hv.vests_symbol, "%s Power" % (hv.token_symbol)])
|
|
1637
1534
|
pt.align = "r"
|
|
1638
1535
|
start_account = ""
|
|
1639
1536
|
limit = 100
|
|
@@ -1646,8 +1543,8 @@ def listdelegations(account):
|
|
|
1646
1543
|
# skip first entry if it was already part of the previous call
|
|
1647
1544
|
delegations = delegations[1:]
|
|
1648
1545
|
for deleg in delegations:
|
|
1649
|
-
vests = Amount(deleg["vesting_shares"], blockchain_instance=
|
|
1650
|
-
token_power = "%.3f" % (
|
|
1546
|
+
vests = Amount(deleg["vesting_shares"], blockchain_instance=hv)
|
|
1547
|
+
token_power = "%.3f" % (hv.vests_to_token_power(vests))
|
|
1651
1548
|
pt.add_row([deleg["delegatee"], str(vests), token_power])
|
|
1652
1549
|
start_account = deleg["delegatee"]
|
|
1653
1550
|
print(pt)
|
|
@@ -1662,25 +1559,23 @@ def listdelegations(account):
|
|
|
1662
1559
|
@click.option(
|
|
1663
1560
|
"--auto_vest",
|
|
1664
1561
|
help="Set to true if the from account should receive the VESTS as"
|
|
1665
|
-
"VESTS, or false if it should receive them as
|
|
1562
|
+
"VESTS, or false if it should receive them as HIVE.",
|
|
1666
1563
|
is_flag=True,
|
|
1667
1564
|
)
|
|
1668
1565
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
1669
1566
|
def powerdownroute(to, percentage, account, auto_vest, export):
|
|
1670
1567
|
"""Setup a powerdown route"""
|
|
1671
|
-
|
|
1672
|
-
if
|
|
1673
|
-
|
|
1568
|
+
hv = shared_blockchain_instance()
|
|
1569
|
+
if hv.rpc is not None:
|
|
1570
|
+
hv.rpc.rpcconnect()
|
|
1674
1571
|
if not account:
|
|
1675
|
-
account =
|
|
1676
|
-
if not unlock_wallet(
|
|
1572
|
+
account = hv.config["default_account"]
|
|
1573
|
+
if not unlock_wallet(hv):
|
|
1677
1574
|
return
|
|
1678
|
-
acc = Account(account, blockchain_instance=
|
|
1575
|
+
acc = Account(account, blockchain_instance=hv)
|
|
1679
1576
|
tx = acc.set_withdraw_vesting_route(to, percentage, auto_vest=auto_vest)
|
|
1680
|
-
if
|
|
1681
|
-
tx =
|
|
1682
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1683
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1577
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1578
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1684
1579
|
export_trx(tx, export)
|
|
1685
1580
|
tx = json.dumps(tx, indent=4)
|
|
1686
1581
|
print(tx)
|
|
@@ -1692,15 +1587,15 @@ def powerdownroute(to, percentage, account, auto_vest, export):
|
|
|
1692
1587
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
1693
1588
|
def changerecovery(new_recovery_account, account, export):
|
|
1694
1589
|
"""Changes the recovery account with the owner key (needs 30 days to be active)"""
|
|
1695
|
-
|
|
1696
|
-
if
|
|
1697
|
-
|
|
1590
|
+
hv = shared_blockchain_instance()
|
|
1591
|
+
if hv.rpc is not None:
|
|
1592
|
+
hv.rpc.rpcconnect()
|
|
1698
1593
|
if not account:
|
|
1699
|
-
account =
|
|
1700
|
-
# if not unlock_wallet(
|
|
1594
|
+
account = hv.config["default_account"]
|
|
1595
|
+
# if not unlock_wallet(hv):
|
|
1701
1596
|
# return
|
|
1702
|
-
new_recovery_account = Account(new_recovery_account, blockchain_instance=
|
|
1703
|
-
account = Account(account, blockchain_instance=
|
|
1597
|
+
new_recovery_account = Account(new_recovery_account, blockchain_instance=hv)
|
|
1598
|
+
account = Account(account, blockchain_instance=hv)
|
|
1704
1599
|
op = operations.Change_recovery_account(
|
|
1705
1600
|
**{
|
|
1706
1601
|
"account_to_recover": account["name"],
|
|
@@ -1709,9 +1604,9 @@ def changerecovery(new_recovery_account, account, export):
|
|
|
1709
1604
|
}
|
|
1710
1605
|
)
|
|
1711
1606
|
|
|
1712
|
-
tb = TransactionBuilder(blockchain_instance=
|
|
1607
|
+
tb = TransactionBuilder(blockchain_instance=hv)
|
|
1713
1608
|
tb.appendOps([op])
|
|
1714
|
-
if
|
|
1609
|
+
if hv.unsigned:
|
|
1715
1610
|
tb.addSigningInformation(account["name"], "owner")
|
|
1716
1611
|
tx = tb
|
|
1717
1612
|
else:
|
|
@@ -1722,10 +1617,8 @@ def changerecovery(new_recovery_account, account, export):
|
|
|
1722
1617
|
tb.appendWif(str(owner_key))
|
|
1723
1618
|
tb.sign()
|
|
1724
1619
|
tx = tb.broadcast()
|
|
1725
|
-
if
|
|
1726
|
-
tx =
|
|
1727
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1728
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1620
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1621
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1729
1622
|
export_trx(tx, export)
|
|
1730
1623
|
tx = json.dumps(tx, indent=4)
|
|
1731
1624
|
print(tx)
|
|
@@ -1736,24 +1629,22 @@ def changerecovery(new_recovery_account, account, export):
|
|
|
1736
1629
|
@click.option("--account", "-a", help="Powerup from this account")
|
|
1737
1630
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
1738
1631
|
def convert(amount, account, export):
|
|
1739
|
-
"""Convert
|
|
1740
|
-
|
|
1741
|
-
if
|
|
1742
|
-
|
|
1632
|
+
"""Convert HBD to HIVE (takes ~1 week to settle)"""
|
|
1633
|
+
hv = shared_blockchain_instance()
|
|
1634
|
+
if hv.rpc is not None:
|
|
1635
|
+
hv.rpc.rpcconnect()
|
|
1743
1636
|
if not account:
|
|
1744
|
-
account =
|
|
1745
|
-
if not unlock_wallet(
|
|
1637
|
+
account = hv.config["default_account"]
|
|
1638
|
+
if not unlock_wallet(hv):
|
|
1746
1639
|
return
|
|
1747
|
-
acc = Account(account, blockchain_instance=
|
|
1640
|
+
acc = Account(account, blockchain_instance=hv)
|
|
1748
1641
|
try:
|
|
1749
1642
|
amount = float(amount)
|
|
1750
1643
|
except Exception:
|
|
1751
1644
|
amount = str(amount)
|
|
1752
1645
|
tx = acc.convert(amount)
|
|
1753
|
-
if
|
|
1754
|
-
tx =
|
|
1755
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
1756
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
1646
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
1647
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
1757
1648
|
export_trx(tx, export)
|
|
1758
1649
|
tx = json.dumps(tx, indent=4)
|
|
1759
1650
|
print(tx)
|
|
@@ -1762,17 +1653,17 @@ def convert(amount, account, export):
|
|
|
1762
1653
|
@cli.command()
|
|
1763
1654
|
def changewalletpassphrase():
|
|
1764
1655
|
"""Change wallet password"""
|
|
1765
|
-
|
|
1766
|
-
if
|
|
1767
|
-
|
|
1768
|
-
if not unlock_wallet(
|
|
1656
|
+
hv = shared_blockchain_instance()
|
|
1657
|
+
if hv.rpc is not None:
|
|
1658
|
+
hv.rpc.rpcconnect()
|
|
1659
|
+
if not unlock_wallet(hv, allow_wif=False):
|
|
1769
1660
|
return
|
|
1770
1661
|
newpassword = None
|
|
1771
1662
|
newpassword = click.prompt("New wallet password", confirmation_prompt=True, hide_input=True)
|
|
1772
1663
|
if not bool(newpassword):
|
|
1773
1664
|
print("Password cannot be empty! Quitting...")
|
|
1774
1665
|
return
|
|
1775
|
-
password_storage =
|
|
1666
|
+
password_storage = hv.config["password_storage"]
|
|
1776
1667
|
if password_storage == "keyring" and is_keyring_available():
|
|
1777
1668
|
import keyring
|
|
1778
1669
|
|
|
@@ -1781,21 +1672,21 @@ def changewalletpassphrase():
|
|
|
1781
1672
|
print(
|
|
1782
1673
|
"The new wallet password can be stored in the UNLOCK invironment variable to skip password prompt!"
|
|
1783
1674
|
)
|
|
1784
|
-
|
|
1675
|
+
hv.wallet.changePassphrase(newpassword)
|
|
1785
1676
|
|
|
1786
1677
|
|
|
1787
1678
|
@cli.command()
|
|
1788
1679
|
@click.argument("account", nargs=-1)
|
|
1789
1680
|
def power(account):
|
|
1790
1681
|
"""Shows vote power and bandwidth"""
|
|
1791
|
-
|
|
1792
|
-
if
|
|
1793
|
-
|
|
1682
|
+
hv = shared_blockchain_instance()
|
|
1683
|
+
if hv.rpc is not None:
|
|
1684
|
+
hv.rpc.rpcconnect()
|
|
1794
1685
|
if len(account) == 0:
|
|
1795
|
-
if "default_account" in
|
|
1796
|
-
account = [
|
|
1686
|
+
if "default_account" in hv.config:
|
|
1687
|
+
account = [hv.config["default_account"]]
|
|
1797
1688
|
for name in account:
|
|
1798
|
-
a = Account(name, blockchain_instance=
|
|
1689
|
+
a = Account(name, blockchain_instance=hv)
|
|
1799
1690
|
print("\n@%s" % a.name)
|
|
1800
1691
|
a.print_info(use_table=True)
|
|
1801
1692
|
|
|
@@ -1804,16 +1695,16 @@ def power(account):
|
|
|
1804
1695
|
@click.argument("account", nargs=-1)
|
|
1805
1696
|
def balance(account):
|
|
1806
1697
|
"""Shows balance"""
|
|
1807
|
-
|
|
1808
|
-
if
|
|
1809
|
-
|
|
1698
|
+
hv = shared_blockchain_instance()
|
|
1699
|
+
if hv.rpc is not None:
|
|
1700
|
+
hv.rpc.rpcconnect()
|
|
1810
1701
|
if len(account) == 0:
|
|
1811
|
-
if "default_account" in
|
|
1812
|
-
account = [
|
|
1702
|
+
if "default_account" in hv.config:
|
|
1703
|
+
account = [hv.config["default_account"]]
|
|
1813
1704
|
for name in account:
|
|
1814
|
-
a = Account(name, blockchain_instance=
|
|
1705
|
+
a = Account(name, blockchain_instance=hv)
|
|
1815
1706
|
print("\n@%s" % a.name)
|
|
1816
|
-
t = PrettyTable(["Account",
|
|
1707
|
+
t = PrettyTable(["Account", hv.token_symbol, hv.backed_token_symbol, "VESTS"])
|
|
1817
1708
|
t.align = "r"
|
|
1818
1709
|
t.add_row(
|
|
1819
1710
|
[
|
|
@@ -1854,19 +1745,19 @@ def balance(account):
|
|
|
1854
1745
|
@click.argument("account", nargs=-1, required=False)
|
|
1855
1746
|
def interest(account):
|
|
1856
1747
|
"""Get information about interest payment"""
|
|
1857
|
-
|
|
1858
|
-
if
|
|
1859
|
-
|
|
1748
|
+
hv = shared_blockchain_instance()
|
|
1749
|
+
if hv.rpc is not None:
|
|
1750
|
+
hv.rpc.rpcconnect()
|
|
1860
1751
|
if not account:
|
|
1861
|
-
if "default_account" in
|
|
1862
|
-
account = [
|
|
1752
|
+
if "default_account" in hv.config:
|
|
1753
|
+
account = [hv.config["default_account"]]
|
|
1863
1754
|
|
|
1864
1755
|
t = PrettyTable(
|
|
1865
1756
|
["Account", "Last Interest Payment", "Next Payment", "Interest rate", "Interest"]
|
|
1866
1757
|
)
|
|
1867
1758
|
t.align = "r"
|
|
1868
1759
|
for a in account:
|
|
1869
|
-
a = Account(a, blockchain_instance=
|
|
1760
|
+
a = Account(a, blockchain_instance=hv)
|
|
1870
1761
|
i = a.interest()
|
|
1871
1762
|
t.add_row(
|
|
1872
1763
|
[
|
|
@@ -1874,7 +1765,7 @@ def interest(account):
|
|
|
1874
1765
|
i["last_payment"],
|
|
1875
1766
|
"in %s" % (i["next_payment_duration"]),
|
|
1876
1767
|
"%.1f%%" % i["interest_rate"],
|
|
1877
|
-
"%.3f %s" % (i["interest"],
|
|
1768
|
+
"%.3f %s" % (i["interest"], hv.backed_token_symbol),
|
|
1878
1769
|
]
|
|
1879
1770
|
)
|
|
1880
1771
|
print(t)
|
|
@@ -1890,13 +1781,13 @@ def followlist(follow_type, account, limit):
|
|
|
1890
1781
|
follow_type can be blog
|
|
1891
1782
|
On Hive, follow type can also be one the following: blacklisted, follow_blacklist, muted, or follow_muted
|
|
1892
1783
|
"""
|
|
1893
|
-
|
|
1894
|
-
if
|
|
1895
|
-
|
|
1784
|
+
hv = shared_blockchain_instance()
|
|
1785
|
+
if hv.rpc is not None:
|
|
1786
|
+
hv.rpc.rpcconnect()
|
|
1896
1787
|
if not account:
|
|
1897
|
-
if "default_account" in
|
|
1898
|
-
account = [
|
|
1899
|
-
account = Account(account, blockchain_instance=
|
|
1788
|
+
if "default_account" in hv.config:
|
|
1789
|
+
account = [hv.config["default_account"]]
|
|
1790
|
+
account = Account(account, blockchain_instance=hv)
|
|
1900
1791
|
if follow_type == "blog":
|
|
1901
1792
|
name_list = account.get_following(limit=limit)
|
|
1902
1793
|
else:
|
|
@@ -1914,14 +1805,14 @@ def followlist(follow_type, account, limit):
|
|
|
1914
1805
|
@click.argument("account", nargs=-1, required=False)
|
|
1915
1806
|
def follower(account):
|
|
1916
1807
|
"""Get information about followers"""
|
|
1917
|
-
|
|
1918
|
-
if
|
|
1919
|
-
|
|
1808
|
+
hv = shared_blockchain_instance()
|
|
1809
|
+
if hv.rpc is not None:
|
|
1810
|
+
hv.rpc.rpcconnect()
|
|
1920
1811
|
if not account:
|
|
1921
|
-
if "default_account" in
|
|
1922
|
-
account = [
|
|
1812
|
+
if "default_account" in hv.config:
|
|
1813
|
+
account = [hv.config["default_account"]]
|
|
1923
1814
|
for a in account:
|
|
1924
|
-
a = Account(a, blockchain_instance=
|
|
1815
|
+
a = Account(a, blockchain_instance=hv)
|
|
1925
1816
|
print("\nFollowers statistics for @%s (please wait...)" % a.name)
|
|
1926
1817
|
followers = a.get_followers(False)
|
|
1927
1818
|
followers.print_summarize_table(tag_type="Followers")
|
|
@@ -1931,14 +1822,14 @@ def follower(account):
|
|
|
1931
1822
|
@click.argument("account", nargs=-1, required=False)
|
|
1932
1823
|
def following(account):
|
|
1933
1824
|
"""Get information about following"""
|
|
1934
|
-
|
|
1935
|
-
if
|
|
1936
|
-
|
|
1825
|
+
hv = shared_blockchain_instance()
|
|
1826
|
+
if hv.rpc is not None:
|
|
1827
|
+
hv.rpc.rpcconnect()
|
|
1937
1828
|
if not account:
|
|
1938
|
-
if "default_account" in
|
|
1939
|
-
account = [
|
|
1829
|
+
if "default_account" in hv.config:
|
|
1830
|
+
account = [hv.config["default_account"]]
|
|
1940
1831
|
for a in account:
|
|
1941
|
-
a = Account(a, blockchain_instance=
|
|
1832
|
+
a = Account(a, blockchain_instance=hv)
|
|
1942
1833
|
print("\nFollowing statistics for @%s (please wait...)" % a.name)
|
|
1943
1834
|
following = a.get_following(False)
|
|
1944
1835
|
following.print_summarize_table(tag_type="Following")
|
|
@@ -1948,14 +1839,14 @@ def following(account):
|
|
|
1948
1839
|
@click.argument("account", nargs=-1, required=False)
|
|
1949
1840
|
def muter(account):
|
|
1950
1841
|
"""Get information about muter"""
|
|
1951
|
-
|
|
1952
|
-
if
|
|
1953
|
-
|
|
1842
|
+
hv = shared_blockchain_instance()
|
|
1843
|
+
if hv.rpc is not None:
|
|
1844
|
+
hv.rpc.rpcconnect()
|
|
1954
1845
|
if not account:
|
|
1955
|
-
if "default_account" in
|
|
1956
|
-
account = [
|
|
1846
|
+
if "default_account" in hv.config:
|
|
1847
|
+
account = [hv.config["default_account"]]
|
|
1957
1848
|
for a in account:
|
|
1958
|
-
a = Account(a, blockchain_instance=
|
|
1849
|
+
a = Account(a, blockchain_instance=hv)
|
|
1959
1850
|
print("\nMuters statistics for @%s (please wait...)" % a.name)
|
|
1960
1851
|
muters = a.get_muters(False)
|
|
1961
1852
|
muters.print_summarize_table(tag_type="Muters")
|
|
@@ -1965,14 +1856,14 @@ def muter(account):
|
|
|
1965
1856
|
@click.argument("account", nargs=-1, required=False)
|
|
1966
1857
|
def muting(account):
|
|
1967
1858
|
"""Get information about muting"""
|
|
1968
|
-
|
|
1969
|
-
if
|
|
1970
|
-
|
|
1859
|
+
hv = shared_blockchain_instance()
|
|
1860
|
+
if hv.rpc is not None:
|
|
1861
|
+
hv.rpc.rpcconnect()
|
|
1971
1862
|
if not account:
|
|
1972
|
-
if "default_account" in
|
|
1973
|
-
account = [
|
|
1863
|
+
if "default_account" in hv.config:
|
|
1864
|
+
account = [hv.config["default_account"]]
|
|
1974
1865
|
for a in account:
|
|
1975
|
-
a = Account(a, blockchain_instance=
|
|
1866
|
+
a = Account(a, blockchain_instance=hv)
|
|
1976
1867
|
print("\nMuting statistics for @%s (please wait...)" % a.name)
|
|
1977
1868
|
muting = a.get_mutings(False)
|
|
1978
1869
|
muting.print_summarize_table(tag_type="Muting")
|
|
@@ -2007,19 +1898,19 @@ def notifications(
|
|
|
2007
1898
|
account, limit, all, mark_as_read, replies, mentions, follows, votes, reblogs, reverse
|
|
2008
1899
|
):
|
|
2009
1900
|
"""Show notifications of an account"""
|
|
2010
|
-
|
|
2011
|
-
if
|
|
2012
|
-
|
|
1901
|
+
hv = shared_blockchain_instance()
|
|
1902
|
+
if hv.rpc is not None:
|
|
1903
|
+
hv.rpc.rpcconnect()
|
|
2013
1904
|
if account is None or account == "":
|
|
2014
|
-
if "default_account" in
|
|
2015
|
-
account =
|
|
2016
|
-
if mark_as_read and not unlock_wallet(
|
|
1905
|
+
if "default_account" in hv.config:
|
|
1906
|
+
account = hv.config["default_account"]
|
|
1907
|
+
if mark_as_read and not unlock_wallet(hv):
|
|
2017
1908
|
return
|
|
2018
1909
|
if not replies and not mentions and not follows and not votes and not reblogs:
|
|
2019
1910
|
show_all = True
|
|
2020
1911
|
else:
|
|
2021
1912
|
show_all = False
|
|
2022
|
-
account = Account(account, blockchain_instance=
|
|
1913
|
+
account = Account(account, blockchain_instance=hv)
|
|
2023
1914
|
t = PrettyTable(["Date", "Type", "Message"], hrules=0)
|
|
2024
1915
|
t.align = "r"
|
|
2025
1916
|
last_read = None
|
|
@@ -2059,13 +1950,13 @@ def notifications(
|
|
|
2059
1950
|
@click.argument("account", nargs=1, required=False)
|
|
2060
1951
|
def permissions(account):
|
|
2061
1952
|
"""Show permissions of an account"""
|
|
2062
|
-
|
|
2063
|
-
if
|
|
2064
|
-
|
|
1953
|
+
hv = shared_blockchain_instance()
|
|
1954
|
+
if hv.rpc is not None:
|
|
1955
|
+
hv.rpc.rpcconnect()
|
|
2065
1956
|
if not account:
|
|
2066
|
-
if "default_account" in
|
|
2067
|
-
account =
|
|
2068
|
-
account = Account(account, blockchain_instance=
|
|
1957
|
+
if "default_account" in hv.config:
|
|
1958
|
+
account = hv.config["default_account"]
|
|
1959
|
+
account = Account(account, blockchain_instance=hv)
|
|
2069
1960
|
t = PrettyTable(["Permission", "Threshold", "Key/Account"], hrules=0)
|
|
2070
1961
|
t.align = "r"
|
|
2071
1962
|
for permission in ["owner", "active", "posting"]:
|
|
@@ -2109,29 +2000,27 @@ def allow(foreign_account, permission, account, weight, threshold, export):
|
|
|
2109
2000
|
When not given, password will be asked, from which a public key is derived.
|
|
2110
2001
|
This derived key will then interact with your account.
|
|
2111
2002
|
"""
|
|
2112
|
-
|
|
2113
|
-
if
|
|
2114
|
-
|
|
2003
|
+
hv = shared_blockchain_instance()
|
|
2004
|
+
if hv.rpc is not None:
|
|
2005
|
+
hv.rpc.rpcconnect()
|
|
2115
2006
|
if not account:
|
|
2116
|
-
account =
|
|
2117
|
-
if not unlock_wallet(
|
|
2007
|
+
account = hv.config["default_account"]
|
|
2008
|
+
if not unlock_wallet(hv):
|
|
2118
2009
|
return
|
|
2119
2010
|
if permission not in ["posting", "active", "owner"]:
|
|
2120
2011
|
print("Wrong permission, please use: posting, active or owner!")
|
|
2121
2012
|
return
|
|
2122
|
-
acc = Account(account, blockchain_instance=
|
|
2013
|
+
acc = Account(account, blockchain_instance=hv)
|
|
2123
2014
|
if not foreign_account:
|
|
2124
2015
|
from nectargraphenebase.account import PasswordKey
|
|
2125
2016
|
|
|
2126
2017
|
pwd = click.prompt("Password for Key Derivation", confirmation_prompt=True, hide_input=True)
|
|
2127
|
-
foreign_account = format(PasswordKey(account, pwd, permission).get_public(),
|
|
2018
|
+
foreign_account = format(PasswordKey(account, pwd, permission).get_public(), hv.prefix)
|
|
2128
2019
|
if threshold is not None:
|
|
2129
2020
|
threshold = int(threshold)
|
|
2130
2021
|
tx = acc.allow(foreign_account, weight=weight, permission=permission, threshold=threshold)
|
|
2131
|
-
if
|
|
2132
|
-
tx =
|
|
2133
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2134
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2022
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2023
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2135
2024
|
export_trx(tx, export)
|
|
2136
2025
|
tx = json.dumps(tx, indent=4)
|
|
2137
2026
|
print(tx)
|
|
@@ -2151,29 +2040,27 @@ def allow(foreign_account, permission, account, weight, threshold, export):
|
|
|
2151
2040
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
2152
2041
|
def disallow(foreign_account, permission, account, threshold, export):
|
|
2153
2042
|
"""Remove allowance an account/key to interact with your account"""
|
|
2154
|
-
|
|
2155
|
-
if
|
|
2156
|
-
|
|
2043
|
+
hv = shared_blockchain_instance()
|
|
2044
|
+
if hv.rpc is not None:
|
|
2045
|
+
hv.rpc.rpcconnect()
|
|
2157
2046
|
if not account:
|
|
2158
|
-
account =
|
|
2159
|
-
if not unlock_wallet(
|
|
2047
|
+
account = hv.config["default_account"]
|
|
2048
|
+
if not unlock_wallet(hv):
|
|
2160
2049
|
return
|
|
2161
2050
|
if permission not in ["posting", "active", "owner"]:
|
|
2162
2051
|
print("Wrong permission, please use: posting, active or owner!")
|
|
2163
2052
|
return
|
|
2164
2053
|
if threshold is not None:
|
|
2165
2054
|
threshold = int(threshold)
|
|
2166
|
-
acc = Account(account, blockchain_instance=
|
|
2055
|
+
acc = Account(account, blockchain_instance=hv)
|
|
2167
2056
|
if not foreign_account:
|
|
2168
2057
|
from nectargraphenebase.account import PasswordKey
|
|
2169
2058
|
|
|
2170
2059
|
pwd = click.prompt("Password for Key Derivation", confirmation_prompt=True)
|
|
2171
|
-
foreign_account = [format(PasswordKey(account, pwd, permission).get_public(),
|
|
2060
|
+
foreign_account = [format(PasswordKey(account, pwd, permission).get_public(), hv.prefix)]
|
|
2172
2061
|
tx = acc.disallow(foreign_account, permission=permission, threshold=threshold)
|
|
2173
|
-
if
|
|
2174
|
-
tx =
|
|
2175
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2176
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2062
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2063
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2177
2064
|
export_trx(tx, export)
|
|
2178
2065
|
tx = json.dumps(tx, indent=4)
|
|
2179
2066
|
print(tx)
|
|
@@ -2189,7 +2076,7 @@ def disallow(foreign_account, permission, account, threshold, export):
|
|
|
2189
2076
|
@click.option(
|
|
2190
2077
|
"--number",
|
|
2191
2078
|
"-n",
|
|
2192
|
-
help="Number of subsidized accounts to be claimed (default = 1), when fee = 0
|
|
2079
|
+
help="Number of subsidized accounts to be claimed (default = 1), when fee = 0 HIVE",
|
|
2193
2080
|
default=1,
|
|
2194
2081
|
)
|
|
2195
2082
|
@click.option(
|
|
@@ -2199,24 +2086,21 @@ def disallow(foreign_account, permission, account, threshold, export):
|
|
|
2199
2086
|
)
|
|
2200
2087
|
def claimaccount(creator, fee, number, export):
|
|
2201
2088
|
"""Claim account for claimed account creation."""
|
|
2202
|
-
|
|
2203
|
-
if
|
|
2204
|
-
|
|
2089
|
+
hv = shared_blockchain_instance()
|
|
2090
|
+
if hv.rpc is not None:
|
|
2091
|
+
hv.rpc.rpcconnect()
|
|
2205
2092
|
if not creator:
|
|
2206
|
-
creator =
|
|
2207
|
-
if not unlock_wallet(
|
|
2093
|
+
creator = hv.config["default_account"]
|
|
2094
|
+
if not unlock_wallet(hv):
|
|
2208
2095
|
return
|
|
2209
|
-
creator = Account(creator, blockchain_instance=
|
|
2210
|
-
fee = Amount("%.3f %s" % (float(fee),
|
|
2096
|
+
creator = Account(creator, blockchain_instance=hv)
|
|
2097
|
+
fee = Amount("%.3f %s" % (float(fee), hv.token_symbol), blockchain_instance=hv)
|
|
2211
2098
|
tx = None
|
|
2212
|
-
if
|
|
2213
|
-
tx =
|
|
2214
|
-
tx =
|
|
2215
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2216
|
-
tx = stm.claim_account(creator, fee=fee)
|
|
2217
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2099
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2100
|
+
tx = hv.claim_account(creator, fee=fee)
|
|
2101
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2218
2102
|
elif float(fee) == 0:
|
|
2219
|
-
rc = RC(blockchain_instance=
|
|
2103
|
+
rc = RC(blockchain_instance=hv)
|
|
2220
2104
|
current_costs = rc.claim_account(tx_size=200)
|
|
2221
2105
|
current_mana = creator.get_rc_manabar()["current_mana"]
|
|
2222
2106
|
last_mana = current_mana
|
|
@@ -2235,7 +2119,7 @@ def claimaccount(creator, fee, number, export):
|
|
|
2235
2119
|
tx = json.dumps(tx, indent=4)
|
|
2236
2120
|
print(tx)
|
|
2237
2121
|
cnt += 1
|
|
2238
|
-
tx =
|
|
2122
|
+
tx = hv.claim_account(creator, fee=fee)
|
|
2239
2123
|
time.sleep(10)
|
|
2240
2124
|
creator.refresh()
|
|
2241
2125
|
current_mana = creator.get_rc_manabar()["current_mana"]
|
|
@@ -2244,7 +2128,7 @@ def claimaccount(creator, fee, number, export):
|
|
|
2244
2128
|
if cnt == 0:
|
|
2245
2129
|
print("Not enough RC for a claim!")
|
|
2246
2130
|
else:
|
|
2247
|
-
tx =
|
|
2131
|
+
tx = hv.claim_account(creator, fee=fee)
|
|
2248
2132
|
if tx is not None:
|
|
2249
2133
|
export_trx(tx, export)
|
|
2250
2134
|
tx = json.dumps(tx, indent=4)
|
|
@@ -2271,10 +2155,10 @@ def changekeys(account, owner, active, posting, memo, import_pub, export):
|
|
|
2271
2155
|
"""Changes all keys for the specified account
|
|
2272
2156
|
Keys are given in their public form.
|
|
2273
2157
|
Asks for the owner key for broadcasting the op to the chain."""
|
|
2274
|
-
|
|
2275
|
-
if
|
|
2276
|
-
|
|
2277
|
-
account = Account(account, blockchain_instance=
|
|
2158
|
+
hv = shared_blockchain_instance()
|
|
2159
|
+
if hv.rpc is not None:
|
|
2160
|
+
hv.rpc.rpcconnect()
|
|
2161
|
+
account = Account(account, blockchain_instance=hv)
|
|
2278
2162
|
|
|
2279
2163
|
if import_pub and import_pub != "":
|
|
2280
2164
|
owner, active, posting, memo = import_pubkeys(import_pub)
|
|
@@ -2298,13 +2182,13 @@ def changekeys(account, owner, active, posting, memo, import_pub, export):
|
|
|
2298
2182
|
t.add_row(["new posting pubkey", str(posting)])
|
|
2299
2183
|
t.add_row(["new memo pubkey", str(memo)])
|
|
2300
2184
|
print(t)
|
|
2301
|
-
if not
|
|
2185
|
+
if not hv.unsigned:
|
|
2302
2186
|
wif = click.prompt(
|
|
2303
2187
|
"Owner key for %s" % account["name"], confirmation_prompt=False, hide_input=True
|
|
2304
2188
|
)
|
|
2305
|
-
|
|
2189
|
+
hv.wallet.setKeys([wif])
|
|
2306
2190
|
|
|
2307
|
-
tx =
|
|
2191
|
+
tx = hv.update_account(
|
|
2308
2192
|
account,
|
|
2309
2193
|
owner_key=owner,
|
|
2310
2194
|
active_key=active,
|
|
@@ -2312,10 +2196,8 @@ def changekeys(account, owner, active, posting, memo, import_pub, export):
|
|
|
2312
2196
|
memo_key=memo,
|
|
2313
2197
|
password=None,
|
|
2314
2198
|
)
|
|
2315
|
-
if
|
|
2316
|
-
tx =
|
|
2317
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2318
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2199
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2200
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2319
2201
|
export_trx(tx, export)
|
|
2320
2202
|
tx = json.dumps(tx, indent=4)
|
|
2321
2203
|
print(tx)
|
|
@@ -2369,18 +2251,18 @@ def newaccount(
|
|
|
2369
2251
|
|
|
2370
2252
|
Please use keygen and set public keys
|
|
2371
2253
|
"""
|
|
2372
|
-
|
|
2373
|
-
if
|
|
2374
|
-
|
|
2254
|
+
hv = shared_blockchain_instance()
|
|
2255
|
+
if hv.rpc is not None:
|
|
2256
|
+
hv.rpc.rpcconnect()
|
|
2375
2257
|
if not account:
|
|
2376
|
-
account =
|
|
2377
|
-
if not unlock_wallet(
|
|
2258
|
+
account = hv.config["default_account"]
|
|
2259
|
+
if not unlock_wallet(hv):
|
|
2378
2260
|
return
|
|
2379
|
-
acc = Account(account, blockchain_instance=
|
|
2261
|
+
acc = Account(account, blockchain_instance=hv)
|
|
2380
2262
|
if import_pub and import_pub != "":
|
|
2381
2263
|
owner, active, posting, memo = import_pubkeys(import_pub)
|
|
2382
2264
|
if create_claimed_account:
|
|
2383
|
-
tx =
|
|
2265
|
+
tx = hv.create_claimed_account(
|
|
2384
2266
|
accountname,
|
|
2385
2267
|
creator=acc,
|
|
2386
2268
|
owner_key=owner,
|
|
@@ -2389,7 +2271,7 @@ def newaccount(
|
|
|
2389
2271
|
posting_key=posting,
|
|
2390
2272
|
)
|
|
2391
2273
|
else:
|
|
2392
|
-
tx =
|
|
2274
|
+
tx = hv.create_account(
|
|
2393
2275
|
accountname,
|
|
2394
2276
|
creator=acc,
|
|
2395
2277
|
owner_key=owner,
|
|
@@ -2408,12 +2290,12 @@ def newaccount(
|
|
|
2408
2290
|
return
|
|
2409
2291
|
password = generate_password(import_password, wif)
|
|
2410
2292
|
if create_claimed_account:
|
|
2411
|
-
tx =
|
|
2293
|
+
tx = hv.create_claimed_account(accountname, creator=acc, password=password)
|
|
2412
2294
|
else:
|
|
2413
|
-
tx =
|
|
2295
|
+
tx = hv.create_account(accountname, creator=acc, password=password)
|
|
2414
2296
|
else:
|
|
2415
2297
|
if create_claimed_account:
|
|
2416
|
-
tx =
|
|
2298
|
+
tx = hv.create_claimed_account(
|
|
2417
2299
|
accountname,
|
|
2418
2300
|
creator=acc,
|
|
2419
2301
|
owner_key=owner,
|
|
@@ -2422,7 +2304,7 @@ def newaccount(
|
|
|
2422
2304
|
posting_key=posting,
|
|
2423
2305
|
)
|
|
2424
2306
|
else:
|
|
2425
|
-
tx =
|
|
2307
|
+
tx = hv.create_account(
|
|
2426
2308
|
accountname,
|
|
2427
2309
|
creator=acc,
|
|
2428
2310
|
owner_key=owner,
|
|
@@ -2430,10 +2312,8 @@ def newaccount(
|
|
|
2430
2312
|
memo_key=memo,
|
|
2431
2313
|
posting_key=posting,
|
|
2432
2314
|
)
|
|
2433
|
-
if
|
|
2434
|
-
tx =
|
|
2435
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2436
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2315
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2316
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2437
2317
|
export_trx(tx, export)
|
|
2438
2318
|
tx = json.dumps(tx, indent=4)
|
|
2439
2319
|
print(tx)
|
|
@@ -2447,9 +2327,9 @@ def newaccount(
|
|
|
2447
2327
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
2448
2328
|
def setprofile(variable, value, account, pair, export):
|
|
2449
2329
|
"""Set a variable in an account\'s profile"""
|
|
2450
|
-
|
|
2451
|
-
if
|
|
2452
|
-
|
|
2330
|
+
hv = shared_blockchain_instance()
|
|
2331
|
+
if hv.rpc is not None:
|
|
2332
|
+
hv.rpc.rpcconnect()
|
|
2453
2333
|
keys = []
|
|
2454
2334
|
values = []
|
|
2455
2335
|
if pair:
|
|
@@ -2464,18 +2344,16 @@ def setprofile(variable, value, account, pair, export):
|
|
|
2464
2344
|
profile = Profile(keys, values)
|
|
2465
2345
|
|
|
2466
2346
|
if not account:
|
|
2467
|
-
account =
|
|
2468
|
-
if not unlock_wallet(
|
|
2347
|
+
account = hv.config["default_account"]
|
|
2348
|
+
if not unlock_wallet(hv):
|
|
2469
2349
|
return
|
|
2470
|
-
acc = Account(account, blockchain_instance=
|
|
2350
|
+
acc = Account(account, blockchain_instance=hv)
|
|
2471
2351
|
|
|
2472
2352
|
json_metadata = Profile(acc["json_metadata"] if acc["json_metadata"] else {})
|
|
2473
2353
|
json_metadata.update(profile)
|
|
2474
2354
|
tx = acc.update_account_profile(json_metadata)
|
|
2475
|
-
if
|
|
2476
|
-
tx =
|
|
2477
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2478
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2355
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2356
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2479
2357
|
export_trx(tx, export)
|
|
2480
2358
|
tx = json.dumps(tx, indent=4)
|
|
2481
2359
|
print(tx)
|
|
@@ -2487,25 +2365,23 @@ def setprofile(variable, value, account, pair, export):
|
|
|
2487
2365
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
2488
2366
|
def delprofile(variable, account, export):
|
|
2489
2367
|
"""Delete a variable in an account\'s profile"""
|
|
2490
|
-
|
|
2491
|
-
if
|
|
2492
|
-
|
|
2368
|
+
hv = shared_blockchain_instance()
|
|
2369
|
+
if hv.rpc is not None:
|
|
2370
|
+
hv.rpc.rpcconnect()
|
|
2493
2371
|
|
|
2494
2372
|
if not account:
|
|
2495
|
-
account =
|
|
2496
|
-
if not unlock_wallet(
|
|
2373
|
+
account = hv.config["default_account"]
|
|
2374
|
+
if not unlock_wallet(hv):
|
|
2497
2375
|
return
|
|
2498
|
-
acc = Account(account, blockchain_instance=
|
|
2376
|
+
acc = Account(account, blockchain_instance=hv)
|
|
2499
2377
|
json_metadata = Profile(acc["json_metadata"])
|
|
2500
2378
|
|
|
2501
2379
|
for var in variable:
|
|
2502
2380
|
json_metadata.remove(var)
|
|
2503
2381
|
|
|
2504
2382
|
tx = acc.update_account_profile(json_metadata)
|
|
2505
|
-
if
|
|
2506
|
-
tx =
|
|
2507
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2508
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2383
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2384
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2509
2385
|
export_trx(tx, export)
|
|
2510
2386
|
tx = json.dumps(tx, indent=4)
|
|
2511
2387
|
print(tx)
|
|
@@ -2533,12 +2409,12 @@ def importaccount(account, roles, import_coldcard, wif):
|
|
|
2533
2409
|
"""Import an account using a passphrase"""
|
|
2534
2410
|
from nectargraphenebase.account import PasswordKey
|
|
2535
2411
|
|
|
2536
|
-
|
|
2537
|
-
if
|
|
2538
|
-
|
|
2539
|
-
if not unlock_wallet(
|
|
2412
|
+
hv = shared_blockchain_instance()
|
|
2413
|
+
if hv.rpc is not None:
|
|
2414
|
+
hv.rpc.rpcconnect()
|
|
2415
|
+
if not unlock_wallet(hv):
|
|
2540
2416
|
return
|
|
2541
|
-
account = Account(account, blockchain_instance=
|
|
2417
|
+
account = Account(account, blockchain_instance=hv)
|
|
2542
2418
|
imported = False
|
|
2543
2419
|
if import_coldcard is None:
|
|
2544
2420
|
password = click.prompt("Account Passphrase", confirmation_prompt=False, hide_input=True)
|
|
@@ -2558,38 +2434,38 @@ def importaccount(account, roles, import_coldcard, wif):
|
|
|
2558
2434
|
|
|
2559
2435
|
if "owner" in roles:
|
|
2560
2436
|
owner_key = PasswordKey(account["name"], password, role="owner")
|
|
2561
|
-
owner_pubkey = format(owner_key.get_public_key(),
|
|
2437
|
+
owner_pubkey = format(owner_key.get_public_key(), hv.prefix)
|
|
2562
2438
|
if owner_pubkey in [x[0] for x in account["owner"]["key_auths"]]:
|
|
2563
2439
|
print("Importing owner key!")
|
|
2564
2440
|
owner_privkey = owner_key.get_private_key()
|
|
2565
|
-
|
|
2441
|
+
hv.wallet.addPrivateKey(owner_privkey)
|
|
2566
2442
|
imported = True
|
|
2567
2443
|
|
|
2568
2444
|
if "active" in roles:
|
|
2569
2445
|
active_key = PasswordKey(account["name"], password, role="active")
|
|
2570
|
-
active_pubkey = format(active_key.get_public_key(),
|
|
2446
|
+
active_pubkey = format(active_key.get_public_key(), hv.prefix)
|
|
2571
2447
|
if active_pubkey in [x[0] for x in account["active"]["key_auths"]]:
|
|
2572
2448
|
print("Importing active key!")
|
|
2573
2449
|
active_privkey = active_key.get_private_key()
|
|
2574
|
-
|
|
2450
|
+
hv.wallet.addPrivateKey(active_privkey)
|
|
2575
2451
|
imported = True
|
|
2576
2452
|
|
|
2577
2453
|
if "posting" in roles:
|
|
2578
2454
|
posting_key = PasswordKey(account["name"], password, role="posting")
|
|
2579
|
-
posting_pubkey = format(posting_key.get_public_key(),
|
|
2455
|
+
posting_pubkey = format(posting_key.get_public_key(), hv.prefix)
|
|
2580
2456
|
if posting_pubkey in [x[0] for x in account["posting"]["key_auths"]]:
|
|
2581
2457
|
print("Importing posting key!")
|
|
2582
2458
|
posting_privkey = posting_key.get_private_key()
|
|
2583
|
-
|
|
2459
|
+
hv.wallet.addPrivateKey(posting_privkey)
|
|
2584
2460
|
imported = True
|
|
2585
2461
|
|
|
2586
2462
|
if "memo" in roles:
|
|
2587
2463
|
memo_key = PasswordKey(account["name"], password, role="memo")
|
|
2588
|
-
memo_pubkey = format(memo_key.get_public_key(),
|
|
2464
|
+
memo_pubkey = format(memo_key.get_public_key(), hv.prefix)
|
|
2589
2465
|
if memo_pubkey == account["memo_key"]:
|
|
2590
2466
|
print("Importing memo key!")
|
|
2591
2467
|
memo_privkey = memo_key.get_private_key()
|
|
2592
|
-
|
|
2468
|
+
hv.wallet.addPrivateKey(memo_privkey)
|
|
2593
2469
|
imported = True
|
|
2594
2470
|
|
|
2595
2471
|
if not imported:
|
|
@@ -2602,14 +2478,14 @@ def importaccount(account, roles, import_coldcard, wif):
|
|
|
2602
2478
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
2603
2479
|
def updatememokey(account, key, export):
|
|
2604
2480
|
"""Update an account\'s memo key"""
|
|
2605
|
-
|
|
2606
|
-
if
|
|
2607
|
-
|
|
2481
|
+
hv = shared_blockchain_instance()
|
|
2482
|
+
if hv.rpc is not None:
|
|
2483
|
+
hv.rpc.rpcconnect()
|
|
2608
2484
|
if not account:
|
|
2609
|
-
account =
|
|
2610
|
-
if not unlock_wallet(
|
|
2485
|
+
account = hv.config["default_account"]
|
|
2486
|
+
if not unlock_wallet(hv):
|
|
2611
2487
|
return
|
|
2612
|
-
acc = Account(account, blockchain_instance=
|
|
2488
|
+
acc = Account(account, blockchain_instance=hv)
|
|
2613
2489
|
if not key:
|
|
2614
2490
|
from nectargraphenebase.account import PasswordKey
|
|
2615
2491
|
|
|
@@ -2617,15 +2493,13 @@ def updatememokey(account, key, export):
|
|
|
2617
2493
|
"Password for Memo Key Derivation", confirmation_prompt=True, hide_input=True
|
|
2618
2494
|
)
|
|
2619
2495
|
memo_key = PasswordKey(account, pwd, "memo")
|
|
2620
|
-
key = format(memo_key.get_public_key(),
|
|
2496
|
+
key = format(memo_key.get_public_key(), hv.prefix)
|
|
2621
2497
|
memo_privkey = memo_key.get_private_key()
|
|
2622
|
-
if not
|
|
2623
|
-
|
|
2498
|
+
if not hv.nobroadcast:
|
|
2499
|
+
hv.wallet.addPrivateKey(memo_privkey)
|
|
2624
2500
|
tx = acc.update_memo_key(key)
|
|
2625
|
-
if
|
|
2626
|
-
tx =
|
|
2627
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2628
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2501
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2502
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2629
2503
|
export_trx(tx, export)
|
|
2630
2504
|
tx = json.dumps(tx, indent=4)
|
|
2631
2505
|
print(tx)
|
|
@@ -2637,15 +2511,15 @@ def updatememokey(account, key, export):
|
|
|
2637
2511
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
2638
2512
|
def beneficiaries(authorperm, beneficiaries, export):
|
|
2639
2513
|
"""Set beneficaries"""
|
|
2640
|
-
|
|
2641
|
-
if
|
|
2642
|
-
|
|
2643
|
-
c = Comment(authorperm, blockchain_instance=
|
|
2514
|
+
hv = shared_blockchain_instance()
|
|
2515
|
+
if hv.rpc is not None:
|
|
2516
|
+
hv.rpc.rpcconnect()
|
|
2517
|
+
c = Comment(authorperm, blockchain_instance=hv)
|
|
2644
2518
|
account = c["author"]
|
|
2645
2519
|
|
|
2646
2520
|
if not account:
|
|
2647
|
-
account =
|
|
2648
|
-
if not unlock_wallet(
|
|
2521
|
+
account = hv.config["default_account"]
|
|
2522
|
+
if not unlock_wallet(hv):
|
|
2649
2523
|
return
|
|
2650
2524
|
|
|
2651
2525
|
options = {
|
|
@@ -2655,21 +2529,17 @@ def beneficiaries(authorperm, beneficiaries, export):
|
|
|
2655
2529
|
"allow_votes": c["allow_votes"],
|
|
2656
2530
|
"allow_curation_rewards": c["allow_curation_rewards"],
|
|
2657
2531
|
}
|
|
2658
|
-
if "
|
|
2659
|
-
options["percent_steem_dollars"] = c["percent_steem_dollars"]
|
|
2660
|
-
elif "percent_hbd" in c:
|
|
2532
|
+
if "percent_hbd" in c:
|
|
2661
2533
|
options["percent_hbd"] = c["percent_hbd"]
|
|
2662
2534
|
|
|
2663
2535
|
if isinstance(beneficiaries, tuple) and len(beneficiaries) == 1:
|
|
2664
2536
|
beneficiaries = beneficiaries[0].split(",")
|
|
2665
2537
|
beneficiaries_list_sorted = derive_beneficiaries(beneficiaries)
|
|
2666
2538
|
for b in beneficiaries_list_sorted:
|
|
2667
|
-
Account(b["account"], blockchain_instance=
|
|
2668
|
-
tx =
|
|
2669
|
-
if
|
|
2670
|
-
tx =
|
|
2671
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
2672
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
2539
|
+
Account(b["account"], blockchain_instance=hv)
|
|
2540
|
+
tx = hv.comment_options(options, authorperm, beneficiaries_list_sorted, account=account)
|
|
2541
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2542
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
2673
2543
|
export_trx(tx, export)
|
|
2674
2544
|
tx = json.dumps(tx, indent=4)
|
|
2675
2545
|
print(tx)
|
|
@@ -2683,11 +2553,11 @@ def beneficiaries(authorperm, beneficiaries, export):
|
|
|
2683
2553
|
)
|
|
2684
2554
|
def message(message_file, account, verify):
|
|
2685
2555
|
"""Sign and verify a message"""
|
|
2686
|
-
|
|
2687
|
-
if
|
|
2688
|
-
|
|
2556
|
+
hv = shared_blockchain_instance()
|
|
2557
|
+
if hv.rpc is not None:
|
|
2558
|
+
hv.rpc.rpcconnect()
|
|
2689
2559
|
if not account:
|
|
2690
|
-
account =
|
|
2560
|
+
account = hv.config["default_account"]
|
|
2691
2561
|
if message_file is not None:
|
|
2692
2562
|
with open(message_file) as f:
|
|
2693
2563
|
message = f.read()
|
|
@@ -2698,14 +2568,14 @@ def message(message_file, account, verify):
|
|
|
2698
2568
|
return
|
|
2699
2569
|
else:
|
|
2700
2570
|
message = input("Enter message: ")
|
|
2701
|
-
m = Message(message, blockchain_instance=
|
|
2571
|
+
m = Message(message, blockchain_instance=hv)
|
|
2702
2572
|
if verify:
|
|
2703
2573
|
if m.verify():
|
|
2704
2574
|
print("Could verify message!")
|
|
2705
2575
|
else:
|
|
2706
2576
|
print("Could not verify message!")
|
|
2707
2577
|
else:
|
|
2708
|
-
if not unlock_wallet(
|
|
2578
|
+
if not unlock_wallet(hv):
|
|
2709
2579
|
return
|
|
2710
2580
|
out = m.sign(account)
|
|
2711
2581
|
if message_file is not None:
|
|
@@ -2735,22 +2605,22 @@ def decrypt(memo, account, output, info, text, binary):
|
|
|
2735
2605
|
if text and binary:
|
|
2736
2606
|
print("You cannot set text and binary!")
|
|
2737
2607
|
return
|
|
2738
|
-
|
|
2739
|
-
if
|
|
2740
|
-
|
|
2608
|
+
hv = shared_blockchain_instance()
|
|
2609
|
+
if hv.rpc is not None:
|
|
2610
|
+
hv.rpc.rpcconnect()
|
|
2741
2611
|
if not account:
|
|
2742
|
-
account =
|
|
2743
|
-
m = Memo(from_account=None, to_account=account, blockchain_instance=
|
|
2612
|
+
account = hv.config["default_account"]
|
|
2613
|
+
m = Memo(from_account=None, to_account=account, blockchain_instance=hv)
|
|
2744
2614
|
|
|
2745
|
-
if not unlock_wallet(
|
|
2615
|
+
if not unlock_wallet(hv):
|
|
2746
2616
|
return
|
|
2747
2617
|
for entry in memo:
|
|
2748
2618
|
print("\n")
|
|
2749
2619
|
if not binary and info:
|
|
2750
2620
|
from_key, to_key, nonce = m.extract_decrypt_memo_data(entry)
|
|
2751
2621
|
try:
|
|
2752
|
-
from_account =
|
|
2753
|
-
to_account =
|
|
2622
|
+
from_account = hv.wallet.getAccountFromPublicKey(str(from_key))
|
|
2623
|
+
to_account = hv.wallet.getAccountFromPublicKey(str(to_key))
|
|
2754
2624
|
if from_account is not None:
|
|
2755
2625
|
print("from: %s" % str(from_account))
|
|
2756
2626
|
else:
|
|
@@ -2811,13 +2681,13 @@ def encrypt(receiver, memo, account, output, text, binary):
|
|
|
2811
2681
|
if text and binary:
|
|
2812
2682
|
print("You cannot set text and binary!")
|
|
2813
2683
|
return
|
|
2814
|
-
|
|
2815
|
-
if
|
|
2816
|
-
|
|
2684
|
+
hv = shared_blockchain_instance()
|
|
2685
|
+
if hv.rpc is not None:
|
|
2686
|
+
hv.rpc.rpcconnect()
|
|
2817
2687
|
if not account:
|
|
2818
|
-
account =
|
|
2819
|
-
m = Memo(from_account=account, to_account=receiver, blockchain_instance=
|
|
2820
|
-
if not unlock_wallet(
|
|
2688
|
+
account = hv.config["default_account"]
|
|
2689
|
+
m = Memo(from_account=account, to_account=receiver, blockchain_instance=hv)
|
|
2690
|
+
if not unlock_wallet(hv):
|
|
2821
2691
|
return
|
|
2822
2692
|
for entry in memo:
|
|
2823
2693
|
print("\n")
|
|
@@ -2855,14 +2725,14 @@ def encrypt(receiver, memo, account, output, text, binary):
|
|
|
2855
2725
|
@click.option("--account", "-a", help="Account name")
|
|
2856
2726
|
@click.option("--image-name", "-n", help="Image name")
|
|
2857
2727
|
def uploadimage(image, account, image_name):
|
|
2858
|
-
|
|
2859
|
-
if
|
|
2860
|
-
|
|
2728
|
+
hv = shared_blockchain_instance()
|
|
2729
|
+
if hv.rpc is not None:
|
|
2730
|
+
hv.rpc.rpcconnect()
|
|
2861
2731
|
if not account:
|
|
2862
|
-
account =
|
|
2863
|
-
if not unlock_wallet(
|
|
2732
|
+
account = hv.config["default_account"]
|
|
2733
|
+
if not unlock_wallet(hv):
|
|
2864
2734
|
return
|
|
2865
|
-
iu = ImageUploader(blockchain_instance=
|
|
2735
|
+
iu = ImageUploader(blockchain_instance=hv)
|
|
2866
2736
|
tx = iu.upload(image, account, image_name)
|
|
2867
2737
|
if image_name is None:
|
|
2868
2738
|
print("" % tx["url"])
|
|
@@ -2883,12 +2753,12 @@ def uploadimage(image, account, image_name):
|
|
|
2883
2753
|
@click.option("--export", "-e", default=None, help="Export markdown to given a md-file name")
|
|
2884
2754
|
def download(permlink, account, save, export):
|
|
2885
2755
|
"""Download body with yaml header"""
|
|
2886
|
-
|
|
2887
|
-
if
|
|
2888
|
-
|
|
2756
|
+
hv = shared_blockchain_instance()
|
|
2757
|
+
if hv.rpc is not None:
|
|
2758
|
+
hv.rpc.rpcconnect()
|
|
2889
2759
|
if account is None:
|
|
2890
|
-
account =
|
|
2891
|
-
account = Account(account, blockchain_instance=
|
|
2760
|
+
account = hv.config["default_account"]
|
|
2761
|
+
account = Account(account, blockchain_instance=hv)
|
|
2892
2762
|
if len(permlink) == 0:
|
|
2893
2763
|
permlink = []
|
|
2894
2764
|
progress_length = account.virtual_op_count()
|
|
@@ -2922,7 +2792,7 @@ def download(permlink, account, save, export):
|
|
|
2922
2792
|
authorperm = construct_authorperm(account["name"], p)
|
|
2923
2793
|
if len(permlink) > 1:
|
|
2924
2794
|
print(authorperm)
|
|
2925
|
-
comment = Comment(authorperm, blockchain_instance=
|
|
2795
|
+
comment = Comment(authorperm, blockchain_instance=hv)
|
|
2926
2796
|
if comment.parent_author != "" and comment.parent_permlink != "":
|
|
2927
2797
|
reply_identifier = construct_authorperm(comment.parent_author, comment.parent_permlink)
|
|
2928
2798
|
else:
|
|
@@ -2946,9 +2816,7 @@ def download(permlink, account, save, export):
|
|
|
2946
2816
|
else:
|
|
2947
2817
|
yaml_prefix += "last_update: %s\n" % comment.json()["updated"]
|
|
2948
2818
|
yaml_prefix += "max_accepted_payout: %s\n" % str(comment["max_accepted_payout"])
|
|
2949
|
-
if "
|
|
2950
|
-
yaml_prefix += "percent_steem_dollars: %s\n" % str(comment["percent_steem_dollars"])
|
|
2951
|
-
elif "percent_hbd" in comment:
|
|
2819
|
+
if "percent_hbd" in comment:
|
|
2952
2820
|
yaml_prefix += "percent_hbd: %s\n" % str(comment["percent_hbd"])
|
|
2953
2821
|
if "tags" in comment.json_metadata:
|
|
2954
2822
|
if (
|
|
@@ -2990,11 +2858,8 @@ def download(permlink, account, save, export):
|
|
|
2990
2858
|
@click.option(
|
|
2991
2859
|
"--beneficiaries", "-b", help="Post beneficiaries (komma separated, e.g. a:10%,b:20%)"
|
|
2992
2860
|
)
|
|
2993
|
-
@click.option(
|
|
2994
|
-
|
|
2995
|
-
)
|
|
2996
|
-
@click.option("--percent-hbd", "-h", help="50% HBD /50% HP is 10000 (default), 100% HP is 0")
|
|
2997
|
-
@click.option("--max-accepted-payout", "-m", help="Default is 1000000.000 [SBD]")
|
|
2861
|
+
@click.option("--percent-hbd", "-h", help="50% HBD/50% HP is 10000 (default), 100% HP is 0")
|
|
2862
|
+
@click.option("--max-accepted-payout", "-m", help="Default is 1000000.000 [HBD]")
|
|
2998
2863
|
@click.option(
|
|
2999
2864
|
"--no-parse-body",
|
|
3000
2865
|
"-n",
|
|
@@ -3009,15 +2874,14 @@ def createpost(
|
|
|
3009
2874
|
tags,
|
|
3010
2875
|
community,
|
|
3011
2876
|
beneficiaries,
|
|
3012
|
-
percent_steem_dollars,
|
|
3013
2877
|
percent_hbd,
|
|
3014
2878
|
max_accepted_payout,
|
|
3015
2879
|
no_parse_body,
|
|
3016
2880
|
):
|
|
3017
2881
|
"""Creates a new markdown file with YAML header"""
|
|
3018
|
-
|
|
3019
|
-
if
|
|
3020
|
-
|
|
2882
|
+
hv = shared_blockchain_instance()
|
|
2883
|
+
if hv.rpc is not None:
|
|
2884
|
+
hv.rpc.rpcconnect()
|
|
3021
2885
|
|
|
3022
2886
|
if account is None:
|
|
3023
2887
|
account = input("author: ")
|
|
@@ -3053,24 +2917,16 @@ def createpost(
|
|
|
3053
2917
|
beneficiaries = input(
|
|
3054
2918
|
"beneficiaries (komma separated, e.g. a:10%,b:20%) [return to skip]: "
|
|
3055
2919
|
)
|
|
3056
|
-
if
|
|
2920
|
+
if percent_hbd is None:
|
|
3057
2921
|
ret = None
|
|
3058
2922
|
while ret is None:
|
|
3059
|
-
ret = input("50% or 100%
|
|
2923
|
+
ret = input("50% or 100% Hive Power as post reward [50 or 100]? ")
|
|
3060
2924
|
if ret not in ["50", "100"]:
|
|
3061
2925
|
ret = None
|
|
3062
2926
|
if ret == "50":
|
|
3063
|
-
percent_steem_dollars = 10000
|
|
3064
2927
|
percent_hbd = 10000
|
|
3065
2928
|
else:
|
|
3066
|
-
percent_steem_dollars = 0
|
|
3067
2929
|
percent_hbd = 0
|
|
3068
|
-
elif percent_steem_dollars is not None and percent_hbd is not None:
|
|
3069
|
-
raise ValueError("percent_hbd and percent_steem_dollars cannot be both set.")
|
|
3070
|
-
elif percent_steem_dollars is None:
|
|
3071
|
-
percent_steem_dollars = percent_hbd
|
|
3072
|
-
elif percent_hbd is None:
|
|
3073
|
-
percent_hbd = percent_steem_dollars
|
|
3074
2930
|
|
|
3075
2931
|
if max_accepted_payout is None:
|
|
3076
2932
|
max_accepted_payout = input("max accepted payout [return to skip]: ")
|
|
@@ -3078,10 +2934,7 @@ def createpost(
|
|
|
3078
2934
|
yaml_prefix += 'title: "%s"\n' % title
|
|
3079
2935
|
yaml_prefix += "author: %s\n" % account
|
|
3080
2936
|
yaml_prefix += "tags: %s\n" % tags
|
|
3081
|
-
|
|
3082
|
-
yaml_prefix += "percent_hbd: %d\n" % percent_hbd
|
|
3083
|
-
else:
|
|
3084
|
-
yaml_prefix += "percent_steem_dollars: %d\n" % percent_steem_dollars
|
|
2937
|
+
yaml_prefix += "percent_hbd: %d\n" % percent_hbd
|
|
3085
2938
|
if community is not None and community != "":
|
|
3086
2939
|
yaml_prefix += "community: %s\n" % community
|
|
3087
2940
|
if beneficiaries is not None and beneficiaries != "":
|
|
@@ -3113,11 +2966,8 @@ def createpost(
|
|
|
3113
2966
|
@click.option(
|
|
3114
2967
|
"--beneficiaries", "-b", help="Post beneficiaries (komma separated, e.g. a:10%,b:20%)"
|
|
3115
2968
|
)
|
|
3116
|
-
@click.option(
|
|
3117
|
-
|
|
3118
|
-
)
|
|
3119
|
-
@click.option("--percent-hbd", "-h", help="50% SBD /50% SP is 10000 (default), 100% SP is 0")
|
|
3120
|
-
@click.option("--max-accepted-payout", "-m", help="Default is 1000000.000 [SBD]")
|
|
2969
|
+
@click.option("--percent-hbd", "-h", help="50% HBD/50% HP is 10000 (default), 100% HP is 0")
|
|
2970
|
+
@click.option("--max-accepted-payout", "-m", help="Default is 1000000.000 [HBD]")
|
|
3121
2971
|
@click.option(
|
|
3122
2972
|
"--no-parse-body",
|
|
3123
2973
|
"-n",
|
|
@@ -3143,7 +2993,6 @@ def post(
|
|
|
3143
2993
|
community,
|
|
3144
2994
|
canonical_url,
|
|
3145
2995
|
beneficiaries,
|
|
3146
|
-
percent_steem_dollars,
|
|
3147
2996
|
percent_hbd,
|
|
3148
2997
|
max_accepted_payout,
|
|
3149
2998
|
no_parse_body,
|
|
@@ -3161,9 +3010,9 @@ def post(
|
|
|
3161
3010
|
---
|
|
3162
3011
|
|
|
3163
3012
|
"""
|
|
3164
|
-
|
|
3165
|
-
if
|
|
3166
|
-
|
|
3013
|
+
hv = shared_blockchain_instance()
|
|
3014
|
+
if hv.rpc is not None:
|
|
3015
|
+
hv.rpc.rpcconnect()
|
|
3167
3016
|
|
|
3168
3017
|
with open(markdown_file) as f:
|
|
3169
3018
|
content = f.read()
|
|
@@ -3182,10 +3031,6 @@ def post(
|
|
|
3182
3031
|
parameter["community"] = community
|
|
3183
3032
|
if reply_identifier is not None:
|
|
3184
3033
|
parameter["reply_identifier"] = reply_identifier
|
|
3185
|
-
if percent_steem_dollars is not None:
|
|
3186
|
-
parameter["percent_steem_dollars"] = percent_steem_dollars
|
|
3187
|
-
elif "percent-steem-dollars" in parameter:
|
|
3188
|
-
parameter["percent_steem_dollars"] = parameter["percent-steem-dollars"]
|
|
3189
3034
|
if percent_hbd is not None:
|
|
3190
3035
|
parameter["percent_hbd"] = percent_hbd
|
|
3191
3036
|
elif "percent-hbd" in parameter:
|
|
@@ -3198,7 +3043,7 @@ def post(
|
|
|
3198
3043
|
if canonical_url is not None:
|
|
3199
3044
|
parameter["canonical_url"] = canonical_url
|
|
3200
3045
|
|
|
3201
|
-
if not unlock_wallet(
|
|
3046
|
+
if not unlock_wallet(hv):
|
|
3202
3047
|
return
|
|
3203
3048
|
tags = None
|
|
3204
3049
|
if "tags" in parameter:
|
|
@@ -3209,7 +3054,7 @@ def post(
|
|
|
3209
3054
|
if "author" in parameter:
|
|
3210
3055
|
author = parameter["author"]
|
|
3211
3056
|
else:
|
|
3212
|
-
author =
|
|
3057
|
+
author = hv.config["default_account"]
|
|
3213
3058
|
permlink = None
|
|
3214
3059
|
if "permlink" in parameter:
|
|
3215
3060
|
permlink = parameter["permlink"]
|
|
@@ -3224,10 +3069,8 @@ def post(
|
|
|
3224
3069
|
else:
|
|
3225
3070
|
parse_body = not no_parse_body
|
|
3226
3071
|
max_accepted_payout = None
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
if "percent_steem_dollars" in parameter:
|
|
3230
|
-
percent_steem_dollars = parameter["percent_steem_dollars"]
|
|
3072
|
+
if "max_accepted_payout" in parameter:
|
|
3073
|
+
max_accepted_payout = parameter["max_accepted_payout"]
|
|
3231
3074
|
percent_hbd = None
|
|
3232
3075
|
if "percent_hbd" in parameter:
|
|
3233
3076
|
percent_hbd = parameter["percent_hbd"]
|
|
@@ -3235,41 +3078,31 @@ def post(
|
|
|
3235
3078
|
if "max_accepted_payout" in parameter:
|
|
3236
3079
|
max_accepted_payout = parameter["max_accepted_payout"]
|
|
3237
3080
|
comment_options = None
|
|
3238
|
-
if
|
|
3239
|
-
max_accepted_payout is not None
|
|
3240
|
-
or percent_steem_dollars is not None
|
|
3241
|
-
or percent_hbd is not None
|
|
3242
|
-
):
|
|
3081
|
+
if max_accepted_payout is not None or percent_hbd is not None:
|
|
3243
3082
|
comment_options = {}
|
|
3244
3083
|
if max_accepted_payout is not None:
|
|
3245
|
-
if
|
|
3084
|
+
if hv.backed_token_symbol not in max_accepted_payout:
|
|
3246
3085
|
max_accepted_payout = str(
|
|
3247
|
-
Amount(float(max_accepted_payout),
|
|
3086
|
+
Amount(float(max_accepted_payout), hv.backed_token_symbol, blockchain_instance=hv)
|
|
3248
3087
|
)
|
|
3249
3088
|
comment_options["max_accepted_payout"] = max_accepted_payout
|
|
3250
|
-
if percent_hbd is not None
|
|
3089
|
+
if percent_hbd is not None:
|
|
3251
3090
|
comment_options["percent_hbd"] = percent_hbd
|
|
3252
|
-
elif percent_steem_dollars is not None and stm.is_hive:
|
|
3253
|
-
comment_options["percent_hbd"] = percent_steem_dollars
|
|
3254
|
-
elif percent_steem_dollars is not None:
|
|
3255
|
-
comment_options["percent_steem_dollars"] = percent_steem_dollars
|
|
3256
|
-
elif percent_hbd is not None:
|
|
3257
|
-
comment_options["percent_steem_dollars"] = percent_hbd
|
|
3258
3091
|
beneficiaries = None
|
|
3259
3092
|
if "beneficiaries" in parameter:
|
|
3260
3093
|
beneficiaries = derive_beneficiaries(parameter["beneficiaries"])
|
|
3261
3094
|
for b in beneficiaries:
|
|
3262
|
-
Account(b["account"], blockchain_instance=
|
|
3095
|
+
Account(b["account"], blockchain_instance=hv)
|
|
3263
3096
|
|
|
3264
3097
|
if permlink is not None:
|
|
3265
3098
|
try:
|
|
3266
|
-
comment = Comment(construct_authorperm(author, permlink), blockchain_instance=
|
|
3099
|
+
comment = Comment(construct_authorperm(author, permlink), blockchain_instance=hv)
|
|
3267
3100
|
except Exception:
|
|
3268
3101
|
comment = None
|
|
3269
3102
|
else:
|
|
3270
3103
|
comment = None
|
|
3271
3104
|
|
|
3272
|
-
iu = ImageUploader(blockchain_instance=
|
|
3105
|
+
iu = ImageUploader(blockchain_instance=hv)
|
|
3273
3106
|
for link in list(
|
|
3274
3107
|
re.findall(r'!\[[^"\'@\]\(]*\]\([^"\'@\(\)]*\.(?:png|jpg|jpeg|gif|png|svg)\)', body)
|
|
3275
3108
|
):
|
|
@@ -3277,7 +3110,7 @@ def post(
|
|
|
3277
3110
|
image_name = link.split("![")[1].split("]")[0]
|
|
3278
3111
|
if image[:4] == "http":
|
|
3279
3112
|
continue
|
|
3280
|
-
if
|
|
3113
|
+
if hv.unsigned:
|
|
3281
3114
|
continue
|
|
3282
3115
|
basepath = os.path.dirname(markdown_file)
|
|
3283
3116
|
if os.path.exists(image):
|
|
@@ -3290,7 +3123,7 @@ def post(
|
|
|
3290
3123
|
if comment is None and permlink is None and reply_identifier is None:
|
|
3291
3124
|
permlink = derive_permlink(title, with_suffix=False)
|
|
3292
3125
|
try:
|
|
3293
|
-
comment = Comment(construct_authorperm(author, permlink), blockchain_instance=
|
|
3126
|
+
comment = Comment(construct_authorperm(author, permlink), blockchain_instance=hv)
|
|
3294
3127
|
except Exception:
|
|
3295
3128
|
comment = None
|
|
3296
3129
|
if comment is None:
|
|
@@ -3304,7 +3137,7 @@ def post(
|
|
|
3304
3137
|
if "canonical_url" in parameter:
|
|
3305
3138
|
json_metadata["canonical_url"] = parameter["canonical_url"]
|
|
3306
3139
|
else:
|
|
3307
|
-
json_metadata["canonical_url"] =
|
|
3140
|
+
json_metadata["canonical_url"] = hv.config["default_canonical_url"] or "https://hive.blog"
|
|
3308
3141
|
|
|
3309
3142
|
if "canonical_url" in json_metadata and json_metadata["canonical_url"].find("@") < 0:
|
|
3310
3143
|
if json_metadata["canonical_url"][-1] != "/":
|
|
@@ -3319,7 +3152,7 @@ def post(
|
|
|
3319
3152
|
if comment is None or no_patch_on_edit:
|
|
3320
3153
|
if reply_identifier is None and (len(tags) == 0 or tags is None):
|
|
3321
3154
|
raise ValueError("Tags must not be empty!")
|
|
3322
|
-
tx =
|
|
3155
|
+
tx = hv.post(
|
|
3323
3156
|
title,
|
|
3324
3157
|
body,
|
|
3325
3158
|
author=author,
|
|
@@ -3342,7 +3175,7 @@ def post(
|
|
|
3342
3175
|
edit_ok = click.prompt("Should I broadcast %s [y/n]" % (str(permlink)))
|
|
3343
3176
|
if edit_ok not in ["y", "ye", "yes"]:
|
|
3344
3177
|
return
|
|
3345
|
-
tx =
|
|
3178
|
+
tx = hv.post(
|
|
3346
3179
|
title,
|
|
3347
3180
|
patch_text,
|
|
3348
3181
|
author=author,
|
|
@@ -3354,10 +3187,8 @@ def post(
|
|
|
3354
3187
|
parse_body=False,
|
|
3355
3188
|
app="hive-nectar/%s" % (__version__),
|
|
3356
3189
|
)
|
|
3357
|
-
if
|
|
3358
|
-
tx =
|
|
3359
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
3360
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3190
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3191
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
3361
3192
|
export_trx(tx, export)
|
|
3362
3193
|
tx = json.dumps(tx, indent=4)
|
|
3363
3194
|
print(tx)
|
|
@@ -3371,18 +3202,18 @@ def post(
|
|
|
3371
3202
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
3372
3203
|
def reply(authorperm, body, account, title, export):
|
|
3373
3204
|
"""replies to a comment"""
|
|
3374
|
-
|
|
3375
|
-
if
|
|
3376
|
-
|
|
3205
|
+
hv = shared_blockchain_instance()
|
|
3206
|
+
if hv.rpc is not None:
|
|
3207
|
+
hv.rpc.rpcconnect()
|
|
3377
3208
|
|
|
3378
3209
|
if not account:
|
|
3379
|
-
account =
|
|
3380
|
-
if not unlock_wallet(
|
|
3210
|
+
account = hv.config["default_account"]
|
|
3211
|
+
if not unlock_wallet(hv):
|
|
3381
3212
|
return
|
|
3382
3213
|
|
|
3383
3214
|
if title is None:
|
|
3384
3215
|
title = ""
|
|
3385
|
-
tx =
|
|
3216
|
+
tx = hv.post(
|
|
3386
3217
|
title,
|
|
3387
3218
|
body,
|
|
3388
3219
|
json_metadata=None,
|
|
@@ -3390,10 +3221,8 @@ def reply(authorperm, body, account, title, export):
|
|
|
3390
3221
|
reply_identifier=authorperm,
|
|
3391
3222
|
app="hive-nectar/%s" % (__version__),
|
|
3392
3223
|
)
|
|
3393
|
-
if
|
|
3394
|
-
tx =
|
|
3395
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
3396
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3224
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3225
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
3397
3226
|
export_trx(tx, export)
|
|
3398
3227
|
tx = json.dumps(tx, indent=4)
|
|
3399
3228
|
print(tx)
|
|
@@ -3405,19 +3234,17 @@ def reply(authorperm, body, account, title, export):
|
|
|
3405
3234
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
3406
3235
|
def approvewitness(witness, account, export):
|
|
3407
3236
|
"""Approve a witnesses"""
|
|
3408
|
-
|
|
3409
|
-
if
|
|
3410
|
-
|
|
3237
|
+
hv = shared_blockchain_instance()
|
|
3238
|
+
if hv.rpc is not None:
|
|
3239
|
+
hv.rpc.rpcconnect()
|
|
3411
3240
|
if not account:
|
|
3412
|
-
account =
|
|
3413
|
-
if not unlock_wallet(
|
|
3241
|
+
account = hv.config["default_account"]
|
|
3242
|
+
if not unlock_wallet(hv):
|
|
3414
3243
|
return
|
|
3415
|
-
acc = Account(account, blockchain_instance=
|
|
3244
|
+
acc = Account(account, blockchain_instance=hv)
|
|
3416
3245
|
tx = acc.approvewitness(witness, approve=True)
|
|
3417
|
-
if
|
|
3418
|
-
tx =
|
|
3419
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
3420
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3246
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3247
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
3421
3248
|
export_trx(tx, export)
|
|
3422
3249
|
tx = json.dumps(tx, indent=4)
|
|
3423
3250
|
print(tx)
|
|
@@ -3429,19 +3256,17 @@ def approvewitness(witness, account, export):
|
|
|
3429
3256
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
3430
3257
|
def disapprovewitness(witness, account, export):
|
|
3431
3258
|
"""Disapprove a witnesses"""
|
|
3432
|
-
|
|
3433
|
-
if
|
|
3434
|
-
|
|
3259
|
+
hv = shared_blockchain_instance()
|
|
3260
|
+
if hv.rpc is not None:
|
|
3261
|
+
hv.rpc.rpcconnect()
|
|
3435
3262
|
if not account:
|
|
3436
|
-
account =
|
|
3437
|
-
if not unlock_wallet(
|
|
3263
|
+
account = hv.config["default_account"]
|
|
3264
|
+
if not unlock_wallet(hv):
|
|
3438
3265
|
return
|
|
3439
|
-
acc = Account(account, blockchain_instance=
|
|
3266
|
+
acc = Account(account, blockchain_instance=hv)
|
|
3440
3267
|
tx = acc.disapprovewitness(witness)
|
|
3441
|
-
if
|
|
3442
|
-
tx =
|
|
3443
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
3444
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3268
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3269
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
3445
3270
|
export_trx(tx, export)
|
|
3446
3271
|
tx = json.dumps(tx, indent=4)
|
|
3447
3272
|
print(tx)
|
|
@@ -3453,19 +3278,17 @@ def disapprovewitness(witness, account, export):
|
|
|
3453
3278
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
3454
3279
|
def setproxy(proxy, account, export):
|
|
3455
3280
|
"""Set your witness/proposal system proxy"""
|
|
3456
|
-
|
|
3457
|
-
if
|
|
3458
|
-
|
|
3281
|
+
hv = shared_blockchain_instance()
|
|
3282
|
+
if hv.rpc is not None:
|
|
3283
|
+
hv.rpc.rpcconnect()
|
|
3459
3284
|
if not account:
|
|
3460
|
-
account =
|
|
3461
|
-
if not unlock_wallet(
|
|
3285
|
+
account = hv.config["default_account"]
|
|
3286
|
+
if not unlock_wallet(hv):
|
|
3462
3287
|
return
|
|
3463
|
-
acc = Account(account, blockchain_instance=
|
|
3288
|
+
acc = Account(account, blockchain_instance=hv)
|
|
3464
3289
|
tx = acc.setproxy(proxy, account)
|
|
3465
|
-
if
|
|
3466
|
-
tx =
|
|
3467
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
3468
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3290
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3291
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
3469
3292
|
export_trx(tx, export)
|
|
3470
3293
|
tx = json.dumps(tx, indent=4)
|
|
3471
3294
|
print(tx)
|
|
@@ -3476,19 +3299,17 @@ def setproxy(proxy, account, export):
|
|
|
3476
3299
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
3477
3300
|
def delproxy(account, export):
|
|
3478
3301
|
"""Delete your witness/proposal system proxy"""
|
|
3479
|
-
|
|
3480
|
-
if
|
|
3481
|
-
|
|
3302
|
+
hv = shared_blockchain_instance()
|
|
3303
|
+
if hv.rpc is not None:
|
|
3304
|
+
hv.rpc.rpcconnect()
|
|
3482
3305
|
if not account:
|
|
3483
|
-
account =
|
|
3484
|
-
if not unlock_wallet(
|
|
3306
|
+
account = hv.config["default_account"]
|
|
3307
|
+
if not unlock_wallet(hv):
|
|
3485
3308
|
return
|
|
3486
|
-
acc = Account(account, blockchain_instance=
|
|
3309
|
+
acc = Account(account, blockchain_instance=hv)
|
|
3487
3310
|
tx = acc.setproxy("", account)
|
|
3488
|
-
if
|
|
3489
|
-
tx =
|
|
3490
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
3491
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3311
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3312
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
3492
3313
|
export_trx(tx, export)
|
|
3493
3314
|
tx = json.dumps(tx, indent=4)
|
|
3494
3315
|
print(tx)
|
|
@@ -3503,10 +3324,10 @@ def delproxy(account, export):
|
|
|
3503
3324
|
)
|
|
3504
3325
|
def sign(file, outfile):
|
|
3505
3326
|
"""Sign a provided transaction with available and required keys"""
|
|
3506
|
-
|
|
3507
|
-
if
|
|
3508
|
-
|
|
3509
|
-
if not unlock_wallet(
|
|
3327
|
+
hv = shared_blockchain_instance()
|
|
3328
|
+
if hv.rpc is not None:
|
|
3329
|
+
hv.rpc.rpcconnect()
|
|
3330
|
+
if not unlock_wallet(hv):
|
|
3510
3331
|
return
|
|
3511
3332
|
if file and file != "-":
|
|
3512
3333
|
if not os.path.isfile(file):
|
|
@@ -3519,7 +3340,7 @@ def sign(file, outfile):
|
|
|
3519
3340
|
else:
|
|
3520
3341
|
tx = click.get_text_stream("stdin")
|
|
3521
3342
|
tx = ast.literal_eval(tx)
|
|
3522
|
-
tx =
|
|
3343
|
+
tx = hv.sign(tx, reconstruct_tx=False)
|
|
3523
3344
|
tx = json.dumps(tx, indent=4)
|
|
3524
3345
|
if outfile and outfile != "-":
|
|
3525
3346
|
with open(outfile, "w") as fp:
|
|
@@ -3534,9 +3355,9 @@ def sign(file, outfile):
|
|
|
3534
3355
|
)
|
|
3535
3356
|
def broadcast(file):
|
|
3536
3357
|
"""broadcast a signed transaction"""
|
|
3537
|
-
|
|
3538
|
-
if
|
|
3539
|
-
|
|
3358
|
+
hv = shared_blockchain_instance()
|
|
3359
|
+
if hv.rpc is not None:
|
|
3360
|
+
hv.rpc.rpcconnect()
|
|
3540
3361
|
if file and file != "-":
|
|
3541
3362
|
if not os.path.isfile(file):
|
|
3542
3363
|
raise Exception("File %s does not exist!" % file)
|
|
@@ -3548,7 +3369,7 @@ def broadcast(file):
|
|
|
3548
3369
|
else:
|
|
3549
3370
|
tx = click.get_text_stream("stdin")
|
|
3550
3371
|
tx = ast.literal_eval(tx)
|
|
3551
|
-
tx =
|
|
3372
|
+
tx = hv.broadcast(tx)
|
|
3552
3373
|
tx = json.dumps(tx, indent=4)
|
|
3553
3374
|
print(tx)
|
|
3554
3375
|
|
|
@@ -3566,13 +3387,13 @@ def broadcast(file):
|
|
|
3566
3387
|
@click.option("--follow", "-f", help="Constantly stream output", is_flag=True, default=False)
|
|
3567
3388
|
def stream(lines, head, table, follow):
|
|
3568
3389
|
"""Stream operations"""
|
|
3569
|
-
|
|
3570
|
-
if
|
|
3571
|
-
|
|
3390
|
+
hv = shared_blockchain_instance()
|
|
3391
|
+
if hv.rpc is not None:
|
|
3392
|
+
hv.rpc.rpcconnect()
|
|
3572
3393
|
mode = "irreversible"
|
|
3573
3394
|
if head:
|
|
3574
3395
|
mode = "head"
|
|
3575
|
-
b = Blockchain(mode=mode, blockchain_instance=
|
|
3396
|
+
b = Blockchain(mode=mode, blockchain_instance=hv)
|
|
3576
3397
|
op_count = 0
|
|
3577
3398
|
if table:
|
|
3578
3399
|
import pprint
|
|
@@ -3591,7 +3412,7 @@ def stream(lines, head, table, follow):
|
|
|
3591
3412
|
trx_num = ops.pop("trx_num")
|
|
3592
3413
|
for key in ops:
|
|
3593
3414
|
if isinstance(ops[key], dict) and "nai" in ops[key]:
|
|
3594
|
-
ops[key] = str(Amount(ops[key], blockchain_instance=
|
|
3415
|
+
ops[key] = str(Amount(ops[key], blockchain_instance=hv))
|
|
3595
3416
|
elif key == "timestamp":
|
|
3596
3417
|
ops[key] = formatTimeString(ops[key])
|
|
3597
3418
|
# value = json.dumps(ops, indent=4)
|
|
@@ -3631,23 +3452,17 @@ def stream(lines, head, table, follow):
|
|
|
3631
3452
|
|
|
3632
3453
|
|
|
3633
3454
|
@cli.command()
|
|
3634
|
-
|
|
3635
|
-
@click.option("--hbd-to-hive", "-i", help="Show ticker in HBD/HIVE", is_flag=True, default=False)
|
|
3636
|
-
def ticker(sbd_to_steem, hbd_to_hive):
|
|
3455
|
+
def ticker():
|
|
3637
3456
|
"""Show ticker"""
|
|
3638
|
-
|
|
3639
|
-
if
|
|
3640
|
-
|
|
3457
|
+
hv = shared_blockchain_instance()
|
|
3458
|
+
if hv.rpc is not None:
|
|
3459
|
+
hv.rpc.rpcconnect()
|
|
3641
3460
|
t = PrettyTable(["Key", "Value"])
|
|
3642
3461
|
t.align = "l"
|
|
3643
|
-
market = Market(blockchain_instance=
|
|
3462
|
+
market = Market(blockchain_instance=hv)
|
|
3644
3463
|
ticker = market.ticker()
|
|
3645
3464
|
for key in ticker:
|
|
3646
|
-
if key in
|
|
3647
|
-
t.add_row([key, str(ticker[key].as_base(stm.backed_token_symbol))])
|
|
3648
|
-
elif key in "percent_change" and (sbd_to_steem or hbd_to_hive):
|
|
3649
|
-
t.add_row([key, "%.2f %%" % -ticker[key]])
|
|
3650
|
-
elif key in "percent_change":
|
|
3465
|
+
if key in "percent_change":
|
|
3651
3466
|
t.add_row([key, "%.2f %%" % ticker[key]])
|
|
3652
3467
|
else:
|
|
3653
3468
|
t.add_row([key, str(ticker[key])])
|
|
@@ -3660,17 +3475,17 @@ def ticker(sbd_to_steem, hbd_to_hive):
|
|
|
3660
3475
|
@click.option("--ascii", help="Use only ascii symbols", is_flag=True, default=False)
|
|
3661
3476
|
def pricehistory(width, height, ascii):
|
|
3662
3477
|
"""Show price history"""
|
|
3663
|
-
|
|
3664
|
-
if
|
|
3665
|
-
|
|
3666
|
-
feed_history =
|
|
3667
|
-
current_base = Amount(feed_history["current_median_history"]["base"], blockchain_instance=
|
|
3668
|
-
current_quote = Amount(feed_history["current_median_history"]["quote"], blockchain_instance=
|
|
3478
|
+
hv = shared_blockchain_instance()
|
|
3479
|
+
if hv.rpc is not None:
|
|
3480
|
+
hv.rpc.rpcconnect()
|
|
3481
|
+
feed_history = hv.get_feed_history()
|
|
3482
|
+
current_base = Amount(feed_history["current_median_history"]["base"], blockchain_instance=hv)
|
|
3483
|
+
current_quote = Amount(feed_history["current_median_history"]["quote"], blockchain_instance=hv)
|
|
3669
3484
|
price_history = feed_history["price_history"]
|
|
3670
3485
|
price = []
|
|
3671
3486
|
for h in price_history:
|
|
3672
|
-
base = Amount(h["base"], blockchain_instance=
|
|
3673
|
-
quote = Amount(h["quote"], blockchain_instance=
|
|
3487
|
+
base = Amount(h["base"], blockchain_instance=hv)
|
|
3488
|
+
quote = Amount(h["quote"], blockchain_instance=hv)
|
|
3674
3489
|
price.append(float(base.amount / quote.amount))
|
|
3675
3490
|
if ascii:
|
|
3676
3491
|
charset = "ascii"
|
|
@@ -3681,7 +3496,7 @@ def pricehistory(width, height, ascii):
|
|
|
3681
3496
|
)
|
|
3682
3497
|
print(
|
|
3683
3498
|
"\n Price history for %s (median price %4.2f $)\n"
|
|
3684
|
-
% (
|
|
3499
|
+
% (hv.token_symbol, float(current_base) / float(current_quote))
|
|
3685
3500
|
)
|
|
3686
3501
|
|
|
3687
3502
|
chart.adapt_on_series(price)
|
|
@@ -3703,8 +3518,6 @@ def pricehistory(width, height, ascii):
|
|
|
3703
3518
|
@click.option(
|
|
3704
3519
|
"--hours", help="Limit the intervall history intervall (default 2 hours)", default=2.0
|
|
3705
3520
|
)
|
|
3706
|
-
@click.option("--sbd-to-steem", help="Show ticker in SBD/STEEM", is_flag=True, default=False)
|
|
3707
|
-
@click.option("--hbd-to-hive", "-i", help="Show ticker in HBD/HIVE", is_flag=True, default=False)
|
|
3708
3521
|
@click.option(
|
|
3709
3522
|
"--limit",
|
|
3710
3523
|
"-l",
|
|
@@ -3714,22 +3527,20 @@ def pricehistory(width, height, ascii):
|
|
|
3714
3527
|
@click.option("--width", "-w", help="Plot width (default 75)", default=75)
|
|
3715
3528
|
@click.option("--height", "-h", help="Plot height (default 15)", default=15)
|
|
3716
3529
|
@click.option("--ascii", help="Use only ascii symbols", is_flag=True, default=False)
|
|
3717
|
-
def tradehistory(days, hours,
|
|
3530
|
+
def tradehistory(days, hours, limit, width, height, ascii):
|
|
3718
3531
|
"""Show price history"""
|
|
3719
|
-
|
|
3720
|
-
if
|
|
3721
|
-
|
|
3722
|
-
m = Market(blockchain_instance=
|
|
3532
|
+
hv = shared_blockchain_instance()
|
|
3533
|
+
if hv.rpc is not None:
|
|
3534
|
+
hv.rpc.rpcconnect()
|
|
3535
|
+
m = Market(blockchain_instance=hv)
|
|
3723
3536
|
# Using built-in timezone support
|
|
3724
3537
|
stop = datetime.now(timezone.utc)
|
|
3725
3538
|
start = stop - timedelta(days=days)
|
|
3726
3539
|
intervall = timedelta(hours=hours)
|
|
3727
3540
|
trades = m.trade_history(start=start, stop=stop, limit=limit, intervall=intervall)
|
|
3728
3541
|
price = []
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
else:
|
|
3732
|
-
base_str = stm.backed_token_symbol
|
|
3542
|
+
# Hive-only: compute price as TOKEN/BACKED (e.g., HIVE/HBD)
|
|
3543
|
+
base_str = hv.token_symbol
|
|
3733
3544
|
for trade in trades:
|
|
3734
3545
|
base = 0
|
|
3735
3546
|
quote = 0
|
|
@@ -3744,26 +3555,15 @@ def tradehistory(days, hours, sbd_to_steem, hbd_to_hive, limit, width, height, a
|
|
|
3744
3555
|
chart = AsciiChart(
|
|
3745
3556
|
height=height, width=width, offset=3, placeholder="{:6.2f} ", charset=charset
|
|
3746
3557
|
)
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
stm.token_symbol,
|
|
3755
|
-
)
|
|
3756
|
-
)
|
|
3757
|
-
else:
|
|
3758
|
-
print(
|
|
3759
|
-
"\n Trade history %s - %s \n\n%s/%s"
|
|
3760
|
-
% (
|
|
3761
|
-
formatTimeString(start),
|
|
3762
|
-
formatTimeString(stop),
|
|
3763
|
-
stm.token_symbol,
|
|
3764
|
-
stm.backed_token_symbol,
|
|
3765
|
-
)
|
|
3558
|
+
print(
|
|
3559
|
+
"\n Trade history %s - %s \n\n%s/%s"
|
|
3560
|
+
% (
|
|
3561
|
+
formatTimeString(start),
|
|
3562
|
+
formatTimeString(stop),
|
|
3563
|
+
hv.token_symbol,
|
|
3564
|
+
hv.backed_token_symbol,
|
|
3766
3565
|
)
|
|
3566
|
+
)
|
|
3767
3567
|
chart.adapt_on_series(price)
|
|
3768
3568
|
chart.new_chart()
|
|
3769
3569
|
chart.add_axis()
|
|
@@ -3780,16 +3580,16 @@ def tradehistory(days, hours, sbd_to_steem, hbd_to_hive, limit, width, height, a
|
|
|
3780
3580
|
@click.option("--ascii", help="Use only ascii symbols", is_flag=True, default=False)
|
|
3781
3581
|
def orderbook(chart, limit, show_date, width, height, ascii):
|
|
3782
3582
|
"""Obtain orderbook of the internal market"""
|
|
3783
|
-
|
|
3784
|
-
if
|
|
3785
|
-
|
|
3786
|
-
market = Market(blockchain_instance=
|
|
3583
|
+
hv = shared_blockchain_instance()
|
|
3584
|
+
if hv.rpc is not None:
|
|
3585
|
+
hv.rpc.rpcconnect()
|
|
3586
|
+
market = Market(blockchain_instance=hv)
|
|
3787
3587
|
orderbook = market.orderbook(limit=limit, raw_data=False)
|
|
3788
3588
|
if not show_date:
|
|
3789
3589
|
header = [
|
|
3790
|
-
"Asks Sum " +
|
|
3590
|
+
"Asks Sum " + hv.backed_token_symbol,
|
|
3791
3591
|
"Sell Orders",
|
|
3792
|
-
"Bids Sum " +
|
|
3592
|
+
"Bids Sum " + hv.backed_token_symbol,
|
|
3793
3593
|
"Buy Orders",
|
|
3794
3594
|
]
|
|
3795
3595
|
else:
|
|
@@ -3807,13 +3607,13 @@ def orderbook(chart, limit, show_date, width, height, ascii):
|
|
|
3807
3607
|
n = 0
|
|
3808
3608
|
for order in orderbook["asks"]:
|
|
3809
3609
|
asks.append(order)
|
|
3810
|
-
sum_asks += float(order.as_base(
|
|
3610
|
+
sum_asks += float(order.as_base(hv.backed_token_symbol)["base"])
|
|
3811
3611
|
sumsum_asks.append(sum_asks)
|
|
3812
3612
|
if n < len(asks):
|
|
3813
3613
|
n = len(asks)
|
|
3814
3614
|
for order in orderbook["bids"]:
|
|
3815
3615
|
bids.append(order)
|
|
3816
|
-
sum_bids += float(order.as_base(
|
|
3616
|
+
sum_bids += float(order.as_base(hv.backed_token_symbol)["base"])
|
|
3817
3617
|
sumsum_bids.append(sum_bids)
|
|
3818
3618
|
if n < len(bids):
|
|
3819
3619
|
n = len(bids)
|
|
@@ -3884,37 +3684,37 @@ def orderbook(chart, limit, show_date, width, height, ascii):
|
|
|
3884
3684
|
@click.option("--orderid", help="Set an orderid")
|
|
3885
3685
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
3886
3686
|
def buy(amount, asset, price, account, orderid, export):
|
|
3887
|
-
"""Buy
|
|
3687
|
+
"""Buy HIVE or HBD from the internal market
|
|
3888
3688
|
|
|
3889
|
-
Limit buy price denoted in (
|
|
3689
|
+
Limit buy price denoted in (HBD per HIVE)
|
|
3890
3690
|
"""
|
|
3891
|
-
|
|
3892
|
-
if
|
|
3893
|
-
|
|
3691
|
+
hv = shared_blockchain_instance()
|
|
3692
|
+
if hv.rpc is not None:
|
|
3693
|
+
hv.rpc.rpcconnect()
|
|
3894
3694
|
if account is None:
|
|
3895
|
-
account =
|
|
3896
|
-
if asset ==
|
|
3695
|
+
account = hv.config["default_account"]
|
|
3696
|
+
if asset == hv.backed_token_symbol:
|
|
3897
3697
|
market = Market(
|
|
3898
|
-
base=Asset(
|
|
3899
|
-
quote=Asset(
|
|
3900
|
-
blockchain_instance=
|
|
3698
|
+
base=Asset(hv.token_symbol),
|
|
3699
|
+
quote=Asset(hv.backed_token_symbol),
|
|
3700
|
+
blockchain_instance=hv,
|
|
3901
3701
|
)
|
|
3902
3702
|
else:
|
|
3903
3703
|
market = Market(
|
|
3904
|
-
base=Asset(
|
|
3905
|
-
quote=Asset(
|
|
3906
|
-
blockchain_instance=
|
|
3704
|
+
base=Asset(hv.backed_token_symbol),
|
|
3705
|
+
quote=Asset(hv.token_symbol),
|
|
3706
|
+
blockchain_instance=hv,
|
|
3907
3707
|
)
|
|
3908
3708
|
if price is None:
|
|
3909
3709
|
orderbook = market.orderbook(limit=1, raw_data=False)
|
|
3910
|
-
if asset ==
|
|
3710
|
+
if asset == hv.token_symbol and len(orderbook["bids"]) > 0:
|
|
3911
3711
|
p = Price(
|
|
3912
|
-
orderbook["bids"][0]["base"], orderbook["bids"][0]["quote"], blockchain_instance=
|
|
3712
|
+
orderbook["bids"][0]["base"], orderbook["bids"][0]["quote"], blockchain_instance=hv
|
|
3913
3713
|
).invert()
|
|
3914
3714
|
p_show = p
|
|
3915
3715
|
elif len(orderbook["asks"]) > 0:
|
|
3916
3716
|
p = Price(
|
|
3917
|
-
orderbook["asks"][0]["base"], orderbook["asks"][0]["quote"], blockchain_instance=
|
|
3717
|
+
orderbook["asks"][0]["base"], orderbook["asks"][0]["quote"], blockchain_instance=hv
|
|
3918
3718
|
).invert()
|
|
3919
3719
|
p_show = p
|
|
3920
3720
|
price_ok = click.prompt("Is the following Price ok: %s [y/n]" % (str(p_show)))
|
|
@@ -3923,19 +3723,17 @@ def buy(amount, asset, price, account, orderid, export):
|
|
|
3923
3723
|
else:
|
|
3924
3724
|
p = Price(
|
|
3925
3725
|
float(price),
|
|
3926
|
-
"%s:%s" % (
|
|
3927
|
-
blockchain_instance=
|
|
3726
|
+
"%s:%s" % (hv.backed_token_symbol, hv.token_symbol),
|
|
3727
|
+
blockchain_instance=hv,
|
|
3928
3728
|
)
|
|
3929
|
-
if not unlock_wallet(
|
|
3729
|
+
if not unlock_wallet(hv):
|
|
3930
3730
|
return
|
|
3931
3731
|
|
|
3932
|
-
a = Amount(float(amount), asset, blockchain_instance=
|
|
3933
|
-
acc = Account(account, blockchain_instance=
|
|
3732
|
+
a = Amount(float(amount), asset, blockchain_instance=hv)
|
|
3733
|
+
acc = Account(account, blockchain_instance=hv)
|
|
3934
3734
|
tx = market.buy(p, a, account=acc, orderid=orderid)
|
|
3935
|
-
if
|
|
3936
|
-
tx =
|
|
3937
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
3938
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3735
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3736
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
3939
3737
|
export_trx(tx, export)
|
|
3940
3738
|
tx = json.dumps(tx, indent=4)
|
|
3941
3739
|
print(tx)
|
|
@@ -3949,37 +3747,37 @@ def buy(amount, asset, price, account, orderid, export):
|
|
|
3949
3747
|
@click.option("--orderid", help="Set an orderid")
|
|
3950
3748
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
3951
3749
|
def sell(amount, asset, price, account, orderid, export):
|
|
3952
|
-
"""Sell
|
|
3750
|
+
"""Sell HIVE or HBD from the internal market
|
|
3953
3751
|
|
|
3954
|
-
Limit sell price denoted in (
|
|
3752
|
+
Limit sell price denoted in (HBD per HIVE)
|
|
3955
3753
|
"""
|
|
3956
|
-
|
|
3957
|
-
if
|
|
3958
|
-
|
|
3959
|
-
if asset ==
|
|
3754
|
+
hv = shared_blockchain_instance()
|
|
3755
|
+
if hv.rpc is not None:
|
|
3756
|
+
hv.rpc.rpcconnect()
|
|
3757
|
+
if asset == hv.backed_token_symbol:
|
|
3960
3758
|
market = Market(
|
|
3961
|
-
base=Asset(
|
|
3962
|
-
quote=Asset(
|
|
3963
|
-
blockchain_instance=
|
|
3759
|
+
base=Asset(hv.token_symbol),
|
|
3760
|
+
quote=Asset(hv.backed_token_symbol),
|
|
3761
|
+
blockchain_instance=hv,
|
|
3964
3762
|
)
|
|
3965
3763
|
else:
|
|
3966
3764
|
market = Market(
|
|
3967
|
-
base=Asset(
|
|
3968
|
-
quote=Asset(
|
|
3969
|
-
blockchain_instance=
|
|
3765
|
+
base=Asset(hv.backed_token_symbol),
|
|
3766
|
+
quote=Asset(hv.token_symbol),
|
|
3767
|
+
blockchain_instance=hv,
|
|
3970
3768
|
)
|
|
3971
3769
|
if not account:
|
|
3972
|
-
account =
|
|
3770
|
+
account = hv.config["default_account"]
|
|
3973
3771
|
if not price:
|
|
3974
3772
|
orderbook = market.orderbook(limit=1, raw_data=False)
|
|
3975
|
-
if asset ==
|
|
3773
|
+
if asset == hv.backed_token_symbol and len(orderbook["bids"]) > 0:
|
|
3976
3774
|
p = Price(
|
|
3977
|
-
orderbook["bids"][0]["base"], orderbook["bids"][0]["quote"], blockchain_instance=
|
|
3775
|
+
orderbook["bids"][0]["base"], orderbook["bids"][0]["quote"], blockchain_instance=hv
|
|
3978
3776
|
).invert()
|
|
3979
3777
|
p_show = p
|
|
3980
3778
|
else:
|
|
3981
3779
|
p = Price(
|
|
3982
|
-
orderbook["asks"][0]["base"], orderbook["asks"][0]["quote"], blockchain_instance=
|
|
3780
|
+
orderbook["asks"][0]["base"], orderbook["asks"][0]["quote"], blockchain_instance=hv
|
|
3983
3781
|
).invert()
|
|
3984
3782
|
p_show = p
|
|
3985
3783
|
price_ok = click.prompt("Is the following Price ok: %s [y/n]" % (str(p_show)))
|
|
@@ -3988,18 +3786,16 @@ def sell(amount, asset, price, account, orderid, export):
|
|
|
3988
3786
|
else:
|
|
3989
3787
|
p = Price(
|
|
3990
3788
|
float(price),
|
|
3991
|
-
"%s:%s" % (
|
|
3992
|
-
blockchain_instance=
|
|
3789
|
+
"%s:%s" % (hv.backed_token_symbol, hv.token_symbol),
|
|
3790
|
+
blockchain_instance=hv,
|
|
3993
3791
|
)
|
|
3994
|
-
if not unlock_wallet(
|
|
3792
|
+
if not unlock_wallet(hv):
|
|
3995
3793
|
return
|
|
3996
|
-
a = Amount(float(amount), asset, blockchain_instance=
|
|
3997
|
-
acc = Account(account, blockchain_instance=
|
|
3794
|
+
a = Amount(float(amount), asset, blockchain_instance=hv)
|
|
3795
|
+
acc = Account(account, blockchain_instance=hv)
|
|
3998
3796
|
tx = market.sell(p, a, account=acc, orderid=orderid)
|
|
3999
|
-
if
|
|
4000
|
-
tx =
|
|
4001
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4002
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3797
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3798
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4003
3799
|
export_trx(tx, export)
|
|
4004
3800
|
tx = json.dumps(tx, indent=4)
|
|
4005
3801
|
print(tx)
|
|
@@ -4011,20 +3807,18 @@ def sell(amount, asset, price, account, orderid, export):
|
|
|
4011
3807
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
4012
3808
|
def cancel(orderid, account, export):
|
|
4013
3809
|
"""Cancel order in the internal market"""
|
|
4014
|
-
|
|
4015
|
-
if
|
|
4016
|
-
|
|
4017
|
-
market = Market(blockchain_instance=
|
|
3810
|
+
hv = shared_blockchain_instance()
|
|
3811
|
+
if hv.rpc is not None:
|
|
3812
|
+
hv.rpc.rpcconnect()
|
|
3813
|
+
market = Market(blockchain_instance=hv)
|
|
4018
3814
|
if not account:
|
|
4019
|
-
account =
|
|
4020
|
-
if not unlock_wallet(
|
|
3815
|
+
account = hv.config["default_account"]
|
|
3816
|
+
if not unlock_wallet(hv):
|
|
4021
3817
|
return
|
|
4022
|
-
acc = Account(account, blockchain_instance=
|
|
3818
|
+
acc = Account(account, blockchain_instance=hv)
|
|
4023
3819
|
tx = market.cancel(orderid, account=acc)
|
|
4024
|
-
if
|
|
4025
|
-
tx =
|
|
4026
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4027
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3820
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3821
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4028
3822
|
export_trx(tx, export)
|
|
4029
3823
|
tx = json.dumps(tx, indent=4)
|
|
4030
3824
|
print(tx)
|
|
@@ -4034,13 +3828,13 @@ def cancel(orderid, account, export):
|
|
|
4034
3828
|
@click.argument("account", nargs=1, required=False)
|
|
4035
3829
|
def openorders(account):
|
|
4036
3830
|
"""Show open orders"""
|
|
4037
|
-
|
|
4038
|
-
if
|
|
4039
|
-
|
|
4040
|
-
market = Market(blockchain_instance=
|
|
3831
|
+
hv = shared_blockchain_instance()
|
|
3832
|
+
if hv.rpc is not None:
|
|
3833
|
+
hv.rpc.rpcconnect()
|
|
3834
|
+
market = Market(blockchain_instance=hv)
|
|
4041
3835
|
if not account:
|
|
4042
|
-
account =
|
|
4043
|
-
acc = Account(account, blockchain_instance=
|
|
3836
|
+
account = hv.config["default_account"]
|
|
3837
|
+
acc = Account(account, blockchain_instance=hv)
|
|
4044
3838
|
openorders = market.accountopenorders(account=acc)
|
|
4045
3839
|
t = PrettyTable(["Orderid", "Created", "Order", "Account"], hrules=0)
|
|
4046
3840
|
t.align = "r"
|
|
@@ -4056,20 +3850,18 @@ def openorders(account):
|
|
|
4056
3850
|
@click.option("--account", "-a", help="Reblog as this user")
|
|
4057
3851
|
def reblog(identifier, account):
|
|
4058
3852
|
"""Reblog an existing post"""
|
|
4059
|
-
|
|
4060
|
-
if
|
|
4061
|
-
|
|
3853
|
+
hv = shared_blockchain_instance()
|
|
3854
|
+
if hv.rpc is not None:
|
|
3855
|
+
hv.rpc.rpcconnect()
|
|
4062
3856
|
if not account:
|
|
4063
|
-
account =
|
|
4064
|
-
if not unlock_wallet(
|
|
3857
|
+
account = hv.config["default_account"]
|
|
3858
|
+
if not unlock_wallet(hv):
|
|
4065
3859
|
return
|
|
4066
|
-
acc = Account(account, blockchain_instance=
|
|
4067
|
-
post = Comment(identifier, blockchain_instance=
|
|
4068
|
-
tx = post.
|
|
4069
|
-
if
|
|
4070
|
-
tx =
|
|
4071
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4072
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3860
|
+
acc = Account(account, blockchain_instance=hv)
|
|
3861
|
+
post = Comment(identifier, blockchain_instance=hv)
|
|
3862
|
+
tx = post.reblog(account=acc)
|
|
3863
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3864
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4073
3865
|
tx = json.dumps(tx, indent=4)
|
|
4074
3866
|
print(tx)
|
|
4075
3867
|
|
|
@@ -4084,21 +3876,19 @@ def follow(follow, account, what, export):
|
|
|
4084
3876
|
|
|
4085
3877
|
Can be blog ignore blacklist unblacklist follow_blacklist unfollow_blacklist follow_muted unfollow_muted on HIVE
|
|
4086
3878
|
"""
|
|
4087
|
-
|
|
4088
|
-
if
|
|
4089
|
-
|
|
3879
|
+
hv = shared_blockchain_instance()
|
|
3880
|
+
if hv.rpc is not None:
|
|
3881
|
+
hv.rpc.rpcconnect()
|
|
4090
3882
|
if not account:
|
|
4091
|
-
account =
|
|
3883
|
+
account = hv.config["default_account"]
|
|
4092
3884
|
if isinstance(what, str):
|
|
4093
3885
|
what = [what]
|
|
4094
|
-
if not unlock_wallet(
|
|
3886
|
+
if not unlock_wallet(hv):
|
|
4095
3887
|
return
|
|
4096
|
-
acc = Account(account, blockchain_instance=
|
|
3888
|
+
acc = Account(account, blockchain_instance=hv)
|
|
4097
3889
|
tx = acc.follow(follow, what=what)
|
|
4098
|
-
if
|
|
4099
|
-
tx =
|
|
4100
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4101
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3890
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3891
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4102
3892
|
export_trx(tx, export)
|
|
4103
3893
|
tx = json.dumps(tx, indent=4)
|
|
4104
3894
|
print(tx)
|
|
@@ -4111,21 +3901,19 @@ def follow(follow, account, what, export):
|
|
|
4111
3901
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
4112
3902
|
def mute(mute, account, what, export):
|
|
4113
3903
|
"""Mute another account"""
|
|
4114
|
-
|
|
4115
|
-
if
|
|
4116
|
-
|
|
3904
|
+
hv = shared_blockchain_instance()
|
|
3905
|
+
if hv.rpc is not None:
|
|
3906
|
+
hv.rpc.rpcconnect()
|
|
4117
3907
|
if not account:
|
|
4118
|
-
account =
|
|
3908
|
+
account = hv.config["default_account"]
|
|
4119
3909
|
if isinstance(what, str):
|
|
4120
3910
|
what = [what]
|
|
4121
|
-
if not unlock_wallet(
|
|
3911
|
+
if not unlock_wallet(hv):
|
|
4122
3912
|
return
|
|
4123
|
-
acc = Account(account, blockchain_instance=
|
|
3913
|
+
acc = Account(account, blockchain_instance=hv)
|
|
4124
3914
|
tx = acc.follow(mute, what=what)
|
|
4125
|
-
if
|
|
4126
|
-
tx =
|
|
4127
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4128
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3915
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3916
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4129
3917
|
export_trx(tx, export)
|
|
4130
3918
|
tx = json.dumps(tx, indent=4)
|
|
4131
3919
|
print(tx)
|
|
@@ -4137,19 +3925,17 @@ def mute(mute, account, what, export):
|
|
|
4137
3925
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
4138
3926
|
def unfollow(unfollow, account, export):
|
|
4139
3927
|
"""Unfollow/Unmute another account"""
|
|
4140
|
-
|
|
4141
|
-
if
|
|
4142
|
-
|
|
3928
|
+
hv = shared_blockchain_instance()
|
|
3929
|
+
if hv.rpc is not None:
|
|
3930
|
+
hv.rpc.rpcconnect()
|
|
4143
3931
|
if not account:
|
|
4144
|
-
account =
|
|
4145
|
-
if not unlock_wallet(
|
|
3932
|
+
account = hv.config["default_account"]
|
|
3933
|
+
if not unlock_wallet(hv):
|
|
4146
3934
|
return
|
|
4147
|
-
acc = Account(account, blockchain_instance=
|
|
3935
|
+
acc = Account(account, blockchain_instance=hv)
|
|
4148
3936
|
tx = acc.unfollow(unfollow)
|
|
4149
|
-
if
|
|
4150
|
-
tx =
|
|
4151
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4152
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3937
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3938
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4153
3939
|
export_trx(tx, export)
|
|
4154
3940
|
tx = json.dumps(tx, indent=4)
|
|
4155
3941
|
print(tx)
|
|
@@ -4159,7 +3945,6 @@ def unfollow(unfollow, account, export):
|
|
|
4159
3945
|
@click.option("--witness", help="Witness name")
|
|
4160
3946
|
@click.option("--maximum_block_size", help="Max block size")
|
|
4161
3947
|
@click.option("--account_creation_fee", help="Account creation fee")
|
|
4162
|
-
@click.option("--sbd_interest_rate", help="SBD interest rate in percent")
|
|
4163
3948
|
@click.option("--hbd_interest_rate", help="HBD interest rate in percent")
|
|
4164
3949
|
@click.option("--url", help="Witness URL")
|
|
4165
3950
|
@click.option("--signing_key", help="Signing Key")
|
|
@@ -4168,39 +3953,34 @@ def witnessupdate(
|
|
|
4168
3953
|
witness,
|
|
4169
3954
|
maximum_block_size,
|
|
4170
3955
|
account_creation_fee,
|
|
4171
|
-
sbd_interest_rate,
|
|
4172
3956
|
hbd_interest_rate,
|
|
4173
3957
|
url,
|
|
4174
3958
|
signing_key,
|
|
4175
3959
|
export,
|
|
4176
3960
|
):
|
|
4177
3961
|
"""Change witness properties"""
|
|
4178
|
-
|
|
4179
|
-
if
|
|
4180
|
-
|
|
3962
|
+
hv = shared_blockchain_instance()
|
|
3963
|
+
if hv.rpc is not None:
|
|
3964
|
+
hv.rpc.rpcconnect()
|
|
4181
3965
|
if not witness:
|
|
4182
|
-
witness =
|
|
4183
|
-
if not unlock_wallet(
|
|
3966
|
+
witness = hv.config["default_account"]
|
|
3967
|
+
if not unlock_wallet(hv):
|
|
4184
3968
|
return
|
|
4185
|
-
witness = Witness(witness, blockchain_instance=
|
|
3969
|
+
witness = Witness(witness, blockchain_instance=hv)
|
|
4186
3970
|
props = witness["props"]
|
|
4187
3971
|
if account_creation_fee is not None:
|
|
4188
3972
|
props["account_creation_fee"] = str(
|
|
4189
3973
|
Amount(
|
|
4190
|
-
"%.3f %s" % (float(account_creation_fee),
|
|
3974
|
+
"%.3f %s" % (float(account_creation_fee), hv.token_symbol), blockchain_instance=hv
|
|
4191
3975
|
)
|
|
4192
3976
|
)
|
|
4193
3977
|
if maximum_block_size is not None:
|
|
4194
3978
|
props["maximum_block_size"] = int(maximum_block_size)
|
|
4195
|
-
if sbd_interest_rate is not None:
|
|
4196
|
-
props["sbd_interest_rate"] = int(float(sbd_interest_rate) * 100)
|
|
4197
3979
|
if hbd_interest_rate is not None:
|
|
4198
3980
|
props["hbd_interest_rate"] = int(float(hbd_interest_rate) * 100)
|
|
4199
3981
|
tx = witness.update(signing_key or witness["signing_key"], url or witness["url"], props)
|
|
4200
|
-
if
|
|
4201
|
-
tx =
|
|
4202
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4203
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
3982
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
3983
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4204
3984
|
export_trx(tx, export)
|
|
4205
3985
|
tx = json.dumps(tx, indent=4)
|
|
4206
3986
|
print(tx)
|
|
@@ -4211,23 +3991,22 @@ def witnessupdate(
|
|
|
4211
3991
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
4212
3992
|
def witnessdisable(witness, export):
|
|
4213
3993
|
"""Disable a witness"""
|
|
4214
|
-
|
|
4215
|
-
if
|
|
4216
|
-
|
|
3994
|
+
hv = shared_blockchain_instance()
|
|
3995
|
+
if hv.rpc is not None:
|
|
3996
|
+
hv.rpc.rpcconnect()
|
|
4217
3997
|
if not witness:
|
|
4218
|
-
witness =
|
|
4219
|
-
if not unlock_wallet(
|
|
3998
|
+
witness = hv.config["default_account"]
|
|
3999
|
+
if not unlock_wallet(hv):
|
|
4220
4000
|
return
|
|
4221
|
-
witness = Witness(witness, blockchain_instance=
|
|
4001
|
+
witness = Witness(witness, blockchain_instance=hv)
|
|
4222
4002
|
if not witness.is_active:
|
|
4223
4003
|
print("Cannot disable a disabled witness!")
|
|
4224
4004
|
return
|
|
4225
4005
|
props = witness["props"]
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
4006
|
+
null_key = ("%s" + "1111111111111111111111111111111114T1Anm") % hv.prefix
|
|
4007
|
+
tx = witness.update(null_key, witness["url"], props)
|
|
4008
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
4009
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4231
4010
|
export_trx(tx, export)
|
|
4232
4011
|
tx = json.dumps(tx, indent=4)
|
|
4233
4012
|
print(tx)
|
|
@@ -4239,20 +4018,18 @@ def witnessdisable(witness, export):
|
|
|
4239
4018
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
4240
4019
|
def witnessenable(witness, signing_key, export):
|
|
4241
4020
|
"""Enable a witness"""
|
|
4242
|
-
|
|
4243
|
-
if
|
|
4244
|
-
|
|
4021
|
+
hv = shared_blockchain_instance()
|
|
4022
|
+
if hv.rpc is not None:
|
|
4023
|
+
hv.rpc.rpcconnect()
|
|
4245
4024
|
if not witness:
|
|
4246
|
-
witness =
|
|
4247
|
-
if not unlock_wallet(
|
|
4025
|
+
witness = hv.config["default_account"]
|
|
4026
|
+
if not unlock_wallet(hv):
|
|
4248
4027
|
return
|
|
4249
|
-
witness = Witness(witness, blockchain_instance=
|
|
4028
|
+
witness = Witness(witness, blockchain_instance=hv)
|
|
4250
4029
|
props = witness["props"]
|
|
4251
4030
|
tx = witness.update(signing_key, witness["url"], props)
|
|
4252
|
-
if
|
|
4253
|
-
tx =
|
|
4254
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4255
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
4031
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
4032
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4256
4033
|
export_trx(tx, export)
|
|
4257
4034
|
tx = json.dumps(tx, indent=4)
|
|
4258
4035
|
print(tx)
|
|
@@ -4263,7 +4040,6 @@ def witnessenable(witness, signing_key, export):
|
|
|
4263
4040
|
@click.argument("pub_signing_key", nargs=1)
|
|
4264
4041
|
@click.option("--maximum_block_size", help="Max block size", default=65536)
|
|
4265
4042
|
@click.option("--account_creation_fee", help="Account creation fee", default=0.1)
|
|
4266
|
-
@click.option("--sbd_interest_rate", help="SBD interest rate in percent", default=0.0)
|
|
4267
4043
|
@click.option("--hbd_interest_rate", help="HBD interest rate in percent", default=0.0)
|
|
4268
4044
|
@click.option("--url", help="Witness URL", default="")
|
|
4269
4045
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
@@ -4272,39 +4048,27 @@ def witnesscreate(
|
|
|
4272
4048
|
pub_signing_key,
|
|
4273
4049
|
maximum_block_size,
|
|
4274
4050
|
account_creation_fee,
|
|
4275
|
-
sbd_interest_rate,
|
|
4276
4051
|
hbd_interest_rate,
|
|
4277
4052
|
url,
|
|
4278
4053
|
export,
|
|
4279
4054
|
):
|
|
4280
4055
|
"""Create a witness"""
|
|
4281
|
-
|
|
4282
|
-
if
|
|
4283
|
-
|
|
4284
|
-
if not unlock_wallet(
|
|
4056
|
+
hv = shared_blockchain_instance()
|
|
4057
|
+
if hv.rpc is not None:
|
|
4058
|
+
hv.rpc.rpcconnect()
|
|
4059
|
+
if not unlock_wallet(hv):
|
|
4285
4060
|
return
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
"
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
}
|
|
4294
|
-
else:
|
|
4295
|
-
props = {
|
|
4296
|
-
"account_creation_fee": Amount(
|
|
4297
|
-
"%.3f %s" % (float(account_creation_fee), stm.token_symbol), blockchain_instance=stm
|
|
4298
|
-
),
|
|
4299
|
-
"maximum_block_size": int(maximum_block_size),
|
|
4300
|
-
"sbd_interest_rate": int(sbd_interest_rate * 100),
|
|
4301
|
-
}
|
|
4061
|
+
props = {
|
|
4062
|
+
"account_creation_fee": Amount(
|
|
4063
|
+
"%.3f %s" % (float(account_creation_fee), hv.token_symbol), blockchain_instance=hv
|
|
4064
|
+
),
|
|
4065
|
+
"maximum_block_size": int(maximum_block_size),
|
|
4066
|
+
"hbd_interest_rate": int(hbd_interest_rate * 100),
|
|
4067
|
+
}
|
|
4302
4068
|
|
|
4303
|
-
tx =
|
|
4304
|
-
if
|
|
4305
|
-
tx =
|
|
4306
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4307
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
4069
|
+
tx = hv.witness_update(pub_signing_key, url, props, account=witness)
|
|
4070
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
4071
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4308
4072
|
export_trx(tx, export)
|
|
4309
4073
|
tx = json.dumps(tx, indent=4)
|
|
4310
4074
|
print(tx)
|
|
@@ -4317,7 +4081,6 @@ def witnesscreate(
|
|
|
4317
4081
|
@click.option("--account_subsidy_budget", help="Account subisidy per block")
|
|
4318
4082
|
@click.option("--account_subsidy_decay", help="Per block decay of the account subsidy pool")
|
|
4319
4083
|
@click.option("--maximum_block_size", help="Max block size")
|
|
4320
|
-
@click.option("--sbd_interest_rate", help="SBD interest rate in percent")
|
|
4321
4084
|
@click.option("--hbd_interest_rate", help="HBD interest rate in percent")
|
|
4322
4085
|
@click.option("--new_signing_key", help="Set new signing key (pubkey)")
|
|
4323
4086
|
@click.option("--url", help="Witness URL")
|
|
@@ -4328,21 +4091,20 @@ def witnessproperties(
|
|
|
4328
4091
|
account_subsidy_budget,
|
|
4329
4092
|
account_subsidy_decay,
|
|
4330
4093
|
maximum_block_size,
|
|
4331
|
-
sbd_interest_rate,
|
|
4332
4094
|
hbd_interest_rate,
|
|
4333
4095
|
new_signing_key,
|
|
4334
4096
|
url,
|
|
4335
4097
|
):
|
|
4336
4098
|
"""Update witness properties of witness WITNESS with the witness signing key WIF"""
|
|
4337
|
-
|
|
4338
|
-
if
|
|
4339
|
-
|
|
4340
|
-
# if not unlock_wallet(
|
|
4099
|
+
hv = shared_blockchain_instance()
|
|
4100
|
+
if hv.rpc is not None:
|
|
4101
|
+
hv.rpc.rpcconnect()
|
|
4102
|
+
# if not unlock_wallet(hv):
|
|
4341
4103
|
# return
|
|
4342
4104
|
props = {}
|
|
4343
4105
|
if account_creation_fee is not None:
|
|
4344
4106
|
props["account_creation_fee"] = Amount(
|
|
4345
|
-
"%.3f %s" % (float(account_creation_fee),
|
|
4107
|
+
"%.3f %s" % (float(account_creation_fee), hv.token_symbol), blockchain_instance=hv
|
|
4346
4108
|
)
|
|
4347
4109
|
if account_subsidy_budget is not None:
|
|
4348
4110
|
props["account_subsidy_budget"] = int(account_subsidy_budget)
|
|
@@ -4350,8 +4112,6 @@ def witnessproperties(
|
|
|
4350
4112
|
props["account_subsidy_decay"] = int(account_subsidy_decay)
|
|
4351
4113
|
if maximum_block_size is not None:
|
|
4352
4114
|
props["maximum_block_size"] = int(maximum_block_size)
|
|
4353
|
-
if sbd_interest_rate is not None:
|
|
4354
|
-
props["sbd_interest_rate"] = int(float(sbd_interest_rate) * 100)
|
|
4355
4115
|
if hbd_interest_rate is not None:
|
|
4356
4116
|
props["hbd_interest_rate"] = int(float(hbd_interest_rate) * 100)
|
|
4357
4117
|
if new_signing_key is not None:
|
|
@@ -4359,11 +4119,9 @@ def witnessproperties(
|
|
|
4359
4119
|
if url is not None:
|
|
4360
4120
|
props["url"] = url
|
|
4361
4121
|
|
|
4362
|
-
tx =
|
|
4363
|
-
if
|
|
4364
|
-
tx =
|
|
4365
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4366
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
4122
|
+
tx = hv.witness_set_properties(wif, witness, props)
|
|
4123
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
4124
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4367
4125
|
tx = json.dumps(tx, indent=4)
|
|
4368
4126
|
print(tx)
|
|
4369
4127
|
|
|
@@ -4375,7 +4133,9 @@ def witnessproperties(
|
|
|
4375
4133
|
"--base", "-b", help="Set base manually, when not set the base is automatically calculated."
|
|
4376
4134
|
)
|
|
4377
4135
|
@click.option(
|
|
4378
|
-
"--quote",
|
|
4136
|
+
"--quote",
|
|
4137
|
+
"-q",
|
|
4138
|
+
help="HBD/HIVE quote manually; when not set, the base is automatically calculated.",
|
|
4379
4139
|
)
|
|
4380
4140
|
@click.option(
|
|
4381
4141
|
"--support-peg",
|
|
@@ -4385,76 +4145,61 @@ def witnessproperties(
|
|
|
4385
4145
|
)
|
|
4386
4146
|
def witnessfeed(witness, wif, base, quote, support_peg):
|
|
4387
4147
|
"""Publish price feed for a witness"""
|
|
4388
|
-
|
|
4389
|
-
if
|
|
4390
|
-
|
|
4148
|
+
hv = shared_blockchain_instance()
|
|
4149
|
+
if hv.rpc is not None:
|
|
4150
|
+
hv.rpc.rpcconnect()
|
|
4391
4151
|
if wif is None:
|
|
4392
|
-
if not unlock_wallet(
|
|
4152
|
+
if not unlock_wallet(hv):
|
|
4393
4153
|
return
|
|
4394
|
-
witness = Witness(witness, blockchain_instance=
|
|
4395
|
-
market = Market(blockchain_instance=
|
|
4396
|
-
|
|
4154
|
+
witness = Witness(witness, blockchain_instance=hv)
|
|
4155
|
+
market = Market(blockchain_instance=hv)
|
|
4156
|
+
# Prefer HBD exchange rate (Hive-only)
|
|
4397
4157
|
if "hbd_exchange_rate" in witness:
|
|
4398
|
-
use_hbd = True
|
|
4399
4158
|
old_base = witness["hbd_exchange_rate"]["base"]
|
|
4400
4159
|
old_quote = witness["hbd_exchange_rate"]["quote"]
|
|
4401
|
-
last_published_price = Price(witness["hbd_exchange_rate"], blockchain_instance=
|
|
4160
|
+
last_published_price = Price(witness["hbd_exchange_rate"], blockchain_instance=hv)
|
|
4402
4161
|
else:
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4162
|
+
# Fallback to current median price if no prior feed
|
|
4163
|
+
median = hv.get_current_median_history()
|
|
4164
|
+
old_base = median["base"]
|
|
4165
|
+
old_quote = median["quote"]
|
|
4166
|
+
last_published_price = Price(median, blockchain_instance=hv)
|
|
4406
4167
|
|
|
4407
|
-
steem_usd = None
|
|
4408
4168
|
hive_usd = None
|
|
4409
4169
|
print(
|
|
4410
4170
|
"Old price %.3f (base: %s, quote %s)" % (float(last_published_price), old_base, old_quote)
|
|
4411
4171
|
)
|
|
4412
4172
|
if quote is None and not support_peg:
|
|
4413
|
-
quote = Amount("1.000 %s" %
|
|
4414
|
-
elif quote is None
|
|
4415
|
-
latest_price = market.ticker()["latest"]
|
|
4416
|
-
if steem_usd is None:
|
|
4417
|
-
steem_usd = market.steem_usd_implied()
|
|
4418
|
-
sbd_usd = float(latest_price.as_base(stm.backed_token_symbol)) * steem_usd
|
|
4419
|
-
quote = Amount(1.0 / sbd_usd, stm.token_symbol, blockchain_instance=stm)
|
|
4420
|
-
elif quote is None and stm.is_hive:
|
|
4173
|
+
quote = Amount("1.000 %s" % hv.token_symbol, blockchain_instance=hv)
|
|
4174
|
+
elif quote is None:
|
|
4421
4175
|
latest_price = market.ticker()["latest"]
|
|
4422
4176
|
if hive_usd is None:
|
|
4423
4177
|
hive_usd = market.hive_usd_implied()
|
|
4424
|
-
hbd_usd = float(latest_price.as_base(
|
|
4425
|
-
quote = Amount(1.0 / hbd_usd,
|
|
4178
|
+
hbd_usd = float(latest_price.as_base(hv.backed_token_symbol)) * hive_usd
|
|
4179
|
+
quote = Amount(1.0 / hbd_usd, hv.token_symbol, blockchain_instance=hv)
|
|
4426
4180
|
else:
|
|
4427
|
-
if str(quote[-5:]).upper() ==
|
|
4428
|
-
quote = Amount(quote, blockchain_instance=
|
|
4181
|
+
if str(quote[-5:]).upper() == hv.token_symbol:
|
|
4182
|
+
quote = Amount(quote, blockchain_instance=hv)
|
|
4429
4183
|
else:
|
|
4430
|
-
quote = Amount(quote,
|
|
4431
|
-
if base is None
|
|
4432
|
-
if steem_usd is None:
|
|
4433
|
-
steem_usd = market.steem_usd_implied()
|
|
4434
|
-
base = Amount(steem_usd, stm.backed_token_symbol, blockchain_instance=stm)
|
|
4435
|
-
elif base is None and stm.is_hive:
|
|
4184
|
+
quote = Amount(quote, hv.token_symbol, blockchain_instance=hv)
|
|
4185
|
+
if base is None:
|
|
4436
4186
|
if hive_usd is None:
|
|
4437
4187
|
hive_usd = market.hive_usd_implied()
|
|
4438
|
-
base = Amount(hive_usd,
|
|
4188
|
+
base = Amount(hive_usd, hv.backed_token_symbol, blockchain_instance=hv)
|
|
4439
4189
|
else:
|
|
4440
|
-
if str(quote[-3:]).upper() ==
|
|
4441
|
-
base = Amount(base, blockchain_instance=
|
|
4190
|
+
if str(quote[-3:]).upper() == hv.backed_token_symbol:
|
|
4191
|
+
base = Amount(base, blockchain_instance=hv)
|
|
4442
4192
|
else:
|
|
4443
|
-
base = Amount(base,
|
|
4444
|
-
new_price = Price(base=base, quote=quote, blockchain_instance=
|
|
4193
|
+
base = Amount(base, hv.backed_token_symbol, blockchain_instance=hv)
|
|
4194
|
+
new_price = Price(base=base, quote=quote, blockchain_instance=hv)
|
|
4445
4195
|
print("New price %.3f (base: %s, quote %s)" % (float(new_price), base, quote))
|
|
4446
|
-
if wif is not None
|
|
4196
|
+
if wif is not None:
|
|
4447
4197
|
props = {"hbd_exchange_rate": new_price}
|
|
4448
|
-
tx =
|
|
4449
|
-
elif wif is not None:
|
|
4450
|
-
props = {"sbd_exchange_rate": new_price}
|
|
4451
|
-
tx = stm.witness_set_properties(wif, witness["owner"], props)
|
|
4198
|
+
tx = hv.witness_set_properties(wif, witness["owner"], props)
|
|
4452
4199
|
else:
|
|
4453
4200
|
tx = witness.feed_publish(base, quote=quote)
|
|
4454
|
-
if
|
|
4455
|
-
tx =
|
|
4456
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
4457
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
4201
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
4202
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
4458
4203
|
tx = json.dumps(tx, indent=4)
|
|
4459
4204
|
print(tx)
|
|
4460
4205
|
|
|
@@ -4463,23 +4208,28 @@ def witnessfeed(witness, wif, base, quote, support_peg):
|
|
|
4463
4208
|
@click.argument("witness", nargs=1)
|
|
4464
4209
|
def witness(witness):
|
|
4465
4210
|
"""List witness information"""
|
|
4466
|
-
|
|
4467
|
-
if
|
|
4468
|
-
|
|
4469
|
-
witness = Witness(witness, blockchain_instance=
|
|
4211
|
+
hv = shared_blockchain_instance()
|
|
4212
|
+
if hv.rpc is not None:
|
|
4213
|
+
hv.rpc.rpcconnect()
|
|
4214
|
+
witness = Witness(witness, blockchain_instance=hv)
|
|
4470
4215
|
witness_json = witness.json()
|
|
4471
|
-
witness_schedule =
|
|
4472
|
-
config =
|
|
4216
|
+
witness_schedule = hv.get_witness_schedule()
|
|
4217
|
+
config = hv.get_config()
|
|
4473
4218
|
if "VIRTUAL_SCHEDULE_LAP_LENGTH2" in config:
|
|
4474
4219
|
lap_length = int(config["VIRTUAL_SCHEDULE_LAP_LENGTH2"])
|
|
4475
4220
|
elif "HIVE_VIRTUAL_SCHEDULE_LAP_LENGTH2" in config:
|
|
4476
4221
|
lap_length = int(config["HIVE_VIRTUAL_SCHEDULE_LAP_LENGTH2"])
|
|
4477
4222
|
else:
|
|
4478
|
-
|
|
4223
|
+
# Hive-only default
|
|
4224
|
+
lap_length = int(
|
|
4225
|
+
config.get(
|
|
4226
|
+
"HIVE_VIRTUAL_SCHEDULE_LAP_LENGTH2", config.get("VIRTUAL_SCHEDULE_LAP_LENGTH2")
|
|
4227
|
+
)
|
|
4228
|
+
)
|
|
4479
4229
|
rank = 0
|
|
4480
4230
|
active_rank = 0
|
|
4481
4231
|
found = False
|
|
4482
|
-
witnesses = WitnessesRankedByVote(limit=250, blockchain_instance=
|
|
4232
|
+
witnesses = WitnessesRankedByVote(limit=250, blockchain_instance=hv)
|
|
4483
4233
|
vote_sum = witnesses.get_votes_sum()
|
|
4484
4234
|
for w in witnesses:
|
|
4485
4235
|
rank += 1
|
|
@@ -4495,7 +4245,7 @@ def witness(witness):
|
|
|
4495
4245
|
t.align = "l"
|
|
4496
4246
|
for key in sorted(witness_json):
|
|
4497
4247
|
value = witness_json[key]
|
|
4498
|
-
if key in ["props", "
|
|
4248
|
+
if key in ["props", "hbd_exchange_rate"]:
|
|
4499
4249
|
value = json.dumps(value, indent=4)
|
|
4500
4250
|
t.add_row([key, value])
|
|
4501
4251
|
if found:
|
|
@@ -4530,21 +4280,21 @@ def witness(witness):
|
|
|
4530
4280
|
@click.option("--limit", help="How many witnesses should be shown", default=100)
|
|
4531
4281
|
def witnesses(account, limit):
|
|
4532
4282
|
"""List witnesses"""
|
|
4533
|
-
|
|
4534
|
-
if
|
|
4535
|
-
|
|
4283
|
+
hv = shared_blockchain_instance()
|
|
4284
|
+
if hv.rpc is not None:
|
|
4285
|
+
hv.rpc.rpcconnect()
|
|
4536
4286
|
if account:
|
|
4537
|
-
account = Account(account, blockchain_instance=
|
|
4287
|
+
account = Account(account, blockchain_instance=hv)
|
|
4538
4288
|
account_name = account["name"]
|
|
4539
4289
|
if account["proxy"] != "":
|
|
4540
4290
|
account_name = account["proxy"]
|
|
4541
4291
|
account_type = "Proxy"
|
|
4542
4292
|
else:
|
|
4543
4293
|
account_type = "Account"
|
|
4544
|
-
witnesses = WitnessesVotedByAccount(account_name, blockchain_instance=
|
|
4294
|
+
witnesses = WitnessesVotedByAccount(account_name, blockchain_instance=hv)
|
|
4545
4295
|
print("%s: @%s (%d of 30)" % (account_type, account_name, len(witnesses)))
|
|
4546
4296
|
else:
|
|
4547
|
-
witnesses = WitnessesRankedByVote(limit=limit, blockchain_instance=
|
|
4297
|
+
witnesses = WitnessesRankedByVote(limit=limit, blockchain_instance=hv)
|
|
4548
4298
|
witnesses.printAsTable()
|
|
4549
4299
|
|
|
4550
4300
|
|
|
@@ -4559,11 +4309,11 @@ def witnesses(account, limit):
|
|
|
4559
4309
|
@click.option("--export", "-e", default=None, help="Export results to TXT-file")
|
|
4560
4310
|
def votes(account, direction, outgoing, incoming, days, export):
|
|
4561
4311
|
"""List outgoing/incoming account votes"""
|
|
4562
|
-
|
|
4563
|
-
if
|
|
4564
|
-
|
|
4312
|
+
hv = shared_blockchain_instance()
|
|
4313
|
+
if hv.rpc is not None:
|
|
4314
|
+
hv.rpc.rpcconnect()
|
|
4565
4315
|
if not account:
|
|
4566
|
-
account =
|
|
4316
|
+
account = hv.config["default_account"]
|
|
4567
4317
|
if direction is None and not incoming and not outgoing:
|
|
4568
4318
|
direction = "in"
|
|
4569
4319
|
# Using built-in timezone support
|
|
@@ -4571,16 +4321,16 @@ def votes(account, direction, outgoing, incoming, days, export):
|
|
|
4571
4321
|
out_votes_str = ""
|
|
4572
4322
|
in_votes_str = ""
|
|
4573
4323
|
if direction == "out" or outgoing:
|
|
4574
|
-
votes = AccountVotes(account, start=limit_time, blockchain_instance=
|
|
4324
|
+
votes = AccountVotes(account, start=limit_time, blockchain_instance=hv)
|
|
4575
4325
|
out_votes_str = votes.printAsTable(start=limit_time, return_str=True)
|
|
4576
4326
|
if direction == "in" or incoming:
|
|
4577
|
-
account = Account(account, blockchain_instance=
|
|
4327
|
+
account = Account(account, blockchain_instance=hv)
|
|
4578
4328
|
votes_list = []
|
|
4579
4329
|
for v in account.history(start=limit_time, only_ops=["vote"]):
|
|
4580
|
-
vote = Vote(v, blockchain_instance=
|
|
4330
|
+
vote = Vote(v, blockchain_instance=hv)
|
|
4581
4331
|
vote.refresh()
|
|
4582
4332
|
votes_list.append(vote)
|
|
4583
|
-
votes = ActiveVotes(votes_list, blockchain_instance=
|
|
4333
|
+
votes = ActiveVotes(votes_list, blockchain_instance=hv)
|
|
4584
4334
|
in_votes_str = votes.printAsTable(votee=account["name"], return_str=True)
|
|
4585
4335
|
if export:
|
|
4586
4336
|
with open(export, "w") as w:
|
|
@@ -4601,15 +4351,15 @@ def votes(account, direction, outgoing, incoming, days, export):
|
|
|
4601
4351
|
@click.option(
|
|
4602
4352
|
"--min-performance",
|
|
4603
4353
|
"-x",
|
|
4604
|
-
help="Show only votes with performance higher than the given value in HBD
|
|
4354
|
+
help="Show only votes with performance higher than the given value in HBD",
|
|
4605
4355
|
)
|
|
4606
4356
|
@click.option(
|
|
4607
4357
|
"--max-performance",
|
|
4608
4358
|
"-y",
|
|
4609
|
-
help="Show only votes with performance lower than the given value in HBD
|
|
4359
|
+
help="Show only votes with performance lower than the given value in HBD",
|
|
4610
4360
|
)
|
|
4611
4361
|
@click.option(
|
|
4612
|
-
"--payout", default=None, help="Show the curation for a potential payout in
|
|
4362
|
+
"--payout", default=None, help="Show the curation for a potential payout in HBD as float"
|
|
4613
4363
|
)
|
|
4614
4364
|
@click.option("--export", "-e", default=None, help="Export results to HTML-file")
|
|
4615
4365
|
@click.option("--short", "-s", is_flag=True, default=False, help="Show only Curation without sum")
|
|
@@ -4649,12 +4399,10 @@ def curation(
|
|
|
4649
4399
|
the fifth account vote in the given time duration (default is 7 days)
|
|
4650
4400
|
|
|
4651
4401
|
"""
|
|
4652
|
-
|
|
4653
|
-
if
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
if stm.is_hive:
|
|
4657
|
-
SP_symbol = "HP"
|
|
4402
|
+
hv = shared_blockchain_instance()
|
|
4403
|
+
if hv.rpc is not None:
|
|
4404
|
+
hv.rpc.rpcconnect()
|
|
4405
|
+
HP_symbol = "HP"
|
|
4658
4406
|
if authorperm is None:
|
|
4659
4407
|
authorperm = "all"
|
|
4660
4408
|
if account is None and authorperm != "all":
|
|
@@ -4663,10 +4411,10 @@ def curation(
|
|
|
4663
4411
|
show_all_voter = False
|
|
4664
4412
|
if authorperm == "all" or authorperm.isdigit():
|
|
4665
4413
|
if not account:
|
|
4666
|
-
account =
|
|
4414
|
+
account = hv.config["default_account"]
|
|
4667
4415
|
# Using built-in timezone support
|
|
4668
4416
|
limit_time = datetime.now(timezone.utc) - timedelta(days=7)
|
|
4669
|
-
votes = AccountVotes(account, start=limit_time, blockchain_instance=
|
|
4417
|
+
votes = AccountVotes(account, start=limit_time, blockchain_instance=hv)
|
|
4670
4418
|
authorperm_list = [vote.authorperm for vote in votes]
|
|
4671
4419
|
if authorperm.isdigit():
|
|
4672
4420
|
if len(authorperm_list) < int(authorperm):
|
|
@@ -4750,16 +4498,16 @@ def curation(
|
|
|
4750
4498
|
index = 0
|
|
4751
4499
|
for authorperm in authorperm_list:
|
|
4752
4500
|
index += 1
|
|
4753
|
-
comment = Comment(authorperm, blockchain_instance=
|
|
4501
|
+
comment = Comment(authorperm, blockchain_instance=hv)
|
|
4754
4502
|
if payout is not None and comment.is_pending():
|
|
4755
4503
|
payout = float(payout)
|
|
4756
4504
|
elif payout is not None:
|
|
4757
4505
|
payout = None
|
|
4758
|
-
|
|
4759
|
-
|
|
4506
|
+
curation_rewards_HBD = comment.get_curation_rewards(
|
|
4507
|
+
pending_payout_hbd=True, pending_payout_value=payout
|
|
4760
4508
|
)
|
|
4761
|
-
|
|
4762
|
-
|
|
4509
|
+
curation_rewards_HP = comment.get_curation_rewards(
|
|
4510
|
+
pending_payout_hbd=False, pending_payout_value=payout
|
|
4763
4511
|
)
|
|
4764
4512
|
rows = []
|
|
4765
4513
|
sum_curation = [0, 0, 0, 0]
|
|
@@ -4768,26 +4516,26 @@ def curation(
|
|
|
4768
4516
|
for vote in comment.get_votes():
|
|
4769
4517
|
vote_time = vote["time"]
|
|
4770
4518
|
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
if
|
|
4775
|
-
penalty = (comment.get_curation_penalty(vote_time=vote_time)) *
|
|
4776
|
-
performance = float(
|
|
4519
|
+
vote_HBD = hv.rshares_to_token_backed_dollar(int(vote["rshares"]))
|
|
4520
|
+
curation_HBD = curation_rewards_HBD["active_votes"][vote["voter"]]
|
|
4521
|
+
curation_HP = curation_rewards_HP["active_votes"][vote["voter"]]
|
|
4522
|
+
if vote_HBD > 0:
|
|
4523
|
+
penalty = (comment.get_curation_penalty(vote_time=vote_time)) * vote_HBD
|
|
4524
|
+
performance = float(curation_HBD) / vote_HBD * 100
|
|
4777
4525
|
else:
|
|
4778
4526
|
performance = 0
|
|
4779
4527
|
penalty = 0
|
|
4780
4528
|
vote_befor_min = ((vote_time) - comment["created"]).total_seconds() / 60
|
|
4781
|
-
sum_curation[0] +=
|
|
4529
|
+
sum_curation[0] += vote_HBD
|
|
4782
4530
|
sum_curation[1] += penalty
|
|
4783
|
-
sum_curation[2] += float(
|
|
4784
|
-
sum_curation[3] += float(
|
|
4531
|
+
sum_curation[2] += float(curation_HP)
|
|
4532
|
+
sum_curation[3] += float(curation_HBD)
|
|
4785
4533
|
row = [
|
|
4786
4534
|
vote["voter"],
|
|
4787
4535
|
vote_befor_min,
|
|
4788
|
-
|
|
4536
|
+
vote_HBD,
|
|
4789
4537
|
penalty,
|
|
4790
|
-
float(
|
|
4538
|
+
float(curation_HP),
|
|
4791
4539
|
performance,
|
|
4792
4540
|
]
|
|
4793
4541
|
|
|
@@ -4843,9 +4591,9 @@ def curation(
|
|
|
4843
4591
|
+ voter
|
|
4844
4592
|
+ [
|
|
4845
4593
|
"%.1f min" % row[1],
|
|
4846
|
-
"%.3f %s" % (float(row[2]),
|
|
4847
|
-
"%.3f %s" % (float(row[3]),
|
|
4848
|
-
"%.3f %s" % (row[4],
|
|
4594
|
+
"%.3f %s" % (float(row[2]), hv.backed_token_symbol),
|
|
4595
|
+
"%.3f %s" % (float(row[3]), hv.backed_token_symbol),
|
|
4596
|
+
"%.3f %s" % (row[4], HP_symbol),
|
|
4849
4597
|
"%.1f %%" % (row[5]),
|
|
4850
4598
|
]
|
|
4851
4599
|
)
|
|
@@ -4864,9 +4612,9 @@ def curation(
|
|
|
4864
4612
|
sum_line
|
|
4865
4613
|
+ [
|
|
4866
4614
|
"%.1f min" % highest_vote[1],
|
|
4867
|
-
"%.3f %s" % (float(highest_vote[2]),
|
|
4868
|
-
"%.3f %s" % (float(highest_vote[3]),
|
|
4869
|
-
"%.3f %s" % (highest_vote[4],
|
|
4615
|
+
"%.3f %s" % (float(highest_vote[2]), hv.backed_token_symbol),
|
|
4616
|
+
"%.3f %s" % (float(highest_vote[3]), hv.backed_token_symbol),
|
|
4617
|
+
"%.3f %s" % (highest_vote[4], HP_symbol),
|
|
4870
4618
|
"%.1f %%" % (highest_vote[5]),
|
|
4871
4619
|
]
|
|
4872
4620
|
)
|
|
@@ -4875,9 +4623,9 @@ def curation(
|
|
|
4875
4623
|
sum_line
|
|
4876
4624
|
+ [
|
|
4877
4625
|
"%.1f min" % max_curation[1],
|
|
4878
|
-
"%.3f %s" % (float(max_curation[2]),
|
|
4879
|
-
"%.3f %s" % (float(max_curation[3]),
|
|
4880
|
-
"%.3f %s" % (max_curation[4],
|
|
4626
|
+
"%.3f %s" % (float(max_curation[2]), hv.backed_token_symbol),
|
|
4627
|
+
"%.3f %s" % (float(max_curation[3]), hv.backed_token_symbol),
|
|
4628
|
+
"%.3f %s" % (max_curation[4], HP_symbol),
|
|
4881
4629
|
"%.1f %%" % (max_curation[5]),
|
|
4882
4630
|
]
|
|
4883
4631
|
)
|
|
@@ -4886,9 +4634,9 @@ def curation(
|
|
|
4886
4634
|
sum_line
|
|
4887
4635
|
+ [
|
|
4888
4636
|
"-",
|
|
4889
|
-
"%.3f %s" % (sum_curation[0],
|
|
4890
|
-
"%.3f %s" % (sum_curation[1],
|
|
4891
|
-
"%.3f %s" % (sum_curation[2],
|
|
4637
|
+
"%.3f %s" % (sum_curation[0], hv.backed_token_symbol),
|
|
4638
|
+
"%.3f %s" % (sum_curation[1], hv.backed_token_symbol),
|
|
4639
|
+
"%.3f %s" % (sum_curation[2], HP_symbol),
|
|
4892
4640
|
"%.2f %%" % curation_sum_percentage,
|
|
4893
4641
|
]
|
|
4894
4642
|
)
|
|
@@ -4922,11 +4670,11 @@ def curation(
|
|
|
4922
4670
|
)
|
|
4923
4671
|
def rewards(accounts, only_sum, post, comment, curation, length, author, permlink, title, days):
|
|
4924
4672
|
"""Lists received rewards"""
|
|
4925
|
-
|
|
4926
|
-
if
|
|
4927
|
-
|
|
4673
|
+
hv = shared_blockchain_instance()
|
|
4674
|
+
if hv.rpc is not None:
|
|
4675
|
+
hv.rpc.rpcconnect()
|
|
4928
4676
|
if not accounts:
|
|
4929
|
-
accounts = [
|
|
4677
|
+
accounts = [hv.config["default_account"]]
|
|
4930
4678
|
if not comment and not curation and not post:
|
|
4931
4679
|
post = True
|
|
4932
4680
|
permlink = True
|
|
@@ -4938,9 +4686,9 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
4938
4686
|
limit_time = now - timedelta(days=days)
|
|
4939
4687
|
for account in accounts:
|
|
4940
4688
|
sum_reward = [0, 0, 0, 0, 0]
|
|
4941
|
-
account = Account(account, blockchain_instance=
|
|
4942
|
-
median_price = Price(
|
|
4943
|
-
m = Market(blockchain_instance=
|
|
4689
|
+
account = Account(account, blockchain_instance=hv)
|
|
4690
|
+
median_price = Price(hv.get_current_median_history(), blockchain_instance=hv)
|
|
4691
|
+
m = Market(blockchain_instance=hv)
|
|
4944
4692
|
latest = m.ticker()["latest"]
|
|
4945
4693
|
if author and permlink:
|
|
4946
4694
|
t = PrettyTable(
|
|
@@ -4948,8 +4696,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
4948
4696
|
"Author",
|
|
4949
4697
|
"Permlink",
|
|
4950
4698
|
"Payout",
|
|
4951
|
-
|
|
4952
|
-
"%sP + %s" % (
|
|
4699
|
+
hv.backed_token_symbol,
|
|
4700
|
+
"%sP + %s" % (hv.token_symbol[0], hv.token_symbol),
|
|
4953
4701
|
"Liquid USD",
|
|
4954
4702
|
"Invested USD",
|
|
4955
4703
|
]
|
|
@@ -4960,8 +4708,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
4960
4708
|
"Author",
|
|
4961
4709
|
"Title",
|
|
4962
4710
|
"Payout",
|
|
4963
|
-
|
|
4964
|
-
"%sP + %s" % (
|
|
4711
|
+
hv.backed_token_symbol,
|
|
4712
|
+
"%sP + %s" % (hv.token_symbol[0], hv.token_symbol),
|
|
4965
4713
|
"Liquid USD",
|
|
4966
4714
|
"Invested USD",
|
|
4967
4715
|
]
|
|
@@ -4971,8 +4719,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
4971
4719
|
[
|
|
4972
4720
|
"Author",
|
|
4973
4721
|
"Payout",
|
|
4974
|
-
|
|
4975
|
-
"%sP + %s" % (
|
|
4722
|
+
hv.backed_token_symbol,
|
|
4723
|
+
"%sP + %s" % (hv.token_symbol[0], hv.token_symbol),
|
|
4976
4724
|
"Liquid USD",
|
|
4977
4725
|
"Invested USD",
|
|
4978
4726
|
]
|
|
@@ -4982,8 +4730,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
4982
4730
|
[
|
|
4983
4731
|
"Permlink",
|
|
4984
4732
|
"Payout",
|
|
4985
|
-
|
|
4986
|
-
"%sP + %s" % (
|
|
4733
|
+
hv.backed_token_symbol,
|
|
4734
|
+
"%sP + %s" % (hv.token_symbol[0], hv.token_symbol),
|
|
4987
4735
|
"Liquid USD",
|
|
4988
4736
|
"Invested USD",
|
|
4989
4737
|
]
|
|
@@ -4993,8 +4741,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
4993
4741
|
[
|
|
4994
4742
|
"Title",
|
|
4995
4743
|
"Payout",
|
|
4996
|
-
|
|
4997
|
-
"%sP + %s" % (
|
|
4744
|
+
hv.backed_token_symbol,
|
|
4745
|
+
"%sP + %s" % (hv.token_symbol[0], hv.token_symbol),
|
|
4998
4746
|
"Liquid USD",
|
|
4999
4747
|
"Invested USD",
|
|
5000
4748
|
]
|
|
@@ -5003,8 +4751,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
5003
4751
|
t = PrettyTable(
|
|
5004
4752
|
[
|
|
5005
4753
|
"Received",
|
|
5006
|
-
|
|
5007
|
-
"%sP + %s" % (
|
|
4754
|
+
hv.backed_token_symbol,
|
|
4755
|
+
"%sP + %s" % (hv.token_symbol[0], hv.token_symbol),
|
|
5008
4756
|
"Liquid USD",
|
|
5009
4757
|
"Invested USD",
|
|
5010
4758
|
]
|
|
@@ -5026,7 +4774,7 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
5026
4774
|
if not post and not comment and v["type"] == "author_reward":
|
|
5027
4775
|
continue
|
|
5028
4776
|
if v["type"] == "author_reward":
|
|
5029
|
-
c = Comment(v, blockchain_instance=
|
|
4777
|
+
c = Comment(v, blockchain_instance=hv)
|
|
5030
4778
|
try:
|
|
5031
4779
|
c.refresh()
|
|
5032
4780
|
except exceptions.ContentDoesNotExistsException:
|
|
@@ -5035,23 +4783,24 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
5035
4783
|
continue
|
|
5036
4784
|
if not comment and c.is_comment():
|
|
5037
4785
|
continue
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
sum_reward[
|
|
5046
|
-
|
|
5047
|
-
|
|
4786
|
+
# Initialize to zero to avoid UnboundLocalError and support missing fields
|
|
4787
|
+
payout_HBD = Amount("0.000 HBD", blockchain_instance=hv)
|
|
4788
|
+
payout_HIVE = Amount("0.000 HIVE", blockchain_instance=hv)
|
|
4789
|
+
if "hbd_payout" in v:
|
|
4790
|
+
payout_HBD = Amount(v["hbd_payout"], blockchain_instance=hv)
|
|
4791
|
+
if "hive_payout" in v:
|
|
4792
|
+
payout_HIVE = Amount(v["hive_payout"], blockchain_instance=hv)
|
|
4793
|
+
sum_reward[0] += float(payout_HBD)
|
|
4794
|
+
sum_reward[1] += float(payout_HIVE)
|
|
4795
|
+
payout_VESTS = hv.vests_to_token_power(
|
|
4796
|
+
Amount(v["vesting_payout"], blockchain_instance=hv)
|
|
5048
4797
|
)
|
|
5049
|
-
sum_reward[2] += float(
|
|
5050
|
-
liquid_USD = float(
|
|
5051
|
-
|
|
4798
|
+
sum_reward[2] += float(payout_VESTS)
|
|
4799
|
+
liquid_USD = float(payout_HBD) / float(latest) * float(median_price) + float(
|
|
4800
|
+
payout_HIVE
|
|
5052
4801
|
) * float(median_price)
|
|
5053
4802
|
sum_reward[3] += liquid_USD
|
|
5054
|
-
invested_USD = float(
|
|
4803
|
+
invested_USD = float(payout_VESTS) * float(median_price)
|
|
5055
4804
|
sum_reward[4] += invested_USD
|
|
5056
4805
|
if c.is_comment():
|
|
5057
4806
|
permlink_row = c.parent_permlink
|
|
@@ -5070,24 +4819,24 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
5070
4819
|
/ 60
|
|
5071
4820
|
/ 24
|
|
5072
4821
|
),
|
|
5073
|
-
(
|
|
5074
|
-
(
|
|
5075
|
-
(
|
|
4822
|
+
(payout_HBD),
|
|
4823
|
+
(payout_HIVE),
|
|
4824
|
+
(payout_VESTS),
|
|
5076
4825
|
(liquid_USD),
|
|
5077
4826
|
(invested_USD),
|
|
5078
4827
|
]
|
|
5079
4828
|
)
|
|
5080
4829
|
elif v["type"] == "curation_reward":
|
|
5081
|
-
reward = Amount(v["reward"], blockchain_instance=
|
|
5082
|
-
|
|
4830
|
+
reward = Amount(v["reward"], blockchain_instance=hv)
|
|
4831
|
+
payout_VESTS = hv.vests_to_token_power(reward)
|
|
5083
4832
|
liquid_USD = 0
|
|
5084
|
-
invested_USD = float(
|
|
5085
|
-
sum_reward[2] += float(
|
|
4833
|
+
invested_USD = float(payout_VESTS) * float(median_price)
|
|
4834
|
+
sum_reward[2] += float(payout_VESTS)
|
|
5086
4835
|
sum_reward[4] += invested_USD
|
|
5087
4836
|
if title:
|
|
5088
4837
|
c = Comment(
|
|
5089
4838
|
construct_authorperm(v["comment_author"], v["comment_permlink"]),
|
|
5090
|
-
blockchain_instance=
|
|
4839
|
+
blockchain_instance=hv,
|
|
5091
4840
|
)
|
|
5092
4841
|
permlink_row = c.title
|
|
5093
4842
|
else:
|
|
@@ -5104,7 +4853,7 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
5104
4853
|
),
|
|
5105
4854
|
0.000,
|
|
5106
4855
|
0.000,
|
|
5107
|
-
|
|
4856
|
+
payout_VESTS,
|
|
5108
4857
|
(liquid_USD),
|
|
5109
4858
|
(invested_USD),
|
|
5110
4859
|
]
|
|
@@ -5170,8 +4919,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
5170
4919
|
"Sum",
|
|
5171
4920
|
"-",
|
|
5172
4921
|
"-",
|
|
5173
|
-
"%.2f %s" % (sum_reward[0],
|
|
5174
|
-
"%.2f %sP" % (sum_reward[1] + sum_reward[2],
|
|
4922
|
+
"%.2f %s" % (sum_reward[0], hv.backed_token_symbol),
|
|
4923
|
+
"%.2f %sP" % (sum_reward[1] + sum_reward[2], hv.token_symbol[0]),
|
|
5175
4924
|
"%.2f $" % (sum_reward[3]),
|
|
5176
4925
|
"%.2f $" % (sum_reward[4]),
|
|
5177
4926
|
]
|
|
@@ -5181,8 +4930,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
5181
4930
|
t.add_row(
|
|
5182
4931
|
[
|
|
5183
4932
|
"Sum",
|
|
5184
|
-
"%.2f %s" % (sum_reward[0],
|
|
5185
|
-
"%.2f %sP" % (sum_reward[1] + sum_reward[2],
|
|
4933
|
+
"%.2f %s" % (sum_reward[0], hv.backed_token_symbol),
|
|
4934
|
+
"%.2f %sP" % (sum_reward[1] + sum_reward[2], hv.token_symbol[0]),
|
|
5186
4935
|
"%.2f $" % (sum_reward[2]),
|
|
5187
4936
|
"%.2f $" % (sum_reward[3]),
|
|
5188
4937
|
]
|
|
@@ -5193,8 +4942,8 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin
|
|
|
5193
4942
|
[
|
|
5194
4943
|
"Sum",
|
|
5195
4944
|
"-",
|
|
5196
|
-
"%.2f %s" % (sum_reward[0],
|
|
5197
|
-
"%.2f %sP" % (sum_reward[1] + sum_reward[2],
|
|
4945
|
+
"%.2f %s" % (sum_reward[0], hv.backed_token_symbol),
|
|
4946
|
+
"%.2f %sP" % (sum_reward[1] + sum_reward[2], hv.token_symbol[0]),
|
|
5198
4947
|
"%.2f $" % (sum_reward[3]),
|
|
5199
4948
|
"%.2f $" % (sum_reward[4]),
|
|
5200
4949
|
]
|
|
@@ -5248,11 +4997,11 @@ def pending(
|
|
|
5248
4997
|
accounts, only_sum, post, comment, curation, length, author, permlink, title, days, _from
|
|
5249
4998
|
):
|
|
5250
4999
|
"""Lists pending rewards"""
|
|
5251
|
-
|
|
5252
|
-
if
|
|
5253
|
-
|
|
5000
|
+
hv = shared_blockchain_instance()
|
|
5001
|
+
if hv.rpc is not None:
|
|
5002
|
+
hv.rpc.rpcconnect()
|
|
5254
5003
|
if not accounts:
|
|
5255
|
-
accounts = [
|
|
5004
|
+
accounts = [hv.config["default_account"]]
|
|
5256
5005
|
if not comment and not curation and not post:
|
|
5257
5006
|
post = True
|
|
5258
5007
|
permlink = True
|
|
@@ -5266,9 +5015,7 @@ def pending(
|
|
|
5266
5015
|
_from = 7
|
|
5267
5016
|
if _from + days > 7:
|
|
5268
5017
|
days = 7 - _from
|
|
5269
|
-
sp_symbol = "
|
|
5270
|
-
if stm.is_hive:
|
|
5271
|
-
sp_symbol = "HP"
|
|
5018
|
+
sp_symbol = "HP"
|
|
5272
5019
|
|
|
5273
5020
|
# Using built-in timezone support
|
|
5274
5021
|
max_limit_time = datetime.now(timezone.utc) - timedelta(days=7)
|
|
@@ -5276,9 +5023,9 @@ def pending(
|
|
|
5276
5023
|
start_time = datetime.now(timezone.utc) - timedelta(days=_from)
|
|
5277
5024
|
for account in accounts:
|
|
5278
5025
|
sum_reward = [0, 0, 0, 0]
|
|
5279
|
-
account = Account(account, blockchain_instance=
|
|
5280
|
-
median_price = Price(
|
|
5281
|
-
m = Market(blockchain_instance=
|
|
5026
|
+
account = Account(account, blockchain_instance=hv)
|
|
5027
|
+
median_price = Price(hv.get_current_median_history(), blockchain_instance=hv)
|
|
5028
|
+
m = Market(blockchain_instance=hv)
|
|
5282
5029
|
latest = m.ticker()["latest"]
|
|
5283
5030
|
if author and permlink:
|
|
5284
5031
|
t = PrettyTable(
|
|
@@ -5286,7 +5033,7 @@ def pending(
|
|
|
5286
5033
|
"Author",
|
|
5287
5034
|
"Permlink",
|
|
5288
5035
|
"Cashout",
|
|
5289
|
-
|
|
5036
|
+
hv.backed_token_symbol,
|
|
5290
5037
|
sp_symbol,
|
|
5291
5038
|
"Liquid USD",
|
|
5292
5039
|
"Invested USD",
|
|
@@ -5298,7 +5045,7 @@ def pending(
|
|
|
5298
5045
|
"Author",
|
|
5299
5046
|
"Title",
|
|
5300
5047
|
"Cashout",
|
|
5301
|
-
|
|
5048
|
+
hv.backed_token_symbol,
|
|
5302
5049
|
sp_symbol,
|
|
5303
5050
|
"Liquid USD",
|
|
5304
5051
|
"Invested USD",
|
|
@@ -5309,7 +5056,7 @@ def pending(
|
|
|
5309
5056
|
[
|
|
5310
5057
|
"Author",
|
|
5311
5058
|
"Cashout",
|
|
5312
|
-
|
|
5059
|
+
hv.backed_token_symbol,
|
|
5313
5060
|
sp_symbol,
|
|
5314
5061
|
"Liquid USD",
|
|
5315
5062
|
"Invested USD",
|
|
@@ -5320,7 +5067,7 @@ def pending(
|
|
|
5320
5067
|
[
|
|
5321
5068
|
"Permlink",
|
|
5322
5069
|
"Cashout",
|
|
5323
|
-
|
|
5070
|
+
hv.backed_token_symbol,
|
|
5324
5071
|
sp_symbol,
|
|
5325
5072
|
"Liquid USD",
|
|
5326
5073
|
"Invested USD",
|
|
@@ -5331,7 +5078,7 @@ def pending(
|
|
|
5331
5078
|
[
|
|
5332
5079
|
"Title",
|
|
5333
5080
|
"Cashout",
|
|
5334
|
-
|
|
5081
|
+
hv.backed_token_symbol,
|
|
5335
5082
|
sp_symbol,
|
|
5336
5083
|
"Liquid USD",
|
|
5337
5084
|
"Invested USD",
|
|
@@ -5339,7 +5086,7 @@ def pending(
|
|
|
5339
5086
|
)
|
|
5340
5087
|
else:
|
|
5341
5088
|
t = PrettyTable(
|
|
5342
|
-
["Cashout",
|
|
5089
|
+
["Cashout", hv.backed_token_symbol, sp_symbol, "Liquid USD", "Invested USD"]
|
|
5343
5090
|
)
|
|
5344
5091
|
t.align = "l"
|
|
5345
5092
|
rows = []
|
|
@@ -5364,7 +5111,7 @@ def pending(
|
|
|
5364
5111
|
except exceptions.ContentDoesNotExistsException:
|
|
5365
5112
|
continue
|
|
5366
5113
|
author_reward = v.get_author_rewards()
|
|
5367
|
-
if float(author_reward["
|
|
5114
|
+
if float(author_reward["total_payout_HBD"]) < 0.001:
|
|
5368
5115
|
continue
|
|
5369
5116
|
if v.permlink in c_list:
|
|
5370
5117
|
continue
|
|
@@ -5377,15 +5124,15 @@ def pending(
|
|
|
5377
5124
|
continue
|
|
5378
5125
|
if v["author"] != account["name"]:
|
|
5379
5126
|
continue
|
|
5380
|
-
|
|
5381
|
-
sum_reward[0] += float(
|
|
5382
|
-
|
|
5383
|
-
sum_reward[1] += float(
|
|
5127
|
+
payout_HBD = author_reward["payout_HBD"]
|
|
5128
|
+
sum_reward[0] += float(payout_HBD)
|
|
5129
|
+
payout_HP = author_reward["payout_HP"]
|
|
5130
|
+
sum_reward[1] += float(payout_HP)
|
|
5384
5131
|
liquid_USD = (
|
|
5385
|
-
float(author_reward["
|
|
5132
|
+
float(author_reward["payout_HBD"]) / float(latest) * float(median_price)
|
|
5386
5133
|
)
|
|
5387
5134
|
sum_reward[2] += liquid_USD
|
|
5388
|
-
invested_USD = float(author_reward["
|
|
5135
|
+
invested_USD = float(author_reward["payout_HP"]) * float(median_price)
|
|
5389
5136
|
sum_reward[3] += invested_USD
|
|
5390
5137
|
if v.is_comment():
|
|
5391
5138
|
permlink_row = v.permlink
|
|
@@ -5399,20 +5146,18 @@ def pending(
|
|
|
5399
5146
|
v["author"],
|
|
5400
5147
|
permlink_row,
|
|
5401
5148
|
((v["created"] - max_limit_time).total_seconds() / 60 / 60 / 24),
|
|
5402
|
-
(
|
|
5403
|
-
(
|
|
5149
|
+
(payout_HBD),
|
|
5150
|
+
(payout_HP),
|
|
5404
5151
|
(liquid_USD),
|
|
5405
5152
|
(invested_USD),
|
|
5406
5153
|
]
|
|
5407
5154
|
)
|
|
5408
5155
|
if curation:
|
|
5409
|
-
votes = AccountVotes(
|
|
5410
|
-
account, start=limit_time, stop=start_time, blockchain_instance=stm
|
|
5411
|
-
)
|
|
5156
|
+
votes = AccountVotes(account, start=limit_time, stop=start_time, blockchain_instance=hv)
|
|
5412
5157
|
for vote in votes:
|
|
5413
5158
|
authorperm = construct_authorperm(vote["author"], vote["permlink"])
|
|
5414
5159
|
try:
|
|
5415
|
-
c = Comment(authorperm, blockchain_instance=
|
|
5160
|
+
c = Comment(authorperm, blockchain_instance=hv)
|
|
5416
5161
|
except exceptions.ContentDoesNotExistsException:
|
|
5417
5162
|
continue
|
|
5418
5163
|
rewards = c.get_curation_rewards()
|
|
@@ -5421,10 +5166,10 @@ def pending(
|
|
|
5421
5166
|
days_to_payout = (c["created"] - max_limit_time).total_seconds() / 60 / 60 / 24
|
|
5422
5167
|
if days_to_payout < 0:
|
|
5423
5168
|
continue
|
|
5424
|
-
|
|
5169
|
+
payout_HP = rewards["active_votes"][account["name"]]
|
|
5425
5170
|
liquid_USD = 0
|
|
5426
|
-
invested_USD = float(
|
|
5427
|
-
sum_reward[1] += float(
|
|
5171
|
+
invested_USD = float(payout_HP) * float(median_price)
|
|
5172
|
+
sum_reward[1] += float(payout_HP)
|
|
5428
5173
|
sum_reward[3] += invested_USD
|
|
5429
5174
|
if title:
|
|
5430
5175
|
permlink_row = c.title
|
|
@@ -5436,7 +5181,7 @@ def pending(
|
|
|
5436
5181
|
permlink_row,
|
|
5437
5182
|
days_to_payout,
|
|
5438
5183
|
0.000,
|
|
5439
|
-
|
|
5184
|
+
payout_HP,
|
|
5440
5185
|
(liquid_USD),
|
|
5441
5186
|
(invested_USD),
|
|
5442
5187
|
]
|
|
@@ -5502,7 +5247,7 @@ def pending(
|
|
|
5502
5247
|
"Sum",
|
|
5503
5248
|
"-",
|
|
5504
5249
|
"-",
|
|
5505
|
-
"%.2f %s" % (sum_reward[0],
|
|
5250
|
+
"%.2f %s" % (sum_reward[0], hv.backed_token_symbol),
|
|
5506
5251
|
"%.2f %s" % (sum_reward[1], sp_symbol),
|
|
5507
5252
|
"%.2f $" % (sum_reward[2]),
|
|
5508
5253
|
"%.2f $" % (sum_reward[3]),
|
|
@@ -5513,7 +5258,7 @@ def pending(
|
|
|
5513
5258
|
t.add_row(
|
|
5514
5259
|
[
|
|
5515
5260
|
"Sum",
|
|
5516
|
-
"%.2f %s" % (sum_reward[0],
|
|
5261
|
+
"%.2f %s" % (sum_reward[0], hv.backed_token_symbol),
|
|
5517
5262
|
"%.2f %s" % (sum_reward[1], sp_symbol),
|
|
5518
5263
|
"%.2f $" % (sum_reward[2]),
|
|
5519
5264
|
"%.2f $" % (sum_reward[3]),
|
|
@@ -5525,7 +5270,7 @@ def pending(
|
|
|
5525
5270
|
[
|
|
5526
5271
|
"Sum",
|
|
5527
5272
|
"-",
|
|
5528
|
-
"%.2f %s" % (sum_reward[0],
|
|
5273
|
+
"%.2f %s" % (sum_reward[0], hv.backed_token_symbol),
|
|
5529
5274
|
"%.2f %s" % (sum_reward[1], sp_symbol),
|
|
5530
5275
|
"%.2f $" % (sum_reward[2]),
|
|
5531
5276
|
"%.2f $" % (sum_reward[3]),
|
|
@@ -5553,21 +5298,15 @@ def pending(
|
|
|
5553
5298
|
|
|
5554
5299
|
@cli.command()
|
|
5555
5300
|
@click.argument("account", nargs=1, required=False)
|
|
5556
|
-
@click.option("--
|
|
5557
|
-
@click.option("--reward_sbd", help="Amount of SBD/HBD you would like to claim", default=0)
|
|
5301
|
+
@click.option("--reward_sbd", help="Amount of HBD you would like to claim", default=0)
|
|
5558
5302
|
@click.option("--reward_vests", help="Amount of VESTS you would like to claim", default=0)
|
|
5559
|
-
@click.option(
|
|
5560
|
-
"--claim_all_steem", help="Claim all STEEM/HIVE, overwrites reward_steem", is_flag=True
|
|
5561
|
-
)
|
|
5562
|
-
@click.option("--claim_all_sbd", help="Claim all SBD/HBD, overwrites reward_sbd", is_flag=True)
|
|
5303
|
+
@click.option("--claim_all_sbd", help="Claim all HBD, overwrites reward_sbd", is_flag=True)
|
|
5563
5304
|
@click.option("--claim_all_vests", help="Claim all VESTS, overwrites reward_vests", is_flag=True)
|
|
5564
5305
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
5565
5306
|
def claimreward(
|
|
5566
5307
|
account,
|
|
5567
|
-
reward_steem,
|
|
5568
5308
|
reward_sbd,
|
|
5569
5309
|
reward_vests,
|
|
5570
|
-
claim_all_steem,
|
|
5571
5310
|
claim_all_sbd,
|
|
5572
5311
|
claim_all_vests,
|
|
5573
5312
|
export,
|
|
@@ -5576,12 +5315,12 @@ def claimreward(
|
|
|
5576
5315
|
|
|
5577
5316
|
By default, this will claim ``all`` outstanding balances.
|
|
5578
5317
|
"""
|
|
5579
|
-
|
|
5580
|
-
if
|
|
5581
|
-
|
|
5318
|
+
hv = shared_blockchain_instance()
|
|
5319
|
+
if hv.rpc is not None:
|
|
5320
|
+
hv.rpc.rpcconnect()
|
|
5582
5321
|
if not account:
|
|
5583
|
-
account =
|
|
5584
|
-
acc = Account(account, blockchain_instance=
|
|
5322
|
+
account = hv.config["default_account"]
|
|
5323
|
+
acc = Account(account, blockchain_instance=hv)
|
|
5585
5324
|
r = acc.balances["rewards"]
|
|
5586
5325
|
if len(r) == 3 and r[0].amount + r[1].amount + r[2].amount == 0:
|
|
5587
5326
|
print("Nothing to claim.")
|
|
@@ -5589,20 +5328,16 @@ def claimreward(
|
|
|
5589
5328
|
elif len(r) == 2 and r[0].amount + r[1].amount:
|
|
5590
5329
|
print("Nothing to claim.")
|
|
5591
5330
|
return
|
|
5592
|
-
if not unlock_wallet(
|
|
5331
|
+
if not unlock_wallet(hv):
|
|
5593
5332
|
return
|
|
5594
|
-
if claim_all_steem:
|
|
5595
|
-
reward_steem = r[0]
|
|
5596
5333
|
if claim_all_sbd:
|
|
5597
|
-
reward_sbd = r[
|
|
5334
|
+
reward_sbd = r[0]
|
|
5598
5335
|
if claim_all_vests:
|
|
5599
|
-
reward_vests = r[
|
|
5336
|
+
reward_vests = r[1]
|
|
5600
5337
|
|
|
5601
|
-
tx = acc.claim_reward_balance(
|
|
5602
|
-
if
|
|
5603
|
-
tx =
|
|
5604
|
-
elif stm.unsigned and stm.nobroadcast and stm.hivesigner is not None:
|
|
5605
|
-
tx = stm.hivesigner.url_from_tx(tx)
|
|
5338
|
+
tx = acc.claim_reward_balance(reward_sbd, reward_vests)
|
|
5339
|
+
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
5340
|
+
tx = hv.hivesigner.url_from_tx(tx)
|
|
5606
5341
|
export_trx(tx, export)
|
|
5607
5342
|
tx = json.dumps(tx, indent=4)
|
|
5608
5343
|
print(tx)
|
|
@@ -5633,18 +5368,18 @@ def customjson(jsonid, json_data, account, active, export):
|
|
|
5633
5368
|
data = import_custom_json(jsonid, json_data)
|
|
5634
5369
|
if data is None:
|
|
5635
5370
|
return
|
|
5636
|
-
|
|
5637
|
-
if
|
|
5638
|
-
|
|
5371
|
+
hv = shared_blockchain_instance()
|
|
5372
|
+
if hv.rpc is not None:
|
|
5373
|
+
hv.rpc.rpcconnect()
|
|
5639
5374
|
if not account:
|
|
5640
|
-
account =
|
|
5641
|
-
if not unlock_wallet(
|
|
5375
|
+
account = hv.config["default_account"]
|
|
5376
|
+
if not unlock_wallet(hv):
|
|
5642
5377
|
return
|
|
5643
|
-
|
|
5378
|
+
_acc = Account(account, blockchain_instance=hv)
|
|
5644
5379
|
if active:
|
|
5645
|
-
tx =
|
|
5380
|
+
tx = hv.custom_json(jsonid, data, required_auths=[account])
|
|
5646
5381
|
else:
|
|
5647
|
-
tx =
|
|
5382
|
+
tx = hv.custom_json(jsonid, data, required_posting_auths=[account])
|
|
5648
5383
|
export_trx(tx, export)
|
|
5649
5384
|
tx = json.dumps(tx, indent=4)
|
|
5650
5385
|
print(tx)
|
|
@@ -5662,16 +5397,16 @@ def customjson(jsonid, json_data, account, active, export):
|
|
|
5662
5397
|
)
|
|
5663
5398
|
def verify(blocknumber, trx, use_api):
|
|
5664
5399
|
"""Returns the public signing keys for a block"""
|
|
5665
|
-
|
|
5666
|
-
if
|
|
5667
|
-
|
|
5668
|
-
b = Blockchain(blockchain_instance=
|
|
5400
|
+
hv = shared_blockchain_instance()
|
|
5401
|
+
if hv.rpc is not None:
|
|
5402
|
+
hv.rpc.rpcconnect()
|
|
5403
|
+
b = Blockchain(blockchain_instance=hv)
|
|
5669
5404
|
i = 0
|
|
5670
5405
|
if not blocknumber:
|
|
5671
5406
|
blocknumber = b.get_current_block_num()
|
|
5672
5407
|
try:
|
|
5673
5408
|
int(blocknumber)
|
|
5674
|
-
block = Block(blocknumber, blockchain_instance=
|
|
5409
|
+
block = Block(blocknumber, blockchain_instance=hv)
|
|
5675
5410
|
if trx is not None:
|
|
5676
5411
|
i = int(trx)
|
|
5677
5412
|
trxs = [block.json_transactions[int(trx)]]
|
|
@@ -5680,7 +5415,7 @@ def verify(blocknumber, trx, use_api):
|
|
|
5680
5415
|
except Exception:
|
|
5681
5416
|
trxs = [b.get_transaction(blocknumber)]
|
|
5682
5417
|
blocknumber = trxs[0]["block_num"]
|
|
5683
|
-
wallet = Wallet(blockchain_instance=
|
|
5418
|
+
wallet = Wallet(blockchain_instance=hv)
|
|
5684
5419
|
t = PrettyTable(["trx", "Signer key", "Account"])
|
|
5685
5420
|
t.align = "l"
|
|
5686
5421
|
if not use_api:
|
|
@@ -5695,10 +5430,10 @@ def verify(blocknumber, trx, use_api):
|
|
|
5695
5430
|
tx = b.get_transaction(trx["transaction_id"])
|
|
5696
5431
|
signed_tx = Signed_Transaction(tx)
|
|
5697
5432
|
public_keys = []
|
|
5698
|
-
for key in signed_tx.verify(chain=
|
|
5699
|
-
public_keys.append(format(Base58(key, prefix=
|
|
5433
|
+
for key in signed_tx.verify(chain=hv.chain_params, recover_parameter=True):
|
|
5434
|
+
public_keys.append(format(Base58(key, prefix=hv.prefix), hv.prefix))
|
|
5700
5435
|
else:
|
|
5701
|
-
tx = TransactionBuilder(tx=trx, blockchain_instance=
|
|
5436
|
+
tx = TransactionBuilder(tx=trx, blockchain_instance=hv)
|
|
5702
5437
|
public_keys = tx.get_potential_signatures()
|
|
5703
5438
|
accounts = []
|
|
5704
5439
|
empty_public_keys = []
|
|
@@ -5731,15 +5466,15 @@ def verify(blocknumber, trx, use_api):
|
|
|
5731
5466
|
@cli.command()
|
|
5732
5467
|
def chainconfig():
|
|
5733
5468
|
"""Prints chain config in a table"""
|
|
5734
|
-
|
|
5735
|
-
if
|
|
5736
|
-
|
|
5737
|
-
chain_config =
|
|
5469
|
+
hv = shared_blockchain_instance()
|
|
5470
|
+
if hv.rpc is not None:
|
|
5471
|
+
hv.rpc.rpcconnect()
|
|
5472
|
+
chain_config = hv.get_config()
|
|
5738
5473
|
t = PrettyTable(["Key", "Value"])
|
|
5739
5474
|
t.align = "l"
|
|
5740
5475
|
for key in chain_config:
|
|
5741
5476
|
if isinstance(chain_config[key], dict) and "amount" in chain_config[key]:
|
|
5742
|
-
t.add_row([key, str(Amount(chain_config[key], blockchain_instance=
|
|
5477
|
+
t.add_row([key, str(Amount(chain_config[key], blockchain_instance=hv))])
|
|
5743
5478
|
else:
|
|
5744
5479
|
t.add_row([key, chain_config[key]])
|
|
5745
5480
|
print(t)
|
|
@@ -5753,35 +5488,35 @@ def info(objects):
|
|
|
5753
5488
|
General information about the blockchain, a block, an account,
|
|
5754
5489
|
a post/comment and a public key
|
|
5755
5490
|
"""
|
|
5756
|
-
|
|
5757
|
-
if
|
|
5758
|
-
|
|
5491
|
+
hv = shared_blockchain_instance()
|
|
5492
|
+
if hv.rpc is not None:
|
|
5493
|
+
hv.rpc.rpcconnect()
|
|
5759
5494
|
if not objects:
|
|
5760
5495
|
t = PrettyTable(["Key", "Value"])
|
|
5761
5496
|
t.align = "l"
|
|
5762
|
-
info =
|
|
5763
|
-
median_price =
|
|
5764
|
-
token_per_mvest =
|
|
5765
|
-
chain_props =
|
|
5497
|
+
info = hv.get_dynamic_global_properties()
|
|
5498
|
+
median_price = hv.get_current_median_history()
|
|
5499
|
+
token_per_mvest = hv.get_token_per_mvest()
|
|
5500
|
+
chain_props = hv.get_chain_properties()
|
|
5766
5501
|
try:
|
|
5767
5502
|
price = (
|
|
5768
|
-
Amount(median_price["base"], blockchain_instance=
|
|
5769
|
-
/ Amount(median_price["quote"], blockchain_instance=
|
|
5503
|
+
Amount(median_price["base"], blockchain_instance=hv).amount
|
|
5504
|
+
/ Amount(median_price["quote"], blockchain_instance=hv).amount
|
|
5770
5505
|
)
|
|
5771
5506
|
except Exception:
|
|
5772
5507
|
price = None
|
|
5773
5508
|
for key in info:
|
|
5774
5509
|
if isinstance(info[key], dict) and "amount" in info[key]:
|
|
5775
|
-
t.add_row([key, str(Amount(info[key], blockchain_instance=
|
|
5510
|
+
t.add_row([key, str(Amount(info[key], blockchain_instance=hv))])
|
|
5776
5511
|
else:
|
|
5777
5512
|
t.add_row([key, info[key]])
|
|
5778
|
-
t.add_row(["%s per mvest" %
|
|
5513
|
+
t.add_row(["%s per mvest" % hv.token_symbol, token_per_mvest])
|
|
5779
5514
|
if price is not None:
|
|
5780
5515
|
t.add_row(["internal price", price])
|
|
5781
5516
|
t.add_row(
|
|
5782
5517
|
[
|
|
5783
5518
|
"account_creation_fee",
|
|
5784
|
-
str(Amount(chain_props["account_creation_fee"], blockchain_instance=
|
|
5519
|
+
str(Amount(chain_props["account_creation_fee"], blockchain_instance=hv)),
|
|
5785
5520
|
]
|
|
5786
5521
|
)
|
|
5787
5522
|
print(t.get_string(sortby="Key"))
|
|
@@ -5797,11 +5532,11 @@ def info(objects):
|
|
|
5797
5532
|
if re.match(r"^[0-9-]*:[0-9-]", obj):
|
|
5798
5533
|
obj, tran_nr = obj.split(":")
|
|
5799
5534
|
if int(obj) < 1:
|
|
5800
|
-
b = Blockchain(blockchain_instance=
|
|
5535
|
+
b = Blockchain(blockchain_instance=hv)
|
|
5801
5536
|
block_number = b.get_current_block_num() + int(obj) - 1
|
|
5802
5537
|
else:
|
|
5803
5538
|
block_number = obj
|
|
5804
|
-
block = Block(block_number, blockchain_instance=
|
|
5539
|
+
block = Block(block_number, blockchain_instance=hv)
|
|
5805
5540
|
if block:
|
|
5806
5541
|
t = PrettyTable(["Key", "Value"])
|
|
5807
5542
|
t.align = "l"
|
|
@@ -5838,7 +5573,7 @@ def info(objects):
|
|
|
5838
5573
|
else:
|
|
5839
5574
|
print("Block number %s unknown" % obj)
|
|
5840
5575
|
elif re.match(r"^[a-zA-Z0-9\-\._]{2,16}$", obj):
|
|
5841
|
-
account = Account(obj, blockchain_instance=
|
|
5576
|
+
account = Account(obj, blockchain_instance=hv)
|
|
5842
5577
|
t = PrettyTable(["Key", "Value"])
|
|
5843
5578
|
t.align = "l"
|
|
5844
5579
|
t._max_width = {"Value": 80}
|
|
@@ -5860,24 +5595,24 @@ def info(objects):
|
|
|
5860
5595
|
|
|
5861
5596
|
# witness available?
|
|
5862
5597
|
try:
|
|
5863
|
-
witness = Witness(obj, blockchain_instance=
|
|
5598
|
+
witness = Witness(obj, blockchain_instance=hv)
|
|
5864
5599
|
witness_json = witness.json()
|
|
5865
5600
|
t = PrettyTable(["Key", "Value"])
|
|
5866
5601
|
t.align = "l"
|
|
5867
5602
|
for key in sorted(witness_json):
|
|
5868
5603
|
value = witness_json[key]
|
|
5869
|
-
if key in ["props", "
|
|
5604
|
+
if key in ["props", "hbd_exchange_rate"]:
|
|
5870
5605
|
value = json.dumps(value, indent=4)
|
|
5871
5606
|
t.add_row([key, value])
|
|
5872
5607
|
print(t)
|
|
5873
5608
|
except exceptions.WitnessDoesNotExistsException as e:
|
|
5874
5609
|
print(str(e))
|
|
5875
5610
|
# Public Key
|
|
5876
|
-
elif re.match(r"^" +
|
|
5877
|
-
account =
|
|
5611
|
+
elif re.match(r"^" + hv.prefix + ".{48,55}$", obj):
|
|
5612
|
+
account = hv.wallet.getAccountFromPublicKey(obj)
|
|
5878
5613
|
if account:
|
|
5879
|
-
account = Account(account, blockchain_instance=
|
|
5880
|
-
key_type =
|
|
5614
|
+
account = Account(account, blockchain_instance=hv)
|
|
5615
|
+
key_type = hv.wallet.getKeyType(account, obj)
|
|
5881
5616
|
t = PrettyTable(["Account", "Key_type"])
|
|
5882
5617
|
t.align = "l"
|
|
5883
5618
|
t._max_width = {"Value": 80}
|
|
@@ -5887,7 +5622,7 @@ def info(objects):
|
|
|
5887
5622
|
print("Public Key %s not known" % obj)
|
|
5888
5623
|
# Post identifier
|
|
5889
5624
|
elif re.match(r".*@.{3,16}/.*$", obj):
|
|
5890
|
-
post = Comment(obj, blockchain_instance=
|
|
5625
|
+
post = Comment(obj, blockchain_instance=hv)
|
|
5891
5626
|
post_json = post.json()
|
|
5892
5627
|
if post_json:
|
|
5893
5628
|
t = PrettyTable(["Key", "Value"])
|
|
@@ -5908,7 +5643,7 @@ def info(objects):
|
|
|
5908
5643
|
else:
|
|
5909
5644
|
print("Post now known" % obj)
|
|
5910
5645
|
elif re.match(r"^[a-zA-Z0-9\_]{40}$", obj):
|
|
5911
|
-
b = Blockchain(blockchain_instance=
|
|
5646
|
+
b = Blockchain(blockchain_instance=hv)
|
|
5912
5647
|
from nectarapi.exceptions import UnknownTransaction
|
|
5913
5648
|
|
|
5914
5649
|
try:
|
|
@@ -5937,25 +5672,12 @@ def userdata(account, signing_account):
|
|
|
5937
5672
|
|
|
5938
5673
|
The request has to be signed by the requested account or an admin account.
|
|
5939
5674
|
"""
|
|
5940
|
-
|
|
5941
|
-
if
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
if "default_account" in stm.config:
|
|
5947
|
-
account = stm.config["default_account"]
|
|
5948
|
-
account = Account(account, blockchain_instance=stm)
|
|
5949
|
-
if signing_account is not None:
|
|
5950
|
-
signing_account = Account(signing_account, blockchain_instance=stm)
|
|
5951
|
-
c = Conveyor(blockchain_instance=stm)
|
|
5952
|
-
user_data = c.get_user_data(account, signing_account=signing_account)
|
|
5953
|
-
t = PrettyTable(["Key", "Value"])
|
|
5954
|
-
t.align = "l"
|
|
5955
|
-
for key in user_data:
|
|
5956
|
-
# hide internal config data
|
|
5957
|
-
t.add_row([key, user_data[key]])
|
|
5958
|
-
print(t)
|
|
5675
|
+
hv = shared_blockchain_instance()
|
|
5676
|
+
if hv.rpc is not None:
|
|
5677
|
+
hv.rpc.rpcconnect()
|
|
5678
|
+
# Removed in Hive-only build
|
|
5679
|
+
print("'userdata' command is no longer available in the Hive-only build.")
|
|
5680
|
+
return
|
|
5959
5681
|
|
|
5960
5682
|
|
|
5961
5683
|
@cli.command()
|
|
@@ -5983,13 +5705,13 @@ def userdata(account, signing_account):
|
|
|
5983
5705
|
@click.option("--json-file", "-j", help="When set, the results are written into a json file")
|
|
5984
5706
|
def history(account, limit, sort, max_length, virtual_ops, only_ops, exclude_ops, json_file):
|
|
5985
5707
|
"""Returns account history operations as table"""
|
|
5986
|
-
|
|
5987
|
-
if
|
|
5988
|
-
|
|
5708
|
+
hv = shared_blockchain_instance()
|
|
5709
|
+
if hv.rpc is not None:
|
|
5710
|
+
hv.rpc.rpcconnect()
|
|
5989
5711
|
if not account:
|
|
5990
|
-
if "default_account" in
|
|
5991
|
-
account =
|
|
5992
|
-
account = Account(account, blockchain_instance=
|
|
5712
|
+
if "default_account" in hv.config:
|
|
5713
|
+
account = hv.config["default_account"]
|
|
5714
|
+
account = Account(account, blockchain_instance=hv)
|
|
5993
5715
|
t = PrettyTable(["Index", "Type", "Hist op"])
|
|
5994
5716
|
t.align = "l"
|
|
5995
5717
|
t._max_width = {"Hist op": max_length}
|
|
@@ -6035,7 +5757,7 @@ def history(account, limit, sort, max_length, virtual_ops, only_ops, exclude_ops
|
|
|
6035
5757
|
h.pop("trx_id")
|
|
6036
5758
|
for key in h:
|
|
6037
5759
|
if isinstance(h[key], dict) and "nai" in h[key]:
|
|
6038
|
-
h[key] = str(Amount(h[key], blockchain_instance=
|
|
5760
|
+
h[key] = str(Amount(h[key], blockchain_instance=hv))
|
|
6039
5761
|
if key == "json" or key == "json_metadata" and h[key] is not None and h[key] != "":
|
|
6040
5762
|
h[key] = json.loads(h[key])
|
|
6041
5763
|
value = json.dumps(h, indent=4)
|
|
@@ -6056,25 +5778,12 @@ def featureflags(account, signing_account):
|
|
|
6056
5778
|
|
|
6057
5779
|
The request has to be signed by the requested account or an admin account.
|
|
6058
5780
|
"""
|
|
6059
|
-
|
|
6060
|
-
if
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
if "default_account" in stm.config:
|
|
6066
|
-
account = stm.config["default_account"]
|
|
6067
|
-
account = Account(account, blockchain_instance=stm)
|
|
6068
|
-
if signing_account is not None:
|
|
6069
|
-
signing_account = Account(signing_account, blockchain_instance=stm)
|
|
6070
|
-
c = Conveyor(blockchain_instance=stm)
|
|
6071
|
-
user_data = c.get_feature_flags(account, signing_account=signing_account)
|
|
6072
|
-
t = PrettyTable(["Key", "Value"])
|
|
6073
|
-
t.align = "l"
|
|
6074
|
-
for key in user_data:
|
|
6075
|
-
# hide internal config data
|
|
6076
|
-
t.add_row([key, user_data[key]])
|
|
6077
|
-
print(t)
|
|
5781
|
+
hv = shared_blockchain_instance()
|
|
5782
|
+
if hv.rpc is not None:
|
|
5783
|
+
hv.rpc.rpcconnect()
|
|
5784
|
+
# Removed in Hive-only build
|
|
5785
|
+
print("'featureflags' command is no longer available in the Hive-only build.")
|
|
5786
|
+
return
|
|
6078
5787
|
|
|
6079
5788
|
|
|
6080
5789
|
@cli.command()
|
|
@@ -6140,19 +5849,19 @@ def draw(
|
|
|
6140
5849
|
|
|
6141
5850
|
When using --reply, the result is directly broadcasted as comment
|
|
6142
5851
|
"""
|
|
6143
|
-
|
|
6144
|
-
if
|
|
6145
|
-
|
|
5852
|
+
hv = shared_blockchain_instance()
|
|
5853
|
+
if hv.rpc is not None:
|
|
5854
|
+
hv.rpc.rpcconnect()
|
|
6146
5855
|
if not account:
|
|
6147
|
-
account =
|
|
5856
|
+
account = hv.config["default_account"]
|
|
6148
5857
|
if reply is not None:
|
|
6149
|
-
if not unlock_wallet(
|
|
5858
|
+
if not unlock_wallet(hv):
|
|
6150
5859
|
return
|
|
6151
|
-
reply_comment = Comment(reply, blockchain_instance=
|
|
5860
|
+
reply_comment = Comment(reply, blockchain_instance=hv)
|
|
6152
5861
|
if block is not None and block != "":
|
|
6153
|
-
block = Block(int(block), blockchain_instance=
|
|
5862
|
+
block = Block(int(block), blockchain_instance=hv)
|
|
6154
5863
|
else:
|
|
6155
|
-
blockchain = Blockchain(blockchain_instance=
|
|
5864
|
+
blockchain = Blockchain(blockchain_instance=hv)
|
|
6156
5865
|
block = blockchain.get_current_block()
|
|
6157
5866
|
data = None
|
|
6158
5867
|
|