mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Review feedback
This commit is contained in:
parent
24d7201acd
commit
407128bc14
4 changed files with 15 additions and 11 deletions
|
|
@ -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
|
// 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) {
|
func (w *ledgerDriver) SignData(path accounts.DerivationPath, hash []byte) (common.Address, []byte, error) {
|
||||||
return common.Address{}, nil, accounts.ErrNotSupported
|
return common.Address{}, nil, accounts.ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,12 +185,12 @@ func (w *trezorDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
|
||||||
return w.trezorSign(path, tx, chainID)
|
return w.trezorSign(path, tx, chainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignData sends a blob of data to the xUSB device and waits for the user to confirm
|
// 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 *trezorDriver) SignData(path accounts.DerivationPath, hash []byte) (common.Address, []byte, error) {
|
func (w *trezorDriver) SignData(path accounts.DerivationPath, data []byte) (common.Address, []byte, error) {
|
||||||
request := &trezor.EthereumSignMessage{
|
request := &trezor.EthereumSignMessage{
|
||||||
AddressN: path,
|
AddressN: path,
|
||||||
Message: hash,
|
Message: data,
|
||||||
}
|
}
|
||||||
response := new(trezor.EthereumMessageSignature)
|
response := new(trezor.EthereumMessageSignature)
|
||||||
if _, err := w.trezorExchange(request, response); err != nil {
|
if _, err := w.trezorExchange(request, response); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ type driver interface {
|
||||||
SignTx(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error)
|
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
|
// 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)
|
SignData(path accounts.DerivationPath, hash []byte) (common.Address, []byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,12 +142,16 @@ func (api *SignerAPI) sign(addr common.MixedcaseAddress, req *SignDataRequest, l
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pw, err := api.lookupOrQueryPassword(account.Address,
|
// 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",
|
"Password for signing",
|
||||||
fmt.Sprintf("Please enter password for signing data with account %s, or just press 'RETURN'", account.Address.Hex()))
|
fmt.Sprintf("Please enter password for signing data with account %s", account.Address.Hex()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Sign the data with the wallet
|
// Sign the data with the wallet
|
||||||
signature, err := wallet.SignDataWithPassphrase(account, pw, req.ContentType, req.Rawdata)
|
signature, err := wallet.SignDataWithPassphrase(account, pw, req.ContentType, req.Rawdata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue