rpc

package
v0.0.4-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrpcServer

GrpcServer is the gRPC server implementation. It holds all the objects necessary to serve the RPCs and implements the ilxdrpc.proto interface.

func NewGrpcServer

func NewGrpcServer(cfg *GrpcServerConfig) *GrpcServer

NewGrpcServer returns a new GrpcServer which has not yet be started.

func (*GrpcServer) AddPeer

func (s *GrpcServer) AddPeer(ctx context.Context, req *pb.AddPeerRequest) (*pb.AddPeerResponse, error)

AddPeer attempts to connect to the provided peer

func (*GrpcServer) BlockPeer

func (s *GrpcServer) BlockPeer(ctx context.Context, req *pb.BlockPeerRequest) (*pb.BlockPeerResponse, error)

BlockPeer blocks the given peer for the provided time period

func (*GrpcServer) ChangeWalletPassphrase

ChangeWalletPassphrase changes the passphrase used to encrypt the wallet private keys

func (*GrpcServer) Close

func (s *GrpcServer) Close()

func (*GrpcServer) CreateMultiSignature

CreateMultiSignature generates and returns a signature for use when proving a multisig transaction

func (*GrpcServer) CreateMultisigAddress

CreateMultisigAddress generates a new multisig address using the provided public keys

Note this address is *not* imported. You will need to call `ImportAddress` if you want to watch it.

func (*GrpcServer) CreateMultisigSpendKeypair

CreateMultisigSpendKeypair generates a spend keypair for use in a multisig address

func (*GrpcServer) CreateMultisigViewKeypair

CreateMultisigViewKeypair generates a view keypair for use in a multisig address

func (*GrpcServer) CreateRawStakeTransaction

CreateRawStakeTransaction creates a new, unsigned (unproven) stake transaction using the given parameters

func (*GrpcServer) CreateRawTransaction

CreateRawTransaction creates a new, unsigned (unproven) transaction using the given parameters

func (*GrpcServer) DeletePrivateKeys

DeletePrivateKeys deletes the wallet's private keys and seed from disk essentially turning the wallet into a watch-only wallet. It will still record incoming transactions but cannot spend them.

**Requires wallet to be unlocked**

func (*GrpcServer) GetAccumulatorCheckpoint

GetAccumulatorCheckpoint returns the accumulator at the requested height.

func (*GrpcServer) GetAddress

GetAddress returns the most recent address of the wallet.

func (*GrpcServer) GetAddressInfo

GetAddressInfo returns additional metadata about an address.

func (*GrpcServer) GetAddresses

GetAddresses returns all the addresses create by the wallet.

func (*GrpcServer) GetBalance

GetBalance returns the combined balance of all addresses in the wallet

func (*GrpcServer) GetBlock

func (s *GrpcServer) GetBlock(ctx context.Context, req *pb.GetBlockRequest) (*pb.GetBlockResponse, error)

GetBlock returns the detailed data for a block.

func (*GrpcServer) GetBlockInfo

GetBlockInfo returns a BlockHeader plus some extra metadata.

func (*GrpcServer) GetBlockSizeSoftLimit

GetBlockSizeSoftLimit returns the node's current blocksize soft limit.

func (*GrpcServer) GetBlockchainInfo

GetBlockchainInfo returns data about the blockchain including the most recent block hash and height.

func (*GrpcServer) GetCompressedBlock

GetCompressedBlock returns a block that is stripped down to just the outputs.

func (*GrpcServer) GetCompressedBlocks

GetCompressedBlocks returns a batch of CompressedBlocks according to the request parameters.

func (*GrpcServer) GetHeaders

GetHeaders returns a batch of headers according to the request parameters.

func (*GrpcServer) GetHostInfo

GetHostInfo returns info about the libp2p host

func (*GrpcServer) GetMempool

GetMempool returns all the transactions in the mempool

func (*GrpcServer) GetMempoolInfo

GetMempoolInfo returns the state of the current mempool

func (*GrpcServer) GetMerkleProof

GetMerkleProof returns a Merkle (SPV) proof for a specific transaction in the provided block.

func (*GrpcServer) GetMinFeePerKilobyte

GetMinFeePerKilobyte returns the node's current minimum transaction fee needed to relay transactions and admit them into the mempool.

func (*GrpcServer) GetMinStake

GetMinStake returns the node's current minimum stake policy.

func (*GrpcServer) GetNetworkKey

GetNetworkKey returns the node's network private key

func (*GrpcServer) GetNewAddress

GetNewAddress generates a new address and returns it. Both a new spend key and view key will be derived from the mnemonic seed.

func (*GrpcServer) GetPeers

func (s *GrpcServer) GetPeers(ctx context.Context, req *pb.GetPeersRequest) (*pb.GetPeersResponse, error)

GetPeers returns a list of peers that this node is connected to

func (*GrpcServer) GetPrivateKey

GetPrivateKey returns the serialized spend and view keys for the given address

**Requires wallet to be unlocked**

func (*GrpcServer) GetTimelockedAddress

GetTimelockedAddress returns a timelocked address that cannot be spent from until the given timelock has passed. The private key used for this address is the same as the wallet's most recent spend key used in a basic address. This implies the key can be derived from seed, however the wallet will not detect incoming payments to this address unless the timelock is included in the utxo's state field.

func (*GrpcServer) GetTransaction

GetTransaction returns the transaction for the given transaction ID.

func (*GrpcServer) GetTransactions

GetTransactions returns the list of transactions for the wallet

func (*GrpcServer) GetTreasuryWhitelist

GetTreasuryWhitelist returns the current treasury whitelist for the node.

func (*GrpcServer) GetTxoProof

GetTxoProof returns the merkle inclusion proof for the given commitment. This information is needed by the client to create the zero knowledge proof needed to spend the transaction.

