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:
8 files changed
+81
-82
No files matched your search
@@ -43,10 +43,10 @@ func CreateRPCInvoice(invoice *channeldb.Invoice,
|
||||
satAmt := invoice.Terms.Value.ToSatoshis()
|
||||
satAmtPaid := invoice.AmtPaid.ToSatoshis()
|
||||
|
||||
isSettled := invoice.Terms.State == channeldb.ContractSettled
|
||||
isSettled := invoice.State == channeldb.ContractSettled
|
||||
|
||||
var state lnrpc.Invoice_InvoiceState
|
||||
switch invoice.Terms.State {
|
||||
switch invoice.State {
|
||||
case channeldb.ContractOpen:
|
||||
state = lnrpc.Invoice_OPEN
|
||||
case channeldb.ContractSettled:
|
||||
@@ -57,7 +57,7 @@ func CreateRPCInvoice(invoice *channeldb.Invoice,
|
||||
state = lnrpc.Invoice_ACCEPTED
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown invoice state %v",
|
||||
invoice.Terms.State)
|
||||
invoice.State)
|
||||
}
|
||||
|
||||
rpcHtlcs := make([]*lnrpc.InvoiceHTLC, 0, len(invoice.Htlcs))
|
||||
@@ -102,8 +102,8 @@ func CreateRPCInvoice(invoice *channeldb.Invoice,
|
||||
Settled: isSettled,
|
||||
PaymentRequest: paymentRequest,
|
||||
DescriptionHash: descHash,
|
||||
Expiry: int64(invoice.Expiry.Seconds()),
|
||||
CltvExpiry: uint64(invoice.FinalCltvDelta),
|
||||
Expiry: int64(invoice.Terms.Expiry.Seconds()),
|
||||
CltvExpiry: uint64(invoice.Terms.FinalCltvDelta),
|
||||
FallbackAddr: fallbackAddr,
|
||||
RouteHints: routeHints,
|
||||
AddIndex: invoice.AddIndex,
|
||||
|
||||
Reference in new issue
Block a user