Repository: chia-network/chia-blockchain
Issue: [Bug] Cleanup output of `chia data create_data_store`

### What happened?

The current output of `chia data create_data_store` is overly verbose and although appearing to be JSON is not proper JSON so it cannot be piped to `jq` or other json processing tools

example: 
```
❯ chia data create_data_store -m 0.01
{'id': '1a34a5b320767bcbba0d12f1204f2495aaddc4dca717f249a3a2253c7c67771c', 'success': True, 'txs': [{'additions': [{'amount': 1, 'parent_coin_info': '0x23ea7929e6842408f76ebef0de82e61d3e1faac149f6541b54b45a77d2b2dfa8', 'puzzle_hash': '0xeff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9'}, {'amount': 99972799999996, 'parent_coin_info': '0x23ea7929e6842408f76ebef0de82e61d3e1faac149f6541b54b45a77d2b2dfa8', 'puzzle_hash': '0x98f6821a24ee90d187e84ed49c2baee0ee2a6a712dd27c211f734852623cf443'}, {'amount': 1, 'parent_coin_info': '0x1a34a5b320767bcbba0d12f1204f2495aaddc4dca717f249a3a2253c7c67771c', 'puzzle_hash': '0x032bd9039f98a5b7e0c55295e6e33a6e7772d3505695ae7ea571a049ceb829ba'}], 'amount': 1, 'confirmed': False, 'confirmed_at_height': 0, 'created_at_time': 1692110896, 'fee_amount': 10000000000, 'memos': [], 'name': '0x9ed4b49a8ebd6506fda5068ccd594236cfc887bd63f48b45890be75b80ad4da8', 'removals': [{'amount': 99982799999997, 'parent_coin_info': '0x74762f2a1713edcbb1156293d04df593be64dc9dcf8b7321126199a98878625b', 'puzzle_hash': '0xde4b3b32688ccbd469d1865e8f1b410aa4e8ad6357dfa557f9a2f1c953d79f5f'}, {'amount': 1, 'parent_coin_info': '0x23ea7929e6842408f76ebef0de82e61d3e1faac149f6541b54b45a77d2b2dfa8', 'puzzle_hash': '0xeff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9'}], 'sent': 10, 'sent_to': [], 'spend_bundle': {'aggregated_signature': '0xad11f158801ad673af526dacf52498a0748f0d01b05ecee34cc6c7eb8334fa9a1223a413cc9b4560216ece6b22ca88620177e3d0647b19829873614d054085cc19b2eae18cd2d71f8be04846df6a37ed451e4fcc35d0e775ceba0097923d9448', 'coin_spends': [{'coin': {'amount': 99982799999997, 'parent_coin_info': '0x74762f2a1713edcbb1156293d04df593be64dc9dcf8b7321126199a98878625b', 'puzzle_hash': '0xde4b3b32688ccbd469d1865e8f1b410aa4e8ad6357dfa557f9a2f1c953d79f5f'}, 'puzzle_reveal': '0xff02ffff01ff02ffff01ff02ffff03ff0bffff01ff02ffff03ffff09ff05ffff1dff0bffff1effff0bff0bffff02ff06ffff04ff02ffff04ff17ff8080808080808080ffff01ff02ff17ff2f80ffff01ff088080ff0180ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff17ff80808080ff80808080ffff02ff17ff2f808080ff0180ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080ffff04ffff01b0a8fdae02f161cdf8ae2ac6c4d890da7fdd40bb61cde999288be8c9b57c5d58f2651e5c35f8414af4103ffc8a672dbdd7ff018080', 'solution': '0xff80ffff01ffff33ffa0eff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9ff0180ffff33ffa098f6821a24ee90d187e84ed49c2baee0ee2a6a712dd27c211f734852623cf443ff865aecbb3b2ffc80ffff34ff8502540be40080ffff3cffa0714e0b88f328cb8d64cd1c2e9b5ab0ee08e92c7e9c2844c0b04f79064f2e890980ffff3dffa0b6b9b6c5cbde6df6b8645900d87ed1d88dd63197cf76c1e4c1a4849ec6c258a38080ff8080'}, {'coin': {'amount': 1, 'parent_coin_info': '0x23ea7929e6842408f76ebef0de82e61d3e1faac149f6541b54b45a77d2b2dfa8', 'puzzle_hash': '0xeff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9'}, 'puzzle_reveal': '0xff02ffff01ff04ffff04ff04ffff04ff05ffff04ff0bff80808080ffff04ffff04ff0affff04ffff02ff0effff04ff02ffff04ffff04ff05ffff04ff0bffff04ff17ff80808080ff80808080ff808080ff808080ffff04ffff01ff33ff3cff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff0effff04ff02ffff04ff09ff80808080ffff02ff0effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080', 'solution': '0xffa0032bd9039f98a5b7e0c55295e6e33a6e7772d3505695ae7ea571a049ceb829baff01ffffa00000000000000000000000000000000000000000000000000000000000000000ffa06c9f42ed51293771e85eee1ab942e6a35e2ee3d010139fb820446a2aa19868348080'}]}, 'to_puzzle_hash': '0x0202020202020202020202020202020202020202020202020202020202020202', 'trade_id': None, 'type': 0, 'wallet_id': 0}, {'additions': [{'amount': 1, 'parent_coin_info': '0x23ea7929e6842408f76ebef0de82e61d3e1faac149f6541b54b45a77d2b2dfa8', 'puzzle_hash': '0xeff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9'}, {'amount': 99972799999996, 'parent_coin_info': '0x23ea7929e6842408f76ebef0de82e61d3e1faac149f6541b54b45a77d2b2dfa8', 'puzzle_hash': '0x98f6821a24ee90d187e84ed49c2baee0ee2a6a712dd27c211f734852623cf443'}], 'amount': 1, 'confirmed': False, 'confirmed_at_height': 0, 'created_at_time': 1692110896, 'fee_amount': 10000000000, 'memos': [], 'name': '0x4de37649ff813721b33b439b33d7a5967da39058200b099d2566c58683d40f24', 'removals': [{'amount': 99982799999997, 'parent_coin_info': '0x74762f2a1713edcbb1156293d04df593be64dc9dcf8b7321126199a98878625b', 'puzzle_hash': '0xde4b3b32688ccbd469d1865e8f1b410aa4e8ad6357dfa557f9a2f1c953d79f5f'}], 'sent': 0, 'sent_to': [], 'spend_bundle': None, 'to_puzzle_hash': '0xeff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9', 'trade_id': None, 'type': 1, 'wallet_id': 1}]}
```

