core-lightning/tests
Vincenzo Palazzo f4fd12cc15 channeld: Verify the signature sent by the counterparty
This commit addresses an issue to enhance the resilience of core
lightning when receiving node announcements.

According to BOLT 7 (The announcement_signatures Message),
if the node_signature OR the bitcoin_signature is NOT correct,
it is recommended to either send a warning and close the connection or send an error and fail the channel.

In this commit, we take a strict approach. If any error is detected, we
send an error and fail the open channel operation.
This is because the announcement_signatures operation is optional,
and we assume that it must be correct.

lnprototest at commit dea47c29b5541dbfe7fe53cc2598330e897fa4f4 report
the following error now.

```
2023-07-06T21:03:20.930Z DEBUG   hsmd: Shutting down

ERROR    root:helpers.py:170 Traceback (most recent call last):
  File "/home/vincent/Github/lightning/external/lnprototest/tests/helpers.py", line 167, in run_runner
    runner.run(test)
  File "/home/vincent/Github/lightning/external/lnprototest/lnprototest/runner.py", line 99, in run
    all_done = sequence.action(self)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/vincent/Github/lightning/external/lnprototest/lnprototest/structure.py", line 55, in action
    all_done &= e.action(runner)
                ^^^^^^^^^^^^^^^^
  File "/home/vincent/Github/lightning/external/lnprototest/lnprototest/event.py", line 365, in action
    raise EventError(self, "{}: message was {}".format(err, msg.to_str()))
lnprototest.errors.EventError: `Expected msgtype-warning, got msgtype-error: message was error channel_id=a37362839b13f61cfe82d35bd397b1264c389b245847cfb6111b38892546dc77 data=4661696c656420746f20766572696679206e6f64655f7369676e61747572652e` on event [{"event": "ExpectMsg", "file": "test_bolt2-01-close_channel.py", "pos": "157"},]
============================================================================================================================================================== short test summary info ===============================================================================================================================================================
FAILED tests/test_bolt2-01-close_channel.py::test_close_channel_shutdown_msg_normal_case_receiver_side - AssertionError: `Expected msgtype-shutdown, got msgtype-error: message was error channel_id=a37362839b13f61cfe82d35bd397b1264c389b245847cfb6111b38892546dc77 data=4661696c656420746f20766572696679206e6f64655f7369676e61747572652e` on event [{"event": "ExpectMsg", "file": "test_bolt2-01-close_channel.py", "pos": "75"},]
FAILED tests/test_bolt2-01-close_channel.py::test_close_channel_shutdown_msg_wrong_script_pubkey_receiver_side - AssertionError: `Expected msgtype-warning, got msgtype-error: message was error channel_id=a37362839b13f61cfe82d35bd397b1264c389b245847cfb6111b38892546dc77 data=4661696c656420746f20766572696679206e6f64655f7369676e61747572652e` on event [{"event": "ExpectMsg", "file": "test_bolt2-01-close_channel.py", "pos": "157"},]

```

Changelog-Fixes: channeld: Verify the signature sent in announcement_signatures by the counterparty
Reported-by: lnprototest
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-26 06:57:15 +09:30
..
data lightningd: migrate (and delete) old commando blacklists. 2023-07-25 14:47:12 +09:30
fuzz fuzz: initial sha256 seeds 2023-07-10 14:56:50 +09:30
plugins pytest: test for bad estimatefees results. 2023-07-16 12:57:27 +09:30
vectors pytest: Remove onion test vectors containing legacy onions. 2022-03-18 09:20:11 +10:30
benchmark.py pytest: always provide payment_secret when making payments. 2021-07-14 14:38:00 -05:00
conftest.py tests: add marker for v1/v2 channel opens 2021-05-12 11:25:41 +09:30
db.py test-db-provider: if postgres in tests, startup a bookkeeper db 2022-07-28 12:08:18 +09:30
fixtures.py pyln.testing: remove Throttler. 2023-04-06 09:10:53 +09:30
rkls_github_canned_server.py pytest: add blackbox tests for reckless 2023-04-09 12:41:11 +09:30
test_bookkeeper.py Support p2tr deposit addresses 2023-07-11 11:41:15 +09:30
test_cln_rs.py pyln: Create a dedicated pyln-grpc-proto package 2023-07-10 13:47:38 +09:30
test_closing.py pytest: fix timeout in test_channel_lease_unilat_closes 2023-07-22 08:52:55 +09:30
test_connection.py pytest: test for setchannel's new ignorefeelimits. 2023-07-22 13:11:08 +09:30
test_db.py wallet: fix up PSBTs as a migration. 2023-03-31 09:16:25 +10:30
test_gossip.py pytest: make tor-requiring tests clearly distinguishable 2023-07-22 11:08:04 +09:30
test_invoices.py lightningd: expose created_index and updated_index fields. 2023-07-23 13:48:37 +09:30
test_misc.py channeld: Verify the signature sent by the counterparty 2023-07-26 06:57:15 +09:30
test_mkfunding.py pytest: add tests for devtools/mkfunding 2023-01-09 14:50:30 -06:00
test_onion.py lightningd: remove support for legacy onion format. 2022-03-18 09:20:11 +10:30
test_opening.py pytest: fix test_anchor_min_emergency "bad gossip" messages. 2023-07-22 08:52:55 +09:30
test_pay.py libplugin/pay: allow shortcut for self-pay. 2023-07-26 06:55:48 +09:30
test_plugin.py invoice: return error string from invoice_check_payment. 2023-07-26 06:55:48 +09:30
test_reckless.py pytest: ignore pip warning 2023-04-24 13:08:15 -07:00
test_runes.py lightningd: clean up commando rune_counter from datastore on migration. 2023-07-25 14:47:12 +09:30
test_wallet.py Support p2tr deposit addresses 2023-07-11 11:41:15 +09:30
utils.py Support p2tr deposit addresses 2023-07-11 11:41:15 +09:30
valgrind-suppressions.txt pytest: Use valgrind target suppressions instead of skipping tests 2022-03-10 10:21:41 +10:30