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/hermes) compose these primitives with their own deployDir/keystoreDir conventions and namespace-specific cluster apply steps. The on-disk format is unchanged since OpenClaw (removed in v0.16) wrote it too, so a v0.15 OpenClaw backup still restores into Hermes.
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 (the shape generateRemoteSignerValues writes).
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.
func (Wallet) VerifyKeystore ¶ added in v0.17.0
VerifyKeystore decrypts the wallet's V3 keystore with its recorded password and checks that the derived address is the recorded one. The decrypted key never leaves this function; only addresses appear in the returned error. go-ethereum's decoder is used so keystores imported from other tools (pbkdf2 KDF) verify too.