Skip to content
Snippets Groups Projects
Unverified Commit 661897a0 authored by Brian of London's avatar Brian of London
Browse files

Fix encrypted transfers

Fix originally done by cfoxon

d12631cc131fe9b4846617e21b9d7988360b3433
parent b465c3c4
No related branches found
No related tags found
1 merge request!12Prioritize HIVE_CHAIN_ID property for the chain selection
...@@ -65,3 +65,4 @@ target/ ...@@ -65,3 +65,4 @@ target/
*.swp *.swp
.ropeproject/ .ropeproject/
*/.ropeproject/ */.ropeproject/
.vscode/settings.json
...@@ -159,7 +159,7 @@ class Account(BlockchainObject): ...@@ -159,7 +159,7 @@ class Account(BlockchainObject):
"savings_sbd_seconds_last_update", "savings_sbd_last_interest_payment", "next_vesting_withdrawal", "savings_sbd_seconds_last_update", "savings_sbd_last_interest_payment", "next_vesting_withdrawal",
"last_market_bandwidth_update", "last_post", "last_root_post", "last_bandwidth_update", "last_market_bandwidth_update", "last_post", "last_root_post", "last_bandwidth_update",
"hbd_seconds_last_update", "hbd_last_interest_payment", "savings_hbd_seconds_last_update", "hbd_seconds_last_update", "hbd_last_interest_payment", "savings_hbd_seconds_last_update",
"savings_hbd_last_interest_payment" "savings_hbd_last_interest_payment"
] ]
for p in parse_times: for p in parse_times:
if p in account and isinstance(account.get(p), string_types): if p in account and isinstance(account.get(p), string_types):
...@@ -173,7 +173,7 @@ class Account(BlockchainObject): ...@@ -173,7 +173,7 @@ class Account(BlockchainObject):
"reward_sbd_balance", "reward_sbd_balance",
"hbd_balance", "hbd_balance",
"savings_hbd_balance", "savings_hbd_balance",
"reward_hbd_balance", "reward_hbd_balance",
"reward_steem_balance", "reward_steem_balance",
"reward_hive_balance", "reward_hive_balance",
"reward_vesting_balance", "reward_vesting_balance",
...@@ -217,7 +217,7 @@ class Account(BlockchainObject): ...@@ -217,7 +217,7 @@ class Account(BlockchainObject):
"savings_sbd_seconds_last_update", "savings_sbd_last_interest_payment", "next_vesting_withdrawal", "savings_sbd_seconds_last_update", "savings_sbd_last_interest_payment", "next_vesting_withdrawal",
"last_market_bandwidth_update", "last_post", "last_root_post", "last_bandwidth_update", "last_market_bandwidth_update", "last_post", "last_root_post", "last_bandwidth_update",
"hbd_seconds_last_update", "hbd_last_interest_payment", "savings_hbd_seconds_last_update", "hbd_seconds_last_update", "hbd_last_interest_payment", "savings_hbd_seconds_last_update",
"savings_hbd_last_interest_payment" "savings_hbd_last_interest_payment"
] ]
for p in parse_times: for p in parse_times:
if p in output: if p in output:
...@@ -236,7 +236,7 @@ class Account(BlockchainObject): ...@@ -236,7 +236,7 @@ class Account(BlockchainObject):
"hbd_balance", "hbd_balance",
"savings_hbd_balance", "savings_hbd_balance",
"reward_hbd_balance", "reward_hbd_balance",
"reward_hive_balance", "reward_hive_balance",
"reward_vesting_balance", "reward_vesting_balance",
"reward_vesting_steem", "reward_vesting_steem",
"vesting_shares", "vesting_shares",
...@@ -483,7 +483,7 @@ class Account(BlockchainObject): ...@@ -483,7 +483,7 @@ class Account(BlockchainObject):
props = self.blockchain.get_chain_properties() props = self.blockchain.get_chain_properties()
required_fee_token = Amount(props["account_creation_fee"], blockchain_instance=self.blockchain) required_fee_token = Amount(props["account_creation_fee"], blockchain_instance=self.blockchain)
max_mana = int(self.blockchain.token_power_to_vests(required_fee_token) / 4) max_mana = int(self.blockchain.token_power_to_vests(required_fee_token) / 4)
last_mana = int(self["downvote_manabar"]["current_mana"]) last_mana = int(self["downvote_manabar"]["current_mana"])
last_update_time = self["downvote_manabar"]["last_update_time"] last_update_time = self["downvote_manabar"]["last_update_time"]
last_update = datetime.utcfromtimestamp(last_update_time) last_update = datetime.utcfromtimestamp(last_update_time)
...@@ -1110,7 +1110,7 @@ class Account(BlockchainObject): ...@@ -1110,7 +1110,7 @@ class Account(BlockchainObject):
"""Returns all subscriptions""" """Returns all subscriptions"""
if account is None: if account is None:
account = self["name"] account = self["name"]
account = extract_account_name(account) account = extract_account_name(account)
if not self.blockchain.is_connected(): if not self.blockchain.is_connected():
raise OfflineHasNoRPCException("No RPC available in offline mode!") raise OfflineHasNoRPCException("No RPC available in offline mode!")
self.blockchain.rpc.set_next_node_on_empty_reply(True) self.blockchain.rpc.set_next_node_on_empty_reply(True)
...@@ -1300,7 +1300,7 @@ class Account(BlockchainObject): ...@@ -1300,7 +1300,7 @@ class Account(BlockchainObject):
interest_rate = self.blockchain.get_dynamic_global_properties()[ interest_rate = self.blockchain.get_dynamic_global_properties()[
"hbd_interest_rate"] / 100 # percent "hbd_interest_rate"] / 100 # percent
interest_amount = (interest_rate / 100) * int( interest_amount = (interest_rate / 100) * int(
int(self["hbd_seconds"]) / (60 * 60 * 24 * 356)) * 10**-3 int(self["hbd_seconds"]) / (60 * 60 * 24 * 356)) * 10**-3
return { return {
"interest": interest_amount, "interest": interest_amount,
"last_payment": last_payment, "last_payment": last_payment,
...@@ -1715,7 +1715,7 @@ class Account(BlockchainObject): ...@@ -1715,7 +1715,7 @@ class Account(BlockchainObject):
def get_account_votes(self, account=None, start_author="", start_permlink="", limit=1000, start_date=None): def get_account_votes(self, account=None, start_author="", start_permlink="", limit=1000, start_date=None):
""" Returns all votes that the account has done """ Returns all votes that the account has done
:rtype: list :rtype: list
.. code-block:: python .. code-block:: python
...@@ -1853,7 +1853,7 @@ class Account(BlockchainObject): ...@@ -1853,7 +1853,7 @@ class Account(BlockchainObject):
ret = self.blockchain.rpc.get_account_history(account, start, limit, ret = self.blockchain.rpc.get_account_history(account, start, limit,
operation_filter_low, operation_filter_low,
operation_filter_high, operation_filter_high,
api="database") api="database")
return ret return ret
def _get_blocknum_from_hist(self, index, min_index=1): def _get_blocknum_from_hist(self, index, min_index=1):
...@@ -2057,7 +2057,7 @@ class Account(BlockchainObject): ...@@ -2057,7 +2057,7 @@ class Account(BlockchainObject):
else: else:
operation_filter_high -= 2 ** (op_id - 64 - 1) operation_filter_high -= 2 ** (op_id - 64 - 1)
return operation_filter_low, operation_filter_high return operation_filter_low, operation_filter_high
def get_account_history(self, index, limit, order=-1, start=None, stop=None, use_block_num=True, only_ops=[], exclude_ops=[], raw_output=False): def get_account_history(self, index, limit, order=-1, start=None, stop=None, use_block_num=True, only_ops=[], exclude_ops=[], raw_output=False):
""" Returns a generator for individual account transactions. This call can be used in a """ Returns a generator for individual account transactions. This call can be used in a
...@@ -2110,7 +2110,7 @@ class Account(BlockchainObject): ...@@ -2110,7 +2110,7 @@ class Account(BlockchainObject):
else: else:
txs_list = txs txs_list = txs
for item in txs_list: for item in txs_list:
item_index, event = item item_index, event = item
if start and isinstance(start, (datetime, date, time)): if start and isinstance(start, (datetime, date, time)):
timediff = start - formatTimeString(event["timestamp"]) timediff = start - formatTimeString(event["timestamp"])
if timediff.total_seconds() * float(order) > 0: if timediff.total_seconds() * float(order) > 0:
...@@ -2282,7 +2282,7 @@ class Account(BlockchainObject): ...@@ -2282,7 +2282,7 @@ class Account(BlockchainObject):
start_index = op_est - est_diff start_index = op_est - est_diff
else: else:
start_index = 0 start_index = 0
if stop is not None and not use_block_num and not isinstance(stop, (datetime, date, time)): if stop is not None and not use_block_num and not isinstance(stop, (datetime, date, time)):
if start_index + stop < _limit: if start_index + stop < _limit:
_limit = stop _limit = stop
...@@ -2296,16 +2296,16 @@ class Account(BlockchainObject): ...@@ -2296,16 +2296,16 @@ class Account(BlockchainObject):
elif first < _limit and self.blockchain.rpc.url != "https://api.hive.blog": elif first < _limit and self.blockchain.rpc.url != "https://api.hive.blog":
first = _limit first = _limit
last_round = False last_round = False
if _limit < 0: if _limit < 0:
return return
last_item_index = -1 last_item_index = -1
if self.blockchain.rpc.url == 'https://api.hive.blog' and (len(only_ops) > 0 or len(exclude_ops) > 0): if self.blockchain.rpc.url == 'https://api.hive.blog' and (len(only_ops) > 0 or len(exclude_ops) > 0):
operation_filter = True operation_filter = True
else: else:
operation_filter = False operation_filter = False
while True: while True:
# RPC call # RPC call
if first < _limit - 1 and self.blockchain.rpc.url == "https://api.hive.blog": if first < _limit - 1 and self.blockchain.rpc.url == "https://api.hive.blog":
...@@ -2350,7 +2350,7 @@ class Account(BlockchainObject): ...@@ -2350,7 +2350,7 @@ class Account(BlockchainObject):
if exclude_ops and op_type in exclude_ops: if exclude_ops and op_type in exclude_ops:
continue continue
if not only_ops or op_type in only_ops: if not only_ops or op_type in only_ops:
yield item yield item
last_item_index = item_index last_item_index = item_index
if first < max_index and first + _limit >= max_index and not last_round: if first < max_index and first + _limit >= max_index and not last_round:
_limit = max_index - first _limit = max_index - first
...@@ -2482,12 +2482,12 @@ class Account(BlockchainObject): ...@@ -2482,12 +2482,12 @@ class Account(BlockchainObject):
first = op_est + est_diff first = op_est + est_diff
if stop is not None and isinstance(stop, int) and stop < 0 and not use_block_num: if stop is not None and isinstance(stop, int) and stop < 0 and not use_block_num:
stop += first stop += first
if self.blockchain.rpc.url == 'https://api.hive.blog' and (len(only_ops) > 0 or len(exclude_ops) > 0): if self.blockchain.rpc.url == 'https://api.hive.blog' and (len(only_ops) > 0 or len(exclude_ops) > 0):
operation_filter = True operation_filter = True
else: else:
operation_filter = False operation_filter = False
last_item_index = first + 1 last_item_index = first + 1
while True: while True:
# RPC call # RPC call
...@@ -2535,7 +2535,7 @@ class Account(BlockchainObject): ...@@ -2535,7 +2535,7 @@ class Account(BlockchainObject):
if exclude_ops and op_type in exclude_ops: if exclude_ops and op_type in exclude_ops:
continue continue
if not only_ops or op_type in only_ops: if not only_ops or op_type in only_ops:
yield item yield item
last_item_index = item_index last_item_index = item_index
if operation_filter and batch_count < _limit and _limit == 1000: if operation_filter and batch_count < _limit and _limit == 1000:
first -= 2000 first -= 2000
...@@ -2570,7 +2570,7 @@ class Account(BlockchainObject): ...@@ -2570,7 +2570,7 @@ class Account(BlockchainObject):
.. note:: what can be one of the following on HIVE: .. note:: what can be one of the following on HIVE:
blog, ignore, blacklist, unblacklist, follow_blacklist, blog, ignore, blacklist, unblacklist, follow_blacklist,
unfollow_blacklist, follow_muted, unfollow_muted unfollow_blacklist, follow_muted, unfollow_muted
:param str/list other: Follow this account / accounts (only hive) :param str/list other: Follow this account / accounts (only hive)
:param list what: List of states to follow. :param list what: List of states to follow.
``['blog']`` means to follow ``other``, ``['blog']`` means to follow ``other``,
...@@ -2886,7 +2886,7 @@ class Account(BlockchainObject): ...@@ -2886,7 +2886,7 @@ class Account(BlockchainObject):
""" """
if account is None: if account is None:
account = self account = self
elif not skip_account_check: elif not skip_account_check:
account = Account(account, blockchain_instance=self.blockchain) account = Account(account, blockchain_instance=self.blockchain)
amount = Amount(amount, asset, blockchain_instance=self.blockchain) amount = Amount(amount, asset, blockchain_instance=self.blockchain)
...@@ -2894,16 +2894,16 @@ class Account(BlockchainObject): ...@@ -2894,16 +2894,16 @@ class Account(BlockchainObject):
to = Account(to, blockchain_instance=self.blockchain) to = Account(to, blockchain_instance=self.blockchain)
to_name = extract_account_name(to) to_name = extract_account_name(to)
account_name = extract_account_name(account) account_name = extract_account_name(account)
if memo and memo[0] == "#": if memo and memo[0] == "#":
from .memo import Memo from .memo import Memo
memoObj = Memo( memoObj = Memo(
from_account=account, from_account=account_name,
to_account=to, to_account=to_name,
blockchain_instance=self.blockchain blockchain_instance=self.blockchain
) )
memo = memoObj.encrypt(memo[1:])["message"] memo = memoObj.encrypt(memo[1:])["message"]
op = operations.Transfer(**{ op = operations.Transfer(**{
"amount": amount, "amount": amount,
"to": to_name, "to": to_name,
...@@ -2936,7 +2936,7 @@ class Account(BlockchainObject): ...@@ -2936,7 +2936,7 @@ class Account(BlockchainObject):
if not skip_account_check: if not skip_account_check:
to = Account(to, blockchain_instance=self.blockchain) to = Account(to, blockchain_instance=self.blockchain)
to_name = extract_account_name(to) to_name = extract_account_name(to)
account_name = extract_account_name(account) account_name = extract_account_name(account)
op = operations.Transfer_to_vesting(**{ op = operations.Transfer_to_vesting(**{
"from": account_name, "from": account_name,
...@@ -2965,7 +2965,7 @@ class Account(BlockchainObject): ...@@ -2965,7 +2965,7 @@ class Account(BlockchainObject):
if request_id: if request_id:
request_id = int(request_id) request_id = int(request_id)
else: else:
request_id = random.getrandbits(32) request_id = random.getrandbits(32)
op = operations.Convert( op = operations.Convert(
**{ **{
"owner": account["name"], "owner": account["name"],
...@@ -3097,7 +3097,7 @@ class Account(BlockchainObject): ...@@ -3097,7 +3097,7 @@ class Account(BlockchainObject):
reward_steem=0, reward_steem=0,
reward_sbd=0, reward_sbd=0,
reward_hive=0, reward_hive=0,
reward_hbd=0, reward_hbd=0,
reward_vests=0, reward_vests=0,
account=None, **kwargs): account=None, **kwargs):
""" Claim reward balances. """ Claim reward balances.
...@@ -3133,7 +3133,7 @@ class Account(BlockchainObject): ...@@ -3133,7 +3133,7 @@ class Account(BlockchainObject):
reward_backed_token = "reward_hbd" reward_backed_token = "reward_hbd"
else: else:
reward_token = "reward_steem" reward_token = "reward_steem"
reward_backed_token = "reward_sbd" reward_backed_token = "reward_sbd"
if reward_token_amount.amount == 0 and reward_backed_token_amount.amount == 0 and reward_vests_amount.amount == 0: if reward_token_amount.amount == 0 and reward_backed_token_amount.amount == 0 and reward_vests_amount.amount == 0:
if len(account.balances["rewards"]) == 3: if len(account.balances["rewards"]) == 3:
...@@ -3151,7 +3151,7 @@ class Account(BlockchainObject): ...@@ -3151,7 +3151,7 @@ class Account(BlockchainObject):
reward_backed_token: reward_backed_token_amount, reward_backed_token: reward_backed_token_amount,
"reward_vests": reward_vests_amount, "reward_vests": reward_vests_amount,
"prefix": self.blockchain.prefix, "prefix": self.blockchain.prefix,
}) })
else: else:
op = operations.Claim_reward_balance( op = operations.Claim_reward_balance(
**{ **{
...@@ -3748,7 +3748,7 @@ class Accounts(AccountsObject): ...@@ -3748,7 +3748,7 @@ class Accounts(AccountsObject):
accessing a RPCcreator = Account(creator, blockchain_instance=self) accessing a RPCcreator = Account(creator, blockchain_instance=self)
""" """
def __init__(self, name_list, batch_limit=100, lazy=False, full=True, blockchain_instance=None, **kwargs): def __init__(self, name_list, batch_limit=100, lazy=False, full=True, blockchain_instance=None, **kwargs):
if blockchain_instance is None: if blockchain_instance is None:
if kwargs.get("steem_instance"): if kwargs.get("steem_instance"):
blockchain_instance = kwargs["steem_instance"] blockchain_instance = kwargs["steem_instance"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment