core-lightning/lightningd
Rusty Russell cfa33ce362 lightningd: fix incorrect reuse of dualopend, leading to dev_queryfeerates race
CI hit this issue where it would get a tx_abort in fundchannel.  This
happens when the dualopend we use to query the feerates has not exited
yet (it waits for the tx_abort reply), and we mistakenly reuse it.

With multi-channel support, this is wrong: just run another one and it
all Just Works.

This means we need to rework our dual_open_control.c logic, since it
would previously create an unsaved channel then not clean up if
something went wrong.

Most people will never try to negotiate opening multiple channels to
the same peer at the same time (vs. having an established channel and
opening a new one), so this case is a bit weird.

```
         rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
     
         # l1 leases a channel from l2
         l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
                            feerate='{}perkw'.format(feerate),
 >                          compact_lease=rates['compact_lease'])
 
 tests/test_opening.py:1611: 
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 contrib/pyln-client/pyln/client/lightning.py:833: in fundchannel
     return self.call("fundchannel", payload)
 contrib/pyln-testing/pyln/testing/utils.py:721: in call
     res = LightningRpc.call(self, method, payload, cmdprefix, filter)

 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 
 self = <pyln.testing.utils.PrettyPrintingLightningRpc object at 0x7f6cbcd97950>
 method = 'fundchannel'
 payload = {'amount': 500000, 'announce': True, 'compact_lease': '029a00640064000000644c4b40', 'feerate': '2000perkw', ...}
 cmdprefix = None, filter = None
 
     def call(self, method, payload=None, cmdprefix=None, filter=None):
         """Generic call API: you can set cmdprefix here, or set self.cmdprefix
...
         if not isinstance(resp, dict):
             raise ValueError("Malformed response, response is not a dictionary %s." % resp)
         elif "error" in resp:
 >           raise RpcError(method, payload, resp['error'])
 E           pyln.client.lightning.RpcError: RPC call failed: method: fundchannel, payload: {'id': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'amount': 500000, 'feerate': '2000perkw', 'announce': True, 'request_amt': 500000, 'compact_lease': '029a00640064000000644c4b40'}, error: {'code': -1, 'message': 'Abort requested', 'data': {'id': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'method': 'openchannel_init'}}
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 13:46:21 +09:30
..
test lightningd: create small hsm_sync_req() helper for hsm queries. 2023-04-10 17:26:47 +09:30
.gitignore
bitcoind.c plugins/bcli: use the new feerate levels, and the floor. 2023-04-10 07:31:12 +09:30
bitcoind.h lightningd: handle fees as blockcount + range. 2023-04-10 07:31:12 +09:30
chaintopology.c lightningd: expose default_locktime for wider usage. 2023-04-10 17:26:47 +09:30
chaintopology.h lightningd: expose default_locktime for wider usage. 2023-04-10 17:26:47 +09:30
channel_control.c channeld: use explicit --experimental-upgrade flag, not #ifdef EXPERIMENTAL_FEATURES 2023-05-23 09:34:08 +09:30
channel_control.h
channel_state.h wallet: make it clear that enum state_change is in db. 2023-03-25 15:28:02 +10:30
channel.c lightningd: use channel_type as we're supposed to for forward descisions. 2023-04-10 17:26:47 +09:30
channel.h lightningd: remember depth of closing transaction. 2023-04-07 11:49:09 +09:30
closed_channel.c lightningd: add listclosedchannels command. 2023-03-25 15:28:02 +10:30
closed_channel.h lightningd: add listclosedchannels command. 2023-03-25 15:28:02 +10:30
closing_control.c lightningd: clarify uses of dynamic (mempool) feerate floor, and static. 2023-04-10 07:31:12 +09:30
closing_control.h
coin_mvts.c lightningd: use hash map for peers instead of linked list. 2023-01-21 08:05:31 -06:00
coin_mvts.h
connect_control.c connectd: dev-report-fds to do file descriptor audit. 2023-04-10 09:41:56 +09:30
connect_control.h lightningd: tell connectd we're shutting down. 2023-02-05 20:40:47 +01:00
datastore.c lightningd: unescape JSON strings for db. 2023-02-11 12:22:40 -06:00
dual_open_control.c lightningd: fix incorrect reuse of dualopend, leading to dev_queryfeerates race 2023-05-29 13:46:21 +09:30
dual_open_control.h lightningd: prepare internal json routines for listpeerchannels. 2023-01-13 10:42:42 +10:30
feerate.c lightningd: allow "NNblocks" and "minimum" as feerates. 2023-04-10 07:31:12 +09:30
feerate.h lightningd: clean up feerate handling, deprecate old terms. 2023-04-10 07:31:12 +09:30
gossip_control.c cleanup: rename json_add_amount_msat_only to json_add_amount_msat 2023-03-18 15:55:49 +10:30
gossip_control.h
hsm_control.c lightningd: create small hsm_sync_req() helper for hsm queries. 2023-04-10 17:26:47 +09:30
hsm_control.h lightningd: create small hsm_sync_req() helper for hsm queries. 2023-04-10 17:26:47 +09:30
htlc_end.c channeld: don't calculate blinding shared secret, let lightningd do it. 2022-10-26 11:29:06 +10:30
htlc_end.h channeld: don't calculate blinding shared secret, let lightningd do it. 2022-10-26 11:29:06 +10:30
htlc_set.c Makefile: update bolts a0bbe47b0278b4f152dbaa4f5fab2562413a217c 2023-04-07 21:22:56 +09:30
htlc_set.h
invoice.c lightningd: create small hsm_sync_req() helper for hsm queries. 2023-04-10 17:26:47 +09:30
invoice.h
io_loop_with_timers.c
io_loop_with_timers.h
jsonrpc.c lightningd: require "jsonrpc": "2.0" as per JSONRPC spec. 2023-03-18 15:55:49 +10:30
jsonrpc.h lightningd: only use non-numeric JSON ids if plugin says we can. 2022-11-21 11:23:54 +01:00
lightningd.c build: remove --enable-experimental-features / EXPERIMENTAL_FEATURES 2023-05-23 09:34:08 +09:30
lightningd.h channeld: use explicit --experimental-upgrade flag, not #ifdef EXPERIMENTAL_FEATURES 2023-05-23 09:34:08 +09:30
log_status.c
log_status.h
log.c common: expose node_id_hash functions. 2023-01-21 08:05:31 -06:00
log.h
Makefile onchaind: use lightningd to sign and broadcast htlc_success transactions. 2023-04-07 11:49:09 +09:30
memdump.c lightningd: fix parent reporting for memleaks. 2023-04-10 17:26:47 +09:30
memdump.h
notification.c cleanup: rename json_add_amount_msat_only to json_add_amount_msat 2023-03-18 15:55:49 +10:30
notification.h
offer.c lightningd: create small hsm_sync_req() helper for hsm queries. 2023-04-10 17:26:47 +09:30
onchain_control.c lightningd: create small hsm_sync_req() helper for hsm queries. 2023-04-10 17:26:47 +09:30
onchain_control.h
onion_message.c common: update to latest onion-message spec. 2023-01-30 13:24:29 +10:30
onion_message.h
opening_common.c lightningd: create small hsm_sync_req() helper for hsm queries. 2023-04-10 17:26:47 +09:30
opening_common.h
opening_control.c common/channel_type: routines to set known variants, set scid_alias. 2023-04-10 17:26:47 +09:30
opening_control.h lightningd: prepare internal json routines for listpeerchannels. 2023-01-13 10:42:42 +10:30
options.c build: remove --enable-experimental-features / EXPERIMENTAL_FEATURES 2023-05-23 09:34:08 +09:30
options.h opts: adds the autobool on/off/auto feature 2023-01-25 14:37:56 +01:00
pay.c Makefile: update bolts a0bbe47b0278b4f152dbaa4f5fab2562413a217c 2023-04-07 21:22:56 +09:30
pay.h
peer_control.c jsonrpc: Remove the old "_msat" prefix in the listpeerchannels command 2023-05-09 13:35:09 -07:00
peer_control.h listpeerchannels: add channel_type, both in hex and as array of names. 2023-03-25 15:28:02 +10:30
peer_fd.c
peer_fd.h
peer_htlcs.c ld: Add a couple of logging statements when forwarding 2023-04-11 11:22:30 +09:30
peer_htlcs.h lightningd: fix valgrind reported leak when we exit early. 2023-01-17 14:13:45 +10:30
ping.c
plugin_control.c
plugin_control.h
plugin_hook.c lightningd: don't call memcpy with NULL. 2023-01-12 11:44:10 +10:30
plugin_hook.h
plugin.c lightningd: treat JSON ids as direct tokens. 2023-01-11 11:13:27 +10:30
plugin.h lightningd: correctly exit when an important-plugin fails to start. 2022-11-30 15:47:31 +01:00
routehint.c
routehint.h
signmessage.c lightningd: create small hsm_sync_req() helper for hsm queries. 2023-04-10 17:26:47 +09:30
subd.c
subd.h
watch.c lightningd/chaintopology: ensure htables are always tal objects. 2023-01-12 11:44:10 +10:30
watch.h