lotus/cmd/lotus-storage-miner/rewards.go

86 lines
1.6 KiB
Go
Raw Normal View History

package main
import (
"fmt"
"gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/specs-actors/actors/builtin"
)
var rewardsCmd = &cli.Command{
Name: "rewards",
Subcommands: []*cli.Command{
rewardsRedeemCmd,
},
}
var rewardsRedeemCmd = &cli.Command{
Name: "redeem",
Usage: "Redeem block rewards",
Action: func(cctx *cli.Context) error {
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()
api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer acloser()
ctx := lcli.ReqContext(cctx)
maddr, err := nodeApi.ActorAddress(ctx)
if err != nil {
return err
}
worker, err := api.StateMinerWorker(ctx, maddr, types.EmptyTSK)
if err != nil {
return err
}
params, err := actors.SerializeParams(&maddr)
if err != nil {
return err
}
workerNonce, err := api.MpoolGetNonce(ctx, worker)
if err != nil {
return err
}
2020-04-13 20:43:27 +00:00
panic("todo correct method; call miner actor")
smsg, err := api.WalletSignMessage(ctx, worker, &types.Message{
To: builtin.RewardActorAddr,
From: worker,
Nonce: workerNonce,
Value: types.NewInt(0),
GasPrice: types.NewInt(1),
2020-03-18 20:45:37 +00:00
GasLimit: 100000,
2020-04-13 20:43:27 +00:00
Method: 0,
Params: params,
})
if err != nil {
return err
}
mcid, err := api.MpoolPush(ctx, smsg)
if err != nil {
return err
}
fmt.Printf("Requested rewards withdrawal in message %s\n", mcid)
return nil
},
}