|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
"encoding/hex"
|
|
|
|
"encoding/hex"
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"log"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
@ -92,6 +93,7 @@ type Invoice struct {
|
|
|
|
Msatoshi float64 `json:"msatoshi"`
|
|
|
|
Msatoshi float64 `json:"msatoshi"`
|
|
|
|
Payreq string `json:"payreq"`
|
|
|
|
Payreq string `json:"payreq"`
|
|
|
|
RHash string `json:"rhash"`
|
|
|
|
RHash string `json:"rhash"`
|
|
|
|
|
|
|
|
PreImage string `json:"-"` // used as secret admin token
|
|
|
|
Status string `json:"status"`
|
|
|
|
Status string `json:"status"`
|
|
|
|
PaidAt timestamp `json:"paid_at"`
|
|
|
|
PaidAt timestamp `json:"paid_at"`
|
|
|
|
CreatedAt timestamp `json:"created_at"`
|
|
|
|
CreatedAt timestamp `json:"created_at"`
|
|
|
@ -112,12 +114,14 @@ func (i *Invoice) UnmarshalBinary(b []byte) error {
|
|
|
|
// Create new Invoice from lnrpc.Invoice
|
|
|
|
// Create new Invoice from lnrpc.Invoice
|
|
|
|
func InvoiceFromLndIn(lndInvoice *lnrpc.Invoice) *Invoice {
|
|
|
|
func InvoiceFromLndIn(lndInvoice *lnrpc.Invoice) *Invoice {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.Println(hex.EncodeToString(lndInvoice.RPreimage))
|
|
|
|
invoice := Invoice{
|
|
|
|
invoice := Invoice{
|
|
|
|
AddIndex: lndInvoice.AddIndex,
|
|
|
|
AddIndex: lndInvoice.AddIndex,
|
|
|
|
Description: lndInvoice.GetMemo(),
|
|
|
|
Description: lndInvoice.GetMemo(),
|
|
|
|
Msatoshi: float64(lndInvoice.Value * 1000),
|
|
|
|
Msatoshi: float64(lndInvoice.Value * 1000),
|
|
|
|
Payreq: lndInvoice.PaymentRequest,
|
|
|
|
Payreq: lndInvoice.PaymentRequest,
|
|
|
|
RHash: hex.EncodeToString(lndInvoice.RHash),
|
|
|
|
RHash: hex.EncodeToString(lndInvoice.RHash),
|
|
|
|
|
|
|
|
PreImage: hex.EncodeToString(lndInvoice.RPreimage),
|
|
|
|
CreatedAt: timestamp(time.Unix(lndInvoice.CreationDate, 0)),
|
|
|
|
CreatedAt: timestamp(time.Unix(lndInvoice.CreationDate, 0)),
|
|
|
|
Status: InvoiceStatus[UnPaid],
|
|
|
|
Status: InvoiceStatus[UnPaid],
|
|
|
|
}
|
|
|
|
}
|
|
|
|