Documentation
¶
Overview ¶
Package walletbackup is the runtime-agnostic core of `obol agent wallet backup` / `restore`. It owns the on-disk backup wire format, the AES-256-GCM encryption envelope, and the helpers that read/write the keystore password from values-remote-signer.yaml. Per-runtime callers (internal/openclaw, internal/hermes) compose these primitives with their own deployDir/keystoreDir conventions and namespace-specific cluster apply steps. The on-disk format must round-trip across runtimes, so a backup taken from an OpenClaw instance can restore into a Hermes one and vice versa.
Index ¶
- Constants
- Variables
- func Decrypt(data []byte, passphrase string) ([]byte, error)
- func Encode(f *File, passphrase string) ([]byte, bool, error)
- func Encrypt(plaintext []byte, passphrase string) ([]byte, error)
- func IsEncrypted(data []byte) bool
- func PromptPassphrase(flagValue string, hasFlag bool, u *ui.UI) (string, error)
- func ReadKeystorePassword(deployDir string) (string, error)
- func WriteValuesRemoteSigner(deployDir, content string) error
- type File
- type Wallet
Constants ¶
const Version = 1
Version is the current backup-format version. Bumping requires a parallel bump in Decode's accepted-versions check.
Variables ¶
var Magic = []byte("OBOL")
Magic is the 4-byte prefix of an encrypted backup file.
Functions ¶
func Decrypt ¶
Decrypt reverses Encrypt for the same passphrase, returning an error if the magic, version, or AEAD tag fails to verify.
func Encode ¶
Encode marshals a backup to bytes. If passphrase is non-empty, it returns an encrypted blob; otherwise it returns the indented JSON. The second return value reports which form was emitted.
func Encrypt ¶
Encrypt wraps plaintext with AES-256-GCM under a scrypt-derived key. Layout: magic(4) | version(1) | salt(32) | nonce(12) | ciphertext+tag. Exported so callers (and crypto-only tests) can exercise the envelope without going through Encode's JSON marshalling step.
func IsEncrypted ¶
IsEncrypted reports whether data carries the OBOL magic prefix.
func PromptPassphrase ¶
PromptPassphrase resolves a passphrase for backup. If the caller already passed --passphrase explicitly, hasFlag=true short-circuits the prompt (even when flagValue is the empty string, which means "no encryption").
func ReadKeystorePassword ¶
ReadKeystorePassword extracts keystorePassword.value from values-remote-signer.yaml under deployDir. Both Hermes and OpenClaw write the same shape, generated by their respective generateRemoteSignerValues.
func WriteValuesRemoteSigner ¶
WriteValuesRemoteSigner writes the rendered values-remote-signer.yaml to deployDir. Callers pass the runtime-specific rendered content (the YAML shape is identical across runtimes, but the comment header differs).
Types ¶
type File ¶
type File struct {
Version int `json:"version"`
Instance string `json:"instance"`
Wallets []Wallet `json:"wallets"`
}
File is the JSON shape of a wallet backup. One backup may carry multiple wallets; today both runtimes write a single-wallet file.
type Wallet ¶
type Wallet struct {
Address string `json:"address"`
PublicKey string `json:"publicKey"`
KeystoreUUID string `json:"keystoreUUID"`
CreatedAt string `json:"createdAt"`
Keystore json.RawMessage `json:"keystore"`
KeystorePassword string `json:"keystorePassword"`
}
Wallet holds a single wallet's backup data — enough to restore both the keystore JSON on disk and the keystore password the remote-signer needs.