Following changes are recommended:

- [ ] Change default to only return the singleton id `{"id": "1a34a5b320767bcbba0d12f1204f2495aaddc4dca717f249a3a2253c7c67771c", "success": True}`
- [ ] Add `--verbose` option to return all the rest of the items
- [ ] output legal JSON and not python object

### Version

All

### What platform are you using?

Windows

### What ui mode are you using?

CLI

### Relevant log output

```shell
N/A
```


Changed files:
chia/cmds/data_funcs.py, chia/cmds/data.py, chia/rpc/data_layer_rpc_client.py, chia/rpc/data_layer_rpc_api.py, tests/core/data_layer/test_data_rpc.py

diff --git a/chia/cmds/data.py b/chia/cmds/data.py
index c673e8627..db8d9f74c 100644
--- a/chia/cmds/data.py
+++ b/chia/cmds/data.py
@@ -108,13 +108,15 @@ def create_fee_option() -> Callable[[FC], FC]:
 @data_cmd.command("create_data_store", help="Create a new data store")
 @create_rpc_port_option()
 @create_fee_option()
+@click.option("--verbose", is_flag=True, help="Enable verbose output.")
 def create_data_store(
     data_rpc_port: int,
     fee: Optional[str],
+    verbose: bool,
 ) -> None:
     from chia.cmds.data_funcs import create_data_store_cmd
 
