Hashicorp Vault-based store for the Ethereum 2 wallet.
go-eth2-wallet-store-vault
is a standard Go module which can be installed with:
go get github.com/wealdtech/go-eth2-wallet-store-vault
In normal operation this module should not be used directly. Instead, it should be configured to be used as part of go-eth2-wallet.
The Vault store has the following options:
id
: an ID that is used to differentiate multiple stores created by the same account. If this is not configured an empty ID is usedpassphrase
: a key used to encrypt all data written to the store. If this is not configured data is written to the store unencrypted (although wallet- and account-specific private information may be protected by their own passphrases)
package main
import (
e2wallet "github.com/wealdtech/go-eth2-wallet"
vault "github.com/Stakedllc/go-eth2-wallet-store-vault"
)
func main() {
// Set up and use an encrypted store
store, err := vault.New(vault.WithPassphrase([]byte("my secret")))
if err != nil {
panic(err)
}
e2wallet.UseStore(store)
// Set up and use an encrypted store with a non-default vault address
store, err = vault.New(vault.WithPassphrase([]byte("my secret")), vault.WithVaultAddress("https://my-secret-vault-server"))
if err != nil {
panic(err)
}
e2wallet.UseStore(store)
// Set up and use an encrypted store with a different vault role
store, err = vault.New(vault.WithPassphrase([]byte("my secret")), vault.WithRole("eth2role"))
if err != nil {
panic(err)
}
e2wallet.UseStore(store)
// Set up and use an encrypted store with data stored in a different part of vault
store, err = vault.New(vault.WithPassphrase([]byte("my secret")), vault.WithVaultSubPath("eth-secrets"))
if err != nil {
panic(err)
}
e2wallet.UseStore(store)
}
Max Bucci: @mbucci.
Contributions welcome. Please check out the issues.