Documentation
¶
Index ¶
- Constants
- Variables
- func IsSensitiveMethod(method string) bool
- type Client
- type EncRPCClient
- func NewEncNetworkClient(rpcAddress string, viewingKey *viewingkey.ViewingKey, logger gethlog.Logger) (*EncRPCClient, error)
- func NewEncNetworkClientFromConn(connection *gethrpc.Client, viewingKey *viewingkey.ViewingKey, ...) (*EncRPCClient, error)
- func NewEncRPCClient(client Client, viewingKey *viewingkey.ViewingKey, logger gethlog.Logger) (*EncRPCClient, error)
- func (c *EncRPCClient) Account() *gethcommon.Address
- func (c *EncRPCClient) BackingClient() Client
- 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, namespace string, ch interface{}, args ...interface{}) (*gethrpc.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" GasPrice = "eth_gasPrice" Health = "obscuro_health" Config = "obscuro_config" StopHost = "test_stopHost" SubscribeNamespace = "eth" SubscriptionTypeLogs = "logs" SubscriptionTypeNewHeads = "newHeads" GetBatchByTx = "scan_getBatchByTx" GetLatestRollupHeader = "scan_getLatestRollupHeader" GetTotalTxCount = "scan_getTotalTransactionCount" GetTotalTxsQuery = "scan_getTotalTransactionsQuery" GetTotalContractCount = "scan_getTotalContractCount" GetPublicTransactionData = "scan_getPublicTransactionData" GetBatchListing = "scan_getBatchListing" GetBlockListing = "scan_getBlockListing" GetBatch = "scan_getBatch" GetLatestBatch = "scan_getLatestBatch" GetBatchByHeight = "scan_getBatchByHeight" GetTransaction = "scan_getTransaction" GetRollupListing = "scan_getRollupListing" GetBatchListingNew = "scan_getBatchListingNew" GetRollupByHash = "scan_getRollupByHash" GetRollupBatches = "scan_getRollupBatches" GetRollupBySeqNo = "scan_getRollupBySeqNo" GetBatchTransactions = "scan_getBatchTransactions" )
Variables ¶
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. 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, namespace string, channel interface{}, args ...interface{}) (*rpc.ClientSubscription, error) // Stop closes the client. Stop() }
Client is used by client applications to interact with the Ten 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 NewEncNetworkClientFromConn ¶ added in v0.24.0
func NewEncNetworkClientFromConn(connection *gethrpc.Client, viewingKey *viewingkey.ViewingKey, logger gethlog.Logger) (*EncRPCClient, error)
func NewEncRPCClient ¶
func NewEncRPCClient(client Client, viewingKey *viewingkey.ViewingKey, logger gethlog.Logger) (*EncRPCClient, error)
NewEncRPCClient wrapper over rpc clients with a viewing key for encrypted communication
func (*EncRPCClient) Account ¶
func (c *EncRPCClient) Account() *gethcommon.Address
func (*EncRPCClient) BackingClient ¶ added in v0.24.0
func (c *EncRPCClient) BackingClient() Client
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, namespace string, ch interface{}, args ...interface{}) (*gethrpc.ClientSubscription, error)