nolim1t
5 years ago
No known key found for this signature in database
GPG Key ID: F6287B82CC84BCBD
3 changed files with
25 additions and
0 deletions
-
logic/bitcoind.js
-
routes/v1/bitcoind/info.js
-
services/bitcoind.js
|
|
@ -130,7 +130,16 @@ async function getTransaction(txid) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function getBlockHash(height) { |
|
|
|
const getBlockHashObj = await bitcoindService.getBlockHash(height); |
|
|
|
|
|
|
|
return { |
|
|
|
height: getBlockHashObj.result |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = { |
|
|
|
getBlockHash, |
|
|
|
getTransaction, |
|
|
|
getBlock, |
|
|
|
getBlockCount, |
|
|
|
|
|
@ -35,6 +35,17 @@ router.get('/version', auth.jwt, safeHandler((req, res) => |
|
|
|
.then(version => res.json(version)) |
|
|
|
)); |
|
|
|
|
|
|
|
router.get('/block', auth.jwt, safeHandler((req, res) => { |
|
|
|
if (req.query.hash !== undefined && req.query.hash !== null) { |
|
|
|
bitcoind.getBlock(req.query.hash) |
|
|
|
.then(blockhash => res.json(blockhash)) |
|
|
|
} else if (req.query.height !== undefined && req.query.height !== null) { |
|
|
|
bitcoind.getBlockHash(req.query.height) |
|
|
|
.then(blockhash => res.json(blockhash)) |
|
|
|
} |
|
|
|
} |
|
|
|
)); |
|
|
|
|
|
|
|
// /v1/bitcoind/info/block/<hash>
|
|
|
|
router.get('/block/:id', auth.jwt, safeHandler((req, res) => |
|
|
|
bitcoind.getBlock(req.params.id) |
|
|
|
|
|
@ -64,6 +64,10 @@ function promiseifyParamTwo(rpcObj, rpcFn, param1, param2, what) { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function getBlockHash(height) { |
|
|
|
return promiseifyParam(rpcClient, rpcClient.getBlockHash, height, 'block height'); |
|
|
|
} |
|
|
|
|
|
|
|
function getBlock(hash) { |
|
|
|
return promiseifyParam(rpcClient, rpcClient.getBlock, hash, 'block info'); |
|
|
|
} |
|
|
@ -105,6 +109,7 @@ function help() { |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = { |
|
|
|
getBlockHash, |
|
|
|
getBlock, |
|
|
|
getTransaction, |
|
|
|
getBlockChainInfo, |
|
|
|