Documentation ¶
Index ¶
- Constants
- Variables
- func IsSensitiveMethod(method string) bool
- type Client
- type EncRPCClient
- func (c *EncRPCClient) Account() *gethcommon.Address
- func (c *EncRPCClient) Call(result interface{}, method string, args ...interface{}) error
- func (c *EncRPCClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (c *EncRPCClient) Stop()
- func (c *EncRPCClient) Subscribe(ctx context.Context, _ interface{}, namespace string, ch interface{}, ...) (*rpc.ClientSubscription, error)
Constants ¶
const ( BatchNumber = "eth_blockNumber" Call = "eth_call" ChainID = "eth_chainId" GetBalance = "eth_getBalance" GetBatchByHash = "eth_getBlockByHash" GetBatchByNumber = "eth_getBlockByNumber" GetCode = "eth_getCode" GetTransactionByHash = "eth_getTransactionByHash" GetTransactionCount = "eth_getTransactionCount" GetTransactionReceipt = "eth_getTransactionReceipt" SendRawTransaction = "eth_sendRawTransaction" EstimateGas = "eth_estimateGas" GetLogs = "eth_getLogs" GetStorageAt = "eth_getStorageAt" Health = "obscuro_health" Config = "obscuro_config" GetBlockHeaderByHash = "obscuroscan_getBlockHeaderByHash" GetBatch = "obscuroscan_getBatch" GetBatchForTx = "obscuroscan_getBatchForTx" GetLatestTxs = "obscuroscan_getLatestTransactions" GetTotalTxs = "obscuroscan_getTotalTransactions" Attestation = "obscuroscan_attestation" StopHost = "test_stopHost" Subscribe = "eth_subscribe" Unsubscribe = "eth_unsubscribe" SubscribeNamespace = "eth" SubscriptionTypeLogs = "logs" GetLatestRollupHeader = "scan_getLatestRollupHeader" GetTotalTransactionCount = "scan_getTotalTransactionCount" GetTotalContractCount = "scan_getTotalContractCount" GetPublicTransactionData = "scan_getPublicTransactionData" GetBatchListing = "scan_getBatchListing" GetBlockListing = "scan_getBlockListing" GetFullBatchByHash = "scan_getBatchByHash" )
Variables ¶
var ErrNilResponse = errors.New("nil response received from Obscuro node")
var SensitiveMethods = []string{ Call, GetBalance, GetTransactionByHash, GetTransactionCount, GetTransactionReceipt, SendRawTransaction, EstimateGas, GetLogs, GetStorageAt, }
SensitiveMethods for which the RPC requests and responses should be encrypted
Functions ¶
func IsSensitiveMethod ¶
IsSensitiveMethod indicates whether the RPC method's requests and responses should be encrypted.
Types ¶
type Client ¶
type Client interface { // Call executes the named method via RPC. (Returns `ErrNilResponse` on nil response from Node, this is used as "not found" for some method calls) Call(result interface{}, method string, args ...interface{}) error // CallContext If the context is canceled before the call has successfully returned, CallContext returns immediately. CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error // Subscribe creates a subscription to the Obscuro host. Subscribe(ctx context.Context, result interface{}, namespace string, channel interface{}, args ...interface{}) (*rpc.ClientSubscription, error) // Stop closes the client. Stop() }
Client is used by client applications to interact with the Obscuro node
func NewNetworkClient ¶
NewNetworkClient returns a client that can make RPC calls to an Obscuro node
type EncRPCClient ¶
type EncRPCClient struct {
// contains filtered or unexported fields
}
EncRPCClient is a Client wrapper that implements Client but also has extra functionality for managing viewing key registration and decryption
func NewEncNetworkClient ¶
func NewEncNetworkClient(rpcAddress string, viewingKey *viewingkey.ViewingKey, logger gethlog.Logger) (*EncRPCClient, error)
NewEncNetworkClient returns a network RPC client with Viewing Key encryption/decryption
func NewEncRPCClient ¶
func NewEncRPCClient(client Client, viewingKey *viewingkey.ViewingKey, logger gethlog.Logger) (*EncRPCClient, error)
NewEncRPCClient sets up a client with a viewing key for encrypted communication
func (*EncRPCClient) Account ¶
func (c *EncRPCClient) Account() *gethcommon.Address
func (*EncRPCClient) Call ¶
func (c *EncRPCClient) Call(result interface{}, method string, args ...interface{}) error
Call handles JSON rpc requests without a context - see CallContext for details
func (*EncRPCClient) CallContext ¶
func (c *EncRPCClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
CallContext is the main logic to execute JSON-RPC requests, the context can be nil. - if the method is sensitive it will encrypt the args before sending the request and then decrypts the response before returning - result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored. - callExec handles the delegated call, allows EncClient to use the same code for calling with or without a context
func (*EncRPCClient) Stop ¶
func (c *EncRPCClient) Stop()
func (*EncRPCClient) Subscribe ¶
func (c *EncRPCClient) Subscribe(ctx context.Context, _ interface{}, namespace string, ch interface{}, args ...interface{}) (*rpc.ClientSubscription, error)