aboutsummaryrefslogtreecommitdiffstats
path: root/dex/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'dex/api.go')
-rw-r--r--dex/api.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/dex/api.go b/dex/api.go
index 1209e6583..7ca1a4622 100644
--- a/dex/api.go
+++ b/dex/api.go
@@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"io"
+ "math/big"
"os"
"strings"
@@ -38,6 +39,36 @@ import (
"github.com/tangerine-network/go-tangerine/trie"
)
+// PublicEthereumAPI provides an API to access Ethereum full node-related
+// information.
+type PublicEthereumAPI struct {
+ dex *Tangerine
+}
+
+// NewPublicEthereumAPI creates a new Ethereum protocol API for full nodes.
+func NewPublicEthereumAPI(e *Tangerine) *PublicEthereumAPI {
+ return &PublicEthereumAPI{e}
+}
+
+// Etherbase is the address that mining rewards will be send to
+func (api *PublicEthereumAPI) Etherbase() (common.Address, error) {
+ return api.dex.Etherbase(), nil
+}
+
+// Coinbase is the address that mining rewards will be send to (alias for Etherbase)
+func (api *PublicEthereumAPI) Coinbase() (common.Address, error) {
+ return api.dex.Etherbase(), nil
+}
+
+// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
+func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 {
+ chainID := new(big.Int)
+ if config := api.dex.chainConfig; config.IsEIP155(api.dex.blockchain.CurrentBlock().Number()) {
+ chainID = config.ChainID
+ }
+ return (hexutil.Uint64)(chainID.Uint64())
+}
+
// PrivateAdminAPI is the collection of Ethereum full node-related APIs
// exposed over the private admin endpoint.
type PrivateAdminAPI struct {