Commit Graph

14383 Commits

Author SHA1 Message Date
Rusty Russell 8ed0e43b54 common: remote private_channel_announcement.[ch].
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell 2d15745f9e gossipd: don't put private channel info into store at all.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell 8db7adc76f gossipd: no longer take private channel updates from lightningd
Lightningd now handles private channels, so we're dismantling the
gossipd infrastructure.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell fc642155ff dualopend: remove channel_update message creation.
We don't have to generate these any more: lightningd does it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell d81f243141 channeld: remove channel_update message creation.
We don't have to generate these any more: lightningd does it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell 97ccf05117 lightningd: ignore gossip messages from channeld, switch to our own.
This commit is a bit messy, but it tries to do the minimal switchover.

Some tests change, so those are included here. 

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell a677fad821 lightningd/channel_gossip: new file for handing and generating gossip for our channels.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell c5547e2209 lightningd: add gossip_generation.c
Routines to generate our own channel_update and channel_announcement messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell e84baf78ac lightningd: tweak db remote channel_announcement sigs API.
Don't return false on db errors (we always fail on those), but return
false if they don't exist.

Also, add routine to clear them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell cff166b687 channeld: tell lightningd scid from `announcement_signatures` message.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell db6f0da3b3 connectd: separate routine to inject message without closing connection.
We will want this to send private channel_updates direct to peer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell dac8964093 lightningd: set channel's local alias at init.
Rather than having channeld/dualopend do it, we can set it and tell them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell 9c80a5cebb dualopend: tell lightningd what remote alias the peer sent.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell 2d93ddbdf1 gossipd: get told about new block before splicing code tries to feed us channel_announcement.
```
lightningd-2 2023-11-21T01:02:31.375Z DEBUG   gossipd: Ignoring future channel_announcment for 109x1x0 (current block 108)
lightningd-2 2023-11-21T01:02:31.375Z DEBUG   gossipd: REPLY WIRE_GOSSIPD_ADDGOSSIP_REPLY with 0 fds
lightningd-2 2023-11-21T01:02:31.376Z DEBUG   gossipd: Bad gossip order: WIRE_CHANNEL_UPDATE before announcement 109x1x0/0 from local
lightningd-2 2023-11-21T01:02:31.376Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-hsmd: Got WIRE_HSMD_CHECK_OUTPOINT
lightningd-2 2023-11-21T01:02:31.376Z DEBUG   gossipd: REPLY WIRE_GOSSIPD_ADDGOSSIP_REPLY with 0 fds
lightningd-2 2023-11-21T01:02:31.376Z DEBUG   hsmd: Client: Received message 32 from client
lightningd-2 2023-11-21T01:02:31.376Z DEBUG   gossipd: REPLY WIRE_GOSSIPD_NEW_BLOCKHEIGHT_REPLY with 0 fd
s
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell f2f43eeffa gossipd: strip private updates from gossip_store on startup.
We rename them to _obs, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell ad4a8a510d hsmd: add command to allow lightningd to sign channel announcement.
Before this it was channeld doing it, which was tied to a particular
channel.  Create an API for lightningd to sign for any channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell 3e1d34f6ab lightningd: use explicit accessor to get channel_update for errors.
We want this later, so do the prep work now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell 1093b43ccf lnprototest: remove.
At this point it needs a complete rewrite to be useful, and it's just
constraining development.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:10:51 +10:30
Rusty Russell d2e7831d87 pytest: fix flake in test_upgrade_statickey_onchaind
We need to make sure l1 has closed previous channel:

```
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')

tests/test_connection.py:3866: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
contrib/pyln-testing/pyln/testing/utils.py:88: in wait_for
    while not success():
tests/test_connection.py:3866: in <lambda>
    wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

