Permalink
Browse files

faucet: add command line option to denote chain of lnd node

  • Loading branch information...
Roasbeef committed May 2, 2017
1 parent d317e2a commit d9106f5f95f496e42520adc8f6fd9382961b314e
Showing with 15 additions and 4 deletions.
  1. +7 −1 faucet.go
  2. +6 −1 main.go
  3. +2 −2 static/index.html
View
@@ -113,14 +113,16 @@ type lightningFaucet struct {
templates *template.Template
network string
openChanMtx sync.RWMutex
openChannels map[wire.OutPoint]time.Time
}
// newLightningFaucet creates a new channel faucet that's bound to a cluster of
// lnd nodes, and uses the passed templates to render the web page.
func newLightningFaucet(lndHost string,
templates *template.Template) (*lightningFaucet, error) {
templates *template.Template, network string) (*lightningFaucet, error) {
// First attempt to establish a connection to lnd's RPC sever.
opts := []grpc.DialOption{grpc.WithInsecure()}
@@ -137,6 +139,7 @@ func newLightningFaucet(lndHost string,
return &lightningFaucet{
lnd: lnd,
templates: templates,
network: network,
}, nil
}
@@ -317,6 +320,9 @@ type homePageContext struct {
// NumConfs is the number of confirmations required for the channel to
// open up.
NumConfs uint32
// Network is the network the faucet is running on.
Network string
}
// fetchHomeState is helper functions that populates the homePageContext with
View
@@ -52,6 +52,11 @@ var (
// work.
domain = flag.String("domain", "faucet.lightning.community", "the "+
"domain of the faucet, required for TLS")
// network is the network the faucet is running on. This value must
// either be "litecoin" or "bitcoin".
network = flag.String("network", "bitcoin", "the network of the "+
"faucet")
)
// equal reports whether the first argument is equal to any of the remaining
@@ -95,7 +100,7 @@ func main() {
ParseGlob(templateGlobPattern))
// With the templates loaded, create the faucet itself.
faucet, err := newLightningFaucet(*lndNodes, faucetTemplates)
faucet, err := newLightningFaucet(*lndNodes, faucetTemplates, *network)
if err != nil {
log.Fatalf("unable to create faucet: %v", err)
return
View
@@ -5,7 +5,7 @@
<div class="col m3"> </div>
<div class="center col s12 m6">
<a href="/">
<h1 id="title" class="flow-text">Testnet Lightning Network Faucet</h1>
<h1 id="title" class="flow-text">{{ if eq .Network "bitcoin" }} Bitcoin {{else}} Litecoin {{end}} Testnet Lightning Network Faucet</h1>
</a>
<ul class="collection">
<li class="collection-item">{{ .NodeAddr }}</li>
@@ -21,7 +21,7 @@ <h1 id="title" class="flow-text">Testnet Lightning Network Faucet</h1>
<div class="center col m6">
<div class="chan-form card-panel hoverable">
{{if eq .ChannelTxid ""}}
<h6 class="flow-text">{{ .NumCoins }} BTC are available for channel creation. </h6>
<h6 class="flow-text">{{ .NumCoins }} {{ if eq .Network "bitcoin" }} BTC {{else}} LTC {{end}} are available for channel creation. </h6>
<h6 class="flow-text">The faucet has {{ .NumChannels }} active {{if eq .NumChannels 1}} channel {{else}} channels {{end}} on the network. </h6>
<h6 class="flow-text">The max channel size is 4 million satoshis. </h6>

0 comments on commit d9106f5

Please sign in to comment.