Skip to content

Commit

Permalink
RPC API endpoint to get wallet rescan status
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapsk committed Apr 28, 2024
1 parent 085ef08 commit 6ae9f87
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/api/wallet-rpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,27 @@ paths:
$ref: '#/components/responses/400-BadRequest'
'404':
$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}:
get:
security:
Expand Down Expand Up @@ -805,6 +826,16 @@ components:
walletname:
type: string
example: "wallet.jmdat"
RescanInfoResponse:
type: object
required:
- rescanning
- progress
properties:
rescanning:
type: boolean
block_height:
type: number
SessionResponse:
type: object
required:
Expand Down Expand Up @@ -1190,6 +1221,12 @@ components:
application/json:
schema:
$ref: "#/components/schemas/RescanBlockchainResponse"
RescanInfo-200-OK:
description: "Blockchain rescan status retrieved successfully"
content:
application/json:
schema:
$ref: "#/components/schemas/RescanInfoResponse"
Create-201-OK:
description: "wallet created successfully"
content:
Expand Down
18 changes: 18 additions & 0 deletions src/jmclient/wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,24 @@ def rescanblockchain(self, request, walletname, blockheight):
self.services["wallet"].rescanblockchain(blockheight)
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()
return make_jmwalletd_response(request, walletname=walletname,
rescanning=rescanning, progress=progress)

@app.route('/getinfo', methods=['GET'])
def version(self, request):
""" This route sends information about the backend, including
Expand Down

0 comments on commit 6ae9f87

Please sign in to comment.