Browse Source

RPC API endpoint to get wallet rescan status

master
Kristaps Kaupe 2 years ago
parent
commit
5b47d1c906
No known key found for this signature in database
GPG Key ID: 33E472FE870C7E5D
  1. 37
      docs/api/wallet-rpc.yaml
  2. 23
      src/jmclient/wallet_rpc.py

37
docs/api/wallet-rpc.yaml

@ -240,6 +240,27 @@ paths:
$ref: '#/components/responses/400-BadRequest' $ref: '#/components/responses/400-BadRequest'
'404': '404':
$ref: '#/components/responses/404-NotFound' $ref: '#/components/responses/404-NotFound'
/wallet/{walletname}/getrescaninfo:
get:
security:
- bearerAuth: []
summary: get the current rescan status
operationId: getrescaninfo
description: get the current rescan status
parameters:
- name: walletname
in: path
description: name of wallet including .jmdat
required: true
schema:
type: string
responses:
'200':
$ref: '#/components/responses/RescanInfo-200-OK'
'400':
$ref: '#/components/responses/400-BadRequest'
'404':
$ref: '#/components/responses/404-NotFound'
/wallet/{walletname}/address/timelock/new/{lockdate}: /wallet/{walletname}/address/timelock/new/{lockdate}:
get: get:
security: security:
@ -805,6 +826,16 @@ components:
walletname: walletname:
type: string type: string
example: "wallet.jmdat" example: "wallet.jmdat"
RescanInfoResponse:
type: object
required:
- rescanning
properties:
rescanning:
type: boolean
progress:
type: number
example: 0.04665404082350701
SessionResponse: SessionResponse:
type: object type: object
required: required:
@ -1190,6 +1221,12 @@ components:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/RescanBlockchainResponse" $ref: "#/components/schemas/RescanBlockchainResponse"
RescanInfo-200-OK:
description: "Blockchain rescan status retrieved successfully"
content:
application/json:
schema:
$ref: "#/components/schemas/RescanInfoResponse"
Create-201-OK: Create-201-OK:
description: "wallet created successfully" description: "wallet created successfully"
content: content:

23
src/jmclient/wallet_rpc.py

@ -692,6 +692,29 @@ class JMWalletDaemon(Service):
self.services["wallet"].rescanblockchain(blockheight) self.services["wallet"].rescanblockchain(blockheight)
return make_jmwalletd_response(request, walletname=walletname) return make_jmwalletd_response(request, walletname=walletname)
@app.route('/wallet/<string:walletname>/getrescaninfo', methods=['GET'])
def getrescaninfo(self, request, walletname):
""" This route lets the user get the current rescan status.
"""
print_req(request)
self.check_cookie(request)
if not self.services["wallet"]:
jlog.warn("getrescaninfo called, but no wallet service active.")
raise NoWalletFound()
if not self.wallet_name == walletname:
jlog.warn("called getrescaninfo with wrong wallet")
raise InvalidRequestFormat()
else:
rescanning, progress = \
self.services["wallet"].get_backend_wallet_rescan_status()
if rescanning:
return make_jmwalletd_response(request,
walletname=walletname, rescanning=rescanning,
progress=progress)
else:
return make_jmwalletd_response(request,
walletname=walletname, rescanning=rescanning)
@app.route('/getinfo', methods=['GET']) @app.route('/getinfo', methods=['GET'])
def version(self, request): def version(self, request):
""" This route sends information about the backend, including """ This route sends information about the backend, including

Loading…
Cancel
Save