labels plugin: handle setting a label to None
This commit is contained in:
@@ -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):
|
||||||
|
|||||||
Reference in New Issue
Block a user