Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Oct 26, 2024
2 parents a4c08d9 + 4017844 commit 9aa3819
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
4 changes: 2 additions & 2 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19748,7 +19748,7 @@
"received_time": {
"type": "number",
"description": [
"The UNIX timestamp when this was received."
"The UNIX timestamp when this was received (may be zero for old forwards)."
]
},
"out_channel": {
Expand Down Expand Up @@ -26645,7 +26645,7 @@
"rpc": "openchannel_abort",
"title": "Command to abort a channel to a peer",
"description": [
"`openchannel_init` is a low level RPC command which initiates a channel open with a specified peer. It uses the openchannel protocol which allows for interactive transaction construction."
"`openchannel_abort` is a low level RPC command which initiates an abort for specified channel. It uses the openchannel protocol which allows for interactive transaction construction."
],
"request": {
"required": [
Expand Down
2 changes: 1 addition & 1 deletion doc/schemas/lightning-listforwards.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"received_time": {
"type": "number",
"description": [
"The UNIX timestamp when this was received."
"The UNIX timestamp when this was received (may be zero for old forwards)."
]
},
"out_channel": {
Expand Down
2 changes: 1 addition & 1 deletion doc/schemas/lightning-openchannel_abort.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"rpc": "openchannel_abort",
"title": "Command to abort a channel to a peer",
"description": [
"`openchannel_init` is a low level RPC command which initiates a channel open with a specified peer. It uses the openchannel protocol which allows for interactive transaction construction."
"`openchannel_abort` is a low level RPC command which initiates an abort for specified channel. It uses the openchannel protocol which allows for interactive transaction construction."
],
"request": {
"required": [
Expand Down
12 changes: 2 additions & 10 deletions lightningd/forwards.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,11 @@ void json_add_forwarding_fields(struct json_stream *response,
json_add_string(response, "style",
forward_style_name(cur->forward_style));

#ifdef COMPAT_V070
/* If a forwarding doesn't have received_time it was created
* before we added the tracking, do not include it here. */
if (cur->received_time.ts.tv_sec) {
json_add_timeabs(response, "received_time", cur->received_time);
if (cur->resolved_time)
json_add_timeabs(response, "resolved_time", *cur->resolved_time);
}
#else
/* Forwards didn't originally have received_time. They should be 0
in the database due to a previous migration. */
json_add_timeabs(response, "received_time", cur->received_time);
if (cur->resolved_time)
json_add_timeabs(response, "resolved_time", *cur->resolved_time);
#endif
}

static void listforwardings_add_forwardings(struct json_stream *response,
Expand Down
23 changes: 23 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,29 @@ def test_listforwards_wait(node_factory, executor):
'status': 'failed'}}


@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "modifies database, which is assumed sqlite3")
def test_listforwards_ancient(node_factory, bitcoind):
"""Test listforwards command with old records."""
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True)

amt1 = 1000
inv1 = l3.rpc.invoice(amt1, 'inv1', 'desc')
l1.rpc.pay(inv1['bolt11'])

forwards = l2.rpc.listforwards()['forwards']
assert len(forwards) == 1
assert forwards[0]['received_time']

# Make this forward look like an older record, with received_time default 0.
l2.stop()
l2.db_manip("UPDATE forwards SET received_time=0;")
l2.start()

forwards = l2.rpc.listforwards()['forwards']
assert len(forwards) == 1
assert forwards[0]['received_time'] == 0


@pytest.mark.openchannel('v1')
def test_version_reexec(node_factory, bitcoind):
badopeningd = os.path.join(os.path.dirname(__file__), "plugins", "badopeningd.sh")
Expand Down

0 comments on commit 9aa3819

Please sign in to comment.