Repository: Chia-Network/chia-blockchain

Issue:
[ENHANCEMENT] `chia wallet` should have a way to get next receive address
Right now the only easy way to get a wallet receive address is in the GUI or to grab the first wallet address in `chia keys show`.

We should probably both:

- Display a current valid receive address in `chia wallet show`
- Have a way to increment the receive address in `chia wallet show` and/or `chia keys show` via the command line




Discussion:
It could be something like https://bitcoincore.org/en/doc/0.18.0/rpc/wallet/getnewaddress/ - e.g. `bitcoin-cli getnewaddress "label" "address_type"`

Maybe in addition to `chia wallet show` displaying the current valid receive address, something like `chia wallet getnewaddress` would return a new address and set it as the current address.
The #1021 PR (already merged) covers at least part of this issue.
@hoffmang9 if you give me some explanation of next steps, I can try to make the extra changes needed to close this issue.
There only thing left is to see current address because new_address leads to the question of "well, what is the old one."

We should just add a line to `chia wallet show` which shows current wallet receive address - though I'm unclear where we keeping the state of the increment into the derivation path?
There is no rpc for this, we would have to add an rpc that just gets the last address used instead of generating a new one.

This was done on purpose to avoid reusing addresses. But I'm not opposed to adding it 
Maybe there is a better label for this. get_address that is always unique could work. Most of the words I can think of drive questions.

How about `get_address     get a wallet receive address` and drop new and follow the other get_'s?
Sure that works. So just renaming new_address to get_address? 
I think that works and is the easiest path.
@hoffmang9 @mariano54 great, thanks, I'll create a quick PR for that.

Resolving patch:
diff --git a/src/cmds/wallet.py b/src/cmds/wallet.py
--- a/src/cmds/wallet.py
+++ b/src/cmds/wallet.py
@@ -81,7 +81,7 @@ async def send(args: dict, wallet_client: WalletRpcClient, fingerprint: int) ->
     print(f"Do 'chia wallet get_transaction -f {fingerprint} -tx 0x{tx_id}' to get status")
 
 
-async def new_address(args: dict, wallet_client: WalletRpcClient, fingerprint: int) -> None:
+async def get_address(args: dict, wallet_client: WalletRpcClient, fingerprint: int) -> None:
     wallet_id = args["id"]
     res = await wallet_client.get_next_address(wallet_id)
     print(res)
@@ -295,7 +295,7 @@ def show_cmd(wallet_rpc_port: int, fingerprint: int) -> None:
     asyncio.run(execute_with_wallet(wallet_rpc_port, fingerprint, {}, print_balances))
 
 
-@wallet_cmd.command("new_address", short_help="add a new wallet address")
+@wallet_cmd.command("get_address", short_help="get a wallet receive address")
 @click.option(
     "-wp",
     "--wallet-rpc-port",
@@ -306,6 +306,6 @@ def show_cmd(wallet_rpc_port: int, fingerprint: int) -> None:
 )
 @click.option("-i", "--id", help="Id of the wallet to use.", type=int, default=1, show_default=True, required=True)
 @click.option("-f", "--fingerprint", help="Set the fingerprint to specify which wallet to use.", type=int)
-def new_address_cmd(wallet_rpc_port: int, id, fingerprint: int) -> None:
+def get_address_cmd(wallet_rpc_port: int, id, fingerprint: int) -> None:
     extra_params = {"id": id}
-    asyncio.run(execute_with_wallet(wallet_rpc_port, fingerprint, extra_params, new_address))
+    asyncio.run(execute_with_wallet(wallet_rpc_port, fingerprint, extra_params, get_address))


Test patch: