lnrpc: populate new AmpInvoiceState field in CreateRPCInvoice
This commit is contained in:
5 files changed
+2002
-1687
No files matched your search
@@ -370,6 +370,30 @@
|
|||||||
},
|
},
|
||||||
"description": "Details specific to AMP HTLCs."
|
"description": "Details specific to AMP HTLCs."
|
||||||
},
|
},
|
||||||
|
"lnrpcAMPInvoiceState": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"state": {
|
||||||
|
"$ref": "#/definitions/lnrpcInvoiceHTLCState",
|
||||||
|
"description": "The state the HTLCs associated with this setID are in."
|
||||||
|
},
|
||||||
|
"settle_index": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64",
|
||||||
|
"description": "The settle index of this HTLC set, if the invoice state is settled."
|
||||||
|
},
|
||||||
|
"settle_time": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "The time this HTLC set was settled expressed in unix epoch."
|
||||||
|
},
|
||||||
|
"amt_paid_msat": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "The total amount paid for the sub-invoice expressed in milli satoshis."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"lnrpcFeature": {
|
"lnrpcFeature": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -540,11 +564,19 @@
|
|||||||
"payment_addr": {
|
"payment_addr": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "byte",
|
"format": "byte",
|
||||||
"description": "The payment address of this invoice. This value will be used in MPP\npayments, and also for newer invoies that always require the MPP paylaod\nfor added end-to-end security."
|
"description": "The payment address of this invoice. This value will be used in MPP\npayments, and also for newer invoices that always require the MPP payload\nfor added end-to-end security."
|
||||||
},
|
},
|
||||||
"is_amp": {
|
"is_amp": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Signals whether or not this is an AMP invoice."
|
"description": "Signals whether or not this is an AMP invoice."
|
||||||
|
},
|
||||||
|
"amp_invoice_state": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/definitions/lnrpcAMPInvoiceState"
|
||||||
|
},
|
||||||
|
"description": "Maps a 32-byte hex-encoded set ID to the sub-invoice AMP state for the\ngiven set ID. This field is always populated for AMP invoices, and can be\nused along side LookupInvoice to obtain the HTLC information related to a\ngiven sub-invoice.",
|
||||||
|
"title": "[EXPERIMENTAL]:"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -177,6 +177,39 @@ func CreateRPCInvoice(invoice *channeldb.Invoice,
|
|||||||
IsAmp: isAmp,
|
IsAmp: isAmp,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpcInvoice.AmpInvoiceState = make(map[string]*lnrpc.AMPInvoiceState)
|
||||||
|
for setID, ampState := range invoice.AMPState {
|
||||||
|
|
||||||
|
setIDStr := hex.EncodeToString(setID[:])
|
||||||
|
|
||||||
|
var state lnrpc.InvoiceHTLCState
|
||||||
|
switch ampState.State {
|
||||||
|
case channeldb.HtlcStateAccepted:
|
||||||
|
state = lnrpc.InvoiceHTLCState_ACCEPTED
|
||||||
|
case channeldb.HtlcStateSettled:
|
||||||
|
state = lnrpc.InvoiceHTLCState_SETTLED
|
||||||
|
case channeldb.HtlcStateCanceled:
|
||||||
|
state = lnrpc.InvoiceHTLCState_CANCELED
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unknown state %v", ampState.State)
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcInvoice.AmpInvoiceState[setIDStr] = &lnrpc.AMPInvoiceState{
|
||||||
|
State: state,
|
||||||
|
SettleIndex: ampState.SettleIndex,
|
||||||
|
SettleTime: ampState.SettleDate.Unix(),
|
||||||
|
AmtPaidMsat: int64(ampState.AmtPaid),
|
||||||
|
}
|
||||||
|
|
||||||
|
// If at least one of the present HTLC sets show up as being
|
||||||
|
// settled, then we'll mark the invoice itself as being
|
||||||
|
// settled.
|
||||||
|
if ampState.State == channeldb.HtlcStateSettled {
|
||||||
|
rpcInvoice.Settled = true // nolint:staticcheck
|
||||||
|
rpcInvoice.State = lnrpc.Invoice_SETTLED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if preimage != nil {
|
if preimage != nil {
|
||||||
rpcInvoice.RPreimage = preimage[:]
|
rpcInvoice.RPreimage = preimage[:]
|
||||||
}
|
}
|
||||||
|
|||||||
+1874
-1684
File diff suppressed because it is too large.
Load diff
+29
-1
@@ -3056,6 +3056,10 @@ message HopHint {
|
|||||||
uint32 cltv_expiry_delta = 5;
|
uint32 cltv_expiry_delta = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message SetID {
|
||||||
|
bytes set_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message RouteHint {
|
message RouteHint {
|
||||||
/*
|
/*
|
||||||
A list of hop hints that when chained together can assist in reaching a
|
A list of hop hints that when chained together can assist in reaching a
|
||||||
@@ -3064,6 +3068,20 @@ message RouteHint {
|
|||||||
repeated HopHint hop_hints = 1;
|
repeated HopHint hop_hints = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message AMPInvoiceState {
|
||||||
|
// The state the HTLCs associated with this setID are in.
|
||||||
|
InvoiceHTLCState state = 1;
|
||||||
|
|
||||||
|
// The settle index of this HTLC set, if the invoice state is settled.
|
||||||
|
uint64 settle_index = 2;
|
||||||
|
|
||||||
|
// The time this HTLC set was settled expressed in unix epoch.
|
||||||
|
int64 settle_time = 3;
|
||||||
|
|
||||||
|
// The total amount paid for the sub-invoice expressed in milli satoshis.
|
||||||
|
int64 amt_paid_msat = 5;
|
||||||
|
}
|
||||||
|
|
||||||
message Invoice {
|
message Invoice {
|
||||||
/*
|
/*
|
||||||
An optional memo to attach along with the invoice. Used for record keeping
|
An optional memo to attach along with the invoice. Used for record keeping
|
||||||
@@ -3209,7 +3227,7 @@ message Invoice {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
The payment address of this invoice. This value will be used in MPP
|
The payment address of this invoice. This value will be used in MPP
|
||||||
payments, and also for newer invoies that always require the MPP paylaod
|
payments, and also for newer invoices that always require the MPP payload
|
||||||
for added end-to-end security.
|
for added end-to-end security.
|
||||||
*/
|
*/
|
||||||
bytes payment_addr = 26;
|
bytes payment_addr = 26;
|
||||||
@@ -3218,6 +3236,16 @@ message Invoice {
|
|||||||
Signals whether or not this is an AMP invoice.
|
Signals whether or not this is an AMP invoice.
|
||||||
*/
|
*/
|
||||||
bool is_amp = 27;
|
bool is_amp = 27;
|
||||||
|
|
||||||
|
/*
|
||||||
|
[EXPERIMENTAL]:
|
||||||
|
|
||||||
|
Maps a 32-byte hex-encoded set ID to the sub-invoice AMP state for the
|
||||||
|
given set ID. This field is always populated for AMP invoices, and can be
|
||||||
|
used along side LookupInvoice to obtain the HTLC information related to a
|
||||||
|
given sub-invoice.
|
||||||
|
*/
|
||||||
|
map<string, AMPInvoiceState> amp_invoice_state = 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum InvoiceHTLCState {
|
enum InvoiceHTLCState {
|
||||||
|
|||||||
@@ -2838,6 +2838,30 @@
|
|||||||
},
|
},
|
||||||
"description": "Details specific to AMP HTLCs."
|
"description": "Details specific to AMP HTLCs."
|
||||||
},
|
},
|
||||||
|
"lnrpcAMPInvoiceState": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"state": {
|
||||||
|
"$ref": "#/definitions/lnrpcInvoiceHTLCState",
|
||||||
|
"description": "The state the HTLCs associated with this setID are in."
|
||||||
|
},
|
||||||
|
"settle_index": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64",
|
||||||
|
"description": "The settle index of this HTLC set, if the invoice state is settled."
|
||||||
|
},
|
||||||
|
"settle_time": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "The time this HTLC set was settled expressed in unix epoch."
|
||||||
|
},
|
||||||
|
"amt_paid_msat": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "The total amount paid for the sub-invoice expressed in milli satoshis."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"lnrpcAMPRecord": {
|
"lnrpcAMPRecord": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -4755,11 +4779,19 @@
|
|||||||
"payment_addr": {
|
"payment_addr": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "byte",
|
"format": "byte",
|
||||||
"description": "The payment address of this invoice. This value will be used in MPP\npayments, and also for newer invoies that always require the MPP paylaod\nfor added end-to-end security."
|
"description": "The payment address of this invoice. This value will be used in MPP\npayments, and also for newer invoices that always require the MPP payload\nfor added end-to-end security."
|
||||||
},
|
},
|
||||||
"is_amp": {
|
"is_amp": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Signals whether or not this is an AMP invoice."
|
"description": "Signals whether or not this is an AMP invoice."
|
||||||
|
},
|
||||||
|
"amp_invoice_state": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/definitions/lnrpcAMPInvoiceState"
|
||||||
|
},
|
||||||
|
"description": "Maps a 32-byte hex-encoded set ID to the sub-invoice AMP state for the\ngiven set ID. This field is always populated for AMP invoices, and can be\nused along side LookupInvoice to obtain the HTLC information related to a\ngiven sub-invoice.",
|
||||||
|
"title": "[EXPERIMENTAL]:"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user