-
Notifications
You must be signed in to change notification settings - Fork 8
Add UI Support for Faucet Endpoint #56
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
base: master
Are you sure you want to change the base?
Conversation
Although my use case only requires Bitcoin, I know that Liquid is also supported by Nigiri. If it's limited to a single network, I can easily inject it into the HTML template. Otherwise, I’d prefer to add a dropdown menu to allow selecting the network. |
the faucet supporst both network yes, based on the address type |
But the question is: can I know the network a priori? Looking at the code, it seems like the network is chosen based on the configuration rather than the address. Correct me if I'm wrong:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds UI support for the faucet endpoint by creating a web interface that allows users to interact with the faucet feature through a browser instead of using CLI commands or raw API calls. The implementation provides a user-friendly HTML form for requesting Bitcoin or Liquid Bitcoin from the faucet.
Key Changes
- Added a new HTML template with a responsive form interface for faucet requests
- Registered a GET route handler for
/faucet
to serve the UI page - Implemented server-side template rendering with network-specific data
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
router/main.go | Adds GET route handler for /faucet endpoint to serve the UI page |
router/faucet_handler.go | Implements HandleFaucetPage function to render HTML template with network data |
pages/faucet.html | Creates responsive HTML interface with form for faucet requests and JavaScript for API calls |
faucet := faucet.NewFaucet(config.RPCServerURL(), rpcClient) | ||
r.Faucet = faucet | ||
r.HandleFunc("/faucet", r.HandleFaucetRequest).Methods(http.MethodPost, http.MethodOptions) | ||
r.HandleFunc("/faucet", r.HandleFaucetPage).Methods(http.MethodGet, http.MethodOptions) |
Copilot
AI
Aug 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the same path /faucet
for both GET and POST methods could be confusing. Consider using a more specific path like /faucet/ui
for the UI page as mentioned in the PR description, which would make the API more self-documenting and avoid potential routing conflicts.
r.HandleFunc("/faucet", r.HandleFaucetPage).Methods(http.MethodGet, http.MethodOptions) | |
r.HandleFunc("/faucet/ui", r.HandleFaucetPage).Methods(http.MethodGet, http.MethodOptions) |
Copilot uses AI. Check for mistakes.
|
||
// HandleFaucetPage will return an HTML page that will allow us to interact with the faucet endpoints | ||
func (r *Router) HandleFaucetPage(res http.ResponseWriter, _ *http.Request) { | ||
filepath := "pages/faucet.html" |
Copilot
AI
Aug 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded file path "pages/faucet.html" makes the code less maintainable and could fail if the file structure changes. Consider making this configurable or using a constant to define template paths.
filepath := "pages/faucet.html" | |
filepath := faucetPageTemplatePath |
Copilot uses AI. Check for mistakes.
type PageData struct { | ||
Network string | ||
Asset string | ||
} |
Copilot
AI
Aug 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The PageData struct is defined inside the function scope. Consider moving it to package level or using an existing struct type to improve code organization and reusability.
type PageData struct { | |
Network string | |
Asset string | |
} |
Copilot uses AI. Check for mistakes.
This PR adds a new HTML template to support the
/faucet
endpoint, enabling a basic frontend interface for the faucet feature. The goal is to provide a user-friendly way to interact with the faucet without using raw API calls or the nigiri CLI.The motivation for this change came while I was developing my wallet using Nigiri to deploy a local Bitcoin test network. Although the CLI-based faucet is effective and scriptable, I found it disruptive to break my workflow or run scripts just to request BTC manually. This new page offers a more accessible alternative that introduces no breaking changes and can coexist with the existing CLI and API methods.
Modified Files:
pages/faucet
router/main.go
/faucet/ui
.router/faucet
/faucet/ui
.How to Test:
Desing
This is how it looks