> For the complete documentation index, see [llms.txt](https://docs.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bsvblockchain.org/network-topology/spv-wallet/developer-docs/spv-wallet-admin-keygen.md).

# Keygen

## Table of Contents

* [Overview](#overview)
* [Usage](#usage)
  * [Running Locally in command line](#running-locally-in-command-line)
  * [Running in Docker](#running-in-docker)
* [Example](#example)

🔗 [GitHub URL](https://github.com/bitcoin-sv/spv-wallet-admin-keygen)

## Overview

This tool generates public and private key pairs for SPV Wallet applications. It can just print those keys or (by default) store it in the Kubernetes secret.

## Usage

### Running in Docker

#### Printing Keys

To print the keys, run the following command:

```bash
docker run bsvb/spv-wallet-admin-keygen:latest --print --no-k8s
```

#### Kubernetes Secret Creation

**Connect to Kubernetes cluster**

To set the keys in kubernetes secret, you need to setup the image to have access to the namespace kubernetes cluster.

You can do this, for example, by creating a dedicated `kubeconfig` file and mounting it to the container.\
Simplest way to do this is to mount your `.kube/config` file to the container.

```bash
docker run -v {my/kube/config/file}:/kubeconfig -e KUBECONFIG=/kubeconfig bsvb/spv-wallet-admin-keygen:latest
```

**Configure the secret name**

By default the secret name is `spv-wallet-keys`.\
You can change it by using argument `-s` or `--secret`

ℹ️ To configure k8s connection look at the section [connect to kubernetes cluster](#connect-to-kubernetes-cluster)

```bash
docker run bsvb/spv-wallet-admin-keygen:latest --secret my-secret-name
```

If you prefer to use environment variables, you can set the `SECRET_NAME` environment variable instead.

```bash
docker run -e SECRET_NAME=my-secret-name bsvb/spv-wallet-admin-keygen:latest
```

**Configure the key names**

By default, the key names are `admin_xpub` and `admin_xpriv`.\
You can change it by using arguments -pb and -pv or --xpub-key and --xprv-key respectively.

ℹ️ To configure k8s connection look at the section [connect to kubernetes cluster](#connect-to-kubernetes-cluster)

```bash
docker run bsvb/spv-wallet-admin-keygen:latest --xpub-key my-xpub-key-name --xprv-key my-xpriv-key-name
```

If you prefer to use environment variables, you can set the `XPUB_KEY_NAME` and `XPRV_KEY_NAME` environment variables instead.

```bash
docker run -e XPUB_KEY_NAME=my-xpub-key-name -e XPRV_KEY_NAME=my-xpriv-key-name bsvb/spv-wallet-admin-keygen:latest
```

### Running from source code

Alternatively, you can generate a key pair directly from the source code.\
To use the tool, simply run the following command:

```bash
go run main.go
```

and it will generate a new key pair for you and store it in two files: `xpub_key.txt` and `xpriv_key.txt`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.bsvblockchain.org/network-topology/spv-wallet/developer-docs/spv-wallet-admin-keygen.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
