rgb-cln/channeld
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
..
test global: thread zero fee option everywhere. 2023-06-29 11:28:47 -04:00
Makefile channeld: remove onion objects. 2022-09-29 16:10:57 +09:30
channeld.c channeld: Verify the signature sent by the counterparty 2023-07-26 06:57:15 +09:30
channeld.h channeld: simply exit if hsmd vanishes. 2022-02-08 11:15:52 +10:30
channeld_htlc.h channeld: remove dead HTLCs from htable and free them (eventually) 2023-01-20 14:04:08 -06:00
channeld_wire.csv channeld: use explicit --experimental-upgrade flag, not #ifdef EXPERIMENTAL_FEATURES 2023-05-23 09:34:08 +09:30
commit_tx.c global: thread zero fee option everywhere. 2023-06-29 11:28:47 -04:00
commit_tx.h global: thread zero fee option everywhere. 2023-06-29 11:28:47 -04:00
full_channel.c Support p2tr deposit addresses 2023-07-11 11:41:15 +09:30
full_channel.h dusty-htlcs: enforce limit on dusty htlcs 2021-10-23 12:59:13 +02:00
full_channel_error.h dusty-htlcs: enforce limit on dusty htlcs 2021-10-23 12:59:13 +02:00
watchtower.c Support p2tr deposit addresses 2023-07-11 11:41:15 +09:30
watchtower.h hsmd: Add wallet index metadata to existing messages 2022-03-10 10:22:29 +10:30