diff --git a/plugins/pay.c b/plugins/pay.c index f7c9595a47a2..e7ea42c3c4ad 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1666,6 +1666,9 @@ struct pay_mpp { * only). Null if we have any part for which we didn't know the * amount. */ struct amount_msat *amount; + + /* Timestamp of the first part */ + u32 timestamp; }; static const struct sha256 *pay_mpp_key(const struct pay_mpp *pm) @@ -1735,6 +1738,8 @@ static void add_new_entry(struct json_stream *ret, json_object_start(ret, NULL); json_add_string(ret, "bolt11", pm->b11); json_add_string(ret, "status", pm->status); + json_add_u32(ret, "timestamp", pm->timestamp); + if (pm->label) json_add_tok(ret, "label", pm->label, buf); if (pm->preimage) @@ -1777,15 +1782,19 @@ static struct command_result *listsendpays_done(struct command *cmd, ret = jsonrpc_stream_success(cmd); json_array_start(ret, "pays"); json_for_each_arr(i, t, arr) { - const jsmntok_t *status, *b11tok, *hashtok; + const jsmntok_t *status, *b11tok, *hashtok, *timestamptok; const char *b11 = b11str; struct sha256 payment_hash; + u32 timestamp; b11tok = json_get_member(buf, t, "bolt11"); hashtok = json_get_member(buf, t, "payment_hash"); + timestamptok = json_get_member(buf, t, "timestamp"); assert(hashtok != NULL); + assert(timestamptok != NULL); json_to_sha256(buf, hashtok, &payment_hash); + json_to_u32(buf, timestamptok, ×tamp); if (b11tok) b11 = json_strdup(cmd, buf, b11tok); @@ -1800,6 +1809,7 @@ static struct command_result *listsendpays_done(struct command *cmd, pm->amount = talz(pm, struct amount_msat); pm->num_nonfailed_parts = 0; pm->status = NULL; + pm->timestamp = timestamp; pay_map_add(&pay_map, pm); } diff --git a/tests/test_pay.py b/tests/test_pay.py index 8d22f86589b4..862aafded0bb 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -3221,3 +3221,4 @@ def test_bolt11_null_after_pay(node_factory, bitcoind): pays = l2.rpc.listpays()["pays"] assert(pays[0]["bolt11"] == invl1) assert('amount_msat' in pays[0] and pays[0]['amount_msat'] == amt) + assert('timestamp' in pays[0])