|
|
|
|
@ -88,6 +88,11 @@ class TransactionFailed(Exception):
|
|
|
|
|
class NotEnoughCoinsForMaker(Exception): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
# raised when we cannot read data from our |
|
|
|
|
# yigen-statement csv file: |
|
|
|
|
class YieldGeneratorDataUnreadable(Exception): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def get_ssl_context(cert_directory): |
|
|
|
|
"""Construct an SSL context factory from the user's privatekey/cert. |
|
|
|
|
TODO: |
|
|
|
|
@ -299,6 +304,11 @@ class JMWalletDaemon(Service):
|
|
|
|
|
request.setResponseCode(409) |
|
|
|
|
return self.err(request, "Maker could not start, no coins.") |
|
|
|
|
|
|
|
|
|
@app.handle_errors(YieldGeneratorDataUnreadable) |
|
|
|
|
def yieldgenerator_report_unavailable(self, request, failure): |
|
|
|
|
request.setResponseCode(404) |
|
|
|
|
return self.err(request, "Yield generator report not available.") |
|
|
|
|
|
|
|
|
|
def check_cookie(self, request): |
|
|
|
|
#part after bearer is what we need |
|
|
|
|
try: |
|
|
|
|
@ -600,6 +610,35 @@ class JMWalletDaemon(Service):
|
|
|
|
|
self.services["maker"].stopService() |
|
|
|
|
return make_jmwalletd_response(request, status=202) |
|
|
|
|
|
|
|
|
|
def get_json_yigen_report(self): |
|
|
|
|
""" Returns a json object whose contents are: |
|
|
|
|
a list of strings, each string is a comma separated record of |
|
|
|
|
a coinjoin event, directly read from yigen-statement.csv without |
|
|
|
|
further processing. |
|
|
|
|
""" |
|
|
|
|
try: |
|
|
|
|
datadir = os.path.join(jm_single().datadir, "logs") |
|
|
|
|
with open(os.path.join(datadir, "yigen-statement.csv"), "r") as f: |
|
|
|
|
yigen_data = f.readlines() |
|
|
|
|
return yigen_data |
|
|
|
|
except Exception as e: |
|
|
|
|
jlog.warn("Yigen report failed to find file: {}".format(repr(e))) |
|
|
|
|
raise YieldGeneratorDataUnreadable() |
|
|
|
|
|
|
|
|
|
@app.route('/wallet/yieldgen/report', methods=['GET']) |
|
|
|
|
def yieldgen_report(self, request): |
|
|
|
|
# Note that this is *not* a maker function, and |
|
|
|
|
# not wallet specific (the report aggregates over time, |
|
|
|
|
# even with different wallets), and does not require |
|
|
|
|
# an authenticated session (it reads the filesystem, like |
|
|
|
|
# /all) |
|
|
|
|
# note: can raise, most particularly if file has not been |
|
|
|
|
# created because maker never ran (or deleted): |
|
|
|
|
yigen_data = self.get_json_yigen_report() |
|
|
|
|
# this is the successful case; note the object can |
|
|
|
|
# be an empty list: |
|
|
|
|
return make_jmwalletd_response(request, yigen_data=yigen_data) |
|
|
|
|
|
|
|
|
|
@app.route('/wallet/<string:walletname>/lock', methods=['GET']) |
|
|
|
|
def lockwallet(self, request, walletname): |
|
|
|
|
print_req(request) |
|
|
|
|
|