Skip to content

Commit

Permalink
Merge pull request #264 from HathorNetwork/dev
Browse files Browse the repository at this point in the history
Release v0.19.2
  • Loading branch information
r4mmer authored Dec 20, 2022
2 parents 34b6d45 + 004ffc5 commit f8c95fa
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
18 changes: 18 additions & 0 deletions __tests__/send-tx.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HathorWallet } from '@hathor/wallet-lib';
import TestUtils from './test-utils';
import { MAX_DATA_SCRIPT_LENGTH } from '../src/constants';

Expand Down Expand Up @@ -321,4 +322,21 @@ describe('send-tx api', () => {
expect(response2.body.hash).toBeTruthy();
expect(response2.body.success).toBeTruthy();
});

it('should log errors on send-tx when debug=true on req.body', async () => {
const spy = jest.spyOn(HathorWallet.prototype, 'sendManyOutputsTransaction').mockImplementation(() => {
throw new Error('Boom!');
});
const response = await TestUtils.request
.post('/wallet/send-tx')
.send({
debug: true,
outputs: [{ address: 'WPynsVhyU6nP7RSZAkqfijEutC88KgAyFc', value: 1 }],
})
.set({ 'x-wallet-id': walletId });
expect(response.status).toBe(200);
expect(response.body.success).toBeFalsy();
expect(response.body.error).toEqual('Boom!');
spy.mockRestore();
});
});
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hathor-wallet-headless",
"version": "0.19.1",
"version": "0.19.2",
"description": "Hathor Wallet Headless, i.e., without graphical user interface",
"main": "index.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/api-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const apiDoc = {
info: {
title: 'Headless Hathor Wallet API',
description: 'This wallet is fully controlled through an HTTP API.',
version: '0.19.1',
version: '0.19.2',
},
produces: ['application/json'],
components: {
Expand Down
8 changes: 5 additions & 3 deletions src/controllers/wallet/wallet.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* LICENSE file in the root directory of this source tree.
*/

// import is used because there is an issue with winston logger when using require ref: #262
import logger from '../../logger'; // eslint-disable-line import/no-import-module-exports

const { txApi, walletApi, constants: hathorLibConstants, helpersUtils, errors, tokensUtils, PartialTx } = require('@hathor/wallet-lib');
const { matchedData } = require('express-validator');
const { parametersValidation } = require('../../helpers/validations.helper');
const { lock, lockTypes } = require('../../lock');
const { cantSendTxErrorMessage, friendlyWalletState } = require('../../helpers/constants');
const { mapTxReturn, prepareTxFunds } = require('../../helpers/tx.helper');
const logger = require('../../logger');
const { initializedWallets } = require('../../services/wallets.service');

function getStatus(req, res) {
Expand Down Expand Up @@ -363,8 +365,8 @@ async function sendTx(req, res) {
const ret = { success: false, error: err.message };
if (debug) {
logger.debug('/send-tx failed', {
body: req.body,
response: ret,
body: JSON.stringify(req.body),
response: JSON.stringify(ret),
});
}
res.send(ret);
Expand Down

0 comments on commit f8c95fa

Please sign in to comment.