Renamed Go SDK API services and documentation from BlockAPI/InfoAPI to BlockUtilsSdkClientGo/InfoUtilsSdkClientGo for consistency. Updated all references, method receivers, and usage examples accordingly. Added new Java SDK client, models, API, documentation, and build files under utils/sdk/client/java. Updated Go module dependencies and added go.sum. Enhanced Go models to support additional properties in JSON unmarshalling.
8.6 KiB
Generated
\BlockUtilsSdkClientGo
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(ctx).BlockTemplateRequestModel(blockTemplateRequestModel).Execute()
Create a block template for mining
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)
func main() {
blockTemplateRequestModel := *openapiclient.NewBlockTemplateRequestModel() // BlockTemplateRequestModel |
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.BlockUtilsSdkClientGo.CreateBlockTemplate(context.Background()).BlockTemplateRequestModel(blockTemplateRequestModel).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.CreateBlockTemplate``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `CreateBlockTemplate`: BlockTemplateModel
fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.CreateBlockTemplate`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiCreateBlockTemplateRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| blockTemplateRequestModel | BlockTemplateRequestModel |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
GetBlock
BlockDetailsModel GetBlock(ctx, identifier).Execute()
Get a block by its hash or height (ID)
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)
func main() {
identifier := "identifier_example" // string | The hash (hex string) or height (integer) of the block to retrieve.
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.BlockUtilsSdkClientGo.GetBlock(context.Background(), identifier).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.GetBlock``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetBlock`: BlockDetailsModel
fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.GetBlock`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
| identifier | string | The hash (hex string) or height (integer) of the block to retrieve. |
Other Parameters
Other parameters are passed through a pointer to a apiGetBlockRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
GetBlocks
[]BlockDetailsModel GetBlocks(ctx).Execute()
Get one or more blocks, with optional pagination.
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)
func main() {
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.BlockUtilsSdkClientGo.GetBlocks(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.GetBlocks``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetBlocks`: []BlockDetailsModel
fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.GetBlocks`: %v\n", resp)
}
Path Parameters
This endpoint does not need any parameter.
Other Parameters
Other parameters are passed through a pointer to a apiGetBlocksRequest struct via the builder pattern
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
GetHeight
HeightModel GetHeight(ctx).Execute()
Get the current blockchain height
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)
func main() {
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.BlockUtilsSdkClientGo.GetHeight(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.GetHeight``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetHeight`: HeightModel
fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.GetHeight`: %v\n", resp)
}
Path Parameters
This endpoint does not need any parameter.
Other Parameters
Other parameters are passed through a pointer to a apiGetHeightRequest struct via the builder pattern
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
SubmitBlock
SubmitBlockResponseModel SubmitBlock(ctx).SubmitBlockRequestModel(submitBlockRequestModel).Execute()
Submit a new block to the network
Example
package main
import (
"context"
"fmt"
"os"
openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)
func main() {
submitBlockRequestModel := *openapiclient.NewSubmitBlockRequestModel() // SubmitBlockRequestModel |
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.BlockUtilsSdkClientGo.SubmitBlock(context.Background()).SubmitBlockRequestModel(submitBlockRequestModel).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.SubmitBlock``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `SubmitBlock`: SubmitBlockResponseModel
fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.SubmitBlock`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiSubmitBlockRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| submitBlockRequestModel | SubmitBlockRequestModel |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]