From 54dd7b77f3486eb57f165c20a33db34f83b83f7a Mon Sep 17 00:00:00 2001 From: Stefan Stammberger Date: Sun, 1 Aug 2021 10:32:43 +0200 Subject: [PATCH] feat: add more data to get bitcoin info response --- app/repositories/bitcoin.py | 2 ++ app/routers/bitcoin.py | 5 +++-- app/routers/bitcoin_docs.py | 45 +++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/app/repositories/bitcoin.py b/app/repositories/bitcoin.py index 98c3373..4668cf9 100644 --- a/app/repositories/bitcoin.py +++ b/app/repositories/bitcoin.py @@ -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 diff --git a/app/routers/bitcoin.py b/app/routers/bitcoin.py index c4eaa3d..c5716f2 100644 --- a/app/routers/bitcoin.py +++ b/app/routers/bitcoin.py @@ -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(): diff --git a/app/routers/bitcoin_docs.py b/app/routers/bitcoin_docs.py index db3cb10..489b583 100644 --- a/app/routers/bitcoin_docs.py +++ b/app/routers/bitcoin_docs.py @@ -11,3 +11,48 @@ If verbosity is 2, returns an Object with information about block 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 +} +``` +"""