SiaFoundation / siad

The Sia daemon
https://sia.tech
MIT License
130 stars 28 forks source link

Unlock wallet before other modules startup #144

Closed n8maninger closed 2 years ago

n8maninger commented 2 years ago

Moves the wallet auto unlock before other modules have loaded to prevent host proof issues

storageobligations.go:1351: failed to build storage proof trransaction: Host error when funding a storage proof transaction fee: wallet must be unlocked before it can be used

When SIA_WALLET_PASSWORD is provided, startup will now look like this:

siad v1.5.9
Git Revision 064e33833
Loading...
(1/7) Loading siad...
(2/7) Loading gateway...
(3/7) Loading consensus...
(4/7) Loading transaction pool...
(5/7) Loading wallet...
  Wallet password found, attempting to unlock wallet...
  Auto-unlock successful.
(6/7) Loading host...
(7/7) Loading accounting...
API is now available, synchronous startup completed in 20.172 seconds
Finished full setup in 34s
n8maninger commented 2 years ago

Added ignores for the new gosec errors since they're not from new code:

[lint: types/currency.go#L243] G113: Potential uncontrolled memory consumption in Rat.SetString (CVE-2022-23772) (gosec)
[lint: node/api/server_helpers_test.go#L135] G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec)
[lint: cmd/siac/parse.go#L97] G113: Potential uncontrolled memory consumption in Rat.SetString (CVE-2022-23772) (gosec)