-    run(create_data_store_cmd(data_rpc_port, fee))
+    run(create_data_store_cmd(data_rpc_port, fee, verbose))
 
 
 @data_cmd.command("get_value", help="Get the value for a given key and store")
diff --git a/chia/cmds/data_funcs.py b/chia/cmds/data_funcs.py
index 1be504f1f..23d498bba 100644
--- a/chia/cmds/data_funcs.py
+++ b/chia/cmds/data_funcs.py
@@ -14,11 +14,11 @@ from chia.util.default_root import DEFAULT_ROOT_PATH
 from chia.util.ints import uint64
 
 
-async def create_data_store_cmd(rpc_port: Optional[int], fee: Optional[str]) -> None:
+async def create_data_store_cmd(rpc_port: Optional[int], fee: Optional[str], verbose: bool) -> None:
     final_fee = None if fee is None else uint64(int(Decimal(fee) * units["chia"]))
     async with get_any_service_client(DataLayerRpcClient, rpc_port) as (client, _):
-        res = await client.create_data_store(fee=final_fee)
-        print(res)
+        res = await client.create_data_store(fee=final_fee, verbose=verbose)
+        print(json.dumps(res, indent=4))
 
 
 async def get_value_cmd(rpc_port: Optional[int], store_id: str, key: str, root_hash: Optional[str]) -> None:
diff --git a/chia/rpc/data_layer_rpc_api.py b/chia/rpc/data_layer_rpc_api.py
index de187bf9a..e8f845800 100644
--- a/chia/rpc/data_layer_rpc_api.py
+++ b/chia/rpc/data_layer_rpc_api.py
@@ -112,8 +112,12 @@ class DataLayerRpcApi:
         if self.service is None:
             raise Exception("Data layer not created")
         fee = get_fee(self.service.config, request)
+        verbose = request.get("verbose", False)
         txs, value = await self.service.create_store(uint64(fee))
-        return {"txs": txs, "id": value.hex()}
+        if verbose:
+            return {"txs": txs, "id": value.hex()}
+        else:
+            return {"id": value.hex()}
 
     async def get_owned_stores(self, request: Dict[str, Any]) -> EndpointResult:
         if self.service is None:
diff --git a/chia/rpc/data_layer_rpc_client.py b/chia/rpc/data_layer_rpc_client.py
index 6b5ab3836..6d0bcf13d 100644
--- a/chia/rpc/data_layer_rpc_client.py
+++ b/chia/rpc/data_layer_rpc_client.py
@@ -10,8 +10,8 @@ from chia.util.ints import uint64
 
 
 class DataLayerRpcClient(RpcClient):
-    async def create_data_store(self, fee: Optional[uint64]) -> Dict[str, Any]:
-        response = await self.fetch("create_data_store", {"fee": fee})
+    async def create_data_store(self, fee: Optional[uint64], verbose: bool) -> Dict[str, Any]:
+        response = await self.fetch("create_data_store", {"fee": fee, "verbose": verbose})
         return response
 
     async def get_value(self, store_id: bytes32, key: bytes, root_hash: Optional[bytes32]) -> Dict[str, Any]:
diff --git a/tests/core/data_layer/test_data_rpc.py b/tests/core/data_layer/test_data_rpc.py
index f46d7c78d..27ed347b0 100644
--- a/tests/core/data_layer/test_data_rpc.py
+++ b/tests/core/data_layer/test_data_rpc.py
@@ -712,7 +712,7 @@ async def offer_setup_fixture(
             )
             data_rpc_api = DataLayerRpcApi(data_layer)
 
-            create_response = await data_rpc_api.create_data_store({})
+            create_response = await data_rpc_api.create_data_store({"verbose": True})
             await full_node_api.process_transaction_records(records=create_response["txs"])
 
             store_setups.append(