Categorygithub.com/ross-weir/go-ergo-rest
modulepackage
0.0.1
Repository: https://github.com/ross-weir/go-ergo-rest.git
Documentation: pkg.go.dev

# README

Go API client for ergo_rest

API docs for Ergo Node. Models are shared between all Ergo products

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 4.0.23
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://ergoplatform.org

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
go get github.com/antihax/optional

Put the package under your project folder and add the following in import:

import "./ergo_rest"

Documentation for API Endpoints

All URIs are relative to http://127.0.0.1:9053

ClassMethodHTTP requestDescription
BlocksApiGetBlockHeaderByIdGet /blocks/{headerId}/headerGet the block header info by a given signature
BlocksApiGetBlockTransactionsByIdGet /blocks/{headerId}/transactionsGet the block transactions info by a given signature
BlocksApiGetChainSliceGet /blocks/chainSliceGet headers in a specified range
BlocksApiGetFullBlockAtGet /blocks/at/{blockHeight}Get the header ids at a given height
BlocksApiGetFullBlockByIdGet /blocks/{headerId}Get the full block info by a given signature
BlocksApiGetHeaderIdsGet /blocksGet the Array of header ids
BlocksApiGetLastHeadersGet /blocks/lastHeaders/{count}Get the last headers objects
BlocksApiGetModifierByIdGet /blocks/modifier/{modifierId}Get the persistent modifier by its id
BlocksApiGetProofForTxGet /blocks/{headerId}/proofFor/{txId}Get Merkle proof for transaction
BlocksApiSendMinedBlockPost /blocksSend a mined block
InfoApiGetNodeInfoGet /infoGet the information about the Node
MiningApiMiningReadMinerRewardAddressGet /mining/rewardAddressRead miner reward address
MiningApiMiningReadMinerRewardPubkeyGet /mining/rewardPublicKeyRead public key associated with miner rewards
MiningApiMiningRequestBlockCandidateGet /mining/candidateRequest block candidate
MiningApiMiningRequestBlockCandidateWithMandatoryTransactionsPost /mining/candidateWithTxsRequest block candidate
MiningApiMiningSubmitSolutionPost /mining/solutionSubmit solution for current candidate
NipopowApiGetPopowHeaderByHeightGet /nipopow/popowHeaderByHeight/{height}Construct PoPow header for best header at given height
NipopowApiGetPopowHeaderByIdGet /nipopow/popowHeaderById/{headerId}Construct PoPow header according to given header id
NipopowApiGetPopowProofGet /nipopow/proof/{minChainLength}/{suffixLength}Construct PoPoW proof for given min superchain length and suffix length
NipopowApiGetPopowProofByHeaderIdGet /nipopow/proof/{minChainLength}/{suffixLength}/{headerId}Construct PoPoW proof for given min superchain length, suffix length and header ID
NodeApiNodeShutdownPost /node/shutdownShuts down the node
PeersApiConnectToPeerPost /peers/connectAdd address to peers list
PeersApiGetAllPeersGet /peers/allGet all known peers
PeersApiGetBlacklistedPeersGet /peers/blacklistedGet blacklisted peers
PeersApiGetConnectedPeersGet /peers/connectedGet current connected peers
PeersApiGetPeersStatusGet /peers/statusGet last incoming message timestamp and current network time
PeersApiGetPeersSyncInfoGet /peers/syncInfoGet sync info reported by peers, including versions, current status and height (if available)
PeersApiGetPeersTrackInfoGet /peers/trackInfoGet track info reported by peers, including count of invalid modifiers and details of requested and received modifiers
ScanApiAddBoxPost /scan/addBoxAdds a box to scans, writes box to database if it is not there. You can use scan number 10 to add a box to the wallet.
ScanApiDeregisterScanPost /scan/deregisterStop tracking and deregister scan
ScanApiListAllScansGet /scan/listAllList all the registered scans
ScanApiListUnspentScansGet /scan/unspentBoxes/{scanId}List boxes which are not spent.
ScanApiRegisterScanPost /scan/registerRegister a scan
ScanApiScanStopTrackingPost /scan/stopTrackingStop scan-related box tracking
ScriptApiAddressToBytesGet /script/addressToBytes/{address}Convert an address to hex-encoded Sigma byte array constant which contains script bytes
ScriptApiAddressToTreeGet /script/addressToTree/{address}Convert an address to hex-encoded serialized ErgoTree (script)
ScriptApiExecuteWithContextPost /script/executeWithContextExecute script with context
ScriptApiScriptP2SAddressPost /script/p2sAddressCreate P2SAddress from Sigma source
ScriptApiScriptP2SHAddressPost /script/p2shAddressCreate P2SHAddress from Sigma source
TransactionsApiCheckTransactionPost /transactions/checkChecks an Ergo transaction without sending it over the network. Checks that transaction is valid and its inputs are in the UTXO set. Returns transaction identifier if the transaction is passing the checks.
TransactionsApiGetExpectedWaitTimeGet /transactions/waitTimeGet expected wait time for the transaction with specified fee and size
TransactionsApiGetFeeHistogramGet /transactions/poolHistogramGet histogram (waittime, (n_trans, sum(fee)) for transactions in mempool. It contains "bins"+1 bins, where i-th elements corresponds to transaction with wait time [i*maxtime/bins, (i+1)*maxtime/bins), and last bin corresponds to the transactions with wait time >= maxtime.
TransactionsApiGetRecommendedFeeGet /transactions/getFeeGet recommended fee (in nanoErgs) for a transaction with specified size (in bytes) to be proceeded in specified time (in minutes)
TransactionsApiGetUnconfirmedTransactionsGet /transactions/unconfirmedGet current pool of the unconfirmed transactions pool
TransactionsApiSendTransactionPost /transactionsSubmit an Ergo transaction to unconfirmed pool to send it over the network
UtilsApiAddressToRawGet /utils/addressToRaw/{address}Convert Pay-To-Public-Key Address to raw representation (hex-encoded serialized curve point)
UtilsApiCheckAddressValidityGet /utils/address/{address}Check address validity
UtilsApiErgoTreeToAddressGet /utils/ergoTreeToAddress/{ergoTreeHex}Generate Ergo address from hex-encoded ErgoTree
UtilsApiGetRandomSeedGet /utils/seedGet random seed of 32 bytes
UtilsApiGetRandomSeedWithLengthGet /utils/seed/{length}Generate random seed of specified length in bytes
UtilsApiHashBlake2bPost /utils/hash/blake2bReturn Blake2b hash of specified message
UtilsApiRawToAddressGet /utils/rawToAddress/{pubkeyHex}Generate Pay-To-Public-Key address from hex-encoded raw pubkey (secp256k1 serialized point)
UtxoApiGenesisBoxesGet /utxo/genesisGet genesis boxes (boxes existed before the very first block)
UtxoApiGetBoxByIdGet /utxo/byId/{boxId}Get box contents for a box by a unique identifier.
UtxoApiGetBoxByIdBinaryGet /utxo/byIdBinary/{boxId}Get serialized box from UTXO pool in Base16 encoding by an identifier.
UtxoApiGetBoxWithPoolByIdGet /utxo/withPool/byId/{boxId}Get box contents for a box by a unique identifier, from UTXO set and also the mempool.
UtxoApiGetBoxWithPoolByIdBinaryGet /utxo/withPool/byIdBinary/{boxId}Get serialized box in Base16 encoding by an identifier, considering also the mempool.
UtxoApiGetBoxesBinaryProofPost /utxo/getBoxesBinaryProofGet serialized batch proof for given set of boxes
WalletApiAddBoxPost /scan/addBoxAdds a box to scans, writes box to database if it is not there. You can use scan number 10 to add a box to the wallet.
WalletApiCheckSeedPost /wallet/checkCheck whether mnemonic phrase is corresponding to the wallet seed
WalletApiExtractHintsPost /wallet/extractHintsExtract hints from a transaction
WalletApiGenerateCommitmentsPost /wallet/generateCommitmentsGenerate signature commitments for inputs of an unsigned transaction
WalletApiGetWalletStatusGet /wallet/statusGet wallet status
WalletApiWalletAddressesGet /wallet/addressesGet wallet addresses
WalletApiWalletBalancesGet /wallet/balancesGet total amount of confirmed Ergo tokens and assets
WalletApiWalletBalancesUnconfirmedGet /wallet/balances/withUnconfirmedGet summary amount of confirmed plus unconfirmed Ergo tokens and assets
WalletApiWalletBoxesGet /wallet/boxesGet a list of all wallet-related boxes, both spent and unspent. Set minConfirmations to -1 to get mempool boxes included.
WalletApiWalletBoxesCollectPost /wallet/boxes/collectGet a list of collected boxes.
WalletApiWalletDeriveKeyPost /wallet/deriveKeyDerive new key according to a provided path
WalletApiWalletDeriveNextKeyGet /wallet/deriveNextKeyDerive next key
WalletApiWalletGetTransactionGet /wallet/transactionByIdGet wallet-related transaction by id
WalletApiWalletInitPost /wallet/initInitialize new wallet with randomly generated seed
WalletApiWalletLockGet /wallet/lockLock wallet
WalletApiWalletPaymentTransactionGenerateAndSendPost /wallet/payment/sendGenerate and send payment transaction (default fee of 0.001 Erg is used)
WalletApiWalletRescanGet /wallet/rescanRescan wallet (all the available full blocks)
WalletApiWalletRestorePost /wallet/restoreCreate new wallet from existing mnemonic seed
WalletApiWalletTransactionGeneratePost /wallet/transaction/generateGenerate arbitrary transaction from array of requests.
WalletApiWalletTransactionGenerateAndSendPost /wallet/transaction/sendGenerate and send arbitrary transaction
WalletApiWalletTransactionSignPost /wallet/transaction/signSign arbitrary unsigned transaction with wallet secrets and also secrets provided.
WalletApiWalletTransactionsGet /wallet/transactionsGet a list of all wallet-related transactions
WalletApiWalletTransactionsByScanIdGet /wallet/transactionsByScanId/{scanId}Get scan-related transactions by scan id
WalletApiWalletUnlockPost /wallet/unlockUnlock wallet
WalletApiWalletUnsignedTransactionGeneratePost /wallet/transaction/generateUnsignedGenerate unsigned transaction from array of requests.
WalletApiWalletUnspentBoxesGet /wallet/boxes/unspentGet a list of unspent boxes. Set minConfirmations to -1 to have mempool boxes considered.
WalletApiWalletUpdateChangeAddressPost /wallet/updateChangeAddressUpdate address to be used to send change to

Documentation For Models

Documentation For Authorization

ApiKeyAuth

  • Type: API key

Example

auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
    Key: "APIKEY",
    Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)

