forked from lthn/blockchain
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages. ### Highlights * **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications. * **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities. * **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
8.9 KiB
Generated
8.9 KiB
Generated
BlockApi
All URIs are relative to http://127.0.0.1:36943
| Method | HTTP request | Description |
|---|---|---|
| createBlockTemplate | POST /block/template | Create a block template for mining |
| getBlock | GET /block/{identifier} | Get a block by its hash or height (ID) |
| getBlocks | GET /block | Get one or more blocks, with optional pagination. |
| getHeight | GET /block/height | Get the current blockchain height |
| submitBlock | POST /block/submit | Submit a new block to the network |
createBlockTemplate
BlockTemplateModel createBlockTemplate(blockTemplateRequestModel)
Create a block template for mining
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
BlockTemplateRequestModel blockTemplateRequestModel = new BlockTemplateRequestModel(); // BlockTemplateRequestModel |
try {
BlockTemplateModel result = apiInstance.createBlockTemplate(blockTemplateRequestModel);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#createBlockTemplate");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| blockTemplateRequestModel | BlockTemplateRequestModel |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 500 | text/plain | - |
| 400 | text/plain | - |
| 200 | OK | - |
getBlock
BlockDetailsModel getBlock(identifier)
Get a block by its hash or height (ID)
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
String identifier = "identifier_example"; // String | The hash (hex string) or height (integer) of the block to retrieve.
try {
BlockDetailsModel result = apiInstance.getBlock(identifier);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#getBlock");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| identifier | String | The hash (hex string) or height (integer) of the block to retrieve. |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 404 | text/plain | - |
| 400 | text/plain | - |
| 200 | OK | - |
getBlocks
List<BlockDetailsModel> getBlocks()
Get one or more blocks, with optional pagination.
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
try {
List<BlockDetailsModel> result = apiInstance.getBlocks();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#getBlocks");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
This endpoint does not need any parameter.
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 404 | text/plain | - |
| 400 | text/plain | - |
| 200 | A list of block objects. | - |
getHeight
HeightModel getHeight()
Get the current blockchain height
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
try {
HeightModel result = apiInstance.getHeight();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#getHeight");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
This endpoint does not need any parameter.
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | OK | - |
submitBlock
SubmitBlockResponseModel submitBlock(submitBlockRequestModel)
Submit a new block to the network
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
SubmitBlockRequestModel submitBlockRequestModel = new SubmitBlockRequestModel(); // SubmitBlockRequestModel |
try {
SubmitBlockResponseModel result = apiInstance.submitBlock(submitBlockRequestModel);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#submitBlock");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| submitBlockRequestModel | SubmitBlockRequestModel |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 406 | text/plain | - |
| 400 | text/plain | - |
| 200 | OK | - |