holgern/beem

Unable to Claim Specific Reward Asset

Closed this issue · 1 comments

As a tool developer, I would like the ability to claim a specific reward asset, so that it is not all or nothing.

Claiming all reward assets at once works as expected (by passing zero arguments, as documented). But when claiming a specific asset, for example:

account = Account('inertia')
account.claim_reward_balance(reward_vests=10)

... I get the following error:

Traceback (most recent call last):
.
.
.
  File "/usr/local/lib/python3.9/site-packages/beem/account.py", line 3190, in claim_reward_balance
    return self.blockchain.finalizeOp(op, account, "posting", **kwargs)
UnboundLocalError: local variable 'op' referenced before assignment

It appears to me that the arguments specifying a single asset result in unreachable code.

beem/beem/account.py

Lines 3166 to 3190 in d9b9f96

if reward_steem.amount == 0 and reward_sbd.amount == 0 and reward_vests.amount == 0:
if len(account.balances["rewards"]) == 3:
reward_steem = account.balances["rewards"][0]
reward_sbd = account.balances["rewards"][1]
reward_vests = account.balances["rewards"][2]
op = operations.Claim_reward_balance(
**{
"account": account["name"],
reward_token: reward_steem,
reward_backed_token: reward_sbd,
"reward_vests": reward_vests,
"prefix": self.blockchain.prefix,
})
else:
reward_steem = account.balances["rewards"][0]
reward_vests = account.balances["rewards"][1]
op = operations.Claim_reward_balance(
**{
"account": account["name"],
reward_token: reward_steem,
"reward_vests": reward_vests,
"prefix": self.blockchain.prefix,
})
return self.blockchain.finalizeOp(op, account, "posting", **kwargs)

AC

  • Able to claim any combination of reward assets.

There was a not complete conditional structure, it should be fixed by now