Skip to content
Snippets Groups Projects
Commit ab9465ed authored by Holger Nahrstaedt's avatar Holger Nahrstaedt
Browse files

Add claimreward to cli

cli
* add claimreward
unit test
* add unit test for claimreward
parent 0ba943a6
Branches
Tags
No related merge requests found
...@@ -42,7 +42,7 @@ class Block(BlockchainObject): ...@@ -42,7 +42,7 @@ class Block(BlockchainObject):
self.identifier = int(self.identifier) self.identifier = int(self.identifier)
if self.steem.rpc.get_use_appbase(): if self.steem.rpc.get_use_appbase():
block = self.steem.rpc.get_block({"block_num": self.identifier}, api="block") block = self.steem.rpc.get_block({"block_num": self.identifier}, api="block")
if "block" in block: if block and "block" in block:
block = block["block"] block = block["block"]
else: else:
block = self.steem.rpc.get_block(self.identifier) block = self.steem.rpc.get_block(self.identifier)
......
...@@ -92,19 +92,13 @@ def unlock_wallet(stm, password=None): ...@@ -92,19 +92,13 @@ def unlock_wallet(stm, password=None):
'--no-wallet', '-p', is_flag=True, default=False, help="Do not load the wallet") '--no-wallet', '-p', is_flag=True, default=False, help="Do not load the wallet")
@click.option( @click.option(
'--unsigned', '-x', is_flag=True, default=False, help="Nothing will be signed") '--unsigned', '-x', is_flag=True, default=False, help="Nothing will be signed")
@click.option(
'--blocking', is_flag=True, default=False,
help="Wait for broadcasted transactions to be included in a block and return full transaction")
@click.option(
'--bundle', is_flag=True, default=False,
help="Do not broadcast transactions right away, but allow to bundle operations ")
@click.option( @click.option(
'--expires', '-e', default=30, '--expires', '-e', default=30,
help='Delay in seconds until transactions are supposed to expire(defaults to 60)') help='Delay in seconds until transactions are supposed to expire(defaults to 60)')
@click.option( @click.option(
'--verbose', '-v', default=3, help='Verbosity') '--verbose', '-v', default=3, help='Verbosity')
@click.version_option(version=__version__) @click.version_option(version=__version__)
def cli(node, offline, no_broadcast, no_wallet, unsigned, blocking, bundle, expires, verbose): def cli(node, offline, no_broadcast, no_wallet, unsigned, expires, verbose):
# Logging # Logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -125,8 +119,6 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, blocking, bundle, expi ...@@ -125,8 +119,6 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, blocking, bundle, expi
offline=offline, offline=offline,
nowallet=no_wallet, nowallet=no_wallet,
unsigned=unsigned, unsigned=unsigned,
blocking=blocking,
bundle=bundle,
expiration=expires, expiration=expires,
debug=debug debug=debug
) )
...@@ -227,7 +219,7 @@ def addkey(unsafe_import_key): ...@@ -227,7 +219,7 @@ def addkey(unsafe_import_key):
if not unlock_wallet(stm): if not unlock_wallet(stm):
return return
if not unsafe_import_key: if not unsafe_import_key:
unsafe_import_key = click.prompt("Enter private key", confirmation_prompt=False, hide_input=False) unsafe_import_key = click.prompt("Enter private key", confirmation_prompt=False, hide_input=True)
stm.wallet.addPrivateKey(unsafe_import_key) stm.wallet.addPrivateKey(unsafe_import_key)
set_shared_steem_instance(stm) set_shared_steem_instance(stm)
...@@ -1091,6 +1083,28 @@ def witnesses(account, limit): ...@@ -1091,6 +1083,28 @@ def witnesses(account, limit):
witnesses.printAsTable() witnesses.printAsTable()
@cli.command()
@click.option('--reward_steem', help='Amount of STEEM you would like to claim', default="0 STEEM")
@click.option('--reward_sbd', help='Amount of SBD you would like to claim', default="0 SBD")
@click.option('--reward_vests', help='Amount of VESTS you would like to claim', default="0 VESTS")
@click.option('--account', '-a', help='Voter account name')
def claimreward(reward_steem, reward_sbd, reward_vests, account):
"""Claim reward balances
By default, this will claim ``all`` outstanding balances.
"""
stm = shared_steem_instance()
if not account:
account = stm.config["default_account"]
if not unlock_wallet(stm):
return
acc = Account(account, steem_instance=stm)
tx = acc.claim_reward_balance(reward_steem, reward_sbd, reward_vests)
tx = json.dumps(tx, indent=4)
print(tx)
@cli.command() @cli.command()
@click.argument('objects', nargs=-1) @click.argument('objects', nargs=-1)
def info(objects): def info(objects):
......
...@@ -249,3 +249,8 @@ class Testcases(unittest.TestCase): ...@@ -249,3 +249,8 @@ class Testcases(unittest.TestCase):
self.assertEqual(result.exit_code, 0) self.assertEqual(result.exit_code, 0)
result = runner.invoke(cli, ['delprofile', 'url'], input="test\n") result = runner.invoke(cli, ['delprofile', 'url'], input="test\n")
self.assertEqual(result.exit_code, 0) self.assertEqual(result.exit_code, 0)
def test_claimreward(self):
runner = CliRunner()
result = runner.invoke(cli, ['claimreward'], input="test\n")
self.assertEqual(result.exit_code, 0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment