diff options
Diffstat (limited to 'internal/ethapi')
-rw-r--r-- | internal/ethapi/api.go | 35 | ||||
-rw-r--r-- | internal/ethapi/backend.go | 5 | ||||
-rw-r--r-- | internal/ethapi/tracer.go | 2 |
3 files changed, 34 insertions, 8 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 7874b7101..0775749e7 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -230,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) { @@ -612,7 +635,8 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr // Setup the gas pool (also for unmetered requests) // and apply the message. gp := new(core.GasPool).AddGas(math.MaxBig256) - res, gas, err := core.ApplyMessage(evm, msg, gp) + // TODO utilize failed flag to help gas estimation + res, gas, _, err := core.ApplyMessage(evm, msg, gp) if err := vmError(); err != nil { return nil, common.Big0, err } @@ -1241,7 +1265,6 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxAr if err != nil { return common.Hash{}, err } - s.b.RemoveTx(p.Hash()) if err = s.b.SendTx(ctx, signedTx); err != nil { return common.Hash{}, err } diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index d122b7915..368fa4872 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -53,15 +53,18 @@ type Backend interface { GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error) GetTd(blockHash common.Hash) *big.Int GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error) + SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription + SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription + SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription // TxPool API SendTx(ctx context.Context, signedTx *types.Transaction) error - RemoveTx(txHash common.Hash) GetPoolTransactions() (types.Transactions, error) GetPoolTransaction(txHash common.Hash) *types.Transaction GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) Stats() (pending int, queued int) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) + SubscribeTxPreEvent(chan<- core.TxPreEvent) event.Subscription ChainConfig() *params.ChainConfig CurrentBlock() *types.Block diff --git a/internal/ethapi/tracer.go b/internal/ethapi/tracer.go index fc66839ea..051626527 100644 --- a/internal/ethapi/tracer.go +++ b/internal/ethapi/tracer.go @@ -346,7 +346,7 @@ func (jst *JavascriptTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, } // CaptureEnd is called after the call finishes -func (jst *JavascriptTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration) error { +func (jst *JavascriptTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error { //TODO! @Arachnid please figure out of there's anything we can use this method for return nil } |