Skip to content

Commit

Permalink
Bit20 only tries to import 'announce' key when not already present
Browse files Browse the repository at this point in the history
  • Loading branch information
wackou committed Feb 5, 2018
1 parent 6cfd660 commit 4c2cd7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 8 additions & 5 deletions bts_tools/feed_providers/bit20.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ def get_bit20_feed_usd(node):
bit20feed = node.get_account_history('bittwenty.feed', 15)

if not bit20feed:
# import the 'announce' key to be able to read the memo publications
log.info('Importing the "announce" key in the wallet')
node.import_key('announce', '5KJJNfiSyzsbHoVb81WkHHjaX2vZVQ1Fqq5wE5ro8HWXe6qNFyQ')
# try again
bit20feed = node.get_account_history('bittwenty.feed', 15)
BIT20_ANNOUNCE_KEY = '5KJJNfiSyzsbHoVb81WkHHjaX2vZVQ1Fqq5wE5ro8HWXe6qNFyQ'
announce_key_exists = any(priv == BIT20_ANNOUNCE_KEY for pub, priv in node.dump_private_keys())
if not announce_key_exists:
# import the 'announce' key to be able to read the memo publications
log.info('Importing the "announce" key in the wallet')
node.import_key('announce', BIT20_ANNOUNCE_KEY)
# try again
bit20feed = node.get_account_history('bittwenty.feed', 15)

# find bit20 composition
for f in bit20feed:
Expand Down
3 changes: 1 addition & 2 deletions bts_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def green_if_true(cond):
# info_items, attrs = split_columns(info_items, attrs)

global feeds
feeds_obj = {}

if rpc.main_node.is_witness() and rpc.main_node.type() in ['bts']:
published_feeds = rpc.main_node.get_witness_feeds(rpc.main_node.name, feeds.visible_feeds)
Expand Down Expand Up @@ -320,8 +321,6 @@ def format_feeds(fds):

feeds_obj = dict(assets=feeds.visible_feeds, feeds=lfeeds, pfeeds=pfeeds,
mfeeds=mfeeds, bfeeds=bfeeds, last_update=last_update)
else:
feeds_obj = {}

if rpc.main_node.is_witness():
info_items2 = sorted(rpc.main_node.get_witness(rpc.main_node.name).items())
Expand Down

0 comments on commit 4c2cd7b

Please sign in to comment.