Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pay: Track payment completion time for successful payments #5398

Merged
merged 5 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,15 @@
"ListPays.pays[].amount_sent_msat": 9,
"ListPays.pays[].bolt11": 6,
"ListPays.pays[].bolt12": 7,
"ListPays.pays[].completed_at": 12,
"ListPays.pays[].created_at": 4,
"ListPays.pays[].description": 11,
"ListPays.pays[].destination": 3,
"ListPays.pays[].erroronion": 10,
"ListPays.pays[].label": 5,
"ListPays.pays[].number_of_parts": 14,
"ListPays.pays[].payment_hash": 1,
"ListPays.pays[].preimage": 13,
"ListPays.pays[].status": 2
},
"ListpaysRequest": {
Expand Down Expand Up @@ -940,6 +943,7 @@
"SendPay.amount_sent_msat": 8,
"SendPay.bolt11": 11,
"SendPay.bolt12": 12,
"SendPay.completed_at": 15,
"SendPay.created_at": 7,
"SendPay.destination": 6,
"SendPay.groupid": 2,
Expand Down Expand Up @@ -1080,6 +1084,7 @@
"WaitSendPay.amount_sent_msat": 8,
"WaitSendPay.bolt11": 11,
"WaitSendPay.bolt12": 12,
"WaitSendPay.completed_at": 14,
"WaitSendPay.created_at": 7,
"WaitSendPay.destination": 6,
"WaitSendPay.groupid": 2,
Expand Down
7 changes: 5 additions & 2 deletions cln-grpc/proto/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ message SendpayResponse {
optional Amount amount_msat = 5;
optional bytes destination = 6;
uint64 created_at = 7;
optional uint64 completed_at = 15;
Amount amount_sent_msat = 8;
optional string label = 9;
optional uint64 partid = 10;
Expand Down Expand Up @@ -918,6 +919,7 @@ message WaitsendpayResponse {
optional Amount amount_msat = 5;
optional bytes destination = 6;
uint64 created_at = 7;
optional double completed_at = 14;
Amount amount_sent_msat = 8;
optional string label = 9;
optional uint64 partid = 10;
Expand Down Expand Up @@ -1263,12 +1265,13 @@ message ListpaysPays {
ListpaysPaysStatus status = 2;
optional bytes destination = 3;
uint64 created_at = 4;
optional uint64 completed_at = 12;
optional string label = 5;
optional string bolt11 = 6;
optional string description = 11;
optional string bolt12 = 7;
optional Amount amount_msat = 8;
optional Amount amount_sent_msat = 9;
optional bytes preimage = 13;
optional uint64 number_of_parts = 14;
optional bytes erroronion = 10;
}

Expand Down
7 changes: 5 additions & 2 deletions cln-grpc/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ impl From<&responses::SendpayResponse> for pb::SendpayResponse {
amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat?
destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey?
created_at: c.created_at.clone(), // Rule #2 for type u64
completed_at: c.completed_at.clone(), // Rule #2 for type u64?
amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat
label: c.label.clone(), // Rule #2 for type string?
partid: c.partid.clone(), // Rule #2 for type u64?
Expand Down Expand Up @@ -683,6 +684,7 @@ impl From<&responses::WaitsendpayResponse> for pb::WaitsendpayResponse {
amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat?
destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey?
created_at: c.created_at.clone(), // Rule #2 for type u64
completed_at: c.completed_at.clone(), // Rule #2 for type number?
amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat
label: c.label.clone(), // Rule #2 for type string?
partid: c.partid.clone(), // Rule #2 for type u64?
Expand Down Expand Up @@ -924,12 +926,13 @@ impl From<&responses::ListpaysPays> for pb::ListpaysPays {
status: c.status as i32,
destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey?
created_at: c.created_at.clone(), // Rule #2 for type u64
completed_at: c.completed_at.clone(), // Rule #2 for type u64?
label: c.label.clone(), // Rule #2 for type string?
bolt11: c.bolt11.clone(), // Rule #2 for type string?
description: c.description.clone(), // Rule #2 for type string?
bolt12: c.bolt12.clone(), // Rule #2 for type string?
amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat?
amount_sent_msat: c.amount_sent_msat.map(|f| f.into()), // Rule #2 for type msat?
preimage: c.preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex?
number_of_parts: c.number_of_parts.clone(), // Rule #2 for type u64?
erroronion: c.erroronion.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex?
}
}
Expand Down
14 changes: 10 additions & 4 deletions cln-rpc/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,8 @@ pub mod responses {
pub destination: Option<Pubkey>,
#[serde(alias = "created_at")]
pub created_at: u64,
#[serde(alias = "completed_at", skip_serializing_if = "Option::is_none")]
pub completed_at: Option<u64>,
#[serde(alias = "amount_sent_msat")]
pub amount_sent_msat: Amount,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -2327,6 +2329,8 @@ pub mod responses {
pub destination: Option<Pubkey>,
#[serde(alias = "created_at")]
pub created_at: u64,
#[serde(alias = "completed_at", skip_serializing_if = "Option::is_none")]
pub completed_at: Option<f64>,
#[serde(alias = "amount_sent_msat")]
pub amount_sent_msat: Amount,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -2725,6 +2729,8 @@ pub mod responses {
pub destination: Option<Pubkey>,
#[serde(alias = "created_at")]
pub created_at: u64,
#[serde(alias = "completed_at", skip_serializing_if = "Option::is_none")]
pub completed_at: Option<u64>,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
Expand All @@ -2733,10 +2739,10 @@ pub mod responses {
pub description: Option<String>,
#[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "amount_sent_msat", skip_serializing_if = "Option::is_none")]
pub amount_sent_msat: Option<Amount>,
#[serde(alias = "preimage", skip_serializing_if = "Option::is_none")]
pub preimage: Option<String>,
#[serde(alias = "number_of_parts", skip_serializing_if = "Option::is_none")]
pub number_of_parts: Option<u64>,
#[serde(alias = "erroronion", skip_serializing_if = "Option::is_none")]
pub erroronion: Option<String>,
}
Expand Down
7 changes: 5 additions & 2 deletions contrib/pyln-testing/pyln/testing/grpc2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def sendpay2py(m):
"amount_msat": amount2msat(m.amount_msat), # PrimitiveField in generate_composite
"destination": hexlify(m.destination), # PrimitiveField in generate_composite
"created_at": m.created_at, # PrimitiveField in generate_composite
"completed_at": m.completed_at, # PrimitiveField in generate_composite
"amount_sent_msat": amount2msat(m.amount_sent_msat), # PrimitiveField in generate_composite
"label": m.label, # PrimitiveField in generate_composite
"partid": m.partid, # PrimitiveField in generate_composite
Expand Down Expand Up @@ -606,6 +607,7 @@ def waitsendpay2py(m):
"amount_msat": amount2msat(m.amount_msat), # PrimitiveField in generate_composite
"destination": hexlify(m.destination), # PrimitiveField in generate_composite
"created_at": m.created_at, # PrimitiveField in generate_composite
"completed_at": m.completed_at, # PrimitiveField in generate_composite
"amount_sent_msat": amount2msat(m.amount_sent_msat), # PrimitiveField in generate_composite
"label": m.label, # PrimitiveField in generate_composite
"partid": m.partid, # PrimitiveField in generate_composite
Expand Down Expand Up @@ -823,12 +825,13 @@ def listpays_pays2py(m):
"status": str(m.status), # EnumField in generate_composite
"destination": hexlify(m.destination), # PrimitiveField in generate_composite
"created_at": m.created_at, # PrimitiveField in generate_composite
"completed_at": m.completed_at, # PrimitiveField in generate_composite
"label": m.label, # PrimitiveField in generate_composite
"bolt11": m.bolt11, # PrimitiveField in generate_composite
"description": m.description, # PrimitiveField in generate_composite
"bolt12": m.bolt12, # PrimitiveField in generate_composite
"amount_msat": amount2msat(m.amount_msat), # PrimitiveField in generate_composite
"amount_sent_msat": amount2msat(m.amount_sent_msat), # PrimitiveField in generate_composite
"preimage": hexlify(m.preimage), # PrimitiveField in generate_composite
"number_of_parts": m.number_of_parts, # PrimitiveField in generate_composite
"erroronion": hexlify(m.erroronion), # PrimitiveField in generate_composite
})

Expand Down
544 changes: 272 additions & 272 deletions contrib/pyln-testing/pyln/testing/node_pb2.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion doc/lightning-delpay.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ On success, an object containing **payments** is returned. It is an array of ob
- **partid** (u64, optional): unique ID within this (multi-part) payment
- **destination** (pubkey, optional): the final destination of the payment if known
- **amount\_msat** (msat, optional): the amount the destination received, if known
- **completed\_at** (u64, optional): the UNIX timestamp showing when this payment was completed
- **groupid** (u64, optional): Grouping key to disambiguate multiple attempts to pay an invoice or the same payment_hash
- **payment\_preimage** (hex, optional): proof of payment (always 64 characters)
- **label** (string, optional): the label, if given to sendpay
Expand Down Expand Up @@ -102,4 +103,4 @@ RESOURCES
---------

Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:08dbf42e6d4bd63f9b6e7a45112b348c84d6192d3ff3087e5e02b4a4788e5605)
[comment]: # ( SHA256STAMP:1ce2241eeae759ed5566342fb7810e62fa2c618f2465314f17376ebe9b6d24f8)
8 changes: 2 additions & 6 deletions doc/lightning-listpays.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ On success, an object containing **pays** is returned. It is an array of object
- **status** (string): status of the payment (one of "pending", "failed", "complete")
- **created\_at** (u64): the UNIX timestamp showing when this payment was initiated
- **destination** (pubkey, optional): the final destination of the payment if known
- **completed\_at** (u64, optional): the UNIX timestamp showing when this payment was completed
- **label** (string, optional): the label, if given to sendpay
- **bolt11** (string, optional): the bolt11 string (if pay supplied one)
- **description** (string, optional): the description matching the bolt11 description hash (if pay supplied one)
- **bolt12** (string, optional): the bolt12 string (if supplied for pay: **experimental-offers** only).

If **status** is "pending" or "complete":

- **amount\_sent\_msat** (msat): the amount we actually sent, including fees
- **amount\_msat** (msat, optional): the amount the destination received, if known

If **status** is "complete":

- **preimage** (hex): proof of payment (always 64 characters)
Expand Down Expand Up @@ -61,4 +57,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:64fd1d2a8673b2a4189623aa42d44384061ff66ba7c8918af40baf92ac29a889)
[comment]: # ( SHA256STAMP:1175415c0f9398e1087d68dd75266bf894249053a4e57f16b8ee16cf5ffa414f)
2 changes: 1 addition & 1 deletion doc/lightning-listsendpays.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:2cd3f5a0d494ea4aaef6eb5ea9ff467da14198c0fa4d9fee6b45e72568a2d481)
[comment]: # ( SHA256STAMP:68af9f1edf2ddc78a7daad1bb72aa773b82c5103b0ba706ef83de36a11cabe26)
3 changes: 2 additions & 1 deletion doc/lightning-sendpay.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ On success, an object is returned, containing:
- **groupid** (u64, optional): Grouping key to disambiguate multiple attempts to pay an invoice or the same payment_hash
- **amount\_msat** (msat, optional): The amount delivered to destination (if known)
- **destination** (pubkey, optional): the final destination of the payment if known
- **completed\_at** (u64, optional): the UNIX timestamp showing when this payment was completed
- **label** (string, optional): the *label*, if given to sendpay
- **partid** (u64, optional): the *partid*, if given to sendpay
- **bolt11** (string, optional): the bolt11 string (if supplied)
Expand Down Expand Up @@ -142,4 +143,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:4878733d02711f919c49740652a3723fbcc78a0cd865b71385db965c878d2b77)
[comment]: # ( SHA256STAMP:c129f537b1af8a5dc767a25a72be419634cb21ebc26a9e6b9bb091db8db7e6ca)
3 changes: 2 additions & 1 deletion doc/lightning-waitsendpay.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ On success, an object is returned, containing:
- **groupid** (u64, optional): Grouping key to disambiguate multiple attempts to pay an invoice or the same payment_hash
- **amount\_msat** (msat, optional): The amount delivered to destination (if known)
- **destination** (pubkey, optional): the final destination of the payment if known
- **completed\_at** (number, optional): the UNIX timestamp showing when this payment was completed
- **label** (string, optional): the label, if given to sendpay
- **partid** (u64, optional): the *partid*, if given to sendpay
- **bolt11** (string, optional): the bolt11 string (if pay supplied one)
Expand Down Expand Up @@ -103,4 +104,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:b87ddb42fd2b1182ef11101f0298be2e4de9b942fd3b8b4b169d1bdc849f48a8)
[comment]: # ( SHA256STAMP:f4dbe3ecc88a294f7bb983a2f2b8e9613e440e4564580e51dd30fc83ba218a91)
4 changes: 4 additions & 0 deletions doc/schemas/delpay.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
"type": "u64",
"description": "the UNIX timestamp showing when this payment was initiated"
},
"completed_at": {
"type": "u64",
"description": "the UNIX timestamp showing when this payment was completed"
},
"groupid": {
"type": "u64",
"description": "Grouping key to disambiguate multiple attempts to pay an invoice or the same payment_hash"
Expand Down
49 changes: 9 additions & 40 deletions doc/schemas/listpays.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
"type": "u64",
"description": "the UNIX timestamp showing when this payment was initiated"
},
"completed_at": {
"type": "u64",
"description": "the UNIX timestamp showing when this payment was completed"
},
"label": {
"type": "string",
"description": "the label, if given to sendpay"
Expand All @@ -58,45 +62,6 @@
}
},
"allOf": [
{
"if": {
"properties": {
"status": {
"type": "string",
"enum": [
"pending",
"complete"
]
}
}
},
"then": {
"additionalProperties": false,
"required": [
"amount_sent_msat"
],
"properties": {
"payment_hash": {},
"status": {},
"destination": {},
"created_at": {},
"label": {},
"bolt11": {},
"description": {},
"bolt12": {},
"preimage": {},
"number_of_parts": {},
"amount_msat": {
"type": "msat",
"description": "the amount the destination received, if known"
},
"amount_sent_msat": {
"type": "msat",
"description": "the amount we actually sent, including fees"
}
}
}
},
{
"if": {
"properties": {
Expand All @@ -111,13 +76,15 @@
"then": {
"additionalProperties": false,
"required": [
"amount_sent_msat",
"preimage"
],
"properties": {
"payment_hash": {},
"status": {},
"destination": {},
"created_at": {},
"completed_at": {},
"label": {},
"bolt11": {},
"description": {},
Expand Down Expand Up @@ -150,7 +117,9 @@
},
"then": {
"additionalProperties": false,
"required": [],
"required": [
"amount_sent_msat"
],
"properties": {
"payment_hash": {},
"status": {},
Expand Down
2 changes: 2 additions & 0 deletions doc/schemas/listsendpays.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"amount_msat": {},
"destination": {},
"created_at": {},
"completed_at": {},
"msatoshi_sent": {},
"amount_sent_msat": {},
"label": {},
Expand Down Expand Up @@ -147,6 +148,7 @@
"amount_msat": {},
"destination": {},
"created_at": {},
"completed_at": {},
"msatoshi_sent": {},
"amount_sent_msat": {},
"label": {},
Expand Down
6 changes: 6 additions & 0 deletions doc/schemas/sendpay.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
"type": "u64",
"description": "the UNIX timestamp showing when this payment was initiated"
},
"completed_at": {
"type": "u64",
"description": "the UNIX timestamp showing when this payment was completed"
},
"msatoshi_sent": {
"deprecated": true
},
Expand Down Expand Up @@ -97,6 +101,7 @@
"amount_msat": {},
"destination": {},
"created_at": {},
"completed_at": {},
"msatoshi_sent": {},
"amount_sent_msat": {},
"label": {},
Expand Down Expand Up @@ -137,6 +142,7 @@
"amount_msat": {},
"destination": {},
"created_at": {},
"completed_at": {},
"msatoshi_sent": {},
"amount_sent_msat": {},
"label": {},
Expand Down
5 changes: 5 additions & 0 deletions doc/schemas/waitsendpay.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"type": "u64",
"description": "the UNIX timestamp showing when this payment was initiated"
},
"completed_at": {
"type": "number",
"description": "the UNIX timestamp showing when this payment was completed"
},
"msatoshi_sent": {
"deprecated": true
},
Expand Down Expand Up @@ -96,6 +100,7 @@
"amount_msat": {},
"destination": {},
"created_at": {},
"completed_at": {},
"msatoshi_sent": {},
"amount_sent_msat": {},
"label": {},
Expand Down
Loading