Compare commits
	
		
			2 Commits
		
	
	
		
			43a2b4e9d5
			...
			99c48cb684
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 99c48cb684 | |||
| 6e39698f18 | 
| @ -3,7 +3,7 @@ package lightning | ||||
| type Bolt11 string | ||||
| 
 | ||||
| type Lightning interface { | ||||
| 	CreateInvoice(msats int64, comment string) (Bolt11, error) | ||||
| 	CreateInvoice(msats int64, description string) (Bolt11, error) | ||||
| } | ||||
| 
 | ||||
| type LightningImpl struct { | ||||
|  | ||||
| @ -53,10 +53,10 @@ func WithPhoenixdWebhookUrl(webhookUrl string) func(*Phoenixd) *Phoenixd { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (p *Phoenixd) CreateInvoice(msats int64, comment string) (lightning.Bolt11, error) { | ||||
| func (p *Phoenixd) CreateInvoice(msats int64, description string) (lightning.Bolt11, error) { | ||||
| 	values := url.Values{} | ||||
| 	values.Add("amountSat", strconv.FormatInt(msats/1000, 10)) | ||||
| 	values.Add("description", comment) | ||||
| 	values.Add("description", description) | ||||
| 	if p.webhookUrl != "" { | ||||
| 		values.Add("webhookUrl", p.webhookUrl) | ||||
| 	} | ||||
|  | ||||
| @ -38,7 +38,7 @@ func payRequest(c echo.Context) error { | ||||
| 			"callback":       callback, | ||||
| 			"minSendable":    MIN_SENDABLE_AMOUNT, | ||||
| 			"maxSendable":    MAX_SENDABLE_AMOUNT, | ||||
| 			"metadata":       fmt.Sprintf("[[\"text/plain\",\"paying %s\"]]", name), | ||||
| 			"metadata":       lnurlMetadata(c), | ||||
| 			"tag":            "payRequest", | ||||
| 			"commentAllowed": MAX_COMMENT_LENGTH, | ||||
| 		}, | ||||
| @ -78,6 +78,14 @@ func pay(ln lightning.Lightning) echo.HandlerFunc { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func lnurlMetadata(c echo.Context) string { | ||||
| 	s := "[" | ||||
| 	s += fmt.Sprintf("[\"text/plain\",\"Paying %s@%s\"]", c.Param("name"), c.Request().Host) | ||||
| 	s += fmt.Sprintf(",[\"text/identifier\",\"%s@%s\"]", c.Param("name"), c.Request().Host) | ||||
| 	s += "]" | ||||
| 	return s | ||||
| } | ||||
| 
 | ||||
| func lnurlError(c echo.Context, code int, err error) error { | ||||
| 	return c.JSON(code, map[string]any{"status": "ERROR", "error": err.Error()}) | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user