Author

[email protected]

# Functions

CacheExpires helper function to determine remaining time before repeating a request.
NewAPIClient creates a new API client.
NewAPIResponse returns a new APIResonse object.
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
NewConfiguration returns a new Configuration object.

# Variables

ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAPIKey takes an APIKey as authentication for the request.
ContextBasicAuth takes BasicAuth as authentication for the request.
ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.

# Structs

AddressHolder Holds encoded ErgoAddress.
AddressValidity Validity status of Ergo address.
AndPredicate struct for AndPredicate.
APIClient manages communication with the Ergo Node API API v4.0.23 In most cases there should be only one, shared, APIClient.
APIError struct for APIError.
APIKey provides API key based authentication to a request passed via context using ContextAPIKey.
APIResponse stores the API response returned by the server.
Asset Token detail in the transaction.
AssetIssueRequest Request for generation of asset issue transaction.
AvlTreeData struct for AvlTreeData.
BalancesSnapshot Amount of Ergo tokens and assets.
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth.
BlacklistedPeers struct for BlacklistedPeers.
BlockAdProofs struct for BlockAdProofs.
BlockHeader struct for BlockHeader.
BlockHeaderWithoutPow struct for BlockHeaderWithoutPow.
BlockTransactions struct for BlockTransactions.
BoxesRequestHolder Holds request for wallet boxes.
BurnTokensRequest Request for burning tokens in wallet.
CandidateBlock Can be null if node is not mining or candidate block is not ready.
CheckWallet struct for CheckWallet.
Commitment basic trait for prover commitments.
CommitmentWithSecret commitment to secret along with secret (!) randomness.
Configuration stores the configuration of the API client.
ConnectedPeer struct for ConnectedPeer.
ContainsAssetPredicate struct for ContainsAssetPredicate.
ContainsPredicate struct for ContainsPredicate.
CryptoResult Result of executeWithContext request (reduceToCrypto).
DeriveKey struct for DeriveKey.
DeriveKeyResult struct for DeriveKeyResult.
DeriveNextKeyResult struct for DeriveNextKeyResult.
DhtSecret Hex-encoded big-endian 256-bits secret exponent \"w\" along with generators \"g\", \"h\", and group elements \"u\", \"v\", such as g^w = u, h^w = v.
DlogCommitment Randomness and commitment for the first step of the Schnorr protocol.
EmissionInfo Emission info for height.
EqualsPredicate struct for EqualsPredicate.
ErgoLikeContext struct for ErgoLikeContext.
ErgoLikeTransaction struct for ErgoLikeTransaction.
ErgoTransaction Ergo transaction.
ErgoTransactionDataInput struct for ErgoTransactionDataInput.
ErgoTransactionInput struct for ErgoTransactionInput.
ErgoTransactionOutput struct for ErgoTransactionOutput.
ErgoTransactionUnsignedInput struct for ErgoTransactionUnsignedInput.
ErgoTreeObject struct for ErgoTreeObject.
ExecuteScript struct for ExecuteScript.
Extension struct for Extension.
FeeHistogramBin Fee histogram bin.
FullBlock Block with header and transactions.
GenerateCommitmentsRequest request to generate commitments to sign a transaction.
GenerateCommitmentsRequestSecrets Optionally, external secrets used for signing.
GenericOpenAPIError Provides access to the body, error and model on returned errors.
GetChainSliceOpts Optional parameters for the method 'GetChainSlice'.
GetFeeHistogramOpts Optional parameters for the method 'GetFeeHistogram'.
GetHeaderIDsOpts Optional parameters for the method 'GetHeaderIDs'.
GetUnconfirmedTransactionsOpts Optional parameters for the method 'GetUnconfirmedTransactions'.
HintExtractionRequest request to extract prover hints from a transaction.
InitWallet struct for InitWallet.
InitWalletResult struct for InitWalletResult.
ListUnspentScansOpts Optional parameters for the method 'ListUnspentScans'.
MerkleProof Merkle proof for a leaf, which is an array of bytes (e.g.
NipopowProof struct for NipopowProof.
NodeInfo struct for NodeInfo.
OrPredicate struct for OrPredicate.
Parameters struct for Parameters.
PassphraseMatch struct for PassphraseMatch.
PaymentRequest Request for generation of payment transaction to a given address.
Peer struct for Peer.
PeerMode struct for PeerMode.
PeersStatus struct for PeersStatus.
PopowHeader struct for PopowHeader.
PowSolutions An object containing all components of pow solution.
PreHeader struct for PreHeader.
ProofOfUpcomingTransactions Proof that a block corresponding to given header without PoW contains some transactions.
RequestedInfo struct for RequestedInfo.
RequestsHolder Holds many transaction requests and transaction fee.
RestoreWallet struct for RestoreWallet.
RewardAddress struct for RewardAddress.
RewardPubKey struct for RewardPubKey.
Scan struct for Scan.
ScanID struct for ScanID.
ScanIDBoxID struct for ScanIDBoxID.
ScanIDsBox Ergo box with associated scans (their respective identifiers).
ScanningPredicate struct for ScanningPredicate.
ScanRequest struct for ScanRequest.
ScriptBytes struct for ScriptBytes.
SecretProven struct for SecretProven.
SerializedBox struct for SerializedBox.
ServerConfiguration stores the information about a server.
ServerVariable stores the information about a server variable.
SigmaBoolean Algebraic data type of sigma proposition expressions.
SigmaBooleanAndPredicate struct for SigmaBooleanAndPredicate.
SigmaBooleanOrPredicate struct for SigmaBooleanOrPredicate.
SigmaBooleanThresholdPredicate struct for SigmaBooleanThresholdPredicate.
SigmaHeader Block header format used for sigma ErgoLikeContext.
SourceHolder struct for SourceHolder.
SpendingProof Spending proof for transaction input.
SyncInfo struct for SyncInfo.
TrackInfo struct for TrackInfo.
TransactionHintsBag prover hints extracted from a transaction.
TransactionSigningRequest A request to sign a transaction with secrets provided.
TransactionSigningRequestSecrets Secrets used for signing.
UnlockWallet struct for UnlockWallet.
UnsignedErgoTransaction Unsigned Ergo transaction.
WalletBox struct for WalletBox.
WalletBoxesOpts Optional parameters for the method 'WalletBoxes'.
WalletStatus Status of the node wallet.
WalletTransaction Transaction augmented with some useful information.
WalletTransactionsByScanIDOpts Optional parameters for the method 'WalletTransactionsByScanID'.
WalletTransactionsOpts Optional parameters for the method 'WalletTransactions'.
WalletUnspentBoxesOpts Optional parameters for the method 'WalletUnspentBoxes'.
WorkMessage Block candidate related data for external miner to perform work.

# Type aliases

BlocksAPIService BlocksAPI service.
InfoAPIService InfoAPI service.
MiningAPIService MiningAPI service.
NipopowAPIService NipopowAPI service.
NodeAPIService NodeAPI service.
PeersAPIService PeersAPI service.
ScanAPIService ScanAPI service.
ScriptAPIService ScriptAPI service.
TransactionsAPIService TransactionsAPI service.
UtilsAPIService UtilsAPI service.
UtxoAPIService UtxoAPI service.
WalletAPIService WalletAPI service.