|
5 | 5 | FundChannel,
|
6 | 6 | ExpectMsg,
|
7 | 7 | ExpectTx,
|
| 8 | + ExpectError, |
| 9 | + MustNotMsg, |
8 | 10 | Msg,
|
9 | 11 | RawMsg,
|
10 | 12 | AcceptFunding,
|
|
45 | 47 | pubkey_of,
|
46 | 48 | gen_random_keyset,
|
47 | 49 | )
|
48 |
| -from lnprototest.utils.ln_spec_utils import connect_to_node_helper |
| 50 | +from lnprototest.utils.ln_spec_utils import ( |
| 51 | + connect_to_node_helper, |
| 52 | + open_and_announce_channel_helper, |
| 53 | +) |
49 | 54 |
|
50 | 55 |
|
51 | 56 | def test_open_channel_announce_features(runner: Runner) -> None:
|
@@ -278,3 +283,55 @@ def test_open_channel_opener_side(runner: Runner) -> None:
|
278 | 283 | TryAll([], RawMsg(bytes.fromhex("270F"))),
|
279 | 284 | ]
|
280 | 285 | run_runner(runner, merge_events_sequences(connections_events, test_events))
|
| 286 | + |
| 287 | + |
| 288 | +def test_open_channel_opener_side_wrong_announcement_signatures(runner: Runner) -> None: |
| 289 | + """Testing the case where the channel is announces in the correct way but one node |
| 290 | + send the wrong signature inside the `announcement_signatures` message.""" |
| 291 | + connections_events = connect_to_node_helper( |
| 292 | + runner=runner, |
| 293 | + tx_spendable=tx_spendable, |
| 294 | + conn_privkey="02", |
| 295 | + ) |
| 296 | + opts = {} |
| 297 | + open_channel_events = open_and_announce_channel_helper(runner, "02", opts=opts) |
| 298 | + pre_events = merge_events_sequences(connections_events, open_channel_events) |
| 299 | + |
| 300 | + dummy_sign = "138c93afb2013c39f959e70a163c3d6d8128cf72f8ae143f87b9d1fd6bb0ad30321116b9c58d69fca9fb33c214f681b664e53d5640abc2fdb972dc62a5571053" |
| 301 | + short_channel_id = opts["short_channel_id"] |
| 302 | + test_events = [ |
| 303 | + ExpectMsg( |
| 304 | + "announcement_signatures", |
| 305 | + channel_id=channel_id(), |
| 306 | + short_channel_id=short_channel_id, |
| 307 | + node_signature=stash_field_from_event( |
| 308 | + "announcement_signatures", dummy_val=dummy_sign |
| 309 | + ), |
| 310 | + bitcoin_signature=stash_field_from_event( |
| 311 | + "announcement_signatures", dummy_val=dummy_sign |
| 312 | + ), |
| 313 | + ), |
| 314 | + # BOLT 7: |
| 315 | + # - if the node_signature OR the bitcoin_signature is NOT correct: |
| 316 | + # - MAY send a warning and close the connection, or send an error and fail the channel. |
| 317 | + # |
| 318 | + # In our case, we send an error and stop the open channel procedure. This approach is |
| 319 | + # considered overly strict since the peer can recover from it. However, this step is |
| 320 | + # optional. If the peer sends it, we assume that the signature must be correct. |
| 321 | + Msg( |
| 322 | + "announcement_signatures", |
| 323 | + channel_id=channel_id(), |
| 324 | + short_channel_id=short_channel_id, |
| 325 | + node_signature=stash_field_from_event( |
| 326 | + "announcement_signatures", dummy_val=dummy_sign |
| 327 | + ), |
| 328 | + bitcoin_signature=stash_field_from_event( |
| 329 | + "announcement_signatures", dummy_val=dummy_sign |
| 330 | + ), |
| 331 | + ), |
| 332 | + ExpectError(), |
| 333 | + # BOLT 2: The channel is not practically usable until at least one side has |
| 334 | + # announced its fee levels and expiry, using channel_update. |
| 335 | + MustNotMsg("channel_update"), |
| 336 | + ] |
| 337 | + run_runner(runner, merge_events_sequences(pre_events, test_events)) |
0 commit comments