diff --git a/chia/cmds/wallet.py b/chia/cmds/wallet.py index 2611b978d1..770c7efff6 100644 --- a/chia/cmds/wallet.py +++ b/chia/cmds/wallet.py @@ -455,6 +455,24 @@ def did_wallet_name_cmd(wallet_rpc_port: Optional[int], fingerprint: int, id: in asyncio.run(execute_with_wallet(wallet_rpc_port, fingerprint, extra_params, did_set_wallet_name)) +@did_cmd.command("get_did", short_help="Get DID from wallet") +@click.option( + "-wp", + "--wallet-rpc-port", + help="Set the port where the Wallet is hosting the RPC interface. See the rpc_port under wallet in config.yaml", + type=int, + default=None, +) +@click.option("-f", "--fingerprint", help="Set the fingerprint to specify which wallet to use", type=int) +@click.option("-i", "--id", help="Id of the wallet to use", type=int, required=True) +def did_get_did_cmd(wallet_rpc_port: Optional[int], fingerprint: int, id: int) -> None: + import asyncio + from .wallet_funcs import execute_with_wallet, get_did + + extra_params = {"did_wallet_id": id} + asyncio.run(execute_with_wallet(wallet_rpc_port, fingerprint, extra_params, get_did)) + + @wallet_cmd.group("nft", short_help="NFT related actions") def nft_cmd(): pass diff --git a/chia/cmds/wallet_funcs.py b/chia/cmds/wallet_funcs.py index 02d33e9c5a..497ce01fbe 100644 --- a/chia/cmds/wallet_funcs.py +++ b/chia/cmds/wallet_funcs.py @@ -669,6 +669,18 @@ async def did_set_wallet_name(args: Dict, wallet_client: WalletRpcClient, finger print(f"Failed to set DID wallet name: {e}") +async def get_did(args: Dict, wallet_client: WalletRpcClient, fingerprint: int) -> None: + did_wallet_id: int = args["did_wallet_id"] + try: + response = await wallet_client.get_did_id(did_wallet_id) + my_did = response["my_did"] + coin_id = response["coin_id"] + print(f"{'DID:'.ljust(23)} {my_did}") + print(f"{'Coin ID:'.ljust(23)} {coin_id}") + except Exception as e: + print(f"Failed to get DID: {e}") + + async def create_nft_wallet(args: Dict, wallet_client: WalletRpcClient, fingerprint: int) -> None: try: response = await wallet_client.create_new_nft_wallet(None)