Adding functionality to check the balance of a given wallet.

This commit is contained in:
Mathew WAller 2017-04-21 02:16:26 +01:00
parent cb8730e696
commit 8f0f27da1a
3 changed files with 46 additions and 8 deletions

View file

@ -1 +1,29 @@
THIS FILE GETS FILLED IN BY BUILD SCRIPT AND INCLUDED IN requirements.txt
Twisted==16.6.0
appdirs==1.4.3
argparse==1.2.1
base58==0.2.2
colorama==0.3.7
dnspython==1.12.0
ecdsa==0.13
envparse==0.2.0
gmpy==1.17
jsonrpc==1.2
jsonrpclib==0.1.7
jsonschema==2.5.1
git+https://github.com/lbryio/lbryschema.git@v0.0.3#egg=lbryschema
git+https://github.com/lbryio/lbryum.git@v2.7.20#egg=lbryum
miniupnpc==1.9
pbkdf2==1.3
protobuf==3.0.0
pycrypto==2.6.1
pyyaml==3.12
qrcode==5.2.2
requests==2.9.1
txrequests==0.9.5
seccure==0.3.1.3
service_identity==16.0.0
six>=1.9.0
slowaes==0.1a1
txJSON-RPC==0.5
wsgiref==0.1.2
zope.interface==4.3.3

View file

@ -738,9 +738,13 @@ class Wallet(object):
def get_claim_metadata_for_sd_hash(self, sd_hash):
return self._get_claim_metadata_for_sd_hash(sd_hash)
def get_balance(self):
return self.wallet_balance - self.total_reserved_points - sum(self.queued_payments.values())
def get_balance(self, address=None):
if address is None:
return self.wallet_balance - self.total_reserved_points - sum(self.queued_payments.values())
else:
c, u, x = self.wallet.get_addr_balance(address)
return Decimal(float(c) / COIN)
def _check_expected_balances(self):
now = datetime.datetime.now()
balances_to_check = []

View file

@ -1303,6 +1303,8 @@ class Daemon(AuthJSONRPCServer):
"""
Return a list of available commands
Returns:
(list) list of available commands
"""
@ -1311,20 +1313,24 @@ class Daemon(AuthJSONRPCServer):
if 'DEPRECATED' not in getattr(self, "jsonrpc_" + command).__doc__]
))
def jsonrpc_get_balance(self):
def jsonrpc_get_balance(self, address=None):
"""
DEPRECATED. Use `wallet_balance` instead.
"""
return self.jsonrpc_wallet_balance()
return self.jsonrpc_wallet_balance(address)
def jsonrpc_wallet_balance(self):
def jsonrpc_wallet_balance(self, address=None):
"""
Return the balance of the wallet
Args:
'address' (optional): (str) Address to get balance of
Returns:
(float) amount of lbry credits in wallet
"""
return self._render_response(float(self.session.wallet.get_balance()))
return self._render_response(float(self.session.wallet.get_balance(address)))
def jsonrpc_stop(self):
"""