diff --git a/python-examples/bisq/bots/bisq_client.py b/python-examples/bisq/bots/bisq_client.py index 91c1c64..b5120f5 100644 --- a/python-examples/bisq/bots/bisq_client.py +++ b/python-examples/bisq/bots/bisq_client.py @@ -396,5 +396,23 @@ class BisqClient(object): currency_code, payment_details) + def get_payment_account(self, payment_account_id): + try: + response = self.payment_accts_stub.GetPaymentAccounts.with_call( + bisq_messages.GetPaymentAccountsRequest(), + metadata=[('password', self.api_password)]) + payment_accounts = list(response[0].payment_accounts) + if len(payment_accounts): + payment_accounts_filter = filter(lambda account: (account.id == payment_account_id), payment_accounts) + filtered_accounts = list(payment_accounts_filter) + if len(filtered_accounts): + return filtered_accounts[0] + else: + return None + else: + return None + except grpc.RpcError as rpc_error: + print('gRPC API Exception: %s', rpc_error) + def __str__(self): return 'host=' + self.host + ' port=' + self.port + ' api_password=' + '*****' diff --git a/python-examples/bisq/bots/sepa_mm_bot.py b/python-examples/bisq/bots/sepa_mm_bot.py index 56c3176..c524f38 100644 --- a/python-examples/bisq/bots/sepa_mm_bot.py +++ b/python-examples/bisq/bots/sepa_mm_bot.py @@ -69,6 +69,14 @@ class SepaMMBot(BisqClient): self.close_channel() self.is_running = False + def is_valid_sepa_payment_account_id(self, sepa_payment_account_id): + account = self.get_payment_account(sepa_payment_account_id) + if account is None: + log.error('{0} is not a valid PaymentAccount.id.'.format(sepa_payment_account_id)) + return False + else: + return True + def make_market(self, reference_price_margin, target_spread, amount_in_satoshis, diff --git a/python-examples/bisq/bots/sepa_mm_bot_ui.py b/python-examples/bisq/bots/sepa_mm_bot_ui.py index cdf248a..8a4254f 100644 --- a/python-examples/bisq/bots/sepa_mm_bot_ui.py +++ b/python-examples/bisq/bots/sepa_mm_bot_ui.py @@ -70,6 +70,12 @@ def start(): def start_bot(): + payment_account_exists = bot.is_valid_sepa_payment_account_id(sepa_payment_account_id) + if payment_account_exists is False: + window.quit() + log.error('Shutting down UI.') + return + disable_button(start_button) enable_button(stop_button) reference_price_margin = Decimal(price_margin_input.get())