multi: restructure invoice Terms field

This commit restructures an invoice's ContractTerms to better encompass
the restrictions placed on settling. For instance, the final ctlv delta
and invoice expiry are moved from the main invoice body (where
additional metadata is stored). Additionally, it moves the State field
outside of the terms since it is rather metadata about the invoice
instead of any terms offered to the sender in the payment request.
This commit is contained in:
Conner Fromknecht committed 2019-11-22 02:25:02 -08:00
1 parent 6cabea563e
commit 3b253e05f6
8 files changed
+81 -82

No files matched your search

+8 -8
View File
@@ -245,7 +245,7 @@ func TestChannelLinkSingleHopPayment(t *testing.T) {
if err != nil {
t.Fatalf("unable to get invoice: %v", err)
}
if invoice.Terms.State != channeldb.ContractSettled {
if invoice.State != channeldb.ContractSettled {
t.Fatal("alice invoice wasn't settled")
}
@@ -505,7 +505,7 @@ func testChannelLinkMultiHopPayment(t *testing.T,
if err != nil {
t.Fatalf("unable to get invoice: %v", err)
}
if invoice.Terms.State != channeldb.ContractSettled {
if invoice.State != channeldb.ContractSettled {
t.Fatal("carol invoice haven't been settled")
}
@@ -919,7 +919,7 @@ func TestUpdateForwardingPolicy(t *testing.T) {
if err != nil {
t.Fatalf("unable to get invoice: %v", err)
}
if invoice.Terms.State != channeldb.ContractSettled {
if invoice.State != channeldb.ContractSettled {
t.Fatal("carol invoice haven't been settled")
}
@@ -1078,7 +1078,7 @@ func TestChannelLinkMultiHopInsufficientPayment(t *testing.T) {
if err != nil {
t.Fatalf("unable to get invoice: %v", err)
}
if invoice.Terms.State == channeldb.ContractSettled {
if invoice.State == channeldb.ContractSettled {
t.Fatal("carol invoice have been settled")
}
@@ -1269,7 +1269,7 @@ func TestChannelLinkMultiHopUnknownNextHop(t *testing.T) {
if err != nil {
t.Fatalf("unable to get invoice: %v", err)
}
if invoice.Terms.State == channeldb.ContractSettled {
if invoice.State == channeldb.ContractSettled {
t.Fatal("carol invoice have been settled")
}
@@ -1384,7 +1384,7 @@ func TestChannelLinkMultiHopDecodeError(t *testing.T) {
if err != nil {
t.Fatalf("unable to get invoice: %v", err)
}
if invoice.Terms.State == channeldb.ContractSettled {
if invoice.State == channeldb.ContractSettled {
t.Fatal("carol invoice have been settled")
}
@@ -3518,7 +3518,7 @@ func TestChannelRetransmission(t *testing.T) {
err = errors.Errorf("unable to get invoice: %v", err)
continue
}
if invoice.Terms.State != channeldb.ContractSettled {
if invoice.State != channeldb.ContractSettled {
err = errors.Errorf("alice invoice haven't been settled")
continue
}
@@ -4055,7 +4055,7 @@ func TestChannelLinkAcceptOverpay(t *testing.T) {
if err != nil {
t.Fatalf("unable to get invoice: %v", err)
}
if invoice.Terms.State != channeldb.ContractSettled {
if invoice.State != channeldb.ContractSettled {
t.Fatal("carol invoice haven't been settled")
}
+1 -1
View File
@@ -560,13 +560,13 @@ func generatePaymentWithPreimage(invoiceAmt, htlcAmt lnwire.MilliSatoshi,
invoice := &channeldb.Invoice{
CreationDate: time.Now(),
Terms: channeldb.ContractTerm{
FinalCltvDelta: testInvoiceCltvExpiry,
Value: invoiceAmt,
PaymentPreimage: preimage,
Features: lnwire.NewFeatureVector(
nil, lnwire.Features,
),
},
FinalCltvDelta: testInvoiceCltvExpiry,
}
htlc := &lnwire.UpdateAddHTLC{