Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Merge 23190cf into cbf1542
Browse files Browse the repository at this point in the history
  • Loading branch information
Franco Victorio committed Jun 7, 2018
2 parents cbf1542 + 23190cf commit bd20f54
Show file tree
Hide file tree
Showing 7 changed files with 2,673 additions and 2,566 deletions.
12 changes: 12 additions & 0 deletions web-dapp/controllers/notifyRegTx.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const validateAddressIndex = require('../server-lib/validate_address_index');
const getAddressIndex = require('../server-lib/get_address_index');
const getAddressDetails = require('../server-lib/get_address_details');
const postcardLimiter = require('../server-lib/postcard_limiter');
const getSha3cc = require('../server-lib/get_sha3cc');

const validateData = (opts, prelog = '') => {
if (!opts.body) return createResponseObject(false, 'request body: empty');
Expand Down Expand Up @@ -150,6 +151,16 @@ const removeUsedSessionKey = (opts, prelog) => {
});
};

const validateTx = (txId, sha3cc) => {
return getSha3cc(txId)
.then(txSha3cc => {
const valid = txSha3cc === sha3cc;
if (!valid) {
throw new Error(`Invalid transaction ${txId}`);
}
});
};

const unlockSession = (sessionKey, prelog) => {
logger.log(`${prelog} unlocking session: ${sessionKey}`);
return db.unlock(sessionKey);
Expand All @@ -163,5 +174,6 @@ module.exports = {
getAddressByBN,
createPostCard,
removeUsedSessionKey,
validateTx,
unlockSession,
};
Loading

0 comments on commit bd20f54

Please sign in to comment.