Merge pull request #166 from ethanmackie/master

Adding a getCurrencyInfo endpoint to bch-api in both v4 and v5 routes
This commit is contained in:
Chris Troutner
2021-10-29 09:48:14 -07:00
committed by GitHub
2 changed files with 88 additions and 0 deletions
+44
View File
@@ -59,6 +59,7 @@ class UtilRoute {
this.router.get('/validateAddress/:address', this.validateAddressSingle)
this.router.post('/validateAddress', this.validateAddressBulk)
this.router.post('/sweep', this.sweepWif)
this.router.get('/getCurrencyInfo', this.getCurrencyInfo)
_this = this
}
@@ -67,6 +68,49 @@ class UtilRoute {
return res.json({ status: 'util' })
}
/**
* @api {get} /util/getCurrencyInfo Get information about the currency.
* @apiName getCurrencyInfo
* @apiGroup Util
* @apiDescription Returns an object containing information about the currency.
*
*
* @apiExample Example usage:
* curl -X GET "https://api.fullstack.cash/v4/util/getCurrencyInfo" -H "accept: application/json"
*
*
*/
async getCurrencyInfo (req, res, next) {
try {
const {
BitboxHTTP,
// username,
// password,
requestConfig
} = routeUtils.setEnvVars()
requestConfig.data.id = 'getcurrencyinfo'
requestConfig.data.method = 'getcurrencyinfo'
const response = await BitboxHTTP(requestConfig)
return res.json(response.data.result)
} catch (err) {
// Attempt to decode the error message.
const { msg, status } = routeUtils.decodeError(err)
if (msg) {
res.status(status)
return res.json({ error: msg })
}
wlogger.error('Error in util.ts/getCurrencyInfo().', err)
res.status(500)
return res.json({ error: util.inspect(err) })
}
}
/**
* @api {get} /util/validateAddress/{address} Get information about single bitcoin cash address.
* @apiName Information about single bitcoin cash address
+44
View File
@@ -39,6 +39,7 @@ class UtilRoute {
this.router.get('/', this.root)
this.router.get('/validateAddress/:address', this.validateAddressSingle)
this.router.post('/validateAddress', this.validateAddressBulk)
this.router.get('/getCurrencyInfo', this.getCurrencyInfo)
// this.router.post('/sweep', this.sweepWif)
// _this = this
@@ -48,6 +49,49 @@ class UtilRoute {
return res.json({ status: 'util' })
}
/**
* @api {get} /util/getCurrencyInfo Get information about the currency.
* @apiName getCurrencyInfo
* @apiGroup Util
* @apiDescription Returns an object containing information about the currency.
*
*
* @apiExample Example usage:
* curl -X GET "https://api.fullstack.cash/v5/util/getCurrencyInfo" -H "accept: application/json"
*
*
*/
async getCurrencyInfo (req, res, next) {
try {
const {
BitboxHTTP,
// username,
// password,
requestConfig
} = routeUtils.setEnvVars()
requestConfig.data.id = 'getcurrencyinfo'
requestConfig.data.method = 'getcurrencyinfo'
const response = await BitboxHTTP(requestConfig)
return res.json(response.data.result)
} catch (err) {
// Attempt to decode the error message.
const { msg, status } = routeUtils.decodeError(err)
if (msg) {
res.status(status)
return res.json({ error: msg })
}
wlogger.error('Error in util.ts/getCurrencyInfo().', err)
res.status(500)
return res.json({ error: util.inspect(err) })
}
}
/**
* @api {get} /util/validateAddress/{address} Get information about single bitcoin cash address.
* @apiName Information about single bitcoin cash address