Commit Graph

125 Commits

Author SHA1 Message Date
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 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 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 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 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 b318811a2d pytest: fix tests in assumption that listchannels will no longer show private gossip.
Some can only be changed once that is true, but some can be removed/amended already.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-12-14 09:16:56 +10:30
Rusty Russell f3b4821d36 pytest: fix test_zeroconf_open()
l2 gave us a routehint, but it should have seen l1 as a dead-end.  It
didn't due to the presence of a channel alias, which was a bug.  We're
about to fix this, which breaks the test.

Add a dummy node off l1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-12-14 09:16:56 +10:30
niftynei 3190c26bc9 dualfund: error on out of order sigs
We weren't blocking if the tx-sigs arrived before the commitment sigs.

This was causing problems in the openchannel (spender plugin)

spenderp: FATAL SIGNAL 11 (version v23.08.1-404-g62ff475-modded)
0x559836dc98ba send_backtrace
	common/daemon.c:33
0x559836dc9951 crashdump
	common/daemon.c:75
0x7f37f42c351f ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7f37f441ac92 ???
	../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:83
0x559836db7760 bitcoin_txid_eq
	./bitcoin/tx.h:29
0x559836db7760 collect_sigs
	plugins/spender/openchannel.c:509
0x559836db81de check_sigs_ready
	plugins/spender/openchannel.c:531
0x559836db84dd json_peer_sigs
	plugins/spender/openchannel.c:611
0x559836dbcad7 ld_command_handle
	plugins/libplugin.c:1611
0x559836dbcd9d ld_read_json_one
	plugins/libplugin.c:1721
0x559836dbce29 ld_read_json
	plugins/libplugin.c:1741
0x559836ef3bff next_plan
	ccan/ccan/io/io.c:59
0x559836ef40da do_plan
	ccan/ccan/io/io.c:407
0x559836ef4177 io_ready
	ccan/ccan/io/io.c:417
0x559836ef5b14 io_loop
	ccan/ccan/io/poll.c:453
0x559836dbd48d plugin_main
	plugins/libplugin.c:1948
0x559836db22bf main
	plugins/spender/main.c:35
0x7f37f42aad8f __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7f37f42aae3f __libc_start_main_impl
	../csu/libc-start.c:392
0x559836da3774 ???
	???:0
0xffffffffffffffff ???
	???:0
2023-10-31T15:15:57.458Z INFO    plugin-spenderp: Killing plugin: exited during normal operation
2023-10-31T15:15:57.458Z **BROKEN** plugin-spenderp: Plugin marked as important, shutting down lightningd!
2023-10-31T15:15:57.458Z DEBUG   lightningd: io_break: lightningd_exit
2023-10-31T15:15:57.458Z DEBUG   lightningd: io_loop_with_timers: main
2023-10-31T15:15:57.458Z DEBUG   connectd: REPLY WIRE_CONNECTD_START_SHUTDOWN_REPLY with 0 fds
2023-10-31T15:15:57.458Z DEBUG   lightningd: io_break: connectd_start_shutdown_reply
2023-10-31T15:15:57.458Z DEBUG   021ccce7bc396996c8f3b7bfeb1e30c6600269517026a74adfe2217b7187879797-dualopend-chan#1: Status closed, but not exited. Killing
2023-10-31T15:15:57.458Z DEBUG   lightningd: Command returned result after jcon close
2023-10-31T15:15:57.458Z INFO    021ccce7bc396996c8f3b7bfeb1e30c6600269517026a74adfe2217b7187879797-chan#1: Unsaved peer failed. Deleting channel.
2023-10-31T15:15:57.464Z DEBUG   lightningd: io_break: destroy_plugin
2023-10-31T15:15:57.464Z DEBUG   connectd: Shutting down
2023-10-31T15:15:57.464Z DEBUG   gossipd: Shutting down
2023-10-31T15:15:57.464Z DEBUG   hsmd: Shutting down

Reported-By: @t-bast
2023-11-02 19:32:05 +10:30
niftynei fa8458c00a dualfund: add test to make sure that tx-sigs sent before commitment
results in an error.
2023-11-02 19:32:05 +10:30
niftynei 30ec8cbf8e dualfund, test: add test for dropping to chain during RBF
Here we make sure we can drop the initial tx to chain, and that an
inflight txid that's missing its commitment sigs is properly ignored.
2023-11-02 19:32:05 +10:30
niftynei 5417312911 tests: update opening tests for new reconnect behavior
Let's test that things stay together!

One cool thing to note is that now we sort of "magically" recover from
pretty brutal disconnects!

