mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-21 16:52:04 -07:00
Merge pull request #21 from christroutner/api-docs
Adding additional api docs
This commit is contained in:
@@ -10,3 +10,4 @@ test-v1
|
||||
nohup.out
|
||||
slp-tx-db/
|
||||
logs/
|
||||
docs/*
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
This directory holds api docs generated by apidoc.
|
||||
Generated
+956
-429
File diff suppressed because it is too large
Load Diff
+7
-1
@@ -15,13 +15,15 @@
|
||||
"test-v3": "export NETWORK=testnet && nyc --reporter=text mocha --timeout 25000 test/v3/",
|
||||
"test:integration": "mocha test/v3/integration",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"coverage:report": "export NETWORK=testnet && nyc --reporter=html mocha test/v2/"
|
||||
"coverage:report": "export NETWORK=testnet && nyc --reporter=html mocha test/v2/",
|
||||
"docs": "./node_modules/.bin/apidoc -i src/routes/v3 -o docs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.15.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@chris.troutner/bitbox-js": "^7.0.2",
|
||||
"apidoc": "^0.17.7",
|
||||
"axios": "^0.19.0",
|
||||
"bitcoincash-zmq-decoder": "0.1.5",
|
||||
"body-parser": "^1.18.3",
|
||||
@@ -82,5 +84,9 @@
|
||||
"npmPublish": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"apidoc": {
|
||||
"title": "bch-api",
|
||||
"url": "localhost:3000"
|
||||
}
|
||||
}
|
||||
|
||||
+5
-10
@@ -47,16 +47,12 @@ const utilV2 = require("./routes/v2/util")
|
||||
const slpV2 = require("./routes/v2/slp")
|
||||
|
||||
// v3
|
||||
const indexV3 = require("./routes/v3/index")
|
||||
const healthCheckV3 = require("./routes/v3/health-check")
|
||||
const blockV3 = require("./routes/v3/block")
|
||||
const blockchainV3 = require("./routes/v3/blockchain")
|
||||
const controlV3 = require("./routes/v3/control")
|
||||
const generatingV3 = require("./routes/v3/generating")
|
||||
const miningV3 = require("./routes/v3/mining")
|
||||
const networkV3 = require("./routes/v3/network")
|
||||
const rawtransactionsV3 = require("./routes/v3/rawtransactions")
|
||||
const transactionV3 = require("./routes/v3/transaction")
|
||||
const utilV3 = require("./routes/v3/util")
|
||||
const slpV3 = require("./routes/v3/slp")
|
||||
const xpubV3 = require("./routes/v3/xpub")
|
||||
@@ -78,7 +74,9 @@ app.enable("trust proxy")
|
||||
app.set("views", path.join(__dirname, "views"))
|
||||
app.set("view engine", "jade")
|
||||
|
||||
app.use("/public", express.static(`${__dirname}/public`))
|
||||
// Mount the docs
|
||||
app.use("/docs", express.static(`${__dirname}/../docs`))
|
||||
|
||||
app.use(logger("dev"))
|
||||
app.use(bodyParser.json())
|
||||
app.use(bodyParser.urlencoded({ extended: false }))
|
||||
@@ -126,17 +124,14 @@ app.use(`/${v2prefix}/` + `transaction`, transactionV2.router)
|
||||
app.use(`/${v2prefix}/` + `util`, utilV2.router)
|
||||
app.use(`/${v2prefix}/` + `slp`, slpV2.router)
|
||||
|
||||
// Rate limit on all v2 routes
|
||||
// Rate limit on all v3 routes
|
||||
app.use(`/${v3prefix}/`, routeRateLimit)
|
||||
app.use(`/${v3prefix}/` + `health-check`, healthCheckV3)
|
||||
app.use(`/${v3prefix}/` + `blockchain`, blockchainV3.router)
|
||||
app.use(`/${v3prefix}/` + `block`, blockV3.router)
|
||||
app.use(`/${v3prefix}/` + `control`, controlV3.router)
|
||||
app.use(`/${v3prefix}/` + `generating`, generatingV3)
|
||||
app.use(`/${v3prefix}/` + `mining`, miningV3.router)
|
||||
app.use(`/${v3prefix}/` + `network`, networkV3)
|
||||
app.use(`/${v3prefix}/` + `rawtransactions`, rawtransactionsV3.router)
|
||||
app.use(`/${v3prefix}/` + `transaction`, transactionV3.router)
|
||||
app.use(`/${v3prefix}/` + `util`, utilV3.router)
|
||||
app.use(`/${v3prefix}/` + `slp`, slpV3.router)
|
||||
app.use(`/${v3prefix}/` + `xpub`, xpubV3.router)
|
||||
@@ -172,7 +167,7 @@ app.use((err, req, res, next) => {
|
||||
*/
|
||||
const port = normalizePort(process.env.PORT || "3000")
|
||||
app.set("port", port)
|
||||
console.log(`rest.bitcoin.com started on port ${port}`)
|
||||
console.log(`bch-api started on port ${port}`)
|
||||
|
||||
/**
|
||||
* Create HTTP server.
|
||||
|
||||
+14
-7
@@ -4,9 +4,9 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>The HTML5 Herald</title>
|
||||
<meta name="description" content="The HTML5 Herald">
|
||||
<meta name="author" content="SitePoint">
|
||||
<title>BCH API</title>
|
||||
<meta name="description" content="BCH API">
|
||||
<meta name="author" content="Chris Troutner">
|
||||
|
||||
<link rel="stylesheet" href="css/styles.css?v=1.0">
|
||||
|
||||
@@ -18,10 +18,17 @@
|
||||
This web server is based on <a href="https://rest.bitcoin.com">rest.bitcoin.com</a>.
|
||||
Go there to view an interactive UI of the REST API endpoints.
|
||||
</p>
|
||||
<p>
|
||||
View the API documentation
|
||||
on <a href="https://developer.bitcoin.com/rest/docs/getting-started">developer.bitcoin.com</a>.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/docs">
|
||||
View the BCH-API documentation
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
View the original rest.bitcoin.com API documentation
|
||||
on <a href="https://developer.bitcoin.com/rest/docs/getting-started">developer.bitcoin.com</a>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<script src="js/scripts.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -61,6 +61,16 @@ async function balanceFromBitcore(thisAddress) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /bitcore/balance/:address Get BCH balance for an address
|
||||
* @apiName GetBalance
|
||||
* @apiGroup Bitcore
|
||||
*
|
||||
* @apiParam {String} address Bitcoin Cash address.
|
||||
*
|
||||
* @apiSuccess {String} firstname Firstname of the User.
|
||||
* @apiSuccess {String} lastname Lastname of the User.
|
||||
*/
|
||||
// GET handler for single balance
|
||||
async function balanceSingle(req, res, next) {
|
||||
try {
|
||||
|
||||
+216
-10
@@ -10,7 +10,6 @@ const router = express.Router()
|
||||
const axios = require("axios")
|
||||
|
||||
const routeUtils = require("./route-utils")
|
||||
const logger = require("./logging.js")
|
||||
const wlogger = require("../../util/winston-logging")
|
||||
|
||||
// Used to convert error messages to strings, to safely pass to users.
|
||||
@@ -26,7 +25,6 @@ router.get("/getBlockchainInfo", getBlockchainInfo)
|
||||
router.get("/getBlockCount", getBlockCount)
|
||||
router.get("/getBlockHeader/:hash", getBlockHeaderSingle)
|
||||
router.post("/getBlockHeader", getBlockHeaderBulk)
|
||||
|
||||
router.get("/getChainTips", getChainTips)
|
||||
router.get("/getDifficulty", getDifficulty)
|
||||
router.get("/getMempoolEntry/:txid", getMempoolEntrySingle)
|
||||
@@ -43,7 +41,18 @@ function root(req, res, next) {
|
||||
return res.json({ status: "blockchain" })
|
||||
}
|
||||
|
||||
// Returns the hash of the best (tip) block in the longest block chain.
|
||||
/**
|
||||
* @api {get} /blockchain/getBestBlockHash Get best block hash
|
||||
* @apiName GetBestBlockHash
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns the hash of the best (tip) block in the longest
|
||||
* block chain.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getBestBlockHash" -H "accept: application/json"
|
||||
*
|
||||
* @apiSuccess {String} bestBlockHash 000000000000000002bc884334336d99c9a9c616670a9244c6a8c1fc35aa91a1
|
||||
*/
|
||||
async function getBestBlockHash(req, res, next) {
|
||||
try {
|
||||
const {
|
||||
@@ -76,6 +85,31 @@ async function getBestBlockHash(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /blockchain/getBlockchainInfo Get blockchain info
|
||||
* @apiName GetBlockchainInfo
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns an object containing various state info regarding blockchain processing.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getBlockchainInfo" -H "accept: application/json"
|
||||
*
|
||||
* @apiSuccess {Object} object Object containing data
|
||||
* @apiSuccess {String} object.chain "main"
|
||||
* @apiSuccess {Number} object.blocks 561838
|
||||
* @apiSuccess {Number} object.headers 561838
|
||||
* @apiSuccess {String} object.bestblockhash "000000000000000002307dd38cd01c7308b8febfcdf5772cf087b5bb023d55bc"
|
||||
* @apiSuccess {Number} object.difficulty 246585566638.1496
|
||||
* @apiSuccess {String} object.mediantime 1545402693
|
||||
* @apiSuccess {Number} object.verificationprogress 0.999998831622689
|
||||
* @apiSuccess {Boolean} object.chainwork "000000000000000000000000000000000000000000d8c09a8ab7262080266b3e"
|
||||
* @apiSuccess {Number} object.pruned false
|
||||
* @apiSuccess {Array} object.softforks Array of objects
|
||||
* @apiSuccess {String} object.softforks.id "bip34"
|
||||
* @apiSuccess {String} object.softforks.version 2
|
||||
* @apiSuccess {Object} object.softforks.reject
|
||||
* @apiSuccess {String} object.softforks.reject.status true
|
||||
*/
|
||||
async function getBlockchainInfo(req, res, next) {
|
||||
try {
|
||||
const {
|
||||
@@ -109,6 +143,17 @@ async function getBlockchainInfo(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /blockchain/getBlockCount Get Block Count
|
||||
* @apiName GetBlockCount
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns the number of blocks in the longest blockchain.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getBlockCount" -H "accept: application/json"
|
||||
*
|
||||
* @apiSuccess {Number} bestBlockCount 587665
|
||||
*/
|
||||
async function getBlockCount(req, res, next) {
|
||||
try {
|
||||
const {
|
||||
@@ -141,6 +186,36 @@ async function getBlockCount(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /blockchain/getBlockHeader/:hash Get single block header
|
||||
* @apiName GetSingleBlockHeader
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription If verbose is false (default), returns a string that is
|
||||
* serialized, hex-encoded data for blockheader 'hash'. If verbose is true,
|
||||
* returns an Object with information about blockheader hash.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getBlockHeader/000000000000000005e14d3f9fdfb70745308706615cfa9edca4f4558332b201?verbose=true" -H "accept: application/json"
|
||||
*
|
||||
* @apiParam {String} hash block hash
|
||||
* @apiParam {Boolean} verbose Return verbose data
|
||||
*
|
||||
* @apiSuccess {Object} object Object containing data
|
||||
* @apiSuccess {String} object.hash "000000000000000005e14d3f9fdfb70745308706615cfa9edca4f4558332b201"
|
||||
* @apiSuccess {Number} object.confirmations 61839
|
||||
* @apiSuccess {Number} object.height 500000
|
||||
* @apiSuccess {Number} object.version 536870912
|
||||
* @apiSuccess {String} object.versionHex "20000000"
|
||||
* @apiSuccess {String} object.merkleroot "4af279645e1b337e655ae3286fc2ca09f58eb01efa6ab27adedd1e9e6ec19091"
|
||||
* @apiSuccess {Number} object.time 1509343584
|
||||
* @apiSuccess {Number} object.mediantime 1509336533
|
||||
* @apiSuccess {Number} object.nonce 3604508752
|
||||
* @apiSuccess {String} object.bits "1809b91a"
|
||||
* @apiSuccess {Number} object.difficulty 113081236211.4533
|
||||
* @apiSuccess {String} object.chainwork "0000000000000000000000000000000000000000007ae48aca46e3b449ad9714"
|
||||
* @apiSuccess {String} object.previousblockhash "0000000000000000043831d6ebb013716f0580287ee5e5687e27d0ed72e6e523"
|
||||
* @apiSuccess {String} object.nextblockhash "00000000000000000568f0a96bf4348847bc84e455cbfec389f27311037a20f3"
|
||||
*/
|
||||
async function getBlockHeaderSingle(req, res, next) {
|
||||
try {
|
||||
let verbose = false
|
||||
@@ -184,6 +259,36 @@ async function getBlockHeaderSingle(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /blockchain/getBlockHeader Get multiple block headers
|
||||
* @apiName GetBulkBlockHeader
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription If verbose is false (default), returns a string that is
|
||||
* serialized, hex-encoded data for blockheader 'hash'. If verbose is true,
|
||||
* returns an Object with information about blockheader hash.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X POST "https://rest.bitcoin.com/v3/blockchain/getBlockHeader" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"hashes\":[\"000000000000000005e14d3f9fdfb70745308706615cfa9edca4f4558332b201\",\"00000000000000000568f0a96bf4348847bc84e455cbfec389f27311037a20f3\"],\"verbose\":true}"
|
||||
*
|
||||
* @apiParam {String} hash block hash
|
||||
* @apiParam {Boolean} verbose Return verbose data
|
||||
*
|
||||
* @apiSuccess {Array} array array containing objects
|
||||
* @apiSuccess {String} object.hash "000000000000000005e14d3f9fdfb70745308706615cfa9edca4f4558332b201"
|
||||
* @apiSuccess {Number} object.confirmations 61839
|
||||
* @apiSuccess {Number} object.height 500000
|
||||
* @apiSuccess {Number} object.version 536870912
|
||||
* @apiSuccess {String} object.versionHex "20000000"
|
||||
* @apiSuccess {String} object.merkleroot "4af279645e1b337e655ae3286fc2ca09f58eb01efa6ab27adedd1e9e6ec19091"
|
||||
* @apiSuccess {Number} object.time 1509343584
|
||||
* @apiSuccess {Number} object.mediantime 1509336533
|
||||
* @apiSuccess {Number} object.nonce 3604508752
|
||||
* @apiSuccess {String} object.bits "1809b91a"
|
||||
* @apiSuccess {Number} object.difficulty 113081236211.4533
|
||||
* @apiSuccess {String} object.chainwork "0000000000000000000000000000000000000000007ae48aca46e3b449ad9714"
|
||||
* @apiSuccess {String} object.previousblockhash "0000000000000000043831d6ebb013716f0580287ee5e5687e27d0ed72e6e523"
|
||||
* @apiSuccess {String} object.nextblockhash "00000000000000000568f0a96bf4348847bc84e455cbfec389f27311037a20f3"
|
||||
*/
|
||||
async function getBlockHeaderBulk(req, res, next) {
|
||||
try {
|
||||
const hashes = req.body.hashes
|
||||
@@ -204,7 +309,7 @@ async function getBlockHeaderBulk(req, res, next) {
|
||||
})
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
wlogger.debug(
|
||||
`Executing blockchain/getBlockHeaderBulk with these hashes: `,
|
||||
hashes
|
||||
)
|
||||
@@ -259,6 +364,17 @@ async function getBlockHeaderBulk(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /blockchain/getChainTips Get Chain Tips
|
||||
* @apiName getChainTips
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Return information about all known tips in the block tree,
|
||||
* including the main chain as well as orphaned branches.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getChainTips" -H "accept: application/json"
|
||||
*
|
||||
*/
|
||||
async function getChainTips(req, res, next) {
|
||||
try {
|
||||
const {
|
||||
@@ -291,7 +407,17 @@ async function getChainTips(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current difficulty value, used to regulate mining power on the network.
|
||||
/**
|
||||
* @api {get} /blockchain/getDifficulty Get difficulty
|
||||
* @apiName getDifficulty
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Get the current difficulty value, used to regulate mining
|
||||
* power on the network.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getDifficulty" -H "accept: application/json"
|
||||
*
|
||||
*/
|
||||
async function getDifficulty(req, res, next) {
|
||||
try {
|
||||
const {
|
||||
@@ -325,7 +451,17 @@ async function getDifficulty(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns mempool data for given transaction. TXID must be in mempool (unconfirmed)
|
||||
/**
|
||||
* @api {get} /blockchain/getMempoolEntry/:txid Get single mempool entry
|
||||
* @apiName getMempoolEntry
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns mempool data for given transaction. TXID must be in
|
||||
* mempool (unconfirmed)
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getMempoolEntry/fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33" -H "accept: application/json"
|
||||
*
|
||||
*/
|
||||
async function getMempoolEntrySingle(req, res, next) {
|
||||
try {
|
||||
// Validate input parameter
|
||||
@@ -366,6 +502,15 @@ async function getMempoolEntrySingle(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /blockchain/getMempoolEntry Get bulk mempool entry
|
||||
* @apiName getMempoolEntryBulk
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns mempool data for multiple transactions
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X POST http://localhost:3000/v3/blockchain/getMempoolEntry -H "Content-Type: application/json" -d "{\"txids\":[\"a5f972572ee1753e2fd2457dd61ce5f40fa2f8a30173d417e49feef7542c96a1\",\"5165dc531aad05d1149bb0f0d9b7bda99c73e2f05e314bcfb5b4bb9ca5e1af5e\"]}"
|
||||
*/
|
||||
async function getMempoolEntryBulk(req, res, next) {
|
||||
try {
|
||||
const txids = req.body.txids
|
||||
@@ -385,7 +530,7 @@ async function getMempoolEntryBulk(req, res, next) {
|
||||
})
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
wlogger.debug(
|
||||
`Executing blockchain/getMempoolEntry with these txids: `,
|
||||
txids
|
||||
)
|
||||
@@ -440,6 +585,16 @@ async function getMempoolEntryBulk(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /blockchain/getMempoolInfo Get mempool info
|
||||
* @apiName getMempoolInfo
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns details on the active state of the TX memory pool.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET http://localhost:3000/v3/getMempoolInfo -H "accept: application/json"
|
||||
*
|
||||
*/
|
||||
async function getMempoolInfo(req, res, next) {
|
||||
try {
|
||||
const {
|
||||
@@ -472,6 +627,29 @@ async function getMempoolInfo(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /blockchain/getRawMempool Get mempool info
|
||||
* @apiName getMempoolInfo
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns details on the active state of the TX memory pool.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET http://localhost:3000/v3/getMempoolInfo -H "accept: application/json"
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @api {get} /blockchain/getRawMempool/?verbose= Get raw mempool
|
||||
* @apiName getRawMempool
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns all transaction ids in memory pool as a json array
|
||||
* of string transaction ids.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/getRawMempool/?verbose=true" -H "accept: application/json"
|
||||
*
|
||||
* @apiParam {Boolean} verbose Return verbose data
|
||||
*
|
||||
*/
|
||||
async function getRawMempool(req, res, next) {
|
||||
try {
|
||||
const {
|
||||
@@ -508,6 +686,20 @@ async function getRawMempool(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /blockchain/getTxOut/:txid/:n?mempool= Get Tx Out
|
||||
* @apiName getTxOut
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns details about an unspent transaction output.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getTxOut/fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33/0?mempool=false" -H "accept: application/json"
|
||||
*
|
||||
* @apiParam {String} txid Transaction id (required)
|
||||
* @apiParam {Number} n Output number (required)
|
||||
* @apiParam {Boolean} mempool Check mempool or not (optional)
|
||||
*
|
||||
*/
|
||||
// Returns details about an unspent transaction output.
|
||||
async function getTxOut(req, res, next) {
|
||||
try {
|
||||
@@ -560,7 +752,18 @@ async function getTxOut(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a hex-encoded proof that 'txid' was included in a block.
|
||||
/**
|
||||
* @api {get} /blockchain/getTxOutProofSingle/:txid Get Tx Out Proof
|
||||
* @apiName getTxOutProofSingle
|
||||
* @apiGroup Blockchain
|
||||
* @apiDescription Returns a hex-encoded proof that 'txid' was included in a block.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/blockchain/getTxOutProofSingle/fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33" -H "accept: application/json"
|
||||
*
|
||||
* @apiParam {String} txid Transaction id (required)
|
||||
*
|
||||
*/
|
||||
async function getTxOutProofSingle(req, res, next) {
|
||||
try {
|
||||
// Validate input parameter
|
||||
@@ -641,7 +844,10 @@ async function getTxOutProofBulk(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug(`Executing blockchain/getTxOutProof with these txids: `, txids)
|
||||
wlogger.debug(
|
||||
`Executing blockchain/getTxOutProof with these txids: `,
|
||||
txids
|
||||
)
|
||||
|
||||
// Loop through each txid and creates an array of requests to call in parallel
|
||||
const promises = txids.map(async txid => {
|
||||
@@ -826,7 +1032,7 @@ async function verifyTxOutProofBulk(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
wlogger.debug(
|
||||
`Executing blockchain/verifyTxOutProof with these proofs: `,
|
||||
proofs
|
||||
)
|
||||
|
||||
@@ -4,7 +4,6 @@ const express = require("express")
|
||||
const router = express.Router()
|
||||
const axios = require("axios")
|
||||
|
||||
const logger = require("./logging.js")
|
||||
const routeUtils = require("./route-utils")
|
||||
const wlogger = require("../../util/winston-logging")
|
||||
|
||||
@@ -13,13 +12,34 @@ const util = require("util")
|
||||
util.inspect.defaultOptions = { depth: 1 }
|
||||
|
||||
router.get("/", root)
|
||||
router.get("/getInfo", getInfo)
|
||||
router.get("/getinfo", getInfo)
|
||||
|
||||
function root(req, res, next) {
|
||||
return res.json({ status: "control" })
|
||||
}
|
||||
|
||||
// Execute the RPC getinfo call.
|
||||
/**
|
||||
* @api {get} /control/getinfo Get full node info
|
||||
* @apiName GetInfo
|
||||
* @apiGroup Control
|
||||
* @apiDescription RPC call which gets basic full node information.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "http://localhost:3000/v3/control/getinfo" -H "accept: application/json"
|
||||
*
|
||||
* @apiSuccess {Object} object Object containing data
|
||||
* @apiSuccess {Number} object.version Full node version
|
||||
* @apiSuccess {Number} object.protocolversion Protocol version
|
||||
* @apiSuccess {Number} object.blocks Current block
|
||||
* @apiSuccess {Number} object.timeoffset ?
|
||||
* @apiSuccess {Number} object.connections Number of connected peers
|
||||
* @apiSuccess {String} object.proxy ?
|
||||
* @apiSuccess {Number} object.difficulty Current difficulty setting
|
||||
* @apiSuccess {Boolean} object.testnet testnet = true, mainnet = false
|
||||
* @apiSuccess {Number} object.paytxfee ?
|
||||
* @apiSuccess {Number} object.relayfee ?
|
||||
* @apiSuccess {String} object.errors Recent errors
|
||||
*/
|
||||
async function getInfo(req, res, next) {
|
||||
const {
|
||||
BitboxHTTP,
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
"use strict"
|
||||
|
||||
const express = require("express")
|
||||
const router = express.Router()
|
||||
//const axios = require("axios");
|
||||
|
||||
//const BITBOXCli = require("bitbox-sdk/lib/bitbox-sdk").default;
|
||||
//const BITBOX = new BITBOXCli();
|
||||
|
||||
//const BitboxHTTP = axios.create({
|
||||
// baseURL: process.env.RPC_BASEURL,
|
||||
//});
|
||||
//const username = process.env.RPC_USERNAME;
|
||||
//const password = process.env.RPC_PASSWORD;
|
||||
|
||||
router.get("/", (req, res, next) => {
|
||||
res.json({ status: "generating" })
|
||||
})
|
||||
//
|
||||
// router.post('/generateToAddress/:nblocks/:address', (req, res, next) => {
|
||||
// let maxtries = 1000000;
|
||||
// if(req.query.maxtries) {
|
||||
// maxtries = parseInt(req.query.maxtries);
|
||||
// }
|
||||
//
|
||||
// BitboxHTTP({
|
||||
// method: 'post',
|
||||
// auth: {
|
||||
// username: username,
|
||||
// password: password
|
||||
// },
|
||||
// data: {
|
||||
// jsonrpc: "1.0",
|
||||
// id:"generatetoaddress",
|
||||
// method: "generatetoaddress",
|
||||
// params: [
|
||||
// req.params.nblocks,
|
||||
// req.params.address,
|
||||
// maxtries
|
||||
// ]
|
||||
// }
|
||||
// })
|
||||
// .then((response) => {
|
||||
// res.json(response.data.result);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// res.send(error.response.data.error.message);
|
||||
// });
|
||||
// });
|
||||
|
||||
module.exports = router
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
This health-check API can be used to test the server for aliveness and
|
||||
readiness.
|
||||
*/
|
||||
|
||||
"use strict"
|
||||
|
||||
const express = require("express")
|
||||
@@ -5,7 +10,7 @@ const router = express.Router()
|
||||
|
||||
/* GET home page. */
|
||||
router.get("/", (req, res, next) => {
|
||||
res.json({ status: "winning v2" })
|
||||
res.json({ status: true })
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
"use strict"
|
||||
|
||||
const express = require("express")
|
||||
const router = express.Router()
|
||||
|
||||
/* GET home page. */
|
||||
router.get("/", (req, res, next) => {
|
||||
res.render("swagger-v2")
|
||||
})
|
||||
|
||||
router.get("/v2", (req, res, next) => {
|
||||
res.render("swagger-v2")
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
A utility library for setting up greylog2 logging.
|
||||
*/
|
||||
|
||||
"use strict"
|
||||
|
||||
// This will be uncommented and correct once we have our logging server functioning.
|
||||
/*
|
||||
var graylog2 = require("graylog2");
|
||||
var logger = new graylog2.graylog({
|
||||
servers: [
|
||||
{ 'host': '127.0.0.1', port: 12201 },
|
||||
{ 'host': '127.0.0.2', port: 12201 }
|
||||
],
|
||||
hostname: 'server.name', // the name of this host
|
||||
// (optional, default: os.hostname())
|
||||
facility: 'Node.js', // the facility for these log messages
|
||||
// (optional, default: "Node.js")
|
||||
bufferSize: 1350 // max UDP packet size, should never exceed the
|
||||
// MTU of your system (optional, default: 1400)
|
||||
});
|
||||
|
||||
logger.on('error', function (error) {
|
||||
console.error('Error while trying to write to graylog2:', error);
|
||||
});
|
||||
*/
|
||||
|
||||
// This is just a placeholder function that will be replaced once we get the
|
||||
// greylog server working.
|
||||
function log(msg, obj) {
|
||||
//console.log(msg, obj)
|
||||
}
|
||||
|
||||
// This is just a placeholder function that will be replaced once we get the
|
||||
// greylog server working.
|
||||
function error(msg, obj) {
|
||||
if (!obj) console.error(msg)
|
||||
else console.error(msg, obj)
|
||||
}
|
||||
|
||||
// This is just a placeholder function that will be replaced once we get the
|
||||
// greylog server working.
|
||||
function debug(msg, obj) {
|
||||
//console.log(msg, obj)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
log,
|
||||
error,
|
||||
debug
|
||||
}
|
||||
@@ -5,7 +5,6 @@ const router = express.Router()
|
||||
const axios = require("axios")
|
||||
|
||||
const routeUtils = require("./route-utils")
|
||||
const logger = require("./logging.js")
|
||||
const wlogger = require("../../util/winston-logging")
|
||||
|
||||
// Used to convert error messages to strings, to safely pass to users.
|
||||
|
||||
@@ -5,7 +5,6 @@ const router = express.Router()
|
||||
const axios = require("axios")
|
||||
|
||||
const routeUtils = require("./route-utils")
|
||||
const logger = require("./logging.js")
|
||||
const wlogger = require("../../util/winston-logging")
|
||||
|
||||
// Used to convert error messages to strings, to safely pass to users.
|
||||
|
||||
@@ -5,7 +5,6 @@ const router = express.Router()
|
||||
const axios = require("axios")
|
||||
|
||||
const routeUtils = require("./route-utils")
|
||||
const logger = require("./logging.js")
|
||||
const strftime = require("strftime")
|
||||
const wlogger = require("../../util/winston-logging")
|
||||
|
||||
@@ -812,7 +811,7 @@ async function validateBulk(req, res, next) {
|
||||
})
|
||||
}
|
||||
|
||||
logger.debug(`Executing slp/validate with these txids: `, txids)
|
||||
wlogger.debug(`Executing slp/validate with these txids: `, txids)
|
||||
|
||||
// Validate each txid
|
||||
const validatePromises = txids.map(async txid => {
|
||||
@@ -865,7 +864,7 @@ async function validateSingle(req, res, next) {
|
||||
return res.json({ error: "txid can not be empty" })
|
||||
}
|
||||
|
||||
logger.debug(`Executing slp/validate/:txid with this txid: `, txid)
|
||||
wlogger.debug(`Executing slp/validate/:txid with this txid: `, txid)
|
||||
|
||||
// Validate txid
|
||||
// Dev note: must call module.exports to allow stubs in unit tests.
|
||||
|
||||
@@ -5,7 +5,6 @@ const router = express.Router()
|
||||
const axios = require("axios")
|
||||
|
||||
const routeUtils = require("./route-utils")
|
||||
const logger = require("./logging.js")
|
||||
const wlogger = require("../../util/winston-logging")
|
||||
|
||||
const BITBOXJS = require("@chris.troutner/bitbox-js")
|
||||
@@ -122,7 +121,7 @@ async function validateAddressBulk(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug(`Executing util/validate with these addresses: `, addresses)
|
||||
wlogger.debug(`Executing util/validate with these addresses: `, addresses)
|
||||
|
||||
const {
|
||||
BitboxHTTP,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
const express = require("express")
|
||||
const requestUtils = require("./services/requestUtils")
|
||||
const axios = require("axios")
|
||||
const logger = require("./logging.js")
|
||||
const routeUtils = require("./route-utils")
|
||||
const wlogger = require("../../util/winston-logging")
|
||||
|
||||
@@ -48,7 +47,6 @@ async function fromXPubSingle(req, res, next) {
|
||||
})
|
||||
}
|
||||
|
||||
logger.debug(`Executing address/fromXPub with this xpub: `, xpub)
|
||||
wlogger.debug(`Executing address/fromXPub with this xpub: `, xpub)
|
||||
|
||||
const cashAddr = BITBOX.Address.fromXPub(xpub, hdPath)
|
||||
@@ -67,7 +65,6 @@ async function fromXPubSingle(req, res, next) {
|
||||
}
|
||||
|
||||
// Write out error to error log.
|
||||
//logger.error(`Error in rawtransactions/decodeRawTransaction: `, err)
|
||||
wlogger.error(`Error in address.ts/fromXPubSingle().`, err)
|
||||
|
||||
res.status(500)
|
||||
|
||||
Reference in New Issue
Block a user