Skip to content

Commit

Permalink
Avoid stdin passphrase prompt with --noinitialload.
Browse files Browse the repository at this point in the history
Fixes #188.
  • Loading branch information
jrick committed Apr 23, 2016
1 parent b28ae9a commit 8ed9a8c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
16 changes: 13 additions & 3 deletions dcrwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ func walletMain() error {
TicketBuyFreq: cfg.TicketBuyFreq,
}
loader := wallet.NewLoader(activeNet.Params, dbDir, stakeOptions,
cfg.AutomaticRepair, cfg.UnsafeMainNet, cfg.PromptPass,
cfg.AddrIdxScanLen)
cfg.AutomaticRepair, cfg.UnsafeMainNet, cfg.AddrIdxScanLen)

// Create and start HTTP server to serve wallet client connections.
// This will be updated with the wallet and chain server RPC client
Expand All @@ -120,7 +119,18 @@ func walletMain() error {
}

loader.RunAfterLoad(func(w *wallet.Wallet) {
startPromptPass(w)
// TODO(jrick): I think that this prompt should be removed
// entirely instead of enabling it when --noinitialload is
// unset. It can be replaced with an RPC request (either
// providing the private passphrase as a parameter, or require
// unlocking the wallet first) to trigger a full accounts
// rescan.
//
// Until then, since --noinitialload users are expecting to use
// the wallet only over RPC, disable this feature for them.
if !cfg.NoInitialLoad {
startPromptPass(w)
}
startWalletRPCServices(w, rpcs, legacyRPCServer)
})

Expand Down
4 changes: 1 addition & 3 deletions wallet/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ type Loader struct {
stakeOptions *StakeOptions
autoRepair bool
unsafeMainNet bool
promptPass bool
addrIdxScanLen int
}

Expand All @@ -74,14 +73,13 @@ type StakeOptions struct {
// NewLoader constructs a Loader.
func NewLoader(chainParams *chaincfg.Params, dbDirPath string,
stakeOptions *StakeOptions, autoRepair bool, unsafeMainNet bool,
promptPass bool, addrIdxScanLen int) *Loader {
addrIdxScanLen int) *Loader {
return &Loader{
chainParams: chainParams,
dbDirPath: dbDirPath,
stakeOptions: stakeOptions,
autoRepair: autoRepair,
unsafeMainNet: unsafeMainNet,
promptPass: promptPass,
addrIdxScanLen: addrIdxScanLen,
}
}
Expand Down
3 changes: 1 addition & 2 deletions walletsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ func createWallet(cfg *config) error {
TicketMaxPrice: cfg.TicketMaxPrice,
}
loader := wallet.NewLoader(activeNet.Params, dbDir, stakeOptions,
cfg.AutomaticRepair, cfg.UnsafeMainNet, cfg.PromptPass,
cfg.AddrIdxScanLen)
cfg.AutomaticRepair, cfg.UnsafeMainNet, cfg.AddrIdxScanLen)

// When there is a legacy keystore, open it now to ensure any errors
// don't end up exiting the process after the user has spent time
Expand Down

0 comments on commit 8ed9a8c

Please sign in to comment.