lnrpc/invoicesrpc: remove lnrpc type from add invoice

This commit is contained in:
Joost Jager
2019-01-15 10:06:48 +01:00
parent b9cc165341
commit 8392f6d28f
4 changed files with 102 additions and 50 deletions

View File

@@ -38,6 +38,7 @@ import (
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/macaroons"
@@ -3291,7 +3292,37 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
ChanDB: r.server.chanDB,
}
return invoicesrpc.AddInvoice(ctx, addInvoiceCfg, invoice)
addInvoiceData := &invoicesrpc.AddInvoiceData{
Memo: invoice.Memo,
Receipt: invoice.Receipt,
Value: btcutil.Amount(invoice.Value),
DescriptionHash: invoice.DescriptionHash,
Expiry: invoice.Expiry,
FallbackAddr: invoice.FallbackAddr,
CltvExpiry: invoice.CltvExpiry,
Private: invoice.Private,
}
if invoice.RPreimage != nil {
preimage, err := lntypes.MakePreimage(invoice.RPreimage)
if err != nil {
return nil, err
}
addInvoiceData.Preimage = &preimage
}
hash, dbInvoice, err := invoicesrpc.AddInvoice(
ctx, addInvoiceCfg, addInvoiceData,
)
if err != nil {
return nil, err
}
return &lnrpc.AddInvoiceResponse{
AddIndex: dbInvoice.AddIndex,
PaymentRequest: string(dbInvoice.PaymentRequest),
RHash: hash[:],
}, nil
}
// LookupInvoice attempts to look up an invoice according to its payment hash.