aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ethapi/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ethapi/api.go')
-rw-r--r--internal/ethapi/api.go60
1 files changed, 30 insertions, 30 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 1b23ac559..c3924b93a 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -46,7 +46,6 @@ import (
const (
defaultGas = 90000
defaultGasPrice = 50 * params.Shannon
- emptyHex = "0x"
)
// PublicEthereumAPI provides an API to access Ethereum related information.
@@ -231,22 +230,45 @@ func (s *PrivateAccountAPI) ListAccounts() []common.Address {
type rawWallet struct {
URL string `json:"url"`
Status string `json:"status"`
- Accounts []accounts.Account `json:"accounts"`
+ Failure string `json:"failure,omitempty"`
+ Accounts []accounts.Account `json:"accounts,omitempty"`
}
// ListWallets will return a list of wallets this node manages.
func (s *PrivateAccountAPI) ListWallets() []rawWallet {
wallets := make([]rawWallet, 0) // return [] instead of nil if empty
for _, wallet := range s.am.Wallets() {
- wallets = append(wallets, rawWallet{
+ status, failure := wallet.Status()
+
+ raw := rawWallet{
URL: wallet.URL().String(),
- Status: wallet.Status(),
+ Status: status,
Accounts: wallet.Accounts(),
- })
+ }
+ if failure != nil {
+ raw.Failure = failure.Error()
+ }
+ wallets = append(wallets, raw)
}
return wallets
}
+// OpenWallet initiates a hardware wallet opening procedure, establishing a USB
+// connection and attempting to authenticate via the provided passphrase. Note,
+// the method may return an extra challenge requiring a second open (e.g. the
+// Trezor PIN matrix challenge).
+func (s *PrivateAccountAPI) OpenWallet(url string, passphrase *string) error {
+ wallet, err := s.am.Wallet(url)
+ if err != nil {
+ return err
+ }
+ pass := ""
+ if passphrase != nil {
+ pass = *passphrase
+ }
+ return wallet.Open(pass)
+}
+
// DeriveAccount requests a HD wallet to derive a new account, optionally pinning
// it for later reuse.
func (s *PrivateAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error) {
@@ -548,26 +570,6 @@ func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.A
return res[:], state.Error()
}
-// callmsg is the message type used for call transitions.
-type callmsg struct {
- addr common.Address
- to *common.Address
- gas, gasPrice *big.Int
- value *big.Int
- data []byte
-}
-
-// accessor boilerplate to implement core.Message
-func (m callmsg) From() (common.Address, error) { return m.addr, nil }
-func (m callmsg) FromFrontier() (common.Address, error) { return m.addr, nil }
-func (m callmsg) Nonce() uint64 { return 0 }
-func (m callmsg) CheckNonce() bool { return false }
-func (m callmsg) To() *common.Address { return m.to }
-func (m callmsg) GasPrice() *big.Int { return m.gasPrice }
-func (m callmsg) Gas() *big.Int { return m.gas }
-func (m callmsg) Value() *big.Int { return m.value }
-func (m callmsg) Data() []byte { return m.data }
-
// CallArgs represents the arguments for a call.
type CallArgs struct {
From common.Address `json:"from"`
@@ -626,10 +628,8 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
// Wait for the context to be done and cancel the evm. Even if the
// EVM has finished, cancelling may be done (repeatedly)
go func() {
- select {
- case <-ctx.Done():
- evm.Cancel()
- }
+ <-ctx.Done()
+ evm.Cancel()
}()
// Setup the gas pool (also for unmetered requests)
@@ -1306,7 +1306,7 @@ func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (strin
if block == nil {
return "", fmt.Errorf("block #%d not found", number)
}
- return fmt.Sprintf("%s", block), nil
+ return block.String(), nil
}
// SeedHash retrieves the seed hash of a block.