diff --git a/api/api_wallet.go b/api/api_wallet.go index 9c289ca95..b3dbd5fa9 100644 --- a/api/api_wallet.go +++ b/api/api_wallet.go @@ -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 diff --git a/chain/wallet/wallet.go b/chain/wallet/wallet.go index 5f501307f..607380547 100644 --- a/chain/wallet/wallet.go +++ b/chain/wallet/wallet.go @@ -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() diff --git a/cmd/lotus-wallet/logged.go b/cmd/lotus-wallet/logged.go index 4cdd62825..adafb7cc5 100644 --- a/cmd/lotus-wallet/logged.go +++ b/cmd/lotus-wallet/logged.go @@ -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) diff --git a/node/impl/full/wallet.go b/node/impl/full/wallet.go index 6252e12a4..13880a03a 100644 --- a/node/impl/full/wallet.go +++ b/node/impl/full/wallet.go @@ -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) {