diff --git a/docs/api/wallet-rpc.yaml b/docs/api/wallet-rpc.yaml index 5bc34bf..bf0c8ff 100644 --- a/docs/api/wallet-rpc.yaml +++ b/docs/api/wallet-rpc.yaml @@ -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: @@ -805,6 +826,16 @@ components: walletname: type: string example: "wallet.jmdat" + RescanInfoResponse: + type: object + required: + - rescanning + properties: + rescanning: + type: boolean + progress: + type: number + example: 0.04665404082350701 SessionResponse: type: object required: @@ -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: diff --git a/src/jmclient/wallet_rpc.py b/src/jmclient/wallet_rpc.py index a2fdc7d..3d3cee9 100644 --- a/src/jmclient/wallet_rpc.py +++ b/src/jmclient/wallet_rpc.py @@ -692,6 +692,29 @@ class JMWalletDaemon(Service): self.services["wallet"].rescanblockchain(blockheight) return make_jmwalletd_response(request, walletname=walletname) + @app.route('/wallet//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']) def version(self, request): """ This route sends information about the backend, including