Skip to content

Commit

Permalink
Added possibility to simply forward address to an exisiting one
Browse files Browse the repository at this point in the history
  • Loading branch information
believethehype committed Mar 10, 2023
1 parent f5329e6 commit 64d605b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
9 changes: 6 additions & 3 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ func SaveName(
params.Name = name
params.Domain = domain

// check if the given data works
if inv, err = makeInvoice(params, 1000, &pin, "", ""); err != nil {
return "", "", fmt.Errorf("couldn't make an invoice with the given data: %w", err)
if params.Kind != "forward" {
// check if the given data works
if inv, err = makeInvoice(params, 1000, &pin, "", ""); err != nil {
return "", "", fmt.Errorf("couldn't make an invoice with the given data: %w", err)
}

}

// save it
Expand Down
3 changes: 3 additions & 0 deletions grab.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
<button class="copy-button" @click="copyToClipboard">
{{ copied ? 'Copied!' : 'Copy Secret PIN' }}
</button>
<div v-if="invoice != ''">
<div class="bold-small">
To ensure the connection with your Lightning backend is configured
properly, we've created a test invoice that can be seen below.
</div>

<canvas id="qr"></canvas>
<div class="code">{{ invoice }}</div>
</div>
</div>
<div class="resources">
<a class="resource-button" target="_blank" href="https://t.me/lnurl">
Not working? Ask for help!
Expand Down
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,26 @@
<option value="sparko">Sparko (CLN)</option>
<option value="eclair">Eclair</option>
<option value="lnpay">LNPay</option>
<option value="forward">Forward</option>

</select>
</div>

<div v-if="kind == 'forward'">
<div class="field">
<label for="host">
Forward URl
</label>
<input
class="input full-width"
name="host"
id="host"
placeholder="https://walletofsatoshi.com/.well-known/lnurlp/ninthtractor31"
/>
</div>

</div>

<div v-if="kind == 'lnd'">
<div class="field">
<label for="host">
Expand Down
5 changes: 5 additions & 0 deletions lnurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func handleLNURL(w http.ResponseWriter, r *http.Request) {
return
}

if params.Kind == "forward" {
http.Redirect(w, r, params.Host, http.StatusSeeOther)
return
}

log.Info().Str("username", username).Str("domain", domain).Msg("got lnurl request")

if amount := r.URL.Query().Get("amount"); amount == "" {
Expand Down
9 changes: 6 additions & 3 deletions nostr.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ func handleNip05(w http.ResponseWriter, r *http.Request) {
}

if s.Nip05 {
middlestringtrim := middlestring[:len(middlestring)-2]
middlestringtrim += "\n"
response = firstpartstring + middlestringtrim + finalpartstring
if len(middlestring) > 2 {
middlestringtrim := middlestring[:len(middlestring)-2]

middlestringtrim += "\n"
response = firstpartstring + middlestringtrim + finalpartstring
}
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
fmt.Fprintf(w, response)
Expand Down

0 comments on commit 64d605b

Please sign in to comment.