Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handleV2VerifyAddress(req: express.Request): { isValid: boolean } {
if (!_.isString(req.body.address)) {
throw new Error('Expected address to be a string');
}
if (req.body.supportOldScriptHashVersion !== undefined && !_.isBoolean(req.body.supportOldScriptHashVersion)) {
throw new Error('Expected supportOldScriptHashVersion to be a boolean.');
}
const bitgo = req.bitgo;
const coin = bitgo.coin(req.params.coin);
if (coin instanceof Coin.AbstractUtxoCoin) {
return {
isValid: coin.isValidAddress(req.body.address, !!req.body.supportOldScriptHashVersion),
};
}
return {
isValid: coin.isValidAddress(req.body.address),
};
}