mirror of
https://github.com/aljazceru/cyphernode.git
synced 2026-01-31 10:14:35 +01:00
Added getblockhash call
This commit is contained in:
@@ -5,6 +5,7 @@ action_helloworld=stats
|
||||
action_getblockchaininfo=stats
|
||||
action_installation_info=stats
|
||||
action_getmempoolinfo=stats
|
||||
action_getblockhash=stats
|
||||
|
||||
# Watcher can do what the stats can do, plus:
|
||||
action_watch=watcher
|
||||
|
||||
@@ -376,6 +376,24 @@ Proxy response:
|
||||
}
|
||||
```
|
||||
|
||||
### Get the Block Hash from Height (called by application)
|
||||
|
||||
Returns the best block hash matching height provided.
|
||||
|
||||
```http
|
||||
GET http://cyphernode:8888/getblockhash/593104
|
||||
```
|
||||
|
||||
Proxy response:
|
||||
|
||||
```json
|
||||
{
|
||||
"result":"00000000000000000005dc459f0575b17413dbe7685e3e0fd382ed521f1be68b",
|
||||
"error":null,
|
||||
"id":null
|
||||
}
|
||||
```
|
||||
|
||||
### Get the Best Block Hash (called by application)
|
||||
|
||||
Returns the best block hash of the watching Bitcoin node.
|
||||
|
||||
@@ -436,6 +436,38 @@ paths:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseTemporarilyUnavailable'
|
||||
|
||||
/getblockhash:
|
||||
get:
|
||||
tags:
|
||||
- "block"
|
||||
- "core features"
|
||||
summary: "Get block hash matching height provided."
|
||||
description: "Returns the block matching the height provided of the watching Bitcoin node."
|
||||
operationId: "getBlockHash"
|
||||
responses:
|
||||
'200':
|
||||
description: "successful operation"
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: "object"
|
||||
required:
|
||||
- "result"
|
||||
properties:
|
||||
result:
|
||||
$ref: '#/components/schemas/TypeHashString'
|
||||
error:
|
||||
type: "string"
|
||||
id:
|
||||
type: "string"
|
||||
'403':
|
||||
$ref: '#/components/schemas/ApiResponseNotAllowed'
|
||||
'503':
|
||||
description: "Resource temporarily unavailable"
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponseTemporarilyUnavailable'
|
||||
/getbestblockhash:
|
||||
get:
|
||||
tags:
|
||||
|
||||
@@ -84,3 +84,10 @@ get_mempool_info() {
|
||||
send_to_watcher_node "${data}" | jq ".result"
|
||||
return $?
|
||||
}
|
||||
get_blockhash() {
|
||||
trace "Entering get_blockhash()..."
|
||||
local blockheight=${1}
|
||||
local data="{\"method\":\"getblockhash\",\"params\":[${blockheight}]}"
|
||||
send_to_watcher_node "${data}" | jq ".result"
|
||||
return $?
|
||||
}
|
||||
|
||||
@@ -182,6 +182,13 @@ main() {
|
||||
response_to_client "${response}" ${?}
|
||||
break
|
||||
;;
|
||||
getblockhash)
|
||||
# curl (GET) http://192.168.111.152:8080/getblockhash/522322
|
||||
|
||||
response=$(get_blockhash $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3))
|
||||
response_to_client "${response}" ${?}
|
||||
break
|
||||
;;
|
||||
getblockinfo)
|
||||
# curl (GET) http://192.168.111.152:8080/getblockinfo/000000006f82a384c208ecfa04d05beea02d420f3f398ddda5c7f900de5718ea
|
||||
|
||||
|
||||
Reference in New Issue
Block a user