From 407128bc145fd59d69b1aebc51e6c1d635ea799b Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Wed, 17 Jul 2019 15:41:51 +0200 Subject: [PATCH] Review feedback --- accounts/usbwallet/ledger.go | 2 +- accounts/usbwallet/trezor.go | 8 ++++---- accounts/usbwallet/wallet.go | 2 +- signer/core/signed_data.go | 14 +++++++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go index 15c1d7b8d3..ef713da0cb 100644 --- a/accounts/usbwallet/ledger.go +++ b/accounts/usbwallet/ledger.go @@ -169,7 +169,7 @@ func (w *ledgerDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio } // SignData sends a blob of data to the USB device and waits for the user to confirm -// or deny the transaction. +// or deny the signing request. func (w *ledgerDriver) SignData(path accounts.DerivationPath, hash []byte) (common.Address, []byte, error) { return common.Address{}, nil, accounts.ErrNotSupported } diff --git a/accounts/usbwallet/trezor.go b/accounts/usbwallet/trezor.go index a1edb250d3..ce7ff19d01 100644 --- a/accounts/usbwallet/trezor.go +++ b/accounts/usbwallet/trezor.go @@ -185,12 +185,12 @@ func (w *trezorDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio return w.trezorSign(path, tx, chainID) } -// SignData sends a blob of data to the xUSB device and waits for the user to confirm -// or deny the transaction. -func (w *trezorDriver) SignData(path accounts.DerivationPath, hash []byte) (common.Address, []byte, error) { +// SignData sends a blob of data to the USB device and waits for the user to confirm +// or deny the signing request. +func (w *trezorDriver) SignData(path accounts.DerivationPath, data []byte) (common.Address, []byte, error) { request := &trezor.EthereumSignMessage{ AddressN: path, - Message: hash, + Message: data, } response := new(trezor.EthereumMessageSignature) if _, err := w.trezorExchange(request, response); err != nil { diff --git a/accounts/usbwallet/wallet.go b/accounts/usbwallet/wallet.go index 6622836896..0a77c81fcb 100644 --- a/accounts/usbwallet/wallet.go +++ b/accounts/usbwallet/wallet.go @@ -69,7 +69,7 @@ type driver interface { SignTx(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error) // SignData sends a blob of data to the USB device and waits for the user to confirm - // or deny the transaction. + // or deny the signing request. SignData(path accounts.DerivationPath, hash []byte) (common.Address, []byte, error) } diff --git a/signer/core/signed_data.go b/signer/core/signed_data.go index e7056c1e27..926ae037ac 100644 --- a/signer/core/signed_data.go +++ b/signer/core/signed_data.go @@ -142,11 +142,15 @@ func (api *SignerAPI) sign(addr common.MixedcaseAddress, req *SignDataRequest, l if err != nil { return nil, err } - pw, err := api.lookupOrQueryPassword(account.Address, - "Password for signing", - fmt.Sprintf("Please enter password for signing data with account %s, or just press 'RETURN'", account.Address.Hex())) - if err != nil { - return nil, err + // Only ask for the passphrase if the account is keystore based + pw := "" + if strings.Compare(wallet.URL().Scheme, "keystore") == 0 { + pw, err = api.lookupOrQueryPassword(account.Address, + "Password for signing", + fmt.Sprintf("Please enter password for signing data with account %s", account.Address.Hex())) + if err != nil { + return nil, err + } } // Sign the data with the wallet signature, err := wallet.SignDataWithPassphrase(account, pw, req.ContentType, req.Rawdata)