Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
_obj
_test

# Test data directories
testdata/

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ XARGS := xargs -L 1

VERSION_TAG = $(shell git describe --tags)

DEV_TAGS = kvdb_etcd kvdb_postgres kvdb_sqlite
RELEASE_TAGS = $(DEV_TAGS)

BUILD_SYSTEM = darwin-amd64 \
darwin-arm64 \
linux-386 \
linux-amd64 \
linux-armv6 \
Expand All @@ -49,7 +53,7 @@ endif
make_ldflags = $(2) -X main.Commit=$(COMMIT)

DEV_GCFLAGS := -gcflags "all=-N -l"
LDFLAGS := -ldflags "$(call make_ldflags, ${tags}, -s -w)"
LDFLAGS := -ldflags "$(call make_ldflags, $(DEV_TAGS), -s -w)"
DEV_LDFLAGS := -ldflags "$(call make_ldflags, $(DEV_TAGS))"

# For the release, we want to remove the symbol table and debug information (-s)
Expand Down Expand Up @@ -83,15 +87,15 @@ build:

install:
@$(call print, "Installing lndinit.")
$(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)
$(GOINSTALL) -tags="$(DEV_TAGS)" $(LDFLAGS) $(PKG)

release-install:
@$(call print, "Installing release lndinit.")
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)

release:
@$(call print, "Creating release of lndinit.")
./release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_LDFLAGS)"
./release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_LDFLAGS)" "$(RELEASE_TAGS)"

docker-tools:
@$(call print, "Building tools docker image.")
Expand All @@ -105,7 +109,7 @@ scratch: build

unit:
@$(call print, "Running unit tests.")
$(GOTEST) ./...
$(GOTEST) -tags="$(DEV_TAGS)" ./...

fmt: $(GOIMPORTS_BIN)
@$(call print, "Fixing imports.")
Expand All @@ -115,7 +119,7 @@ fmt: $(GOIMPORTS_BIN)

lint: docker-tools
@$(call print, "Linting source.")
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
$(DOCKER_TOOLS) golangci-lint run -v --build-tags="$(DEV_TAGS)"$(LINT_WORKERS)

vendor:
@$(call print, "Re-creating vendor directory.")
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ initialization, including seed and password generation.
- [`store-configmap`](#store-configmap)
- [`init-wallet`](#init-wallet)
- [`wait-ready`](#wait-ready)
- [`migrate-db`](#migrate-db)
- [Example usage](#example-usage)
- [Basic setup](#example-use-case-1-basic-setup)
- [Kubernetes](#example-use-case-2-kubernetes)
Expand Down Expand Up @@ -64,6 +65,11 @@ No `lnd` needed, but seed will be in `lnd`-specific [`aezeed` format](https://gi
`wait-ready` waits for `lnd` to be ready by connecting to `lnd`'s status RPC
- Needs `lnd` to run, eventually

### migrate-db
`migrate-db` migrates the content of one `lnd` database to another, for example
from `bbolt` to Postgres. See [data migration guide](docs/data-migration.md) for
Comment thread
guggero marked this conversation as resolved.
more information.

---

## Example Usage
Expand Down
22 changes: 11 additions & 11 deletions cmd_init_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (x *initWalletCommand) Execute(_ []string) error {
if x.InitRpc.WatchOnly {
// For initializing a watch-only wallet we need the
// accounts JSON file.
log("Reading accounts from file")
logger.Info("Reading accounts from file")
accountsBytes, err := readFile(x.InitRpc.AccountsFile)
if err != nil {
return err
Expand Down Expand Up @@ -215,7 +215,7 @@ func (x *initWalletCommand) readInput(requireSeed bool) (string, string, string,
// Read all secrets from individual files.
case storageFile:
if requireSeed {
log("Reading seed from file")
logger.Info("Reading seed from file")
seed, err = readFile(x.File.Seed)
if err != nil {
return "", "", "", err
Expand All @@ -224,14 +224,14 @@ func (x *initWalletCommand) readInput(requireSeed bool) (string, string, string,

// The seed passphrase is optional.
if x.File.SeedPassphrase != "" {
log("Reading seed passphrase from file")
logger.Info("Reading seed passphrase from file")
seedPassPhrase, err = readFile(x.File.SeedPassphrase)
if err != nil {
return "", "", "", err
}
}

log("Reading wallet password from file")
logger.Info("Reading wallet password from file")
walletPassword, err = readFile(x.File.WalletPassword)
if err != nil {
return "", "", "", err
Expand All @@ -248,7 +248,7 @@ func (x *initWalletCommand) readInput(requireSeed bool) (string, string, string,
}

if requireSeed {
log("Reading seed from k8s secret %s (namespace %s)",
logger.Infof("Reading seed from k8s secret %s (namespace %s)",
x.K8s.SecretName, x.K8s.Namespace)
seed, _, err = readK8s(k8sSecret)
if err != nil {
Expand All @@ -258,7 +258,7 @@ func (x *initWalletCommand) readInput(requireSeed bool) (string, string, string,

// The seed passphrase is optional.
if x.K8s.SeedPassphraseKeyName != "" {
log("Reading seed passphrase from k8s secret %s "+
logger.Infof("Reading seed passphrase from k8s secret %s "+
"(namespace %s)", x.K8s.SecretName,
x.K8s.Namespace)
k8sSecret.KeyName = x.K8s.SeedPassphraseKeyName
Expand All @@ -268,7 +268,7 @@ func (x *initWalletCommand) readInput(requireSeed bool) (string, string, string,
}
}

log("Reading wallet password from k8s secret %s (namespace %s)",
logger.Infof("Reading wallet password from k8s secret %s (namespace %s)",
x.K8s.SecretName, x.K8s.Namespace)
k8sSecret.KeyName = x.K8s.WalletPasswordKeyName
walletPassword, _, err = readK8s(k8sSecret)
Expand Down Expand Up @@ -329,7 +329,7 @@ func createWalletFile(cipherSeed *aezeed.CipherSeed, walletPassword, walletDir,
func createWallet(walletDir string, cipherSeed *aezeed.CipherSeed,
walletPassword []byte, network string) error {

log("Creating new wallet in %s", walletDir)
logger.Infof("Creating new wallet in %s", walletDir)

// The network parameters are needed for some wallet internal things
// like the chain genesis hash and timestamp.
Expand Down Expand Up @@ -358,15 +358,15 @@ func createWallet(walletDir string, cipherSeed *aezeed.CipherSeed,
err)
}

log("Wallet created successfully in %s", walletDir)
logger.Infof("Wallet created successfully in %s", walletDir)

return nil
}

func validateWallet(walletDir string, walletPassword []byte,
network string) error {

log("Validating password for wallet in %s", walletDir)
logger.Infof("Validating password for wallet in %s", walletDir)

// The network parameters are needed for some wallet internal things
// like the chain genesis hash and timestamp.
Expand All @@ -391,7 +391,7 @@ func validateWallet(walletDir string, walletPassword []byte,
err)
}

log("Wallet password validated successfully")
logger.Info("Wallet password validated successfully")

return nil
}
Expand Down
Loading