From cde5cfb4135b9ab33cd211511d3f73e81ef1f8d3 Mon Sep 17 00:00:00 2001 From: Daniel <10026790+dnlggr@users.noreply.github.com> Date: Fri, 10 Jun 2022 10:13:55 +0200 Subject: [PATCH 1/7] feat: scheduler status flag in session --- jmclient/jmclient/wallet_rpc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jmclient/jmclient/wallet_rpc.py b/jmclient/jmclient/wallet_rpc.py index 04de24434..483cfc74a 100644 --- a/jmclient/jmclient/wallet_rpc.py +++ b/jmclient/jmclient/wallet_rpc.py @@ -580,6 +580,7 @@ def session(self, request): session = not self.cookie==None maker_running = self.coinjoin_state == CJ_MAKER_RUNNING coinjoin_in_process = self.coinjoin_state == CJ_TAKER_RUNNING + coinjoin_is_part_of_schedule = self.coinjoin_state == CJ_TAKER_RUNNING and self.tumbler_options is not None if self.services["wallet"]: if self.services["wallet"].isRunning(): wallet_name = self.wallet_name @@ -590,6 +591,7 @@ def session(self, request): return make_jmwalletd_response(request,session=session, maker_running=maker_running, coinjoin_in_process=coinjoin_in_process, + coinjoin_is_part_of_schedule=coinjoin_is_part_of_schedule, wallet_name=wallet_name) @app.route('/wallet//taker/direct-send', methods=['POST']) @@ -1102,7 +1104,7 @@ def start_tumbler(self, request, walletname): self.check_cookie(request) if self.coinjoin_state is not CJ_NOT_RUNNING or self.tumbler_options is not None: - # Tumbler or taker seems to be running already. + # Tumbler, taker, or maker seems to be running already. return make_jmwalletd_response(request, status=409) if not self.services["wallet"]: From 12bcbe1aa10902778e9c6d0e7307723a5137cb44 Mon Sep 17 00:00:00 2001 From: Daniel <10026790+dnlggr@users.noreply.github.com> Date: Mon, 13 Jun 2022 11:18:49 +0200 Subject: [PATCH 2/7] docs: add flag to session response spec --- docs/api/wallet-rpc.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/api/wallet-rpc.yaml b/docs/api/wallet-rpc.yaml index 41ba680bf..5e3ae878a 100644 --- a/docs/api/wallet-rpc.yaml +++ b/docs/api/wallet-rpc.yaml @@ -713,6 +713,7 @@ components: - session - maker_running - coinjoin_in_process + - coinjoin_is_part_of_schedule - wallet_name properties: session: @@ -721,6 +722,8 @@ components: type: boolean coinjoin_in_process: type: boolean + coinjoin_is_part_of_schedule: + type: boolean wallet_name: type: string example: wallet.jmdat From ab2803eca06ee2411ca3565e6448c803c0a2e32e Mon Sep 17 00:00:00 2001 From: Daniel <10026790+dnlggr@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:06:33 +0200 Subject: [PATCH 3/7] fix: include schedule in session instead of status flag --- docs/api/wallet-rpc.yaml | 9 ++++++--- jmclient/jmclient/wallet_rpc.py | 12 ++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/api/wallet-rpc.yaml b/docs/api/wallet-rpc.yaml index 5e3ae878a..e8a2fa073 100644 --- a/docs/api/wallet-rpc.yaml +++ b/docs/api/wallet-rpc.yaml @@ -713,7 +713,6 @@ components: - session - maker_running - coinjoin_in_process - - coinjoin_is_part_of_schedule - wallet_name properties: session: @@ -722,8 +721,12 @@ components: type: boolean coinjoin_in_process: type: boolean - coinjoin_is_part_of_schedule: - type: boolean + schedule: + type: array + items: + oneOf: + - type: string + - type: integer wallet_name: type: string example: wallet.jmdat diff --git a/jmclient/jmclient/wallet_rpc.py b/jmclient/jmclient/wallet_rpc.py index 483cfc74a..848926987 100644 --- a/jmclient/jmclient/wallet_rpc.py +++ b/jmclient/jmclient/wallet_rpc.py @@ -580,18 +580,26 @@ def session(self, request): session = not self.cookie==None maker_running = self.coinjoin_state == CJ_MAKER_RUNNING coinjoin_in_process = self.coinjoin_state == CJ_TAKER_RUNNING - coinjoin_is_part_of_schedule = self.coinjoin_state == CJ_TAKER_RUNNING and self.tumbler_options is not None + schedule = None + if self.services["wallet"]: if self.services["wallet"].isRunning(): wallet_name = self.wallet_name + if self.coinjoin_state == CJ_TAKER_RUNNING and self.tumbler_options is not None: + logsdir = os.path.join(os.path.dirname(jm_single().config_location), "logs") + sfile = os.path.join(logsdir, self.tumbler_options['schedulefile']) + res, schedule = get_schedule(sfile) + if not res: + schedule = None else: wallet_name = "not yet loaded" else: wallet_name = "None" + return make_jmwalletd_response(request,session=session, maker_running=maker_running, coinjoin_in_process=coinjoin_in_process, - coinjoin_is_part_of_schedule=coinjoin_is_part_of_schedule, + schedule=schedule, wallet_name=wallet_name) @app.route('/wallet//taker/direct-send', methods=['POST']) From 521189a465bdafd6eb8081d6791947a1db964426 Mon Sep 17 00:00:00 2001 From: Daniel <10026790+dnlggr@users.noreply.github.com> Date: Tue, 28 Jun 2022 15:13:49 +0200 Subject: [PATCH 4/7] fix: add auth check --- jmclient/jmclient/wallet_rpc.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/jmclient/jmclient/wallet_rpc.py b/jmclient/jmclient/wallet_rpc.py index 848926987..9d483a88b 100644 --- a/jmclient/jmclient/wallet_rpc.py +++ b/jmclient/jmclient/wallet_rpc.py @@ -586,10 +586,16 @@ def session(self, request): if self.services["wallet"].isRunning(): wallet_name = self.wallet_name if self.coinjoin_state == CJ_TAKER_RUNNING and self.tumbler_options is not None: - logsdir = os.path.join(os.path.dirname(jm_single().config_location), "logs") - sfile = os.path.join(logsdir, self.tumbler_options['schedulefile']) - res, schedule = get_schedule(sfile) - if not res: + auth_header = request.getHeader('Authorization') + if auth_header is not None: + # At this point if an `auth_header` is present, it has been checked + # by the call to `check_cookie_if_present` above. + logsdir = os.path.join(os.path.dirname(jm_single().config_location), "logs") + sfile = os.path.join(logsdir, self.tumbler_options['schedulefile']) + res, schedule = get_schedule(sfile) + if not res: + schedule = None + else: schedule = None else: wallet_name = "not yet loaded" From 2cb41fcd3ef7930464dd0de26c86dd7a8fe5eadd Mon Sep 17 00:00:00 2001 From: Daniel <10026790+dnlggr@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:43:03 +0200 Subject: [PATCH 5/7] review: reaqd schedule from taker object --- jmclient/jmclient/wallet_rpc.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/jmclient/jmclient/wallet_rpc.py b/jmclient/jmclient/wallet_rpc.py index 9d483a88b..50b33126c 100644 --- a/jmclient/jmclient/wallet_rpc.py +++ b/jmclient/jmclient/wallet_rpc.py @@ -590,11 +590,8 @@ def session(self, request): if auth_header is not None: # At this point if an `auth_header` is present, it has been checked # by the call to `check_cookie_if_present` above. - logsdir = os.path.join(os.path.dirname(jm_single().config_location), "logs") - sfile = os.path.join(logsdir, self.tumbler_options['schedulefile']) - res, schedule = get_schedule(sfile) - if not res: - schedule = None + if self.taker is not None and not self.taker.aborted: + schedule = self.taker.schedule else: schedule = None else: From 57d14765a801f9effa8094e94006ad2916418de3 Mon Sep 17 00:00:00 2001 From: Daniel <10026790+dnlggr@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:16:13 +0200 Subject: [PATCH 6/7] fix: remove redundant else branch --- jmclient/jmclient/wallet_rpc.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/jmclient/jmclient/wallet_rpc.py b/jmclient/jmclient/wallet_rpc.py index 50b33126c..63630959e 100644 --- a/jmclient/jmclient/wallet_rpc.py +++ b/jmclient/jmclient/wallet_rpc.py @@ -592,8 +592,6 @@ def session(self, request): # by the call to `check_cookie_if_present` above. if self.taker is not None and not self.taker.aborted: schedule = self.taker.schedule - else: - schedule = None else: wallet_name = "not yet loaded" else: From 190d56e07b3bf3d93bc53f2414b376019c98abe8 Mon Sep 17 00:00:00 2001 From: Daniel <10026790+dnlggr@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:33:38 +0200 Subject: [PATCH 7/7] fix: update schedule type in API docs --- docs/api/wallet-rpc.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/api/wallet-rpc.yaml b/docs/api/wallet-rpc.yaml index e8a2fa073..bc3af32e8 100644 --- a/docs/api/wallet-rpc.yaml +++ b/docs/api/wallet-rpc.yaml @@ -724,9 +724,11 @@ components: schedule: type: array items: - oneOf: - - type: string - - type: integer + type: array + items: + oneOf: + - type: string + - type: integer wallet_name: type: string example: wallet.jmdat @@ -905,9 +907,11 @@ components: schedule: type: array items: - oneOf: - - type: string - - type: integer + type: array + items: + oneOf: + - type: string + - type: integer LockWalletResponse: type: object required: