[bitcoin core] fix getMempoolAncestors verbose param

This commit is contained in:
nymkappa 2024-01-12 16:38:11 +01:00
parent b38bbb9513
commit f161f7e8e2
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04

View File

@ -163,22 +163,17 @@ class BitcoinBackendRoutes {
res.status(400).send(`invalid param txid ${txid}. must be a string of 64 char`); res.status(400).send(`invalid param txid ${txid}. must be a string of 64 char`);
return; return;
} }
if (typeof(verbose) !== 'string') { if (typeof(verbose) !== 'string' || (verbose !== 'true' && verbose !== 'false')) {
res.status(400).send(`invalid param verbose ${verbose}. must be a string representing an integer`); res.status(400).send(`invalid param verbose ${verbose}. must be a string ('true' | 'false')`);
return; return;
} }
const verboseNumber = parseInt(verbose, 10);
if (typeof(verboseNumber) !== 'number') { const ancestors = await bitcoinClient.getMempoolAncestors(txid, verbose === 'true' ? true : false);
res.status(400).send(`invalid param verbose ${verbose}. must be a valid integer`); if (!ancestors) {
return;
}
const decodedTx = await bitcoinClient.getMempoolAncestors(txid, verboseNumber);
if (!decodedTx) {
res.status(400).send(`unable to get mempool ancestors for txid ${txid}`); res.status(400).send(`unable to get mempool ancestors for txid ${txid}`);
return; return;
} }
res.status(200).send(decodedTx); res.status(200).send(ancestors);
} catch (e: any) { } catch (e: any) {
BitcoinBackendRoutes.handleException(e, 'getMempoolAncestors', res); BitcoinBackendRoutes.handleException(e, 'getMempoolAncestors', res);
} }