2020-09-05 19:36:32 +00:00
|
|
|
package api
|
2020-09-04 20:17:28 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-address"
|
2020-10-08 22:51:04 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/crypto"
|
|
|
|
|
2020-09-04 20:17:28 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
2020-10-08 23:27:38 +00:00
|
|
|
type MsgType string
|
|
|
|
const (
|
|
|
|
MTUnknown = "unknown"
|
|
|
|
|
|
|
|
// Signing message CID. MsgMeta.Extra contains raw cbor message bytes
|
|
|
|
MTChainMsg = "message"
|
|
|
|
|
|
|
|
// Signing a blockheader. signing raw cbor block bytes (MsgMeta.Extra is empty)
|
|
|
|
MTBlock = "block"
|
|
|
|
|
|
|
|
// Signing a deal proposal. signing raw cbor proposal bytes (MsgMeta.Extra is empty)
|
|
|
|
MTDealProposal = "dealproposal"
|
|
|
|
|
|
|
|
// TODO: Deals, Vouchers, VRF
|
|
|
|
)
|
|
|
|
|
|
|
|
type MsgMeta struct {
|
|
|
|
Type MsgType
|
|
|
|
|
|
|
|
// Additional data related to what is signed. Should be verifiable with the
|
|
|
|
// signed bytes (e.g. CID(Extra).Bytes() == toSign)
|
|
|
|
Extra []byte
|
|
|
|
}
|
|
|
|
|
2020-09-05 19:36:32 +00:00
|
|
|
type WalletAPI interface {
|
2020-09-04 20:17:28 +00:00
|
|
|
WalletNew(context.Context, crypto.SigType) (address.Address, error)
|
|
|
|
WalletHas(context.Context, address.Address) (bool, error)
|
|
|
|
WalletList(context.Context) ([]address.Address, error)
|
2020-10-08 23:04:59 +00:00
|
|
|
|
2020-10-08 23:27:38 +00:00
|
|
|
WalletSign(ctx context.Context, signer address.Address, toSign []byte, meta MsgMeta) (*crypto.Signature, error)
|
2020-10-08 23:04:59 +00:00
|
|
|
|
2020-09-04 20:17:28 +00:00
|
|
|
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
|
|
|
|
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
|
|
|
|
WalletDelete(context.Context, address.Address) error
|
|
|
|
}
|