Skip to content
Snippets Groups Projects

Changes specific to HF25 done in https://github.com/holgern/beem master branch

Merged Bartek Wrona requested to merge bw_holgern2gitlab_master into master
4 files
+ 22
4
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 95
0
@@ -2914,6 +2914,69 @@ class Account(BlockchainObject):
})
return self.blockchain.finalizeOp(op, account, "active", **kwargs)
#-------------------------------------------------------------------------------
# Recurring Transfer added in hf25
#-------------------------------------------------------------------------------
def recurring_transfer(self, to, amount, asset, recurrence, executions, memo="", skip_account_check=False, account=None, **kwargs):
""" Transfer an asset to another account.
:param str to: Recipient
:param float amount: Amount to transfer in each occurence, must have 3 decimal points
:param str asset: Asset to transfer
:param int recurrence: How often in hours to execute transfer
:param int executions: Number of times to recur before stopping execution
:param str memo: (optional) Memo, may begin with `#` for encrypted
messaging
:param bool skip_account_check: (optional) When True, the receiver
account name is not checked to speed up sending multiple transfers in a row
:param str account: (optional) the source account for the transfer
if not ``default_account``
Transfer example:
.. code-block:: python
from beem.account import Account
from beem import Hive
active_wif = "5xxxx"
stm = Hive(keys=[active_wif])
acc = Account("test", blockchain_instance=stm)
acc.transfer("test1", 1, "HIVE", 48, 5, "test")
"""
if account is None:
account = self
elif not skip_account_check:
account = Account(account, blockchain_instance=self.blockchain)
amount = Amount(amount, asset, blockchain_instance=self.blockchain)
if not skip_account_check:
to = Account(to, blockchain_instance=self.blockchain)
to_name = extract_account_name(to)
account_name = extract_account_name(account)
if memo and memo[0] == "#":
from .memo import Memo
memoObj = Memo(
from_account=account,
to_account=to,
blockchain_instance=self.blockchain
)
memo = memoObj.encrypt(memo[1:])["message"]
op = operations.Recurring_transfer(**{
"amount": amount,
"to": to_name,
"memo": memo,
"from": account_name,
"recurrence": recurrence,
"executions": executions,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
})
return self.blockchain.finalizeOp(op, account, "active", **kwargs)
def transfer_to_vesting(self, amount, to=None, account=None, skip_account_check=False, **kwargs):
""" Vest STEEM
@@ -2977,6 +3040,38 @@ class Account(BlockchainObject):
return self.blockchain.finalizeOp(op, account, "active")
#Added to differentiate and match the addition of the HF25 convert operation
def collateralized_convert(self, amount, account=None, request_id=None, **kwargs):
""" Convert Hive dollars to Hive (this method is meant to be more instant)
and reflect the method added in HF25
:param float amount: amount of SBD to convert
:param str account: (optional) the source account for the transfer
if not ``default_account``
:param str request_id: (optional) identifier for tracking the
conversion`
"""
if account is None:
account = self
else:
account = Account(account, blockchain_instance=self.blockchain)
amount = self._check_amount(amount, self.blockchain.backed_token_symbol)
if request_id:
request_id = int(request_id)
else:
request_id = random.getrandbits(32)
op = operations.Collateralized_convert(
**{
"owner": account["name"],
"requestid": request_id,
"amount": amount,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
})
return self.blockchain.finalizeOp(op, account, "active", **kwargs)
def transfer_to_savings(self, amount, asset, memo, to=None, account=None, **kwargs):
""" Transfer SBD or STEEM into a 'savings' account.
Loading