func (*GrpcServer) GetUtxos

func (s *GrpcServer) GetUtxos(ctx context.Context, req *pb.GetUtxosRequest) (*pb.GetUtxosResponse, error)

GetUtxos returns a list of the wallet's current unspent transaction outputs (UTXOs)

func (*GrpcServer) GetValidator

GetValidator returns all the information about the given validator including number of staked coins.

func (*GrpcServer) GetValidatorSet

GetValidatorSet returns all the validators in the current validator set.

func (*GrpcServer) GetValidatorSetInfo

GetValidatorSetInfo returns information about the validator set.

func (*GrpcServer) GetWalletSeed

GetWalletSeed returns the mnemonic seed for the wallet. If the wallet seed has been deleted via the `DeletePrivateKeys` RPC an error will be returned.

**Requires wallet to be unlocked**

func (*GrpcServer) GetWalletTransactions

GetWalletTransactions returns a list of transactions for the provided view key.

func (*GrpcServer) ImportAddress

ImportAddress imports a watch address into the wallet.

func (*GrpcServer) ProveMultisig

ProveMultisig creates a proof for a transaction with a multisig input

func (*GrpcServer) ProveRawTransaction

ProveRawTransaction creates the zk-proof for the transaction. Assuming there are no errors, this transaction should be ready for broadcast.

func (*GrpcServer) RecomputeChainState

RecomputeChainState deletes the accumulator, validator set, and nullifier set and rebuilds them by loading and re-processing all blocks from genesis.

func (*GrpcServer) ReconsiderBlock

ReconsiderBlock tries to reprocess the given block

func (*GrpcServer) RegisterViewKey

RegisterViewKey registers a new view key with the server. The server will use this key when attempting to decrypt each output. If outputs decrypt, they will be indexed so the client can fetch them later.

To free up resources keys will automatically unregister if the wallet has not connected in some time.

func (*GrpcServer) SetAutoStakeRewards

SetAutoStakeRewards make it such that any validator rewards that are earned are automatically staked

**Requires wallet to be unlocked**

func (*GrpcServer) SetBlockSizeSoftLimit

SetBlockSizeSoftLimit sets the node's blocksize soft limit policy.

func (*GrpcServer) SetLogLevel

SetLogLevel changes the logging level of the node

func (*GrpcServer) SetMinFeePerKilobyte

SetMinFeePerKilobyte sets the node's fee policy

func (*GrpcServer) SetMinStake

SetMinStake sets the node's minimum stake policy

func (*GrpcServer) SetWalletPassphrase

SetWalletPassphrase encrypts the wallet for the first time

func (*GrpcServer) Spend

func (s *GrpcServer) Spend(ctx context.Context, req *pb.SpendRequest) (*pb.SpendResponse, error)

Spend sends coins from the wallet according to the provided parameters

**Requires wallet to be unlocked**

func (*GrpcServer) Stake

func (s *GrpcServer) Stake(ctx context.Context, req *pb.StakeRequest) (*pb.StakeResponse, error)

Stake stakes the selected wallet UTXOs and turns the node into a validator

**Requires wallet to be unlocked**

func (*GrpcServer) SubmitTransaction

SubmitTransaction validates a transaction and submits it to the network. An error will be returned if it fails validation.

func (*GrpcServer) SubscribeBlocks

SubscribeBlocks returns a stream of notifications when new blocks are finalized and connected to the chain.

func (*GrpcServer) SubscribeCompressedBlocks

SubscribeCompressedBlocks returns a stream of CompressedBlock notifications when new blocks are finalized and connected to the chain.

func (*GrpcServer) SubscribeTransactions

SubscribeTransactions subscribes to a stream of TransactionsNotifications that match to the provided view key.

func (*GrpcServer) SweepWallet

SweepWallet sweeps all the coins from this wallet to the provided address. This RPC is provided so that you don't have to try to guess the correct fee to take the wallet's balance down to zero. Here the fee will be subtracted from the total funds.

**Requires wallet to be unlocked**

func (*GrpcServer) TimelockCoins

TimelockCoins moves coins into a timelocked address using the requested timelock. The internal wallet will be able to spend the coins after the timelock expires and the transaction will be recoverable if the wallet is restored from seed.

This RPC primarily exists to lock coins for staking purposes.

**Requires wallet to be unlocked**

func (*GrpcServer) UnblockPeer

UnblockPeer removes a peer from the block list

func (*GrpcServer) UpdateTreasuryWhitelist

UpdateTreasuryWhitelist adds or removes a transaction to from the treasury whitelist

func (*GrpcServer) WalletLock

WalletLock encrypts the wallet's private keys

func (*GrpcServer) WalletUnlock

WalletUnlock decrypts the wallet seed and holds it in memory for the specified period of time

type GrpcServerConfig

type GrpcServerConfig struct {
	Server     *grpc.Server
	HTTPServer *http.Server

	Chain                *blockchain.Blockchain
	Network              *net.Network
	Wallet               *walletlib.Wallet
	Policy               *policy.Policy
	BroadcastTxFunc      func(tx *transactions.Transaction) error
	SetLogLevelFunc      func(level zapcore.Level)
	ReindexChainFunc     func() error
	RequestBlockFunc     func(blockID types.ID, remotePeer peer.ID)
	AutoStakeFunc        func(bool) error
	NetworkKeyFunc       func() (crypto.PrivKey, error)
	ChainParams          *params.NetworkParams
	Ds                   repo.Datastore
	TxMemPool            *mempool.Mempool
	DisableNodeService   bool
	DisableWalletService bool
	DisableWalletServer  bool

	TxIndex *indexers.TxIndex
	WSIndex *indexers.WalletServerIndex
}

GrpcServerConfig hols the various objects needed by the GrpcServer to perform its functions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL