From 0f3ff119e8f67d778cd84e2043623f9b53dbdfa6 Mon Sep 17 00:00:00 2001 From: Micah Lerner Date: Mon, 4 Dec 2017 22:18:55 -0800 Subject: [PATCH] rpcserver: add SettleDate to rpcserver invoice response --- lnd_test.go | 6 +++++- rpcserver.go | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lnd_test.go b/lnd_test.go index 563ec40d..72787a93 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -2262,10 +2262,14 @@ func testInvoiceSubscriptions(net *networkHarness, t *harnessTest) { } // The invoice update should exactly match the invoice created - // above, but should now be settled. + // above, but should now be settled and have SettleDate if !invoiceUpdate.Settled { t.Fatalf("invoice not settled but shoudl be") } + if invoiceUpdate.SettleDate == 0 { + t.Fatalf("invoice should have non zero settle date, but doesn't") + } + if !bytes.Equal(invoiceUpdate.RPreimage, invoice.RPreimage) { t.Fatalf("payment preimages don't match: expected %v, got %v", invoice.RPreimage, invoiceUpdate.RPreimage) diff --git a/rpcserver.go b/rpcserver.go index c8d518f9..fbbc2fb8 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2123,6 +2123,11 @@ func createRPCInvoice(invoice *channeldb.Invoice) (*lnrpc.Invoice, error) { fallbackAddr = decoded.FallbackAddr.String() } + settleDate := int64(0) + if !invoice.SettleDate.IsZero() { + settleDate = invoice.SettleDate.Unix() + } + // Expiry time will default to 3600 seconds if not specified // explicitly. expiry := int64(decoded.Expiry().Seconds()) @@ -2140,6 +2145,7 @@ func createRPCInvoice(invoice *channeldb.Invoice) (*lnrpc.Invoice, error) { RPreimage: preimage[:], Value: int64(satAmt), CreationDate: invoice.CreationDate.Unix(), + SettleDate: settleDate, Settled: invoice.Terms.Settled, PaymentRequest: paymentRequest, DescriptionHash: descHash,