-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client/{core,db}: headless options #1568
Conversation
850720a
to
3cc70c3
Compare
Working as intended. Added dexc command line switches, but the intended use is directly via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't seem to get --no-wallet-lock
to work.
- Client running with flag, connected to dcr rpc alpha node
- Unlock wallet.
- In harness,
./alpha walletislocked
returnsfalse
- Shut down dexc
- In harness,
./alpha walletislocked
returnstrue
client/asset/btc/btc.go
Outdated
btc.fundingCoins = make(map[outPoint]*utxo) | ||
return btc.node.lockUnspent(true, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
if err := btc.node.lockUnspent(true, nil); err != nil {
return err
}
btc.fundingCoins = make(map[outPoint]*utxo)
return nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. going to apply that in the selective utxo loop below too.
if c.cfg.UnlockCoinsOnLogin { | ||
if err = wallet.ReturnCoins(nil); err != nil { | ||
c.log.Errorf("Failed to unlock all %s wallet coins: %v", unbip(wallet.AssetID), err) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On wallet creation too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. It's in the docs and help for the cli switch. You mean the field name should change? UnlockCoinsOnInitialAccess
? The most routine use is login of course.
I didn't really want to wire this in to the connect helpers.
This comment was marked as resolved.
This comment was marked as resolved.
Oh dear, we've always been locking wallets twice it seems. Once on |
I'm undecided about the last commit ab7660f. Has potential for gotchas, and it's code that hasn't been giving us trouble thus far. If the work in this PR finds it's way back to |
This adds two new core.Config options aimed at improving startup and shutdown depending on the user's use case: - NoAutoWalletLock instructs Core to skip locking the wallet on shutdown. This can be helpful if the user wants the wallet to remain unlocked. e.g. They started with the wallet unlocked, or they intend to start Core again and wish to avoid the time to unlock a locked wallet on startup. - NoAutoDBBackup instructs the DB to skip the creation of a backup DB file on shutdown. This is useful if the consumer is using the BackupDB method, or simply creating manual backups of the DB file after shutdown. These options are intended for direct Core consumers, such as headless applications that drive Core directly instead of via the browser UI. These options are created so that the zero-value corresponds to legacy behavior. That is, the defaults are the existing behavior. However, in client/db/bolt, the BackupOnShutdown is reversed from Core's NoAutoDBBackup flag. The NewDB constructor accepts an optional db.Opts struct, and if it is not provided, a defaultOpts is used that has BackupOnShutdown set to true.
This adds the core.Config.UnlockCoinsOnLogin option that indicates that on wallet connect during login, or on creation of a new wallet, all coins with the wallet should be unlocked. To support this "unlock all" with the wallets, the ReturnCoins method of the asset.Wallet interface now interprets a nil Coins slice to mean that all coins should be unlocked. This is similar to the lockunspent RPC's semantics. The individual implementations of ReturnCoins are modified to recognize a nil unspent input slice and accordingly request the wallet backend unlock all coins.
--no-wallet-lock Disable locking of wallets on shutdown. Use this if you want your external wallets to stay unlocked after closing the DEX app. --no-db-backup Disable creation of a database backup on shutdown. --release-wallet-coins On login or wallet creation, instruct the wallet to release any coins that it may have locked.
These options are aimed at improving startup and shutdown speed of headless clients by avoiding unneeded work.