diff --git a/mmgen/xmrwallet/ops/label.py b/mmgen/xmrwallet/ops/label.py index 0d3b7352..7b6775aa 100755 --- a/mmgen/xmrwallet/ops/label.py +++ b/mmgen/xmrwallet/ops/label.py @@ -15,6 +15,7 @@ xmrwallet.ops.label: Monero wallet ops for the MMGen Suite from ...color import pink, cyan, gray from ...util import msg, ymsg, gmsg, die, make_timestr from ...ui import keypress_confirm +from ...obj import TwComment from ...addr import CoinAddr from ..rpc import MoneroWalletRPC @@ -28,7 +29,7 @@ class OpLabel(OpMixinSpec, OpWallet): opts = () wallet_offline = True - async def main(self): + async def main(self, add_timestr='ask'): gmsg('\n{a} label for wallet {b}, account #{c}, address #{d}'.format( a = 'Setting' if self.label else 'Removing', @@ -53,7 +54,11 @@ class OpLabel(OpMixinSpec, OpWallet): len(ret) - 1)) addr = ret[self.address_idx] - new_label = f'{self.label} [{make_timestr()}]' if self.label else '' + if self.label and add_timestr == 'ask': + add_timestr = keypress_confirm(self.cfg, '\n Add timestamp to label?') + new_label = TwComment( + (self.label + (f' [{make_timestr()}]' if add_timestr else '')) if self.label + else '') ca = CoinAddr(self.proto, addr['address']) from . import addr_width diff --git a/test/cmdtest_d/xmrwallet.py b/test/cmdtest_d/xmrwallet.py index 5da0968c..eaa840f6 100755 --- a/test/cmdtest_d/xmrwallet.py +++ b/test/cmdtest_d/xmrwallet.py @@ -379,12 +379,14 @@ class CmdTestXMRWallet(CmdTestBase): return self.set_label_user( 'miner', '1:0:0,"Miner’s new primary account label [1:0:0]"', + 'y', 'updated') def remove_label_alice(self): return self.set_label_user( 'alice', '4:2:2,""', + None, 'removed', add_opts = ['--full-address']) @@ -392,9 +394,10 @@ class CmdTestXMRWallet(CmdTestBase): return self.set_label_user( 'alice', '4:2:2,"Alice’s new subaddress label [4:2:2]"', + 'n', 'set') - def set_label_user(self, user, label_spec, expect, add_opts=[]): + def set_label_user(self, user, label_spec, add_timestr_resp, expect, add_opts=[]): data = self.users[user] cmd_opts = [f'--wallet-dir={data.udir}', f'--daemon=localhost:{data.md.rpc_port}'] t = self.spawn( @@ -403,6 +406,8 @@ class CmdTestXMRWallet(CmdTestBase): + add_opts + cmd_opts + ['label', data.kafile, label_spec]) + if add_timestr_resp: + t.expect('(y/N): ', add_timestr_resp) t.expect('(y/N): ', 'y') t.expect(f'Label successfully {expect}') return t