Very nice!
2023-11-02 19:32:05 +10:30
Rusty Russell f004952442 lightningd: wumbo is now the default, setting has no effect.
"Patrick, I'm sorry I doubted you."

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Config: `large-channels` is now the default, wumbology for all.
2023-11-02 08:16:51 +01:00
Rusty Russell acc30c0b3f lightningd: split DUALOPEND_OPEN_INIT into DUALOPEND_OPEN_INIT and DUALOPEND_OPEN_COMMITTED.
The latter is used when we're put in the db, the former is the uncommitted state.
Currently dbid == 0 is used in addition to the state, which is unwieldy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Experimental: JSON-RPC: added new dual-funding state `DUALOPEND_OPEN_COMMITTED`
2023-10-02 11:41:19 +10:30
Rusty Russell 6c15ea44dd pytest: use --developer instead of environment variable.
And we always enable it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Tony Giorgio a5367773d5 wallet: Exclude uneconomical UTXOs from fundchannel
If a node has an onchain balance with at least one uneconomical UTXO, the fundchannel RPC call will lock up the node and will eventually crash it with OOM issues if the economical UTXO(s) do not add up to the fundchannel amount. This is because the while loop never exits because it keeps pulling in the same uneconomical UTXOs forever.

Changelog-Fixed: wallet: fundchannel no longer loops forever if the wallet contains insufficient funds, but an uneconomical UTXO.
2023-09-13 14:34:59 +09:30
Rusty Russell 47f4e11c87 tests: test for fundchannel fail with tiny utxo
Tony Giorgio <tonygiorgio@protonmail.com> says:

Reproduce:

1.  Add 1 600 sat UTXO to a fresh node

2.  Verify the fundchannel command fails with a low fee rate:

```
./lightning-cli fundchannel 0366abc8eb4da61e31a8d2c4520d31cabdf58cc5250f855657397f3dd62493938a 100000 1000
{
   "code": 301,
   "message": "Could not afford 100000sat using all 1 available UTXOs: 99522sat short"
}
```

3.  Now do the command again, but with a higher fee rate, making the 600 sat UTXO uneconomical:

```
./lightning-cli fundchannel 0366abc8eb4da61e31a8d2c4520d31cabdf58cc5250f855657397f3dd62493938a 100000 10000
```

4. Observe the RPC call and the logs. The RPC call will never return, and the logs will stop after this:

```
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: multiconnect done.
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: 'parsefeerate' done
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: fundpsbt.
```

5. Keep CLN running long enough and you'll eventually run OOM.
2023-09-13 14:34:59 +09:30
niftynei 9b8909e507 dual-fund: keep track of aborted requests, seamlessly restart daemon
Clean restart of daemon after a tx-abort is a nice way to work around
the 'persistent' disconnect that we t-bast noticed.

Changelog-Fixed: `dualopend`: Fix behavior for tx-aborts. No longer hangs, appropriately continues re-init of RBF requests without reconnction msg exchange.
2023-07-30 15:20:04 +09:30
niftynei c807db4b7f dual-fund tests: add tests for reported incompat with Eclair
Bug Report:
- initiate a channel open eclair -> cln
- wait for the transaction to be published
- eclair initiates rbf, and cancels it by sending tx_abort before exchanging commit_sig
- at that point everything looks good, cln echoes the tx_abort and stays connected
- eclair initiates another RBF attempt and sends tx_init_rbf: for some unknown reason,
  cln answers with channel_reestablish (??) followed by an error saying
  "Bad reestablish message: WIRE_TX_INIT_RBF"

Diagnosis:
  CLN is doing a reconnect after a tx-abort is sent.

Extra Test:
  Realized that if we abort, we won't correctly advanced to NORMAL if
  blocks are mined while we're in hanging state. CLN should advance
  after block containing channel open is mined.

Reported-By: @t-bast
2023-07-30 15:20:04 +09:30
Rusty Russell e91f8ddb51 pytest: fix test_anchor_min_emergency "bad gossip" messages.
l1 shuts down too fast, channeld doesn't get to tell gossipd about the channel,
and l2 sends (private) update_channel and we complain:

