Browse Source

labels plugin: handle setting a label to None

patch-4
ThomasV 3 years ago
parent
commit
ad9030bd15
  1. 16
      electrum/plugins/labels/labels.py

16
electrum/plugins/labels/labels.py

@ -65,12 +65,17 @@ class LabelsPlugin(BasePlugin):
return return
if not item: if not item:
return return
if label is None:
# note: the server does not know whether a label is empty
label = ''
nonce = self.get_nonce(wallet) nonce = self.get_nonce(wallet)
wallet_id = self.wallets[wallet][2] wallet_id = self.wallets[wallet][2]
bundle = {"walletId": wallet_id, bundle = {
"walletNonce": nonce, "walletId": wallet_id,
"externalId": self.encode(wallet, item), "walletNonce": nonce,
"encryptedLabel": self.encode(wallet, label)} "externalId": self.encode(wallet, item),
"encryptedLabel": self.encode(wallet, label)
}
asyncio.run_coroutine_threadsafe(self.do_post_safe("/label", bundle), wallet.network.asyncio_loop) asyncio.run_coroutine_threadsafe(self.do_post_safe("/label", bundle), wallet.network.asyncio_loop)
# Caller will write the wallet # Caller will write the wallet
self.set_nonce(wallet, nonce + 1) self.set_nonce(wallet, nonce + 1)
@ -145,7 +150,8 @@ class LabelsPlugin(BasePlugin):
except: except:
self.logger.info(f'error: no json {key}') self.logger.info(f'error: no json {key}')
continue continue
result[key] = value if value:
result[key] = value
for key, value in result.items(): for key, value in result.items():
if force or not wallet.get_label(key): if force or not wallet.get_label(key):

Loading…
Cancel
Save