diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 11e859b1b..2ce9a996e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -33,6 +33,7 @@ All notable changes to this project are documented in this file. - Fix ``np-import`` not importing headers ahead of block persisting potentially unexpected VM execution results - Fix undesired debug statement printing - Add negative bitwise shifting support for ``BigInteger`` to match C# +- Include address aliases in ``wallet`` command output - Fix ``config maxpeers`` and update tests diff --git a/neo/Implementations/Wallets/peewee/UserWallet.py b/neo/Implementations/Wallets/peewee/UserWallet.py index 291f2d4c7..e9016a932 100755 --- a/neo/Implementations/Wallets/peewee/UserWallet.py +++ b/neo/Implementations/Wallets/peewee/UserWallet.py @@ -525,8 +525,16 @@ def pretty_print(self, verbose=False): 'tokens': self._get_token_balances(addr_str) }}) + aliases = dict() + alia = NamedAddress.select() + for n in alia: + aliases[n.Title] = n.ToString() + # pretty print for address, data in addresses.items(): + for title, addr in aliases.items(): + if address == addr: + print(f"Alias : {title}") addr_str = address + " (watch only)" if data['watchonly'] else address print(f"Address : {addr_str}") if verbose: diff --git a/neo/Prompt/Commands/tests/test_address_commands.py b/neo/Prompt/Commands/tests/test_address_commands.py index e73536d8f..af5391f98 100644 --- a/neo/Prompt/Commands/tests/test_address_commands.py +++ b/neo/Prompt/Commands/tests/test_address_commands.py @@ -97,6 +97,14 @@ def test_wallet_alias(self): res = CommandWallet().execute(args) self.assertFalse(res) + # verify wallet has no aliases + with patch('sys.stdout', new=StringIO()) as mock_print: + args = [""] + res = CommandWallet().execute(args) + self.assertTrue(res) + self.assertEqual(len(PromptData.Wallet.NamedAddr), 0) + self.assertNotIn("Alias", mock_print.getvalue()) + # test wallet alias successful self.assertNotIn('mine', [n.Title for n in PromptData.Wallet.NamedAddr]) @@ -105,6 +113,12 @@ def test_wallet_alias(self): self.assertTrue(res) self.assertIn('mine', [n.Title for n in PromptData.Wallet.NamedAddr]) + with patch('sys.stdout', new=StringIO()) as mock_print: + args = [""] + res = CommandWallet().execute(args) + self.assertTrue(res) + self.assertIn("Alias : mine", mock_print.getvalue()) + def test_6_split_unspent(self): wallet = self.GetWallet1(recreate=True) addr = wallet.ToScriptHash('AJQ6FoaSXDFzA6wLnyZ1nFN7SGSN2oNTc3')