Skip to content

Commit

Permalink
lotus-wallet: ledger flag
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Oct 10, 2020
1 parent 2f684e0 commit 4c520c1
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions cmd/lotus-wallet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"github.com/filecoin-project/lotus/api"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -61,6 +62,10 @@ var runCmd = &cli.Command{
Usage: "host address and port the wallet api will listen on",
Value: "0.0.0.0:1777",
},
&cli.BoolFlag{
Name: "ledger",
Usage: "use a ledger device instead of an on-disk wallet",
},
},
Action: func(cctx *cli.Context) error {
log.Info("Starting lotus wallet")
Expand Down Expand Up @@ -95,26 +100,29 @@ var runCmd = &cli.Command{
return err
}

w, err := wallet.NewWallet(ks)
if err != nil {
return err
}
_ = w
var w api.WalletAPI
if !cctx.Bool("ledger") {
w, err = wallet.NewWallet(ks)
if err != nil {
return err
}
} else {
ds, err := lr.Datastore("/metadata")
if err != nil {
return err
}

ds, err := lr.Datastore("/metadata")
if err != nil {
return err
w = ledgerwallet.NewWallet(ds)
}

lw := ledgerwallet.NewWallet(ds)

address := cctx.String("listen")
mux := mux.NewRouter()

log.Info("Setting up API endpoint at " + address)

rpcServer := jsonrpc.NewServer()
rpcServer.Register("Filecoin", &LoggedWallet{under: lw})
rpcServer.Register("Filecoin", &LoggedWallet{under: w})

mux.Handle("/rpc/v0", rpcServer)
mux.PathPrefix("/").Handler(http.DefaultServeMux) // pprof
Expand Down

0 comments on commit 4c520c1

Please sign in to comment.