From ad9030bd1588db65ce93e6d0277ee8de51bf79cd Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 29 Jul 2022 09:38:15 +0200 Subject: [PATCH] labels plugin: handle setting a label to None --- electrum/plugins/labels/labels.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/electrum/plugins/labels/labels.py b/electrum/plugins/labels/labels.py index be1c65ba9..a358dfef2 100644 --- a/electrum/plugins/labels/labels.py +++ b/electrum/plugins/labels/labels.py @@ -65,12 +65,17 @@ class LabelsPlugin(BasePlugin): return if not item: return + if label is None: + # note: the server does not know whether a label is empty + label = '' nonce = self.get_nonce(wallet) wallet_id = self.wallets[wallet][2] - bundle = {"walletId": wallet_id, - "walletNonce": nonce, - "externalId": self.encode(wallet, item), - "encryptedLabel": self.encode(wallet, label)} + bundle = { + "walletId": wallet_id, + "walletNonce": nonce, + "externalId": self.encode(wallet, item), + "encryptedLabel": self.encode(wallet, label) + } asyncio.run_coroutine_threadsafe(self.do_post_safe("/label", bundle), wallet.network.asyncio_loop) # Caller will write the wallet self.set_nonce(wallet, nonce + 1) @@ -145,7 +150,8 @@ class LabelsPlugin(BasePlugin): except: self.logger.info(f'error: no json {key}') continue - result[key] = value + if value: + result[key] = value for key, value in result.items(): if force or not wallet.get_label(key):