lightningd: expose created_index and updated_index fields.

If you miss a wait event, you can catch up by doing listinvoices and
getting the max of these fields.  It's also a good debugging clue.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-07-22 20:29:17 +09:30
parent 284262d006
commit d25a8ca0fd
27 changed files with 559 additions and 325 deletions

View File

@@ -368,6 +368,7 @@
"CreateInvoice.amount_received_msat": 10,
"CreateInvoice.bolt11": 2,
"CreateInvoice.bolt12": 3,
"CreateInvoice.created_index": 16,
"CreateInvoice.description": 7,
"CreateInvoice.expires_at": 8,
"CreateInvoice.invreq_payer_note": 15,
@@ -574,6 +575,7 @@
"DelInvoice.amount_msat": 4,
"DelInvoice.bolt11": 2,
"DelInvoice.bolt12": 3,
"DelInvoice.created_index": 12,
"DelInvoice.description": 5,
"DelInvoice.expires_at": 8,
"DelInvoice.invreq_payer_note": 11,
@@ -581,7 +583,8 @@
"DelInvoice.local_offer_id": 9,
"DelInvoice.payer_note": 10,
"DelInvoice.payment_hash": 6,
"DelInvoice.status": 7
"DelInvoice.status": 7,
"DelInvoice.updated_index": 13
},
"DisconnectRequest": {
"Disconnect.force": 2,
@@ -764,6 +767,7 @@
},
"InvoiceResponse": {
"Invoice.bolt11": 1,
"Invoice.created_index": 10,
"Invoice.expires_at": 4,
"Invoice.payment_hash": 2,
"Invoice.payment_secret": 3,
@@ -926,6 +930,7 @@
"ListInvoices.invoices[].amount_received_msat": 12,
"ListInvoices.invoices[].bolt11": 7,
"ListInvoices.invoices[].bolt12": 8,
"ListInvoices.invoices[].created_index": 16,
"ListInvoices.invoices[].description": 2,
"ListInvoices.invoices[].expires_at": 5,
"ListInvoices.invoices[].invreq_payer_note": 15,
@@ -936,7 +941,8 @@
"ListInvoices.invoices[].payer_note": 10,
"ListInvoices.invoices[].payment_hash": 3,
"ListInvoices.invoices[].payment_preimage": 14,
"ListInvoices.invoices[].status": 4
"ListInvoices.invoices[].status": 4,
"ListInvoices.invoices[].updated_index": 17
},
"ListinvoicesRequest": {
"ListInvoices.index": 5,
@@ -1513,6 +1519,7 @@
"WaitAnyInvoice.amount_received_msat": 10,
"WaitAnyInvoice.bolt11": 7,
"WaitAnyInvoice.bolt12": 8,
"WaitAnyInvoice.created_index": 13,
"WaitAnyInvoice.description": 2,
"WaitAnyInvoice.expires_at": 5,
"WaitAnyInvoice.label": 1,
@@ -1520,7 +1527,8 @@
"WaitAnyInvoice.pay_index": 9,
"WaitAnyInvoice.payment_hash": 3,
"WaitAnyInvoice.payment_preimage": 12,
"WaitAnyInvoice.status": 4
"WaitAnyInvoice.status": 4,
"WaitAnyInvoice.updated_index": 14
},
"WaitinvoiceRequest": {
"WaitInvoice.label": 1
@@ -1530,6 +1538,7 @@
"WaitInvoice.amount_received_msat": 10,
"WaitInvoice.bolt11": 7,
"WaitInvoice.bolt12": 8,
"WaitInvoice.created_index": 13,
"WaitInvoice.description": 2,
"WaitInvoice.expires_at": 5,
"WaitInvoice.label": 1,
@@ -1537,7 +1546,8 @@
"WaitInvoice.pay_index": 9,
"WaitInvoice.payment_hash": 3,
"WaitInvoice.payment_preimage": 12,
"WaitInvoice.status": 4
"WaitInvoice.status": 4,
"WaitInvoice.updated_index": 14
},
"WaitsendpayRequest": {
"WaitSendPay.groupid": 4,
@@ -1727,6 +1737,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"CreateInvoice.created_index": {
"added": "v23.08",
"deprecated": false
},
"CreateInvoice.description": {
"added": "pre-v0.10.1",
"deprecated": false
@@ -2483,6 +2497,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"DelInvoice.created_index": {
"added": "v23.08",
"deprecated": false
},
"DelInvoice.desconly": {
"added": "pre-v0.10.1",
"deprecated": false
@@ -2515,6 +2533,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"DelInvoice.updated_index": {
"added": "v23.08",
"deprecated": false
},
"Disconnect": {
"added": "pre-v0.10.1",
"deprecated": null
@@ -3039,6 +3061,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"Invoice.created_index": {
"added": "v23.08",
"deprecated": false
},
"Invoice.deschashonly": {
"added": "pre-v0.10.1",
"deprecated": false
@@ -3579,6 +3605,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"ListInvoices.invoices[].created_index": {
"added": "v23.08",
"deprecated": false
},
"ListInvoices.invoices[].description": {
"added": "pre-v0.10.1",
"deprecated": false
@@ -3619,6 +3649,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"ListInvoices.invoices[].updated_index": {
"added": "v23.08",
"deprecated": false
},
"ListInvoices.invstring": {
"added": "pre-v0.10.1",
"deprecated": false
@@ -5315,6 +5349,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"WaitAnyInvoice.created_index": {
"added": "v23.08",
"deprecated": false
},
"WaitAnyInvoice.description": {
"added": "pre-v0.10.1",
"deprecated": false
@@ -5355,6 +5393,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"WaitAnyInvoice.updated_index": {
"added": "v23.08",
"deprecated": false
},
"WaitInvoice": {
"added": "pre-v0.10.1",
"deprecated": null
@@ -5375,6 +5417,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"WaitInvoice.created_index": {
"added": "v23.08",
"deprecated": false
},
"WaitInvoice.description": {
"added": "pre-v0.10.1",
"deprecated": false
@@ -5407,6 +5453,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"WaitInvoice.updated_index": {
"added": "v23.08",
"deprecated": false
},
"WaitSendPay": {
"added": "pre-v0.10.1",
"deprecated": null

View File

@@ -490,6 +490,7 @@ message CreateinvoiceResponse {
CreateinvoiceStatus status = 6;
string description = 7;
uint64 expires_at = 8;
optional uint64 created_index = 16;
optional uint64 pay_index = 9;
optional Amount amount_received_msat = 10;
optional uint64 paid_at = 11;
@@ -582,6 +583,8 @@ message DelinvoiceResponse {
optional Amount amount_msat = 4;
optional string description = 5;
bytes payment_hash = 6;
optional uint64 created_index = 12;
optional uint64 updated_index = 13;
DelinvoiceStatus status = 7;
uint64 expires_at = 8;
optional bytes local_offer_id = 9;
@@ -604,6 +607,7 @@ message InvoiceResponse {
bytes payment_hash = 2;
bytes payment_secret = 3;
uint64 expires_at = 4;
optional uint64 created_index = 10;
optional string warning_capacity = 5;
optional string warning_offline = 6;
optional string warning_deadends = 7;
@@ -662,6 +666,8 @@ message ListinvoicesInvoices {
optional string bolt12 = 8;
optional bytes local_offer_id = 9;
optional string invreq_payer_note = 15;
optional uint64 created_index = 16;
optional uint64 updated_index = 17;
optional uint64 pay_index = 11;
optional Amount amount_received_msat = 12;
optional uint64 paid_at = 13;
@@ -862,6 +868,8 @@ message WaitanyinvoiceResponse {
optional Amount amount_msat = 6;
optional string bolt11 = 7;
optional string bolt12 = 8;
optional uint64 created_index = 13;
optional uint64 updated_index = 14;
optional uint64 pay_index = 9;
optional Amount amount_received_msat = 10;
optional uint64 paid_at = 11;
@@ -886,6 +894,8 @@ message WaitinvoiceResponse {
optional Amount amount_msat = 6;
optional string bolt11 = 7;
optional string bolt12 = 8;
optional uint64 created_index = 13;
optional uint64 updated_index = 14;
optional uint64 pay_index = 9;
optional Amount amount_received_msat = 10;
optional uint64 paid_at = 11;

View File

@@ -421,6 +421,7 @@ impl From<responses::CreateinvoiceResponse> for pb::CreateinvoiceResponse {
status: c.status as i32,
description: c.description, // Rule #2 for type string
expires_at: c.expires_at, // Rule #2 for type u64
created_index: c.created_index, // Rule #2 for type u64?
pay_index: c.pay_index, // Rule #2 for type u64?
amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat?
paid_at: c.paid_at, // Rule #2 for type u64?
@@ -486,6 +487,8 @@ impl From<responses::DelinvoiceResponse> for pb::DelinvoiceResponse {
amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat?
description: c.description, // Rule #2 for type string?
payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash
created_index: c.created_index, // Rule #2 for type u64?
updated_index: c.updated_index, // Rule #2 for type u64?
status: c.status as i32,
expires_at: c.expires_at, // Rule #2 for type u64
local_offer_id: c.local_offer_id.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex?
@@ -502,6 +505,7 @@ impl From<responses::InvoiceResponse> for pb::InvoiceResponse {
payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash
payment_secret: c.payment_secret.to_vec(), // Rule #2 for type secret
expires_at: c.expires_at, // Rule #2 for type u64
created_index: c.created_index, // Rule #2 for type u64?
warning_capacity: c.warning_capacity, // Rule #2 for type string?
warning_offline: c.warning_offline, // Rule #2 for type string?
warning_deadends: c.warning_deadends, // Rule #2 for type string?
@@ -548,6 +552,8 @@ impl From<responses::ListinvoicesInvoices> for pb::ListinvoicesInvoices {
bolt12: c.bolt12, // Rule #2 for type string?
local_offer_id: c.local_offer_id.map(|v| v.to_vec()), // Rule #2 for type hash?
invreq_payer_note: c.invreq_payer_note, // Rule #2 for type string?
created_index: c.created_index, // Rule #2 for type u64?
updated_index: c.updated_index, // Rule #2 for type u64?
pay_index: c.pay_index, // Rule #2 for type u64?
amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat?
paid_at: c.paid_at, // Rule #2 for type u64?
@@ -735,6 +741,8 @@ impl From<responses::WaitanyinvoiceResponse> for pb::WaitanyinvoiceResponse {
amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat?
bolt11: c.bolt11, // Rule #2 for type string?
bolt12: c.bolt12, // Rule #2 for type string?
created_index: c.created_index, // Rule #2 for type u64?
updated_index: c.updated_index, // Rule #2 for type u64?
pay_index: c.pay_index, // Rule #2 for type u64?
amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat?
paid_at: c.paid_at, // Rule #2 for type u64?
@@ -755,6 +763,8 @@ impl From<responses::WaitinvoiceResponse> for pb::WaitinvoiceResponse {
amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat?
bolt11: c.bolt11, // Rule #2 for type string?
bolt12: c.bolt12, // Rule #2 for type string?
created_index: c.created_index, // Rule #2 for type u64?
updated_index: c.updated_index, // Rule #2 for type u64?
pay_index: c.pay_index, // Rule #2 for type u64?
amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat?
paid_at: c.paid_at, // Rule #2 for type u64?

20
cln-rpc/src/model.rs generated
View File

@@ -2503,6 +2503,8 @@ pub mod responses {
pub description: String,
pub expires_at: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub pay_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub amount_received_msat: Option<Amount>,
@@ -2648,6 +2650,10 @@ pub mod responses {
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
pub payment_hash: Sha256,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_index: Option<u64>,
// Path `DelInvoice.status`
pub status: DelinvoiceStatus,
pub expires_at: u64,
@@ -2675,6 +2681,8 @@ pub mod responses {
pub payment_secret: Secret,
pub expires_at: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub warning_capacity: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub warning_offline: Option<String>,
@@ -2777,6 +2785,10 @@ pub mod responses {
#[serde(skip_serializing_if = "Option::is_none")]
pub invreq_payer_note: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub pay_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub amount_received_msat: Option<Amount>,
@@ -3175,6 +3187,10 @@ pub mod responses {
#[serde(skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub pay_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub amount_received_msat: Option<Amount>,
@@ -3239,6 +3255,10 @@ pub mod responses {
#[serde(skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub pay_index: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub amount_received_msat: Option<Amount>,

File diff suppressed because one or more lines are too long

View File

@@ -332,6 +332,7 @@ def createinvoice2py(m):
"status": str(m.status), # EnumField in generate_composite
"description": m.description, # PrimitiveField in generate_composite
"expires_at": m.expires_at, # PrimitiveField in generate_composite
"created_index": m.created_index, # PrimitiveField in generate_composite
"pay_index": m.pay_index, # PrimitiveField in generate_composite
"amount_received_msat": amount2msat(m.amount_received_msat), # PrimitiveField in generate_composite
"paid_at": m.paid_at, # PrimitiveField in generate_composite
@@ -379,6 +380,8 @@ def delinvoice2py(m):
"amount_msat": amount2msat(m.amount_msat), # PrimitiveField in generate_composite
"description": m.description, # PrimitiveField in generate_composite
"payment_hash": hexlify(m.payment_hash), # PrimitiveField in generate_composite
"created_index": m.created_index, # PrimitiveField in generate_composite
"updated_index": m.updated_index, # PrimitiveField in generate_composite
"status": str(m.status), # EnumField in generate_composite
"expires_at": m.expires_at, # PrimitiveField in generate_composite
"local_offer_id": hexlify(m.local_offer_id), # PrimitiveField in generate_composite
@@ -392,6 +395,7 @@ def invoice2py(m):
"payment_hash": hexlify(m.payment_hash), # PrimitiveField in generate_composite
"payment_secret": hexlify(m.payment_secret), # PrimitiveField in generate_composite
"expires_at": m.expires_at, # PrimitiveField in generate_composite
"created_index": m.created_index, # PrimitiveField in generate_composite
"warning_capacity": m.warning_capacity, # PrimitiveField in generate_composite
"warning_offline": m.warning_offline, # PrimitiveField in generate_composite
"warning_deadends": m.warning_deadends, # PrimitiveField in generate_composite
@@ -427,6 +431,8 @@ def listinvoices_invoices2py(m):
"bolt12": m.bolt12, # PrimitiveField in generate_composite
"local_offer_id": hexlify(m.local_offer_id), # PrimitiveField in generate_composite
"invreq_payer_note": m.invreq_payer_note, # PrimitiveField in generate_composite
"created_index": m.created_index, # PrimitiveField in generate_composite
"updated_index": m.updated_index, # PrimitiveField in generate_composite
"pay_index": m.pay_index, # PrimitiveField in generate_composite
"amount_received_msat": amount2msat(m.amount_received_msat), # PrimitiveField in generate_composite
"paid_at": m.paid_at, # PrimitiveField in generate_composite
@@ -568,6 +574,8 @@ def waitanyinvoice2py(m):
"amount_msat": amount2msat(m.amount_msat), # PrimitiveField in generate_composite
"bolt11": m.bolt11, # PrimitiveField in generate_composite
"bolt12": m.bolt12, # PrimitiveField in generate_composite
"created_index": m.created_index, # PrimitiveField in generate_composite
"updated_index": m.updated_index, # PrimitiveField in generate_composite
"pay_index": m.pay_index, # PrimitiveField in generate_composite
"amount_received_msat": amount2msat(m.amount_received_msat), # PrimitiveField in generate_composite
"paid_at": m.paid_at, # PrimitiveField in generate_composite
@@ -585,6 +593,8 @@ def waitinvoice2py(m):
"amount_msat": amount2msat(m.amount_msat), # PrimitiveField in generate_composite
"bolt11": m.bolt11, # PrimitiveField in generate_composite
"bolt12": m.bolt12, # PrimitiveField in generate_composite
"created_index": m.created_index, # PrimitiveField in generate_composite
"updated_index": m.updated_index, # PrimitiveField in generate_composite
"pay_index": m.pay_index, # PrimitiveField in generate_composite
"amount_received_msat": amount2msat(m.amount_received_msat), # PrimitiveField in generate_composite
"paid_at": m.paid_at, # PrimitiveField in generate_composite

View File

@@ -38,6 +38,7 @@ On success, an object is returned, containing:
- **status** (string): Whether it has been paid, or can no longer be paid (one of "paid", "expired", "unpaid")
- **description** (string): Description extracted from **bolt11** or **bolt12**
- **expires\_at** (u64): UNIX timestamp of when invoice expires (or expired)
- **created\_index** (u64): 1-based index indicating order this invoice was created in *(added v23.08)*
- **bolt11** (string, optional): the bolt11 string (always present unless **bolt12** is)
- **bolt12** (string, optional): the bolt12 string instead of **bolt11** (**experimental-offers** only)
- **amount\_msat** (msat, optional): The amount of the invoice (if it has one)
@@ -75,4 +76,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:fffebe36aa6671261082894e8b1429035c08f797064a60b03e3e9ea10ea71038)
[comment]: # ( SHA256STAMP:2d2180c9e903e2b79d5ddb2b0cf995b1f7aa27b0f9bb1f6e19252b94dcd46ef1)

View File

@@ -29,12 +29,14 @@ On success, an object is returned, containing:
- **label** (string): Unique label given at creation time
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment
- **created\_index** (u64): 1-based index indicating order this invoice was created in *(added v23.08)*
- **status** (string): State of invoice (one of "paid", "expired", "unpaid")
- **expires\_at** (u64): UNIX timestamp when invoice expires (or expired)
- **bolt11** (string, optional): BOLT11 string
- **bolt12** (string, optional): BOLT12 string
- **amount\_msat** (msat, optional): the amount required to pay this invoice
- **description** (string, optional): description used in the invoice
- **updated\_index** (u64, optional): 1-based index indicating order this invoice was changed (only present if it has changed since creation) *(added v23.08)*
If **bolt12** is present:
@@ -81,4 +83,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:f29100ae7e0ad26fee559e175e104a9e29e1a2cd6917c4072d521ce0600d1656)
[comment]: # ( SHA256STAMP:4b9c2449a664f955e2155656eaef44f40c36cf84f1fc2890812676a3216b666b)

View File

@@ -82,6 +82,7 @@ On success, an object is returned, containing:
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment
- **payment\_secret** (secret): the *payment\_secret* to place in the onion
- **expires\_at** (u64): UNIX timestamp of when invoice expires
- **created\_index** (u64): 1-based index indicating order this invoice was created in *(added v23.08)*
The following warnings may also be returned:
@@ -119,4 +120,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:095393c4a1050a9a458eba1033162e99283019329747a66b6461a5bb13fa7a2f)
[comment]: # ( SHA256STAMP:ffe488e123bad4592e4083c5eaaad0c01194d6ecc9fe14ce9a6ffd488aae8129)

View File

@@ -32,12 +32,14 @@ On success, an object containing **invoices** is returned. It is an array of ob
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment
- **status** (string): Whether it's paid, unpaid or unpayable (one of "unpaid", "paid", "expired")
- **expires\_at** (u64): UNIX timestamp of when it will become / became unpayable
- **created\_index** (u64): 1-based index indicating order this invoice was created in *(added v23.08)*
- **description** (string, optional): description used in the invoice
- **amount\_msat** (msat, optional): the amount required to pay this invoice
- **bolt11** (string, optional): the BOLT11 string (always present unless *bolt12* is)
- **bolt12** (string, optional): the BOLT12 string (always present unless *bolt11* is)
- **local\_offer\_id** (hash, optional): the *id* of our offer which created this invoice (**experimental-offers** only).
- **invreq\_payer\_note** (string, optional): the optional *invreq\_payer\_note* from invoice\_request which created this invoice (**experimental-offers** only).
- **updated\_index** (u64, optional): 1-based index indicating order this invoice was changed (only present if it has changed since creation) *(added v23.08)*
If **status** is "paid":
@@ -63,4 +65,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:7b1b70f04245395de28eb378e364537920e2f690db3c97ee638cefd282712dca)
[comment]: # ( SHA256STAMP:e698b0e345ed4912b7699b43f2571a4cc3bb4ae909efeb631b02dd94a87e765c)

View File

@@ -45,8 +45,10 @@ On success, an object is returned, containing:
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment
- **status** (string): Whether it's paid, unpaid or unpayable (one of "unpaid", "paid", "expired")
- **expires\_at** (u64): UNIX timestamp of when it will become / became unpayable
- **created\_index** (u64): 1-based index indicating order this invoice was created in *(added v23.08)*
- **amount\_msat** (msat, optional): the amount required to pay this invoice
- **bolt12** (string, optional): the BOLT12 string
- **updated\_index** (u64, optional): 1-based index indicating order this invoice was changed (only present if it has changed since creation) *(added v23.08)*
If **status** is "paid":
@@ -79,4 +81,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:79a371e3dc60c1395f591e16c3dd039f8fdee53c9402f345fa8823d85a18d819)
[comment]: # ( SHA256STAMP:682cf05a868d744b3a70a4747d26a23ba802ffe3abc0cce4bd89683377be1930)

View File

@@ -205,6 +205,8 @@ The following tables are currently supported:
- `bolt12` (type `string`, sqltype `TEXT`)
- `local_offer_id` (type `hash`, sqltype `BLOB`)
- `invreq_payer_note` (type `string`, sqltype `TEXT`)
- `created_index` (type `u64`, sqltype `INTEGER`)
- `updated_index` (type `u64`, sqltype `INTEGER`)
- `pay_index` (type `u64`, sqltype `INTEGER`)
- `amount_received_msat` (type `msat`, sqltype `INTEGER`)
- `paid_at` (type `u64`, sqltype `INTEGER`)
@@ -511,4 +513,4 @@ RESOURCES
---------
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:4cfeeb2855f92a12d6a52d912a58df7573fc34f1f17a190bba26e46695f54de6)
[comment]: # ( SHA256STAMP:094d94f4d2cfd8e8bdc99be8b692100d3cbd70ab3c297ed8e191c8d4a0f9b6a7)

View File

@@ -41,9 +41,11 @@ On success, an object is returned, containing:
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment
- **status** (string): Whether it's paid or expired (one of "paid", "expired")
- **expires\_at** (u64): UNIX timestamp of when it will become / became unpayable
- **created\_index** (u64): 1-based index indicating order this invoice was created in *(added v23.08)*
- **amount\_msat** (msat, optional): the amount required to pay this invoice
- **bolt11** (string, optional): the BOLT11 string (always present unless *bolt12* is)
- **bolt12** (string, optional): the BOLT12 string (always present unless *bolt11* is)
- **updated\_index** (u64, optional): 1-based index indicating order this invoice was changed (only present if it has changed since creation) *(added v23.08)*
If **status** is "paid":
@@ -75,4 +77,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:86e3d74f12d2997b7960a0d0732ff51422af6dc9851134e216723b1497bc0573)
[comment]: # ( SHA256STAMP:a0ace35f11efcdfbac39ef830cd7b2b6c8f48816c5512d7d2300edb9463aa4e6)

View File

@@ -23,9 +23,11 @@ On success, an object is returned, containing:
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment
- **status** (string): Whether it's paid or expired (one of "paid", "expired")
- **expires\_at** (u64): UNIX timestamp of when it will become / became unpayable
- **created\_index** (u64): 1-based index indicating order this invoice was created in *(added v23.08)*
- **amount\_msat** (msat, optional): the amount required to pay this invoice
- **bolt11** (string, optional): the BOLT11 string (always present unless *bolt12* is)
- **bolt12** (string, optional): the BOLT12 string (always present unless *bolt11* is)
- **updated\_index** (u64, optional): 1-based index indicating order this invoice was changed (only present if it has changed since creation) *(added v23.08)*
If **status** is "paid":
@@ -60,4 +62,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:86e3d74f12d2997b7960a0d0732ff51422af6dc9851134e216723b1497bc0573)
[comment]: # ( SHA256STAMP:a0ace35f11efcdfbac39ef830cd7b2b6c8f48816c5512d7d2300edb9463aa4e6)

View File

@@ -4,6 +4,7 @@
"additionalProperties": false,
"required": [
"label",
"created_index",
"payment_hash",
"status",
"description",
@@ -47,6 +48,11 @@
"type": "u64",
"description": "UNIX timestamp of when invoice expires (or expired)"
},
"created_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was created in"
},
"pay_index": {
"type": "u64",
"description": "Incrementing id for when this was paid (**status** *paid* only)"

View File

@@ -5,6 +5,7 @@
"label",
"payment_hash",
"status",
"created_index",
"expires_at"
],
"additionalProperties": true,
@@ -33,6 +34,16 @@
"type": "hash",
"description": "the hash of the *payment_preimage* which will prove payment"
},
"created_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was created in"
},
"updated_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was changed (only present if it has changed since creation)"
},
"status": {
"type": "string",
"description": "State of invoice",
@@ -67,6 +78,8 @@
"description": {},
"payment_hash": {},
"pay_index": {},
"created_index": {},
"updated_index": {},
"amount_received_msat": {},
"paid_at": {},
"payment_preimage": {},
@@ -95,6 +108,8 @@
"description": {},
"payment_hash": {},
"pay_index": {},
"created_index": {},
"updated_index": {},
"amount_received_msat": {},
"msatoshi_received": {},
"paid_at": {},
@@ -133,6 +148,8 @@
"payment_hash": {},
"invreq_payer_note": {},
"local_offer_id": {},
"created_index": {},
"updated_index": {},
"pay_index": {
"type": "u64",
"description": "unique index for this invoice payment"
@@ -163,6 +180,8 @@
"description": {},
"payment_hash": {},
"expires_at": {},
"created_index": {},
"updated_index": {},
"pay_index": {},
"invreq_payer_note": {},
"local_offer_id": {}

View File

@@ -5,6 +5,7 @@
"required": [
"payment_hash",
"expires_at",
"created_index",
"bolt11",
"payment_secret"
],
@@ -25,6 +26,11 @@
"type": "u64",
"description": "UNIX timestamp of when invoice expires"
},
"created_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was created in"
},
"warning_capacity": {
"type": "string",
"description": "even using all possible channels, there's not enough incoming capacity to pay this invoice."

View File

@@ -13,6 +13,7 @@
"additionalProperties": true,
"required": [
"label",
"created_index",
"payment_hash",
"status",
"expires_at"
@@ -62,6 +63,16 @@
"invreq_payer_note": {
"type": "string",
"description": "the optional *invreq_payer_note* from invoice_request which created this invoice (**experimental-offers** only)."
},
"created_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was created in"
},
"updated_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was changed (only present if it has changed since creation)"
}
},
"allOf": [
@@ -96,6 +107,8 @@
"local_offer_id": {},
"invreq_payer_note": {},
"expires_at": {},
"created_index": {},
"updated_index": {},
"pay_index": {
"type": "u64",
"description": "Unique incrementing index for this payment"
@@ -127,6 +140,8 @@
"bolt12": {},
"local_offer_id": {},
"invreq_payer_note": {},
"created_index": {},
"updated_index": {},
"expires_at": {}
}
}

View File

@@ -7,6 +7,7 @@
"description",
"payment_hash",
"status",
"created_index",
"expires_at"
],
"properties": {
@@ -42,6 +43,16 @@
"bolt12": {
"type": "string",
"description": "the BOLT12 string"
},
"created_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was created in"
},
"updated_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was changed (only present if it has changed since creation)"
}
},
"allOf": [
@@ -73,6 +84,8 @@
"amount_msat": {},
"bolt12": {},
"expires_at": {},
"created_index": {},
"updated_index": {},
"pay_index": {
"type": "u64",
"description": "Unique incrementing index for this payment"

View File

@@ -7,6 +7,7 @@
"description",
"payment_hash",
"status",
"created_index",
"expires_at"
],
"properties": {
@@ -45,6 +46,16 @@
"bolt12": {
"type": "string",
"description": "the BOLT12 string (always present unless *bolt11* is)"
},
"created_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was created in"
},
"updated_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was changed (only present if it has changed since creation)"
}
},
"allOf": [
@@ -77,6 +88,8 @@
"bolt11": {},
"bolt12": {},
"expires_at": {},
"created_index": {},
"updated_index": {},
"pay_index": {
"type": "u64",
"description": "Unique incrementing index for this payment"
@@ -106,6 +119,8 @@
"amount_msat": {},
"bolt11": {},
"bolt12": {},
"created_index": {},
"updated_index": {},
"expires_at": {}
}
}

View File

@@ -7,6 +7,7 @@
"description",
"payment_hash",
"status",
"created_index",
"expires_at"
],
"properties": {
@@ -45,6 +46,16 @@
"bolt12": {
"type": "string",
"description": "the BOLT12 string (always present unless *bolt11* is)"
},
"created_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was created in"
},
"updated_index": {
"type": "u64",
"added": "v23.08",
"description": "1-based index indicating order this invoice was changed (only present if it has changed since creation)"
}
},
"allOf": [
@@ -77,6 +88,8 @@
"bolt11": {},
"bolt12": {},
"expires_at": {},
"created_index": {},
"updated_index": {},
"pay_index": {
"type": "u64",
"description": "Unique incrementing index for this payment"
@@ -106,6 +119,8 @@
"amount_msat": {},
"bolt11": {},
"bolt12": {},
"created_index": {},
"updated_index": {},
"expires_at": {}
}
}

View File

@@ -79,6 +79,9 @@ static void json_add_invoice_fields(struct json_stream *response,
tinv->invreq_payer_note,
tal_bytelen(tinv->invreq_payer_note));
}
json_add_u64(response, "created_index", inv->created_index);
if (inv->updated_index)
json_add_u64(response, "updated_index", inv->updated_index);
}
static void json_add_invoice(struct json_stream *response,
@@ -882,6 +885,7 @@ invoice_complete(struct invoice_info *info,
json_add_string(response, "bolt11", details->invstring);
invoice_secret(&details->r, &payment_secret);
json_add_secret(response, "payment_secret", &payment_secret);
json_add_u64(response, "created_index", details->created_index);
notify_invoice_creation(info->cmd->ld, info->b11->msat,
info->payment_preimage, info->label);

View File

@@ -39,6 +39,8 @@ struct invoice_details {
u8 *features;
/* The offer this refers to, if any. */
struct sha256 *local_offer_id;
/* Index values */
u64 created_index, updated_index;
};
/**

View File

@@ -727,6 +727,8 @@ def test_wait_invoices(node_factory, executor):
'details': {'label': 'invlabel',
'bolt11': inv['bolt11'],
'status': 'unpaid'}}
assert only_one(l2.rpc.listinvoices('invlabel')['invoices'])['created_index'] == 1
assert 'updated_index' not in only_one(l2.rpc.listinvoices('invlabel')['invoices'])
# Second returns instantly, without any details.
waitres = l2.rpc.call('wait', {'subsystem': 'invoices', 'indexname': 'created', 'nextvalue': 1})
@@ -745,6 +747,8 @@ def test_wait_invoices(node_factory, executor):
assert waitres == {'subsystem': 'invoices',
'updated': 1,
'details': {'label': 'invlabel', 'status': 'paid'}}
assert only_one(l2.rpc.listinvoices('invlabel')['invoices'])['created_index'] == 1
assert only_one(l2.rpc.listinvoices('invlabel')['invoices'])['updated_index'] == 1
# Second returns instantly, without any details.
waitres = l2.rpc.call('wait', {'subsystem': 'invoices', 'indexname': 'updated', 'nextvalue': 1})
@@ -761,6 +765,9 @@ def test_wait_invoices(node_factory, executor):
# {'label': 'invlabel2', 'bolt11': inv2['bolt11'], 'status': 'expired'}
'details': {'status': 'expired'}}
assert only_one(l2.rpc.listinvoices('invlabel2')['invoices'])['created_index'] == 2
assert only_one(l2.rpc.listinvoices('invlabel2')['invoices'])['updated_index'] == 2
# Now for deletions
waitres = l2.rpc.call('wait', {'subsystem': 'invoices', 'indexname': 'deleted', 'nextvalue': 0})
assert waitres == {'subsystem': 'invoices',
@@ -804,6 +811,8 @@ def test_wait_invoices(node_factory, executor):
'details': {'label': 'invlabel2',
'bolt11': inv['bolt11'],
'status': 'unpaid'}}
assert only_one(l2.rpc.listinvoices('invlabel2')['invoices'])['created_index'] == 3
assert 'updated_index' not in only_one(l2.rpc.listinvoices('invlabel2')['invoices'])
# Deleting a description causes updated to fire!
waitfut = executor.submit(l2.rpc.call, 'wait', {'subsystem': 'invoices', 'indexname': 'updated', 'nextvalue': 3})
@@ -884,6 +893,14 @@ def test_listinvoices_index(node_factory, executor):
# They're all still there!
assert set([inv['label'] for inv in l2.rpc.listinvoices(index='updated')['invoices']]) == set([str(i) for i in range(1, 100)])
# index values are correct.
for inv in l2.rpc.listinvoices(index='updated')['invoices']:
assert inv['created_index'] == int(inv['label'])
if int(inv['label']) in range(70, 60, -1):
assert inv['updated_index'] == 70 - int(inv['label']) + 1
else:
assert 'updated_index' not in inv
# Last 10 are in a defined order:
assert [inv['label'] for inv in l2.rpc.listinvoices(index='updated', start=1)['invoices']] == [str(i) for i in range(70, 60, -1)]
assert [inv['label'] for inv in l2.rpc.listinvoices(index='updated', start=2)['invoices']] == [str(i) for i in range(69, 60, -1)]

View File

@@ -1017,6 +1017,7 @@ def test_cli(node_factory):
' "amount_msat": 123000,',
' "status": "unpaid",',
r' "description": "d\"[]{}",',
' "created_index": 1',
' }',
' ]',
'}']

View File

@@ -3679,6 +3679,10 @@ def test_sql(node_factory, bitcoind):
'type': 'hex'},
{'name': 'invreq_payer_note',
'type': 'string'},
{'name': 'created_index',
'type': 'u64'},
{'name': 'updated_index',
'type': 'u64'},
{'name': 'pay_index',
'type': 'u64'},
{'name': 'amount_received_msat',

View File

@@ -111,7 +111,8 @@ static struct invoice_details *wallet_stmt2invoice_details(const tal_t *ctx,
dtl->features = db_col_arr(dtl, stmt, "features", u8);
dtl->local_offer_id = db_col_optional(dtl, stmt, "local_offer_id", sha256);
dtl->created_index = db_col_u64(stmt, "id");
dtl->updated_index = db_col_u64(stmt, "updated_index");
return dtl;
}
@@ -706,6 +707,8 @@ struct invoice_details *invoices_get_details(const tal_t *ctx,
", description"
", features"
", local_offer_id"
", id"
", updated_index"
" FROM invoices"
" WHERE id = ?;"));
db_bind_u64(stmt, inv_dbid);