Skip to content

Commit

Permalink
faucet: add command line option to denote chain of lnd node
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed May 2, 2017
1 parent d317e2a commit d9106f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion faucet.go
Expand Up @@ -113,14 +113,16 @@ type lightningFaucet struct {


templates *template.Template templates *template.Template


network string

openChanMtx sync.RWMutex openChanMtx sync.RWMutex
openChannels map[wire.OutPoint]time.Time openChannels map[wire.OutPoint]time.Time
} }


// newLightningFaucet creates a new channel faucet that's bound to a cluster of // 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. // lnd nodes, and uses the passed templates to render the web page.
func newLightningFaucet(lndHost string, 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. // First attempt to establish a connection to lnd's RPC sever.
opts := []grpc.DialOption{grpc.WithInsecure()} opts := []grpc.DialOption{grpc.WithInsecure()}
Expand All @@ -137,6 +139,7 @@ func newLightningFaucet(lndHost string,
return &lightningFaucet{ return &lightningFaucet{
lnd: lnd, lnd: lnd,
templates: templates, templates: templates,
network: network,
}, nil }, nil
} }


Expand Down Expand Up @@ -317,6 +320,9 @@ type homePageContext struct {
// NumConfs is the number of confirmations required for the channel to // NumConfs is the number of confirmations required for the channel to
// open up. // open up.
NumConfs uint32 NumConfs uint32

// Network is the network the faucet is running on.
Network string
} }


// fetchHomeState is helper functions that populates the homePageContext with // fetchHomeState is helper functions that populates the homePageContext with
Expand Down
7 changes: 6 additions & 1 deletion main.go
Expand Up @@ -52,6 +52,11 @@ var (
// work. // work.
domain = flag.String("domain", "faucet.lightning.community", "the "+ domain = flag.String("domain", "faucet.lightning.community", "the "+
"domain of the faucet, required for TLS") "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 // equal reports whether the first argument is equal to any of the remaining
Expand Down Expand Up @@ -95,7 +100,7 @@ func main() {
ParseGlob(templateGlobPattern)) ParseGlob(templateGlobPattern))


// With the templates loaded, create the faucet itself. // With the templates loaded, create the faucet itself.
faucet, err := newLightningFaucet(*lndNodes, faucetTemplates) faucet, err := newLightningFaucet(*lndNodes, faucetTemplates, *network)
if err != nil { if err != nil {
log.Fatalf("unable to create faucet: %v", err) log.Fatalf("unable to create faucet: %v", err)
return return
Expand Down
4 changes: 2 additions & 2 deletions static/index.html
Expand Up @@ -5,7 +5,7 @@
<div class="col m3"> </div> <div class="col m3"> </div>
<div class="center col s12 m6"> <div class="center col s12 m6">
<a href="/"> <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> </a>
<ul class="collection"> <ul class="collection">
<li class="collection-item">{{ .NodeAddr }}</li> <li class="collection-item">{{ .NodeAddr }}</li>
Expand All @@ -21,7 +21,7 @@ <h1 id="title" class="flow-text">Testnet Lightning Network Faucet</h1>
<div class="center col m6"> <div class="center col m6">
<div class="chan-form card-panel hoverable"> <div class="chan-form card-panel hoverable">
{{if eq .ChannelTxid ""}} {{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 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> <h6 class="flow-text">The max channel size is 4 million satoshis. </h6>


Expand Down

0 comments on commit d9106f5

Please sign in to comment.