```
lightningd-2 2023-07-20T03:42:37.744Z DEBUG   gossipd: received private channel announcement from channeld for 103x1x0
lightningd-2 2023-07-20T03:42:37.791Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-hsmd: Got WIRE_HSMD_CUPDATE_SIG_REQ
lightningd-2 2023-07-20T03:42:37.796Z DEBUG   hsmd: Client: Received message 3 from client
lightningd-1 2023-07-20T03:42:37.857Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-gossipd: Bad gossip order: WIRE_CHANNEL_UPDATE before announcement 103x1x0/0
lightningd-1 2023-07-20T03:42:37.864Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-gossipd: Bad gossip order: WIRE_CHANNEL_UPDATE before announcement 103x1x0/0
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-22 08:52:55 +09:30
Rusty Russell e6d23b5677 pytest: test for emergency minimum fund violations.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-29 11:28:47 -04:00
Rusty Russell 7894d7136f pytest: adapt all the anchor-iff-EXPERIMENTAL tests to --experimental-anchors.
We use parameterization here.  The old `anchor_expected()` was for
non-zero-fee anchors, and have bitrotted so there are some other
changes as well.

Unfortunately, all the anchor accounting seems to be broken, but I
cannot understand these tests at all.  I had to simply disable them
for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-29 11:28:47 -04:00
Rusty Russell f64188f925 pytest: make dual-funding tests using option_anchors_zero_fee_htlc_tx.
They used to force option_anchor_outputs, so switch them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-29 11:28:47 -04:00
Rusty Russell 96e198f751 openingd: use a lower feerate for first commitment tx for anchors.
We need to know both, because in theory we could negotiate a
non-anchor channel even if they support it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-29 11:28:47 -04:00
Rusty Russell d895ef4fee pytest: test for commitment feerate.
Interesting we didn't actually test that the feerate we use is
actually delivered.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-29 11:28:47 -04:00
Rusty Russell ea928bfca1 pytest: use modern listconfigs.
Use the configs object, as the others are about to be deprecated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-03 10:50:29 +09:30
Rusty Russell ec8bba6b8a dev-allowdustreserve: make this a DEVELOPER option.
Otherwise, we should rename it?

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-03 10:50:29 +09:30
Rusty Russell 548b54e971 pytest: update test_v2_fail_second for listpeers changes.
Now should use listpeerchannels, since listpeers['channels'] is
deprecated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 13:46:21 +09:30
Rusty Russell c11ae1aa34 pytest: remove EXPERIMENTAL_FEATURES as a consideration.
This currently means anchors tests are disabled, awaiting the
PR which implements zero-fee-htlc anchors to reenable them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-23 09:34:08 +09:30
niftynei 3586559fac test (df): check 'require-confirmed-inputs' for v2 opens 2023-02-07 21:03:36 -06:00
niftynei 195a2cf44b dual-open: use tx-abort instead of warning/errors
When a channel open fails, we use tx-abort instead of warning/error.

This means that the peer won't disconnect! And instead when a new
message arrives, we'll need to rebuild the dualopend subd (if missing).

Makes opens a bit easer to retry (no reconnect needed), as well as keeps
the connection alive for other channels we may have with that peer.

Changelog-Changed: Experimental-Dual-Fund: open failures don't disconnect, but instead fail the opening process
2023-02-05 10:02:46 +01:00
niftynei b375a35fa0 v2 open tests: don't drop connection when an openchannel fails
Dropping the connection is bad behavior on an openchannel failure,
especially given that there might be other channels currently connected.

We should maintain the connection but close out the dualopend
daemon for that attempt.

This test partially documents the behaivor, but fails

Changelog-None
2023-02-05 10:02:46 +01:00
niftynei 4c46750001 dual-open-rbf: remember the requested lease amount btw restarts
Don't forget the requested lease across restarts.
2023-02-04 15:31:16 +10:30
niftynei 314c021e2c test: restart node during rbf
state isn't kept around for lease amount, so it should fail
2023-02-04 15:31:16 +10:30
niftynei 4fe8e1eccf tests: check that non-anchor opens can't use liquidity ads
liquidity ads (as proposed) rely on the CSV addition to the to_remote output
that anchors introduced.
2023-02-04 15:31:16 +10:30
niftynei c9c367d770 dual-fund: remove anchor assumption for all dual-funded channels
Only add the anchor channel_type if it's negotiated separately!
2023-02-04 15:31:16 +10:30
niftynei 976f6ef51a df tests: use the amount from the logs to check for! 2023-02-04 15:31:16 +10:30
Michael Schmoock ad249607d6 dual-fund: update extracted CSVs to latest bolt draft
Changelog-None
2023-02-04 15:31:16 +10:30
Rusty Russell 85fc46f76c pyln-testing: don't default openchannel and fundwallet to p2sh-segwit, use bech32.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-01-14 21:17:45 +10:30
Vincenzo Palazzo a2347c7452 tests: use listpeerchannels. 2023-01-13 10:42:42 +10:30
niftynei 26f5dcd2a5 wallet: mark coinbase outputs as 'immature' until spendable
Changelog-Changed: JSON-RPC: `listfunds` now lists coinbase outputs as 'immature' until they're spendable
Changelog-Changed: JSON-RPC: UTXOs aren't spendable while immature
2022-11-09 11:55:25 +01:00
niftynei d60dbba43b tests: test for coinbase wallet spend.
Attempt to spend a coinbase transaction, expected to fail.
2022-11-09 11:55:25 +01:00
niftynei e00857827f funder: cleanup datastore on state-change/channel failure
Let's not leave old state hanging around! Note that this fires
for pretty much every/any channel (even if we're not the opener).
2022-10-20 13:42:41 +02:00
niftynei 38e2428f12 funder: use utxopsbt to build psbt for RBFs
We use the saved previous outputs (plus maybe some new ones?) to build a
psbt for an RBF request.

RBFs utxo reuse is now working so we can unfail the test (and update
it to reflect that the lease sticks around through an RBF cycle).

Changelog-Fixed: Plugins: `funder` now honors lease requests across RBFs
2022-10-20 13:42:41 +02:00
niftynei 00d3e3e492 df: for rbfs, since we know what they asked for, we can abort
if they request less than we wanted/accepted

FIXME: add a test for this?
2022-10-20 13:42:41 +02:00