feat: add more data to get bitcoin info response

This commit is contained in:
Stefan Stammberger 2021-08-01 10:32:43 +02:00
parent 464f22ac54
commit 54dd7b77f3
No known key found for this signature in database
GPG key ID: 645FA807E935D9D5
3 changed files with 50 additions and 2 deletions

View file

@ -37,6 +37,8 @@ async def get_bitcoin_info():
info["headers"] = r["headers"]
info["initialblockdownload"] = r["initialblockdownload"]
info["size_on_disk"] = r["size_on_disk"]
info["verification_progress"] = r["verificationprogress"]
info["pruned"] = r["pruned"]
return info

View file

@ -1,6 +1,7 @@
from app.auth.auth_bearer import JWTBearer
from app.repositories.bitcoin import get_bitcoin_info, handle_block_sub
from app.routers.bitcoin_docs import blocks_sub_doc, get_bitcoin_info_desc
from app.routers.bitcoin_docs import (blocks_sub_doc, get_bitcoin_info_desc,
get_bitcoin_info_response_desc)
from app.sse_starlette import EventSourceResponse
from app.utils import bitcoin_rpc
from fastapi import APIRouter, HTTPException, Request, status
@ -49,7 +50,7 @@ def getblockchaininfo():
@router.get("/getbitcoininfo", summary="Get general information about bitcoin core",
description=get_bitcoin_info_desc,
response_description="A JSON String with relevant information.",
response_description=get_bitcoin_info_response_desc,
dependencies=[Depends(JWTBearer())],
status_code=status.HTTP_200_OK)
async def getbitcoininfo():

View file

@ -11,3 +11,48 @@ If verbosity is 2, returns an Object with information about block <hash> and inf
get_bitcoin_info_desc = """
This endpoint returns a combination of various Bitcoin Core calls for easy access.
"""
get_bitcoin_info_response_desc = """
A JSON object which combines information from Bitcoin Core RPC calls `getnetworkinfo` and `getblockchaininfo`
```JSON
{
"version": 210100,
"subversion": "/Satoshi:0.21.1/",
"networkactive": true,
"networks": [
{
"name": "ipv4",
"limited": false,
"reachable": true,
"proxy": "",
"proxy_randomize_credentials": false
},
{
"name": "ipv6",
"limited": false,
"reachable": true,
"proxy": "",
"proxy_randomize_credentials": false
},
{
"name": "onion",
"limited": true,
"reachable": false,
"proxy": "",
"proxy_randomize_credentials": false
}
],
"connections": 3,
"connections_in": 1,
"connections_out": 3,
"chain": "regtest",
"blocks": 316,
"headers": 316,
"initialblockdownload": false,
"size_on_disk": 102295,
"verification_progress": 1,
"pruned":false
}
```
"""