Skip to content

Commit

Permalink
Merge pull request #1148 from lbryio/channel-bid
Browse files Browse the repository at this point in the history
Update channel balance checking to match claim balance checking
  • Loading branch information
hackrush01 authored Mar 17, 2018
2 parents 0313f85 + 2b69d2f commit 1d9c996
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ at anytime.
* `blob_announce` error when announcing a single blob
* `blob_list` error when looking up blobs by stream or sd hash
* issue#1107 whereing claiming a channel with the exact amount present in wallet would give out proper error
*
* Fix channel creation to use same bid logic as claim ([1148])(https://github.com/lbryio/lbry/pull/1148)

### Deprecated
* `report_bug` jsonrpc command
Expand Down
24 changes: 13 additions & 11 deletions lbrynet/daemon/Daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1852,16 +1852,18 @@ def jsonrpc_channel_new(self, channel_name, amount):
if amount <= 0:
raise Exception("Invalid amount")

balance = yield self.session.wallet.get_max_usable_balance_for_claim(channel_name)
max_bid_amount = balance - MAX_UPDATE_FEE_ESTIMATE
if balance <= MAX_UPDATE_FEE_ESTIMATE:
raise InsufficientFundsError(
"Insufficient funds, please deposit additional LBC. Minimum additional LBC needed {}"
.format(MAX_UPDATE_FEE_ESTIMATE - balance))
elif amount > max_bid_amount:
raise InsufficientFundsError(
"Please lower the bid value, the maximum amount you can specify for this claim is {}"
.format(max_bid_amount))
yield self.session.wallet.update_balance()
if amount >= self.session.wallet.get_balance():
balance = yield self.session.wallet.get_max_usable_balance_for_claim(channel_name)
max_bid_amount = balance - MAX_UPDATE_FEE_ESTIMATE
if balance <= MAX_UPDATE_FEE_ESTIMATE:
raise InsufficientFundsError(
"Insufficient funds, please deposit additional LBC. Minimum additional LBC needed {}"
. format(MAX_UPDATE_FEE_ESTIMATE - balance))
elif amount > max_bid_amount:
raise InsufficientFundsError(
"Please lower the bid value, the maximum amount you can specify for this channel is {}"
.format(max_bid_amount))

result = yield self.session.wallet.claim_new_channel(channel_name, amount)
self.analytics_manager.send_new_channel()
Expand Down Expand Up @@ -2047,7 +2049,7 @@ def jsonrpc_publish(self, name, bid, metadata=None, file_path=None, fee=None, ti
.format(MAX_UPDATE_FEE_ESTIMATE - balance))
elif bid > max_bid_amount:
raise InsufficientFundsError(
"Please lower the bid. After accounting for the estimated fee, you only have {} left."
"Please lower the bid value, the maximum amount you can specify for this claim is {}."
.format(max_bid_amount))

metadata = metadata or {}
Expand Down

0 comments on commit 1d9c996

Please sign in to comment.