diff --git a/package.json b/package.json index cc25062a..74a8ed73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rest-cloud", - "version": "0.1.6", + "version": "0.1.8", "private": true, "scripts": { "start": "node ./bin/www" diff --git a/public/bitbox-rest-v1.json b/public/bitbox-rest-v1.json index f553cd96..edebfe01 100644 --- a/public/bitbox-rest-v1.json +++ b/public/bitbox-rest-v1.json @@ -360,10 +360,10 @@ ], "responses": { "200": { - "description": "successful operation" - }, - "400": { - "description": "Invalid tag value" + "description": "successful operation", + "schema": { + "$ref": "#/definitions/BlockCount" + } } } } @@ -390,10 +390,17 @@ ], "responses": { "200": { - "description": "successful operation" + "description": "successful operation", + "schema": { + "$ref": "#/definitions/BlockHash" + } }, "400": { - "description": "Invalid tag value" + "description": "Block not found", + "schema": { + "status": 500, + "message": "Block not found" + } } } } @@ -428,10 +435,17 @@ ], "responses": { "200": { - "description": "successful operation" + "description": "successful operation", + "schema": { + "$ref": "#/definitions/BlockHeader" + } }, "400": { - "description": "Invalid tag value" + "description": "Block not found", + "schema": { + "status": 500, + "message": "Block not found" + } } } } @@ -467,7 +481,10 @@ ], "responses": { "200": { - "description": "successful operation" + "description": "successful operation", + "schema": { + "$ref": "#/definitions/Difficulty" + } } } } @@ -591,10 +608,10 @@ ], "responses": { "200": { - "description": "successful operation" - }, - "400": { - "description": "Invalid tag value" + "description": "successful operation", + "schema": { + "$ref": "#/definitions/MempoolInfo" + } } } } @@ -1771,6 +1788,84 @@ } } }, + "BlockCount": { + "type": "number" + }, + "BlockHash": { + "type": "string" + }, + "BlockHeader": { + "type": "object", + "properties": { + "hash": { + "type": "string" + }, + "confirmations": { + "type": "number" + }, + "height": { + "type": "number" + }, + "version": { + "type": "number" + }, + "versionHex": { + "type": "string" + }, + "merkleroot": { + "type": "string" + }, + "time": { + "type": "number" + }, + "mediantime": { + "type": "number" + }, + "nonce": { + "type": "number" + }, + "bits": { + "type": "string" + }, + "difficulty": { + "type": "number", + "format": "float" + }, + "chainwork": { + "type": "string" + }, + "previousblockhash": { + "type": "string" + }, + "nextblockhash": { + "type": "string" + } + } + }, + "Difficulty": { + "type": "number", + "format": "float" + }, + "MempoolInfo": { + "type": "object", + "properties": { + "size": { + "type": "number" + }, + "bytes": { + "type": "number" + }, + "usage": { + "type": "number" + }, + "maxmempool": { + "type": "number" + }, + "mempoolminfee": { + "type": "number" + }, + } + }, "transactionDetails": { "type": "object", "properties": { diff --git a/routes/blockchain.js b/routes/blockchain.js index 3b39d94c..8a4250c3 100644 --- a/routes/blockchain.js +++ b/routes/blockchain.js @@ -65,7 +65,7 @@ router.get('/getBlockHeader/:hash', function(req, res, next) { } BITBOX.Blockchain.getBlockHeader(req.params.hash, verbose) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -73,7 +73,7 @@ router.get('/getBlockHeader/:hash', function(req, res, next) { router.get('/getChainTips', function(req, res, next) { BITBOX.Blockchain.getChainTips() .then((result) => { - res.json({result: result}); + res.json(result); }, (err) => { console.log(err); }); }); @@ -93,7 +93,7 @@ router.get('/getMempoolAncestors/:txid', function(req, res, next) { } BITBOX.Blockchain.getMempoolAncestors(req.params.txid, verbose) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -105,7 +105,7 @@ router.get('/getMempoolDescendants/:txid', function(req, res, next) { } BITBOX.Blockchain.getMempoolDescendants(req.params.txid, verbose) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -113,7 +113,7 @@ router.get('/getMempoolDescendants/:txid', function(req, res, next) { router.get('/getMempoolEntry/:txid', function(req, res, next) { BITBOX.Blockchain.getMempoolEntry(req.params.txid) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -121,7 +121,7 @@ router.get('/getMempoolEntry/:txid', function(req, res, next) { router.get('/getMempoolInfo', function(req, res, next) { BITBOX.Blockchain.getMempoolInfo() .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -133,7 +133,7 @@ router.get('/getRawMempool', function(req, res, next) { } BITBOX.Blockchain.getRawMempool(verbose) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -145,7 +145,7 @@ router.get('/getTxOut/:txid/:n', function(req, res, next) { } BITBOX.Blockchain.getTxOut(req.params.txid, parseInt(req.params.n), include_mempool) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -154,7 +154,7 @@ router.get('/getTxOutProof/:txids', function(req, res, next) { // TODO finish this BITBOX.Blockchain.getTxOutProof(req.params.txids) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -162,7 +162,7 @@ router.get('/getTxOutProof/:txids', function(req, res, next) { router.get('/getTxOutSetInfo', function(req, res, next) { BITBOX.Blockchain.getTxOutSetInfo() .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -170,7 +170,7 @@ router.get('/getTxOutSetInfo', function(req, res, next) { router.get('/preciousBlock/:hash', function(req, res, next) { BITBOX.Blockchain.preciousBlock(req.params.hash) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -178,7 +178,7 @@ router.get('/preciousBlock/:hash', function(req, res, next) { router.post('/pruneBlockchain/:height', function(req, res, next) { BITBOX.Blockchain.pruneBlockchain(req.params.height) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); }); @@ -195,7 +195,7 @@ router.get('/verifyChain', function(req, res, next) { router.get('/verifyTxOutProof/:proof', function(req, res, next) { BITBOX.Blockchain.verifyTxOutProof(req.params.proof) .then((result) => { - res.json({ result: result }); + res.json(result); }, (err) => { console.log(err); }); });