> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
