-
Notifications
You must be signed in to change notification settings - Fork 105
/
delete-password.go
54 lines (43 loc) · 1.33 KB
/
delete-password.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package wallet
import (
"fmt"
"net/url"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/gorilla/mux"
"github.com/rocket-pool/node-manager-core/api/server"
"github.com/rocket-pool/node-manager-core/api/types"
)
// ===============
// === Factory ===
// ===============
type walletDeletePasswordContextFactory struct {
handler *WalletHandler
}
func (f *walletDeletePasswordContextFactory) Create(args url.Values) (*walletDeletePasswordContext, error) {
c := &walletDeletePasswordContext{
handler: f.handler,
}
return c, nil
}
func (f *walletDeletePasswordContextFactory) RegisterRoute(router *mux.Router) {
server.RegisterQuerylessGet[*walletDeletePasswordContext, types.SuccessData](
router, "delete-password", f, f.handler.logger.Logger, f.handler.serviceProvider.ServiceProvider,
)
}
// ===============
// === Context ===
// ===============
type walletDeletePasswordContext struct {
handler *WalletHandler
password []byte
save bool
}
func (c *walletDeletePasswordContext) PrepareData(data *types.SuccessData, opts *bind.TransactOpts) (types.ResponseStatus, error) {
sp := c.handler.serviceProvider
w := sp.GetWallet()
err := w.DeletePassword()
if err != nil {
return types.ResponseStatus_Error, fmt.Errorf("error deleting wallet password from disk: %w", err)
}
return types.ResponseStatus_Success, nil
}