@@ -74,27 +74,39 @@ export const FaucetRoutes: FastifyPluginAsync<
74
74
preHandler : missingBtcConfigMiddleware ,
75
75
schema : {
76
76
operationId : 'run_faucet_btc' ,
77
- summary : 'Add testnet BTC tokens to address' ,
78
- description : `Add 1 BTC token to the specified testnet BTC address.
77
+ summary : 'Add regtest BTC tokens to address' ,
78
+ description : `Add 0.01 BTC token to the specified regtest BTC address.
79
79
80
- The endpoint returns the transaction ID, which you can use to view the transaction in a testnet Bitcoin block
80
+ The endpoint returns the transaction ID, which you can use to view the transaction in a regtest Bitcoin block
81
81
explorer. The tokens are delivered once the transaction has been included in a block.
82
82
83
- **Note:** This is a testnet only endpoint. This endpoint will not work on the mainnet.` ,
83
+ **Note:** This is a Bitcoin regtest- only endpoint. This endpoint will not work on the Bitcoin mainnet.` ,
84
84
tags : [ 'Faucets' ] ,
85
85
querystring : Type . Object ( {
86
86
address : Type . Optional (
87
87
Type . String ( {
88
- description : 'A valid testnet BTC address' ,
88
+ description : 'A valid regtest BTC address' ,
89
89
examples : [ '2N4M94S1ZPt8HfxydXzL2P7qyzgVq7MHWts' ] ,
90
90
} )
91
91
) ,
92
+ large : Type . Optional (
93
+ Type . Boolean ( {
94
+ description : 'Request a large amount of regtest BTC than the default' ,
95
+ default : false ,
96
+ } )
97
+ ) ,
98
+ xlarge : Type . Optional (
99
+ Type . Boolean ( {
100
+ description : 'Request an extra large amount of regtest BTC than the default' ,
101
+ default : false ,
102
+ } )
103
+ ) ,
92
104
} ) ,
93
105
body : OptionalNullable (
94
106
Type . Object ( {
95
107
address : Type . Optional (
96
108
Type . String ( {
97
- description : 'A valid testnet BTC address' ,
109
+ description : 'A valid regtest BTC address' ,
98
110
examples : [ '2N4M94S1ZPt8HfxydXzL2P7qyzgVq7MHWts' ] ,
99
111
} )
100
112
) ,
@@ -112,7 +124,7 @@ export const FaucetRoutes: FastifyPluginAsync<
112
124
{
113
125
title : 'RunFaucetResponse' ,
114
126
description :
115
- 'POST request that initiates a transfer of tokens to a specified testnet address' ,
127
+ 'POST request that initiates a transfer of tokens to a specified Bitcoin regtest address' ,
116
128
}
117
129
) ,
118
130
'4xx' : Type . Object ( {
@@ -125,6 +137,21 @@ export const FaucetRoutes: FastifyPluginAsync<
125
137
async ( req , reply ) => {
126
138
await btcFaucetRequestQueue . add ( async ( ) => {
127
139
const address = req . query . address || req . body ?. address ;
140
+ let btcAmount = 0.0001 ;
141
+
142
+ if ( req . query . large && req . query . xlarge ) {
143
+ return await reply . status ( 400 ) . send ( {
144
+ error : 'cannot simultaneously request a large and xlarge amount' ,
145
+ success : false ,
146
+ } ) ;
147
+ }
148
+
149
+ if ( req . query . large ) {
150
+ btcAmount = 0.01 ;
151
+ } else if ( req . query . xlarge ) {
152
+ btcAmount = 0.5 ;
153
+ }
154
+
128
155
if ( ! address ) {
129
156
return await reply . status ( 400 ) . send ( {
130
157
error : 'address required' ,
@@ -156,7 +183,7 @@ export const FaucetRoutes: FastifyPluginAsync<
156
183
} ) ;
157
184
}
158
185
159
- const tx = await makeBtcFaucetPayment ( btc . networks . regtest , address , 0.5 ) ;
186
+ const tx = await makeBtcFaucetPayment ( btc . networks . regtest , address , btcAmount ) ;
160
187
await fastify . writeDb ?. insertFaucetRequest ( {
161
188
ip : `${ ip } ` ,
162
189
address : address ,
@@ -183,7 +210,7 @@ export const FaucetRoutes: FastifyPluginAsync<
183
210
tags : [ 'Faucets' ] ,
184
211
params : Type . Object ( {
185
212
address : Type . String ( {
186
- description : 'A valid testnet BTC address' ,
213
+ description : 'A valid regtest BTC address' ,
187
214
examples : [ '2N4M94S1ZPt8HfxydXzL2P7qyzgVq7MHWts' ] ,
188
215
} ) ,
189
216
} ) ,
0 commit comments