wallet: Drop WalletSignMessage from WalletAPI

This commit is contained in:
Łukasz Magiera 2020-10-09 01:04:59 +02:00
parent 4835109470
commit 114776f2c5
4 changed files with 15 additions and 24 deletions

View File

@ -13,9 +13,9 @@ type WalletAPI interface {
WalletNew(context.Context, crypto.SigType) (address.Address, error)
WalletHas(context.Context, address.Address) (bool, error)
WalletList(context.Context) ([]address.Address, error)
WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
// nonce keeping done by wallet app
WalletSignMessage(context.Context, address.Address, *types.Message) (*types.SignedMessage, error)
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
WalletDelete(context.Context, address.Address) error

View File

@ -74,20 +74,6 @@ func (w *LocalWallet) WalletSign(ctx context.Context, addr address.Address, msg
return sigs.Sign(ActSigType(ki.Type), ki.PrivateKey, msg)
}
func (w *LocalWallet) WalletSignMessage(ctx context.Context, k address.Address, msg *types.Message) (*types.SignedMessage, error) {
mcid := msg.Cid()
sig, err := w.WalletSign(ctx, k, mcid.Bytes())
if err != nil {
return nil, xerrors.Errorf("failed to sign message: %w", err)
}
return &types.SignedMessage{
Message: *msg,
Signature: *sig,
}, nil
}
func (w *LocalWallet) findKey(addr address.Address) (*Key, error) {
w.lk.Lock()
defer w.lk.Unlock()

View File

@ -43,12 +43,6 @@ func (c *LoggedWallet) WalletSign(ctx context.Context, k address.Address, msg []
return c.under.WalletSign(ctx, k, msg)
}
func (c *LoggedWallet) WalletSignMessage(ctx context.Context, k address.Address, msg *types.Message) (*types.SignedMessage, error) {
log.Infow("WalletSignMessage", "address", k)
return c.under.WalletSignMessage(ctx, k, msg)
}
func (c *LoggedWallet) WalletExport(ctx context.Context, a address.Address) (*types.KeyInfo, error) {
log.Infow("WalletExport", "address", a)

View File

@ -3,10 +3,10 @@ package full
import (
"context"
"github.com/filecoin-project/go-address"
"go.uber.org/fx"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
@ -48,7 +48,18 @@ func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, ms
if err != nil {
return nil, xerrors.Errorf("failed to resolve ID address: %w", keyAddr)
}
return a.WalletAPI.WalletSignMessage(ctx, keyAddr, msg)
mcid := msg.Cid()
sig, err := a.WalletAPI.WalletSign(ctx, k, mcid.Bytes())
if err != nil {
return nil, xerrors.Errorf("failed to sign message: %w", err)
}
return &types.SignedMessage{
Message: *msg,
Signature: *sig,
}, nil
}
func (a *WalletAPI) WalletVerify(ctx context.Context, k address.Address, msg []byte, sig *crypto.Signature) (bool, error) {