From fe8074c8c311cb385e68f0fc6b4ea066716bd300 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Thu, 20 May 2021 17:45:27 +0200 Subject: [PATCH] Refuse to parse v2 onion addresses without deprecated_apis Tor v2 hidden services have been deprecated for a while: https://blog.torproject.org/v2-deprecation-timeline . This prevents user from being able to set them in the configuration and to connect to them while still letting us be able to parse them for gossip. Changelog-Deprecated: lightningd: v2 Tor addresses. Use v3. See https://blog.torproject.org/v2-deprecation-timeline. Signed-off-by: Antoine Poinsot --- common/test/run-ip_port_parsing.c | 7 + common/wireaddr.c | 12 +- common/wireaddr.h | 3 +- devtools/gossipwith.c | 2 +- lightningd/connect_control.c | 3 +- lightningd/options.c | 15 ++- tests/test_gossip.py | 20 +-- wallet/db_postgres_sqlgen.c | 2 +- wallet/db_sqlite3_sqlgen.c | 2 +- wallet/statements_gettextgen.po | 208 +++++++++++++++--------------- wallet/test/run-wallet.c | 4 +- wallet/wallet.c | 3 +- 12 files changed, 151 insertions(+), 130 deletions(-) diff --git a/common/test/run-ip_port_parsing.c b/common/test/run-ip_port_parsing.c index 52a60ffef..78d468fc3 100644 --- a/common/test/run-ip_port_parsing.c +++ b/common/test/run-ip_port_parsing.c @@ -113,6 +113,7 @@ void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNE int main(int argc, char *argv[]) { struct wireaddr addr; + struct wireaddr_internal addr_int; char *ip; u16 port; @@ -189,6 +190,12 @@ int main(int argc, char *argv[]) assert(parse_wireaddr("odpzvneidqdf5hdq.onion", &addr, 1, false, NULL)); assert(addr.port == 1); + // Don't accept legacy hidden services with deprecated APIs on + assert(!parse_wireaddr_internal("odpzvneidqdf5hdq.onion", &addr_int, 1, + false, false, false, /* allow_deprecated = */ false, NULL)); + assert(parse_wireaddr_internal("odpzvneidqdf5hdq.onion", &addr_int, 1, + false, false, false, /* allow_deprecated = */ true, NULL)); + assert(tal_count(wireaddr_from_hostname(tmpctx, "odpzvneidqdf5hdq.onion", 1, NULL, NULL, NULL)) > 0); assert(wireaddr_from_hostname(tmpctx, "aaa.onion", 1, NULL, NULL, NULL) == NULL); diff --git a/common/wireaddr.c b/common/wireaddr.c index 8e6769a46..b765157c3 100644 --- a/common/wireaddr.c +++ b/common/wireaddr.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -446,7 +447,7 @@ finish: bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr, u16 port, bool wildcard_ok, bool dns_ok, - bool unresolved_ok, + bool unresolved_ok, bool allow_deprecated, const char **err_msg) { u16 splitport; @@ -578,8 +579,15 @@ bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr, addr->itype = ADDR_INTERNAL_WIREADDR; if (parse_wireaddr(arg, &addr->u.wireaddr, port, - dns_ok ? NULL : &needed_dns, err_msg)) + dns_ok ? NULL : &needed_dns, err_msg)) { + if (!allow_deprecated && addr->u.wireaddr.type == ADDR_TYPE_TOR_V2) { + if (err_msg) + *err_msg = "v2 Tor onion services are deprecated"; + return false; + } + return true; + } if (!needed_dns || !unresolved_ok) return false; diff --git a/common/wireaddr.h b/common/wireaddr.h index 58ac41635..26612a16e 100644 --- a/common/wireaddr.h +++ b/common/wireaddr.h @@ -140,7 +140,8 @@ struct wireaddr_internal { }; bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr, u16 port, bool wildcard_ok, bool dns_ok, - bool unresolved_ok, const char **err_msg); + bool unresolved_ok, bool allow_deprecated, + const char **err_msg); void towire_wireaddr_internal(u8 **pptr, const struct wireaddr_internal *addr); diff --git a/devtools/gossipwith.c b/devtools/gossipwith.c index 31ae79e5c..92983bf92 100644 --- a/devtools/gossipwith.c +++ b/devtools/gossipwith.c @@ -299,7 +299,7 @@ int main(int argc, char *argv[]) (int)(at - argv[1]), argv[1]); if (!parse_wireaddr_internal(at+1, &addr, DEFAULT_PORT, NULL, - true, false, &err_msg)) + true, false, true, &err_msg)) opt_usage_exit_fail("%s '%s'", err_msg, argv[1]); switch (addr.itype) { diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index adbb43408..f0bec05a9 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -166,7 +167,7 @@ static struct command_result *json_connect(struct command *cmd, if (!parse_wireaddr_internal(name, addr, *port, false, !cmd->ld->use_proxy_always && !cmd->ld->pure_tor_setup, - true, + true, deprecated_apis, &err_msg)) { return command_fail(cmd, LIGHTNINGD, "Host %s:%u not valid: %s", diff --git a/lightningd/options.c b/lightningd/options.c index 900129e22..6801d73f7 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -145,7 +145,7 @@ static char *opt_add_addr_withtype(const char *arg, if (!parse_wireaddr_internal(arg, &wi, ld->portnum, wildcard_ok, !ld->use_proxy_always, false, - &err_msg)) { + deprecated_apis, &err_msg)) { return tal_fmt(NULL, "Unable to parse address '%s': %s", arg, err_msg); } tal_arr_expand(&ld->proposed_wireaddr, wi); @@ -202,7 +202,8 @@ static char *opt_add_addr(const char *arg, struct lightningd *ld) struct wireaddr_internal addr; /* handle in case you used the addr option with an .onion */ - if (parse_wireaddr_internal(arg, &addr, 0, true, false, true, NULL)) { + if (parse_wireaddr_internal(arg, &addr, 0, true, false, true, + deprecated_apis, NULL)) { if (addr.itype == ADDR_INTERNAL_WIREADDR && ( addr.u.wireaddr.type == ADDR_TYPE_TOR_V2 || addr.u.wireaddr.type == ADDR_TYPE_TOR_V3)) { @@ -249,7 +250,8 @@ static char *opt_add_bind_addr(const char *arg, struct lightningd *ld) struct wireaddr_internal addr; /* handle in case you used the bind option with an .onion */ - if (parse_wireaddr_internal(arg, &addr, 0, true, false, true, NULL)) { + if (parse_wireaddr_internal(arg, &addr, 0, true, false, true, + deprecated_apis, NULL)) { if (addr.itype == ADDR_INTERNAL_WIREADDR && ( addr.u.wireaddr.type == ADDR_TYPE_TOR_V2 || addr.u.wireaddr.type == ADDR_TYPE_TOR_V3)) { @@ -949,7 +951,7 @@ static void register_opts(struct lightningd *ld) "Set an IP address (v4 or v6) to listen on, but not announce"); opt_register_arg("--announce-addr", opt_add_announce_addr, NULL, ld, - "Set an IP address (v4 or v6) or .onion v2/v3 to announce, but not listen on"); + "Set an IP address (v4 or v6) or .onion v3 to announce, but not listen on"); opt_register_noarg("--offline", opt_set_offline, ld, "Start in offline-mode (do not automatically reconnect and do not accept incoming connections)"); @@ -966,8 +968,9 @@ static void register_opts(struct lightningd *ld) opt_register_noarg("--disable-dns", opt_set_invbool, &ld->config.use_dns, "Disable DNS lookups of peers"); - opt_register_noarg("--enable-autotor-v2-mode", opt_set_invbool, &ld->config.use_v3_autotor, - "Try to get a v2 onion address from the Tor service call, default is v3"); + if (deprecated_apis) + opt_register_noarg("--enable-autotor-v2-mode", opt_set_invbool, &ld->config.use_v3_autotor, + "Try to get a v2 onion address from the Tor service call, default is v3"); opt_register_noarg("--encrypted-hsm", opt_set_hsm_password, ld, "Set the password to encrypt hsm_secret with. If no password is passed through command line, " diff --git a/tests/test_gossip.py b/tests/test_gossip.py index d78936743..470505e88 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -111,7 +111,6 @@ def test_announce_address(node_factory, bitcoind): # We do not allow announcement of duplicates. opts = {'announce-addr': ['4acth47i6kxnvkewtm6q7ib2s3ufpo5sqbsnzjpbi7utijcltosqemad.onion', - 'silkroad6ownowfk.onion', '1.2.3.4:1234', '::'], 'log-level': 'io', @@ -127,11 +126,10 @@ def test_announce_address(node_factory, bitcoind): # We should see it send node announce with all addresses (257 = 0x0101) # local ephemeral port is masked out. - l1.daemon.wait_for_log(r"\[OUT\] 0101.*54" + l1.daemon.wait_for_log(r"\[OUT\] 0101.*47" "010102030404d2" "017f000001...." "02000000000000000000000000000000002607" - "039216a8b803f3acd758aa2607" "04e00533f3e8f2aedaa8969b3d0fa03a96e857bbb28064dca5e147e934244b9ba50230032607") @@ -218,7 +216,6 @@ def test_connect_by_gossip(node_factory, bitcoind): opts=[{'announce-addr': ['127.0.0.1:2', '[::]:2', - '3fyb44wdhnd2ghhl.onion', 'vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion'], 'dev-allow-localhost': None}, {}, @@ -904,12 +901,15 @@ def test_query_short_channel_id(node_factory, bitcoind, chainparams): def test_gossip_addresses(node_factory, bitcoind): - l1 = node_factory.get_node(options={'announce-addr': [ - '[::]:3', - '127.0.0.1:2', - 'vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion', - '3fyb44wdhnd2ghhl.onion:1234' - ]}) + l1 = node_factory.get_node(options={ + 'announce-addr': [ + '[::]:3', + '127.0.0.1:2', + 'vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion', + '3fyb44wdhnd2ghhl.onion:1234' + ], + 'allow-deprecated-apis': True, + }) l2 = node_factory.get_node() l1.rpc.connect(l2.info['id'], 'localhost', l2.port) diff --git a/wallet/db_postgres_sqlgen.c b/wallet/db_postgres_sqlgen.c index efeaae5bb..6e4dd0b44 100644 --- a/wallet/db_postgres_sqlgen.c +++ b/wallet/db_postgres_sqlgen.c @@ -1906,4 +1906,4 @@ struct db_query db_postgres_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */ -// SHA256STAMP:3e9e616dd7902bee25e0b17b878a60e57a7a8c9bfec2376b4efe7c4094ffe617 +// SHA256STAMP:0e328ae08429373c5aa43797ae12be23e5b6c3d7e2f06123c2640a1a42ac79ee diff --git a/wallet/db_sqlite3_sqlgen.c b/wallet/db_sqlite3_sqlgen.c index 1e6be805e..994b296e7 100644 --- a/wallet/db_sqlite3_sqlgen.c +++ b/wallet/db_sqlite3_sqlgen.c @@ -1906,4 +1906,4 @@ struct db_query db_sqlite3_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */ -// SHA256STAMP:3e9e616dd7902bee25e0b17b878a60e57a7a8c9bfec2376b4efe7c4094ffe617 +// SHA256STAMP:0e328ae08429373c5aa43797ae12be23e5b6c3d7e2f06123c2640a1a42ac79ee diff --git a/wallet/statements_gettextgen.po b/wallet/statements_gettextgen.po index 7dc0f8185..d4f00c142 100644 --- a/wallet/statements_gettextgen.po +++ b/wallet/statements_gettextgen.po @@ -830,415 +830,415 @@ msgstr "" msgid "SELECT id, node_id, address FROM peers WHERE id=?;" msgstr "" -#: wallet/wallet.c:842 +#: wallet/wallet.c:843 msgid "SELECT signature FROM htlc_sigs WHERE channelid = ?" msgstr "" -#: wallet/wallet.c:876 +#: wallet/wallet.c:877 msgid "SELECT remote_ann_node_sig, remote_ann_bitcoin_sig FROM channels WHERE id = ?" msgstr "" -#: wallet/wallet.c:920 +#: wallet/wallet.c:921 msgid "SELECT hstate, feerate_per_kw FROM channel_feerates WHERE channel_id = ?" msgstr "" -#: wallet/wallet.c:953 +#: wallet/wallet.c:954 msgid "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:988 +#: wallet/wallet.c:989 msgid "UPDATE channel_funding_inflights SET funding_psbt=?, funding_tx_remote_sigs_received=? WHERE channel_id=? AND funding_tx_id=? AND funding_tx_outnum=?" msgstr "" -#: wallet/wallet.c:1011 +#: wallet/wallet.c:1012 msgid "DELETE FROM channel_funding_inflights WHERE channel_id = ?" msgstr "" -#: wallet/wallet.c:1059 +#: wallet/wallet.c:1060 msgid "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate" msgstr "" -#: wallet/wallet.c:1288 +#: wallet/wallet.c:1289 msgid "SELECT id FROM channels ORDER BY id DESC LIMIT 1;" msgstr "" -#: wallet/wallet.c:1305 +#: wallet/wallet.c:1306 msgid "SELECT id, peer_id, short_channel_id, full_channel_id, channel_config_local, channel_config_remote, state, funder, channel_flags, minimum_depth, next_index_local, next_index_remote, next_htlc_id, funding_tx_id, funding_tx_outnum, funding_satoshi, our_funding_satoshi, funding_locked_remote, push_msatoshi, msatoshi_local, fundingkey_remote, revocation_basepoint_remote, payment_basepoint_remote, htlc_basepoint_remote, delayed_payment_basepoint_remote, per_commit_remote, old_per_commit_remote, local_feerate_per_kw, remote_feerate_per_kw, shachain_remote_id, shutdown_scriptpubkey_remote, shutdown_keyidx_local, last_sent_commit_state, last_sent_commit_id, last_tx, last_sig, last_was_revoke, first_blocknum, min_possible_feerate, max_possible_feerate, msatoshi_to_us_min, msatoshi_to_us_max, future_per_commitment_point, last_sent_commit, feerate_base, feerate_ppm, remote_upfront_shutdown_script, option_static_remotekey, option_anchor_outputs, shutdown_scriptpubkey_local, closer, state_change_reason, revocation_basepoint_local, payment_basepoint_local, htlc_basepoint_local, delayed_payment_basepoint_local, funding_pubkey_local, shutdown_wrong_txid, shutdown_wrong_outnum FROM channels WHERE state != ?;" msgstr "" -#: wallet/wallet.c:1403 +#: wallet/wallet.c:1404 msgid "UPDATE channels SET in_payments_offered = COALESCE(in_payments_offered, 0) + 1 , in_msatoshi_offered = COALESCE(in_msatoshi_offered, 0) + ? WHERE id = ?;" msgstr "" -#: wallet/wallet.c:1408 +#: wallet/wallet.c:1409 msgid "UPDATE channels SET in_payments_fulfilled = COALESCE(in_payments_fulfilled, 0) + 1 , in_msatoshi_fulfilled = COALESCE(in_msatoshi_fulfilled, 0) + ? WHERE id = ?;" msgstr "" -#: wallet/wallet.c:1413 +#: wallet/wallet.c:1414 msgid "UPDATE channels SET out_payments_offered = COALESCE(out_payments_offered, 0) + 1 , out_msatoshi_offered = COALESCE(out_msatoshi_offered, 0) + ? WHERE id = ?;" msgstr "" -#: wallet/wallet.c:1418 +#: wallet/wallet.c:1419 msgid "UPDATE channels SET out_payments_fulfilled = COALESCE(out_payments_fulfilled, 0) + 1 , out_msatoshi_fulfilled = COALESCE(out_msatoshi_fulfilled, 0) + ? WHERE id = ?;" msgstr "" -#: wallet/wallet.c:1460 +#: wallet/wallet.c:1461 msgid "SELECT in_payments_offered, in_payments_fulfilled, in_msatoshi_offered, in_msatoshi_fulfilled, out_payments_offered, out_payments_fulfilled, out_msatoshi_offered, out_msatoshi_fulfilled FROM channels WHERE id = ?" msgstr "" -#: wallet/wallet.c:1489 +#: wallet/wallet.c:1490 msgid "SELECT MIN(height), MAX(height) FROM blocks;" msgstr "" -#: wallet/wallet.c:1511 +#: wallet/wallet.c:1512 msgid "INSERT INTO channel_configs DEFAULT VALUES;" msgstr "" -#: wallet/wallet.c:1523 +#: wallet/wallet.c:1524 msgid "UPDATE channel_configs SET dust_limit_satoshis=?, max_htlc_value_in_flight_msat=?, channel_reserve_satoshis=?, htlc_minimum_msat=?, to_self_delay=?, max_accepted_htlcs=? WHERE id=?;" msgstr "" -#: wallet/wallet.c:1547 +#: wallet/wallet.c:1548 msgid "SELECT id, dust_limit_satoshis, max_htlc_value_in_flight_msat, channel_reserve_satoshis, htlc_minimum_msat, to_self_delay, max_accepted_htlcs FROM channel_configs WHERE id= ? ;" msgstr "" -#: wallet/wallet.c:1581 +#: wallet/wallet.c:1582 msgid "UPDATE channels SET remote_ann_node_sig=?, remote_ann_bitcoin_sig=? WHERE id=?" msgstr "" -#: wallet/wallet.c:1600 +#: wallet/wallet.c:1601 msgid "UPDATE channels SET shachain_remote_id=?, short_channel_id=?, full_channel_id=?, state=?, funder=?, channel_flags=?, minimum_depth=?, next_index_local=?, next_index_remote=?, next_htlc_id=?, funding_tx_id=?, funding_tx_outnum=?, funding_satoshi=?, our_funding_satoshi=?, funding_locked_remote=?, push_msatoshi=?, msatoshi_local=?, shutdown_scriptpubkey_remote=?, shutdown_keyidx_local=?, channel_config_local=?, last_tx=?, last_sig=?, last_was_revoke=?, min_possible_feerate=?, max_possible_feerate=?, msatoshi_to_us_min=?, msatoshi_to_us_max=?, feerate_base=?, feerate_ppm=?, remote_upfront_shutdown_script=?, option_static_remotekey=?, option_anchor_outputs=?, shutdown_scriptpubkey_local=?, closer=?, state_change_reason=?, shutdown_wrong_txid=?, shutdown_wrong_outnum=? WHERE id=?" msgstr "" -#: wallet/wallet.c:1692 +#: wallet/wallet.c:1693 msgid "UPDATE channels SET fundingkey_remote=?, revocation_basepoint_remote=?, payment_basepoint_remote=?, htlc_basepoint_remote=?, delayed_payment_basepoint_remote=?, per_commit_remote=?, old_per_commit_remote=?, channel_config_remote=?, future_per_commitment_point=? WHERE id=?" msgstr "" -#: wallet/wallet.c:1719 +#: wallet/wallet.c:1720 msgid "DELETE FROM channel_feerates WHERE channel_id=?" msgstr "" -#: wallet/wallet.c:1729 +#: wallet/wallet.c:1730 msgid "INSERT INTO channel_feerates VALUES(?, ?, ?)" msgstr "" -#: wallet/wallet.c:1746 +#: wallet/wallet.c:1747 msgid "UPDATE channels SET last_sent_commit=? WHERE id=?" msgstr "" -#: wallet/wallet.c:1769 +#: wallet/wallet.c:1770 msgid "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES (?, ?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:1797 +#: wallet/wallet.c:1798 msgid "SELECT timestamp, old_state, new_state, cause, message FROM channel_state_changes WHERE channel_id = ? ORDER BY timestamp ASC;" msgstr "" -#: wallet/wallet.c:1826 +#: wallet/wallet.c:1827 msgid "SELECT id FROM peers WHERE node_id = ?" msgstr "" -#: wallet/wallet.c:1838 +#: wallet/wallet.c:1839 msgid "UPDATE peers SET address = ? WHERE id = ?" msgstr "" -#: wallet/wallet.c:1847 +#: wallet/wallet.c:1848 msgid "INSERT INTO peers (node_id, address) VALUES (?, ?);" msgstr "" -#: wallet/wallet.c:1868 +#: wallet/wallet.c:1869 msgid "INSERT INTO channels ( peer_id, first_blocknum, id, revocation_basepoint_local, payment_basepoint_local, htlc_basepoint_local, delayed_payment_basepoint_local, funding_pubkey_local) VALUES (?, ?, ?, ?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:1909 +#: wallet/wallet.c:1910 msgid "DELETE FROM channel_htlcs WHERE channel_id=?" msgstr "" -#: wallet/wallet.c:1915 +#: wallet/wallet.c:1916 msgid "DELETE FROM htlc_sigs WHERE channelid=?" msgstr "" -#: wallet/wallet.c:1921 +#: wallet/wallet.c:1922 msgid "DELETE FROM channeltxs WHERE channel_id=?" msgstr "" -#: wallet/wallet.c:1928 +#: wallet/wallet.c:1929 msgid "DELETE FROM channel_funding_inflights WHERE channel_id=?" msgstr "" -#: wallet/wallet.c:1934 +#: wallet/wallet.c:1935 msgid "DELETE FROM shachains WHERE id IN ( SELECT shachain_remote_id FROM channels WHERE channels.id=?)" msgstr "" -#: wallet/wallet.c:1944 +#: wallet/wallet.c:1945 msgid "UPDATE channels SET state=?, peer_id=? WHERE channels.id=?" msgstr "" -#: wallet/wallet.c:1958 +#: wallet/wallet.c:1959 msgid "SELECT * FROM channels WHERE peer_id = ?;" msgstr "" -#: wallet/wallet.c:1966 +#: wallet/wallet.c:1967 msgid "DELETE FROM peers WHERE id=?" msgstr "" -#: wallet/wallet.c:1977 +#: wallet/wallet.c:1978 msgid "UPDATE outputs SET confirmation_height = ? WHERE prev_out_tx = ?" msgstr "" -#: wallet/wallet.c:2080 +#: wallet/wallet.c:2081 msgid "INSERT INTO channel_htlcs ( channel_id, channel_htlc_id, direction, msatoshi, cltv_expiry, payment_hash, payment_key, hstate, shared_secret, routing_onion, received_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:2133 +#: wallet/wallet.c:2134 msgid "INSERT INTO channel_htlcs ( channel_id, channel_htlc_id, direction, origin_htlc, msatoshi, cltv_expiry, payment_hash, payment_key, hstate, routing_onion, malformed_onion, partid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?);" msgstr "" -#: wallet/wallet.c:2194 +#: wallet/wallet.c:2195 msgid "UPDATE channel_htlcs SET hstate=?, payment_key=?, malformed_onion=?, failuremsg=?, localfailmsg=?, we_filled=? WHERE id=?" msgstr "" -#: wallet/wallet.c:2410 +#: wallet/wallet.c:2411 msgid "SELECT id, channel_htlc_id, msatoshi, cltv_expiry, hstate, payment_hash, payment_key, routing_onion, failuremsg, malformed_onion, origin_htlc, shared_secret, received_time, we_filled FROM channel_htlcs WHERE direction= ? AND channel_id= ? AND hstate != ?" msgstr "" -#: wallet/wallet.c:2457 +#: wallet/wallet.c:2458 msgid "SELECT id, channel_htlc_id, msatoshi, cltv_expiry, hstate, payment_hash, payment_key, routing_onion, failuremsg, malformed_onion, origin_htlc, shared_secret, received_time, partid, localfailmsg FROM channel_htlcs WHERE direction = ? AND channel_id = ? AND hstate != ?" msgstr "" -#: wallet/wallet.c:2588 +#: wallet/wallet.c:2589 msgid "SELECT channel_id, direction, cltv_expiry, channel_htlc_id, payment_hash FROM channel_htlcs WHERE channel_id = ?;" msgstr "" -#: wallet/wallet.c:2622 +#: wallet/wallet.c:2623 msgid "DELETE FROM channel_htlcs WHERE direction = ? AND origin_htlc = ? AND payment_hash = ? AND partid = ?;" msgstr "" -#: wallet/wallet.c:2675 +#: wallet/wallet.c:2676 msgid "SELECT status FROM payments WHERE payment_hash=? AND partid = ?;" msgstr "" -#: wallet/wallet.c:2693 +#: wallet/wallet.c:2694 msgid "INSERT INTO payments ( status, payment_hash, destination, msatoshi, timestamp, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, total_msat, partid, local_offer_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:2782 +#: wallet/wallet.c:2783 msgid "DELETE FROM payments WHERE payment_hash = ? AND partid = ?" msgstr "" -#: wallet/wallet.c:2796 +#: wallet/wallet.c:2797 msgid "DELETE FROM payments WHERE payment_hash = ?" msgstr "" -#: wallet/wallet.c:2897 +#: wallet/wallet.c:2898 msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid, local_offer_id FROM payments WHERE payment_hash = ? AND partid = ?" msgstr "" -#: wallet/wallet.c:2947 +#: wallet/wallet.c:2948 msgid "UPDATE payments SET status=? WHERE payment_hash=? AND partid=?" msgstr "" -#: wallet/wallet.c:2957 +#: wallet/wallet.c:2958 msgid "UPDATE payments SET payment_preimage=? WHERE payment_hash=? AND partid=?" msgstr "" -#: wallet/wallet.c:2967 +#: wallet/wallet.c:2968 msgid "UPDATE payments SET path_secrets = NULL , route_nodes = NULL , route_channels = NULL WHERE payment_hash = ? AND partid = ?;" msgstr "" -#: wallet/wallet.c:2999 +#: wallet/wallet.c:3000 msgid "SELECT failonionreply, faildestperm, failindex, failcode, failnode, failchannel, failupdate, faildetail, faildirection FROM payments WHERE payment_hash=? AND partid=?;" msgstr "" -#: wallet/wallet.c:3066 +#: wallet/wallet.c:3067 msgid "UPDATE payments SET failonionreply=? , faildestperm=? , failindex=? , failcode=? , failnode=? , failchannel=? , failupdate=? , faildetail=? , faildirection=? WHERE payment_hash=? AND partid=?;" msgstr "" -#: wallet/wallet.c:3125 +#: wallet/wallet.c:3126 msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid, local_offer_id FROM payments WHERE payment_hash = ?;" msgstr "" -#: wallet/wallet.c:3147 +#: wallet/wallet.c:3148 msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid, local_offer_id FROM payments ORDER BY id;" msgstr "" -#: wallet/wallet.c:3198 +#: wallet/wallet.c:3199 msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid, local_offer_id FROM payments WHERE local_offer_id = ?;" msgstr "" -#: wallet/wallet.c:3243 +#: wallet/wallet.c:3244 msgid "DELETE FROM htlc_sigs WHERE channelid = ?" msgstr "" -#: wallet/wallet.c:3250 +#: wallet/wallet.c:3251 msgid "INSERT INTO htlc_sigs (channelid, signature) VALUES (?, ?)" msgstr "" -#: wallet/wallet.c:3262 +#: wallet/wallet.c:3263 msgid "SELECT blobval FROM vars WHERE name='genesis_hash'" msgstr "" -#: wallet/wallet.c:3286 +#: wallet/wallet.c:3287 msgid "INSERT INTO vars (name, blobval) VALUES ('genesis_hash', ?);" msgstr "" -#: wallet/wallet.c:3304 +#: wallet/wallet.c:3305 msgid "SELECT txid, outnum FROM utxoset WHERE spendheight < ?" msgstr "" -#: wallet/wallet.c:3316 +#: wallet/wallet.c:3317 msgid "DELETE FROM utxoset WHERE spendheight < ?" msgstr "" -#: wallet/wallet.c:3324 wallet/wallet.c:3438 +#: wallet/wallet.c:3325 wallet/wallet.c:3439 msgid "INSERT INTO blocks (height, hash, prev_hash) VALUES (?, ?, ?);" msgstr "" -#: wallet/wallet.c:3343 +#: wallet/wallet.c:3344 msgid "DELETE FROM blocks WHERE hash = ?" msgstr "" -#: wallet/wallet.c:3349 +#: wallet/wallet.c:3350 msgid "SELECT * FROM blocks WHERE height >= ?;" msgstr "" -#: wallet/wallet.c:3358 +#: wallet/wallet.c:3359 msgid "DELETE FROM blocks WHERE height > ?" msgstr "" -#: wallet/wallet.c:3370 +#: wallet/wallet.c:3371 msgid "UPDATE outputs SET spend_height = ?, status = ? WHERE prev_out_tx = ? AND prev_out_index = ?" msgstr "" -#: wallet/wallet.c:3388 +#: wallet/wallet.c:3389 msgid "UPDATE utxoset SET spendheight = ? WHERE txid = ? AND outnum = ?" msgstr "" -#: wallet/wallet.c:3411 wallet/wallet.c:3449 +#: wallet/wallet.c:3412 wallet/wallet.c:3450 msgid "INSERT INTO utxoset ( txid, outnum, blockheight, spendheight, txindex, scriptpubkey, satoshis) VALUES(?, ?, ?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:3475 +#: wallet/wallet.c:3476 msgid "SELECT height FROM blocks WHERE height = ?" msgstr "" -#: wallet/wallet.c:3488 +#: wallet/wallet.c:3489 msgid "SELECT txid, spendheight, scriptpubkey, satoshis FROM utxoset WHERE blockheight = ? AND txindex = ? AND outnum = ? AND spendheight IS NULL" msgstr "" -#: wallet/wallet.c:3530 +#: wallet/wallet.c:3531 msgid "SELECT blockheight, txindex, outnum FROM utxoset WHERE spendheight = ?" msgstr "" -#: wallet/wallet.c:3561 wallet/wallet.c:3721 +#: wallet/wallet.c:3562 wallet/wallet.c:3722 msgid "SELECT blockheight FROM transactions WHERE id=?" msgstr "" -#: wallet/wallet.c:3571 +#: wallet/wallet.c:3572 msgid "INSERT INTO transactions ( id, blockheight, txindex, rawtx) VALUES (?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:3592 +#: wallet/wallet.c:3593 msgid "UPDATE transactions SET blockheight = ?, txindex = ? WHERE id = ?" msgstr "" -#: wallet/wallet.c:3609 +#: wallet/wallet.c:3610 msgid "INSERT INTO transaction_annotations (txid, idx, location, type, channel) VALUES (?, ?, ?, ?, ?) ON CONFLICT(txid,idx) DO NOTHING;" msgstr "" -#: wallet/wallet.c:3641 +#: wallet/wallet.c:3642 msgid "SELECT type, channel_id FROM transactions WHERE id=?" msgstr "" -#: wallet/wallet.c:3657 +#: wallet/wallet.c:3658 msgid "UPDATE transactions SET type = ?, channel_id = ? WHERE id = ?" msgstr "" -#: wallet/wallet.c:3676 +#: wallet/wallet.c:3677 msgid "SELECT type FROM transactions WHERE id=?" msgstr "" -#: wallet/wallet.c:3699 +#: wallet/wallet.c:3700 msgid "SELECT rawtx FROM transactions WHERE id=?" msgstr "" -#: wallet/wallet.c:3745 +#: wallet/wallet.c:3746 msgid "SELECT blockheight, txindex FROM transactions WHERE id=?" msgstr "" -#: wallet/wallet.c:3773 +#: wallet/wallet.c:3774 msgid "SELECT id FROM transactions WHERE blockheight=?" msgstr "" -#: wallet/wallet.c:3792 +#: wallet/wallet.c:3793 msgid "INSERT INTO channeltxs ( channel_id, type, transaction_id, input_num, blockheight) VALUES (?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:3816 +#: wallet/wallet.c:3817 msgid "SELECT DISTINCT(channel_id) FROM channeltxs WHERE type = ?;" msgstr "" -#: wallet/wallet.c:3837 +#: wallet/wallet.c:3838 msgid "SELECT c.type, c.blockheight, t.rawtx, c.input_num, c.blockheight - t.blockheight + 1 AS depth, t.id as txid FROM channeltxs c JOIN transactions t ON t.id = c.transaction_id WHERE c.channel_id = ? ORDER BY c.id ASC;" msgstr "" -#: wallet/wallet.c:3882 +#: wallet/wallet.c:3883 msgid "UPDATE forwarded_payments SET in_msatoshi=?, out_msatoshi=?, state=?, resolved_time=?, failcode=? WHERE in_htlc_id=?" msgstr "" -#: wallet/wallet.c:3940 +#: wallet/wallet.c:3941 msgid "INSERT INTO forwarded_payments ( in_htlc_id, out_htlc_id, in_channel_scid, out_channel_scid, in_msatoshi, out_msatoshi, state, received_time, resolved_time, failcode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:3999 +#: wallet/wallet.c:4000 msgid "SELECT CAST(COALESCE(SUM(in_msatoshi - out_msatoshi), 0) AS BIGINT)FROM forwarded_payments WHERE state = ?;" msgstr "" -#: wallet/wallet.c:4048 +#: wallet/wallet.c:4049 msgid "SELECT f.state, in_msatoshi, out_msatoshi, hin.payment_hash as payment_hash, in_channel_scid, out_channel_scid, f.received_time, f.resolved_time, f.failcode FROM forwarded_payments f LEFT JOIN channel_htlcs hin ON (f.in_htlc_id = hin.id) WHERE (1 = ? OR f.state = ?) AND (1 = ? OR f.in_channel_scid = ?) AND (1 = ? OR f.out_channel_scid = ?)" msgstr "" -#: wallet/wallet.c:4170 +#: wallet/wallet.c:4171 msgid "SELECT t.id, t.rawtx, t.blockheight, t.txindex, t.type as txtype, c2.short_channel_id as txchan, a.location, a.idx as ann_idx, a.type as annotation_type, c.short_channel_id FROM transactions t LEFT JOIN transaction_annotations a ON (a.txid = t.id) LEFT JOIN channels c ON (a.channel = c.id) LEFT JOIN channels c2 ON (t.channel_id = c2.id) ORDER BY t.blockheight, t.txindex ASC" msgstr "" -#: wallet/wallet.c:4264 +#: wallet/wallet.c:4265 msgid "INSERT INTO penalty_bases ( channel_id, commitnum, txid, outnum, amount) VALUES (?, ?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:4289 +#: wallet/wallet.c:4290 msgid "SELECT commitnum, txid, outnum, amount FROM penalty_bases WHERE channel_id = ?" msgstr "" -#: wallet/wallet.c:4313 +#: wallet/wallet.c:4314 msgid "DELETE FROM penalty_bases WHERE channel_id = ? AND commitnum = ?" msgstr "" -#: wallet/wallet.c:4331 +#: wallet/wallet.c:4332 msgid "SELECT 1 FROM offers WHERE offer_id = ?;" msgstr "" -#: wallet/wallet.c:4344 +#: wallet/wallet.c:4345 msgid "INSERT INTO offers ( offer_id, bolt12, label, status) VALUES (?, ?, ?, ?);" msgstr "" -#: wallet/wallet.c:4371 +#: wallet/wallet.c:4372 msgid "SELECT bolt12, label, status FROM offers WHERE offer_id = ?;" msgstr "" -#: wallet/wallet.c:4399 +#: wallet/wallet.c:4400 msgid "SELECT offer_id FROM offers;" msgstr "" -#: wallet/wallet.c:4425 +#: wallet/wallet.c:4426 msgid "UPDATE offers SET status=? WHERE offer_id = ?;" msgstr "" -#: wallet/wallet.c:4436 +#: wallet/wallet.c:4437 msgid "UPDATE invoices SET state=? WHERE state=? AND local_offer_id = ?;" msgstr "" -#: wallet/wallet.c:4464 +#: wallet/wallet.c:4465 msgid "SELECT status FROM offers WHERE offer_id = ?;" msgstr "" @@ -1257,4 +1257,4 @@ msgstr "" #: wallet/test/run-wallet.c:1647 msgid "INSERT INTO channels (id) VALUES (1);" msgstr "" -# SHA256STAMP:78ef666d4e867ffdef1d84235050b0a6dc2c6f0c16a3b2703cd70c80e266f543 +# SHA256STAMP:2fdded09bd28387ed024108cbe04c6ba1e158605c4c84eb1cf4caa83e26599fe diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 56254e02a..4401f4468 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -1321,7 +1321,7 @@ static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx) mempat(scriptpubkey, tal_count(scriptpubkey)); c1.first_blocknum = 1; parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false, - NULL); + true, NULL); c1.final_key_idx = 1337; p = new_peer(ld, 0, &id, &addr, false); c1.peer = p; @@ -1482,7 +1482,7 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx) pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk); node_id_from_pubkey(&id, &pk); parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false, - NULL); + true, NULL); /* new channel! */ p = new_peer(ld, 0, &id, &addr, false); diff --git a/wallet/wallet.c b/wallet/wallet.c index eca255c79..06ae0439e 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -820,7 +820,8 @@ static struct peer *wallet_peer_load(struct wallet *w, const u64 dbid) db_column_node_id(stmt, 1, &id); addrstr = db_column_text(stmt, 2); - if (!parse_wireaddr_internal((const char*)addrstr, &addr, DEFAULT_PORT, false, false, true, NULL)) + if (!parse_wireaddr_internal((const char*)addrstr, &addr, DEFAULT_PORT, + false, false, true, true, NULL)) goto done; /* FIXME: save incoming in db! */