Skip to content

Commit

Permalink
feat: change tbtc faucet default, allow user to request more than def…
Browse files Browse the repository at this point in the history
…ault
  • Loading branch information
CharlieC3 committed Dec 17, 2024
1 parent 35eec3b commit 8e3f288
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/api/routes/faucets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const FaucetRoutes: FastifyPluginAsync<
schema: {
operationId: 'run_faucet_btc',
summary: 'Add testnet BTC tokens to address',
description: `Add 1 BTC token to the specified testnet BTC address.
description: `Add 0.01 BTC token to the specified testnet BTC address.
The endpoint returns the transaction ID, which you can use to view the transaction in a testnet Bitcoin block
explorer. The tokens are delivered once the transaction has been included in a block.
Expand All @@ -89,6 +89,13 @@ export const FaucetRoutes: FastifyPluginAsync<
examples: ['2N4M94S1ZPt8HfxydXzL2P7qyzgVq7MHWts'],
})
),
large: Type.Optional(
Type.Boolean({
description:
'Request a larger amount of testnet BTC than the default',
default: false,
})
),
}),
body: OptionalNullable(
Type.Object({
Expand Down Expand Up @@ -125,6 +132,7 @@ export const FaucetRoutes: FastifyPluginAsync<
async (req, reply) => {
await btcFaucetRequestQueue.add(async () => {
const address = req.query.address || req.body?.address;
const tbtcAmount = req.query.large ? 0.5 : 0.01;
if (!address) {
return await reply.status(400).send({
error: 'address required',
Expand Down Expand Up @@ -156,7 +164,7 @@ export const FaucetRoutes: FastifyPluginAsync<
});
}

const tx = await makeBtcFaucetPayment(btc.networks.regtest, address, 0.5);
const tx = await makeBtcFaucetPayment(btc.networks.regtest, address, tbtcAmount);
await fastify.writeDb?.insertFaucetRequest({
ip: `${ip}`,
address: address,
Expand Down

0 comments on commit 8e3f288

Please sign in to comment.