Skip to content

Commit c266189

Browse files
committed
lightningd: handle old Tor version 2 addresses in db without crashing.
In non-developer mode, this results in: "Could not load channels from the database" Fixes: #5238 Signed-off-by: Rusty Russell <[email protected]> Changelog-Fixed: lightningd: fix failed startup "Could not load channels from the database" if old TORv2 addresses were present.
1 parent 3a763be commit c266189

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ which especially hurt larger nodes.
1717
- routing: Fixed an issue where we would exclude the entire channel if either direction was disabled, or we hadn't seen an update yet. ([#5286])
1818
- connectd: large memory usage with many peers fixed. ([#5312])
1919
- connectd: reduce initial CPU load when connecting to peers. ([#5328])
20+
- lightnind: fix failed startup "Could not load channels from the database" if old TORv2 addresses were present. ([#5331])
2021

2122
[#5286]: https://github.com/ElementsProject/lightning/pull/5286
2223
[#5300]: https://github.com/ElementsProject/lightning/pull/5300
2324
[#5312]: https://github.com/ElementsProject/lightning/pull/5312
2425
[#5326]: https://github.com/ElementsProject/lightning/pull/5326
2526
[#5328]: https://github.com/ElementsProject/lightning/pull/5328
27+
[#5331]: https://github.com/ElementsProject/lightning/pull/5331
2628
[0.11.2]: https://github.com/ElementsProject/lightning/releases/tag/v0.11.2
2729

2830
## [0.11.1] - 2022-05-13: Simon's Carefully Chosen Release Name II

wallet/wallet.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,15 @@ static struct peer *wallet_peer_load(struct wallet *w, const u64 dbid)
836836

837837
db_col_node_id(stmt, "node_id", &id);
838838

839+
/* This can happen for peers last seen on Torv2! */
839840
addrstr = db_col_strdup(tmpctx, stmt, "address");
840841
if (!parse_wireaddr_internal(addrstr, &addr, DEFAULT_PORT,
841-
false, false, true, true, NULL))
842-
goto done;
842+
false, false, true, true, NULL)) {
843+
log_unusual(w->log, "Unparsable peer address %s: replacing",
844+
addrstr);
845+
parse_wireaddr_internal("127.0.0.1:1", &addr, DEFAULT_PORT,
846+
false, false, true, true, NULL);
847+
}
843848

844849
/* FIXME: save incoming in db! */
845850
peer = new_peer(w->ld, db_col_u64(stmt, "id"), &id, &addr, false);

0 commit comments

Comments
 (0)