arr = [{'alias': {'local': '7000028x5013088x54781', 'remote': '3360520x6431919x56666'}, 'channel_id': 'fb198b27b1be882937eea...: ['static_remotekey/even']}, 'close_to': '5120888ab14b6e1655d1d00039b836d70b66e3351543ab6cd2f94166255f3d5e6cb5', ...}]

    def only_one(arr):
        """Many JSON RPC calls return an array; often we only expect a single entry
        """
>       assert len(arr) == 1
E       AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 13:39:23 +10:30
Rusty Russell 8454e4910a topology: don't call gossmap for locall added channels.
This happens in deprecated mode, and we get bogus results.  Valgrind caught it!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 13:39:23 +10:30
Rusty Russell 82819433bc pytest: test_gossip_pruning should not assume redundant node_announcement.
This will change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell 9d9c30331a pytest: prepare sql test for faster gossip generation.
Mining 13 blocks to close the l1->l2 channel also causes the l2->l3
channel to confirm, and I was reliably getting the
channel_announcement to l3 in time to confuse this wait_for test.  So
query the channel we want directly to make it more robust.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell a27bbbb734 pytest: fix up test_zeroconf_multichan_forward once routehints fixed.
After this, the invoice (correctly!) gives the zeroconf channel as a routehint,
so this test fails.  Simple workaround: make invoice before creating zeroconf
channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell 412bb137e0 pytest: fix splicing tests to be more explicit, and not rely in private gossip messages.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell e30eadd6a9 pytest: check for short_channel_id, not status.
Status actually changes in this series.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell 11fa3da4cc pytest: Remove check for to-be-removed message about msg from channeld.
This race is resolved with the gossipd changes (and this message is
also removed!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell 8f9af62228 pytest: make sure listincoming sees remote update in test_zeroconf_forward.
Otherwise we get no routehint.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell 64678c43ab pytest: make sure gossipd sees channel before we close it.
This was fine when gossipd saw local channels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell bfa81f30e1 pytest: ignore private updates in test_addgossip.
This was triggering on private updates after gossip changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

1diff --git a/tests/test_gossip.py b/tests/test_gossip.py
index 677ec4825..285290b71 100644
2024-01-31 09:15:46 +10:30
Rusty Russell 0a8003a4d2 pytest: fix psbt db test.
When we rewrite, we actually use the remote channel_announcement signatures from the db, and notice that l1 here is actually l2:

```
0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#1: gossipd rejected our channel announcement: WARNING: Bad node_signature_1 304402204ad9f0ca9b5f1f8eec61290b6008bf2c15f011e35543d25c35c5b89d2e1a183402201aaca5883714dbe11d6ae00a146fac7302352e1b9e987eee5ce98e8eb6a82909 hash e713698e14d3d8f973210e8d93c96d1a7c117c58340ccb195785a672fd0b5ef1 on channel_announcement 01004ad9f0ca9b5f1f8eec61290b6008bf2c15f011e35543d25c35c5b89d2e1a18341aaca5883714dbe11d6ae00a146fac7302352e1b9e987eee5ce98e8eb6a829095c05509264fcf72e19180f0285cf0ca0d786f280a75d79e46e5627be20c9dd9a4e9105aa61d7faf3a375454db94376b9b9df29cf078130ed827836b0849f119014ec750ab163baef701e7889f430ee37ea7e38857aa2b2745440600999c85f2903abefde5210dd06ae12f24b8801416800db84f5c73d35594af594f9001800025dee15519d29eb81e9d1ac761deebdad91ba1d08a05c027c16ea5fc08f3a9b663f8433209392395f0107f6b4d266c46b0946bd098f88c0693817fb560e0526a8000006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006900000100000266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c035180266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c0351802324266de8403b3ab157a09f1f784d587af61831c998c151bcc21bb74c2b2314b0206540493a98599967a61c45172df49681e398a6cb0890a506e74f76c2d2be242
```

Explicitly remove those messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Erik De Smedt 72687d2a75 Schema: Add schema's for detailed fundchannel methods 2024-01-30 18:44:56 +01:00
Erik De Smedt 6e6c94438a Doc: Undocumented parameters in fundchannel_start
- Documented `mindepth` and `reserve` in `fundchannel_start`. These
  parameters are supported but had not been documented (yet).
- Removed `mindepth` from return-type. I'm unable to find any scenario
  in which a value is returned.
- Documented the 312 error code
2024-01-30 18:44:56 +01:00
Christian Decker 948ee4dbc5 pyln: Consolidate on pyln.testing.db
We had a complete copy of the `db_provider` and  associated classes in
teh `tests/` directory, causing them to drift apart. Consolidating on
one version makes this more maintainable.

Changelog-None
2024-01-29 19:13:12 +01:00
Tushar Vyas 464dc02b94 wipe_db() implementation 2024-01-29 19:13:12 +01:00
Rusty Russell af4b244f2f pytest: fix flake in test_peer_anchor_push
If l1 is one block behind, l2 goes onchain one block early:

```
        # Drops to chain
>       wait_for(lambda: only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'AWAITING_UNILATERAL')

tests/test_closing.py:3951:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

success = <function test_peer_anchor_push.<locals>.<lambda> at 0x7f799f9cd1f0>
timeout = 180

    def wait_for(success, timeout=TIMEOUT):
        start_time = time.time()
        interval = 0.25
        while not success():
            time_left = start_time + timeout - time.time()
            if time_left <= 0:
>               raise ValueError("Timeout while waiting for {}".format(success))
E               ValueError: Timeout while waiting for <function test_peer_anchor_push.<locals>.<lambda> at 0x7f799f9cd1f0>
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 16:47:33 +10:30
Rusty Russell bf9cdc597e pytest: fix flake in test_custommsg_triggers_notification
If listpeers on l2 is called too fast, then it won't return any peers, and
we will fail:

```
        # Connect l1 to l2
        l1.connect(l2)
>       wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['connected'])

tests/test_misc.py:2690:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
contrib/pyln-testing/pyln/testing/utils.py:88: in wait_for
    while not success():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['connected'])
E   IndexError: list index out of range
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 16:47:33 +10:30
Rusty Russell 6778f320d2 openingd: make channel-type rejection message clearer.
For example, lnprototest got the error 'You gave bad parameters: Did not support channel_type ' which doesn't make it clear that it's rejecting the empty channel type.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell b805899b06 pytest: check that listpeerchannels gives the same channel type as returned from fund/openchannel
Could have done this in an earlier commit, but that would be a messy rebase.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell 17d0d006d2 fundchannel_start & multifundchannel: add channel_type.
Let's tell the caller what channel_type they got!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `fundchannel`, `multifundchannel`, `fundchannel_start` and `openchannel_init`: new field `channel_type`.
2024-01-29 13:40:34 +10:30
Rusty Russell 4cf4dcc584 dualopend: fix channel_type if we don't negotiate the default.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell 0b38b83aa3 common: move json_add_channel_type from lightningd/
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell 08e29ab47f lightningd: make option_static_remotekey compulsory.
As suggested in https://github.com/lightning/bolts/pull/1092.

We still support channels opened without it, but you can no longer open new ones without it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: `option_gossip_queries` is now required (advertized by all but 16 nodes)
2024-01-29 13:40:34 +10:30
Rusty Russell e531ff83b3 lightningd: add dev-any-channel-type to allow obsolete channel types.
We're about to make static_remotekey compulsory, but we still want to
do tests for pre-existing channels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell 3c2a57598f spenderp: add channel_type parameter to fundchannel / multifundchannel.
And add a request schema for multifundchannel.

Changelog-Added: JSON-RPC: `fundchannel` and `multifundchannel` now take an optional `channel_type` parameter.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell e749aebbff fundchannel_start / openchannel_init: add a channel_type parameter to force channel type.
And add request schemas for openchannel_init and fundchannel_start.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `fundchannel_start` and `openchannel_init` now take an optional `channel_type` parameter.
2024-01-29 13:40:34 +10:30
Rusty Russell a943a53658 common: channel_type_accept doesn't use `their_features`; remove parameter.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell 654a45dad6 common: add param_channel_type helper.
We use an array of bit numbers.  We could use an array of names, but the JSON typing is then harder.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell 031524fab5 openingd: correctly mark channel type zeroconf if negotiated and they offered minimum_depth=0.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: `channel_type` reflects option_zeroconf if explicitly negotiated.
2024-01-29 13:40:34 +10:30
Rusty Russell f450dfeb55 lightningd: make option_gossip_queries compulsory.
As suggested in https://github.com/lightning/bolts/pull/1092.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: `option_gossip_queries` is now required (advertized by all but 11 nodes)
2024-01-29 13:40:34 +10:30
Rusty Russell 88a2146664 lightningd: make option_data_loss_protect compulsory.
As suggested in https://github.com/lightning/bolts/pull/1092.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: `option_data_loss_protect` is now required (advertized by all but 11 nodes)
2024-01-29 13:40:34 +10:30