Merge pull request #265 from nodar-chkuaselidze/fix/rpc-requests

REST API fixes
This commit is contained in:
Christopher Jeffrey (JJ) 2017-08-17 17:23:04 -07:00 committed by GitHub
commit 2c8fcafa0a
2 changed files with 25 additions and 3 deletions

View File

@ -318,7 +318,18 @@ HTTPClient.prototype.getInfo = function getInfo() {
*/
HTTPClient.prototype.getCoinsByAddress = function getCoinsByAddress(address) {
return this._post('/coin/address', { address });
return this._get(`/coin/address/${address}`);
};
/**
* Get coins that pertain to addresses from the mempool or chain database.
* Takes into account spent coins in the mempool.
* @param {String[]} addresses
* @returns {Promise} - Returns {@link Coin}[].
*/
HTTPClient.prototype.getCoinsByAddresses = function getCoinsByAddresses(addresses) {
return this._post('/coin/address', { addresses });
};
/**
@ -341,7 +352,18 @@ HTTPClient.prototype.getCoin = function getCoin(hash, index) {
*/
HTTPClient.prototype.getTXByAddress = function getTXByAddress(address) {
return this._post('/tx/address', { address });
return this._get(`/tx/address/${address}`);
};
/**
* Retrieve transactions pertaining to
* addresses from the mempool or chain database.
* @param {String[]} addresses
* @returns {Promise} - Returns {@link TX}[].
*/
HTTPClient.prototype.getTXByAddresses = function getTXByAddresses(addresses) {
return this._post('/tx/address', { addresses });
};
/**

View File

@ -235,7 +235,7 @@ HTTPServer.prototype.initRouter = function initRouter() {
// Bulk read TXs
this.post('/tx/address', async (req, res) => {
const valid = req.valid();
const address = valid.array('address');
const address = valid.array('addresses');
enforce(address, 'Address is required.');
enforce(!this.chain.options.spv, 'Cannot get TX in SPV mode.');