Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/tbtc faucet amounts #2188

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/api/routes/faucets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,34 @@ export const FaucetRoutes: FastifyPluginAsync<
preHandler: missingBtcConfigMiddleware,
schema: {
operationId: 'run_faucet_btc',
summary: 'Add testnet BTC tokens to address',
description: `Add 1 BTC token to the specified testnet BTC address.
summary: 'Add regtest BTC tokens to address',
description: `Add 0.01 BTC token to the specified regtest BTC address.

The endpoint returns the transaction ID, which you can use to view the transaction in a testnet Bitcoin block
The endpoint returns the transaction ID, which you can use to view the transaction in a regtest Bitcoin block
explorer. The tokens are delivered once the transaction has been included in a block.

**Note:** This is a testnet only endpoint. This endpoint will not work on the mainnet.`,
**Note:** This is a Bitcoin regtest-only endpoint. This endpoint will not work on the Bitcoin mainnet.`,
tags: ['Faucets'],
querystring: Type.Object({
address: Type.Optional(
Type.String({
description: 'A valid testnet BTC address',
description: 'A valid regtest BTC address',
examples: ['2N4M94S1ZPt8HfxydXzL2P7qyzgVq7MHWts'],
})
),
large: Type.Optional(
Type.Boolean({
description:
'Request a larger amount of regtest BTC than the default',
default: false,
})
),
}),
body: OptionalNullable(
Type.Object({
address: Type.Optional(
Type.String({
description: 'A valid testnet BTC address',
description: 'A valid regtest BTC address',
examples: ['2N4M94S1ZPt8HfxydXzL2P7qyzgVq7MHWts'],
})
),
Expand All @@ -112,7 +119,7 @@ export const FaucetRoutes: FastifyPluginAsync<
{
title: 'RunFaucetResponse',
description:
'POST request that initiates a transfer of tokens to a specified testnet address',
'POST request that initiates a transfer of tokens to a specified Bitcoin regtest address',
}
),
'4xx': Type.Object({
Expand All @@ -125,6 +132,7 @@ export const FaucetRoutes: FastifyPluginAsync<
async (req, reply) => {
await btcFaucetRequestQueue.add(async () => {
const address = req.query.address || req.body?.address;
const btcAmount = 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, btcAmount);
await fastify.writeDb?.insertFaucetRequest({
ip: `${ip}`,
address: address,
Expand All @@ -183,7 +191,7 @@ export const FaucetRoutes: FastifyPluginAsync<
tags: ['Faucets'],
params: Type.Object({
address: Type.String({
description: 'A valid testnet BTC address',
description: 'A valid regtest BTC address',
examples: ['2N4M94S1ZPt8HfxydXzL2P7qyzgVq7MHWts'],
}),
}),
Expand Down
Loading