Browse Source

fixes to API and return format

master
Adam Gibson 4 years ago
parent
commit
beaa8b0170
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 17
      docs/api/wallet-rpc.yaml
  2. 16
      jmclient/jmclient/wallet_rpc.py

17
docs/api/wallet-rpc.yaml

@ -127,7 +127,11 @@ paths:
get:
summary: get latest report on yield generating activity
operationId: yieldgenreport
description: get list of coinjoins taken part in as maker (across all wallets)
description: "Get list of coinjoins taken part in as maker (across all wallets).
Data returned as list of strings, each one in the same comma separated format as found in yigen-statement.csv.
Note that this returns all lines in the file, including the lines that are only present to represent the starting
of a bot. Those lines contain the word Connected and can be thus discarded.
The header line is also delivered and so can be ignored as per the client requirements."
responses:
'200':
$ref: "#/components/responses/YieldGenReport-200-OK"
@ -577,6 +581,11 @@ components:
items:
type: string
example: wallet.jmdat
YieldGenReportResponse:
type: array
items:
type: string
example: "2021/10/26 16:40:21,133986791,1,200000000,2680,2680,0.08,"
SessionResponse:
type: object
required:
@ -893,6 +902,12 @@ components:
application/json:
schema:
$ref: "#/components/schemas/FreezeResponse"
YieldGenReport-200-OK:
description: "get list of coinjoins taken part in as maker (across all wallets)"
content:
application/json:
schema:
$ref: "#/components/schemas/YieldGenReportResponse"
202-Accepted:
description: The request has been submitted successfully for processing, but the processing has not been completed.
# Clientside error responses

16
jmclient/jmclient/wallet_rpc.py

@ -611,12 +611,18 @@ class JMWalletDaemon(Service):
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().config.datadir, "logs")
with open(os.path.join(datadir, "yigen-statement.csv"), "rb") as f:
yigen_data_raw = f.readlines()
return json.loads(yigen_data_raw)
except:
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'])

Loading…
Cancel
Save