mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 20:54:23 +01:00
channel: make error 'hard' if awaiting lockin
if the channel hasn't been locked in yet, allow for a 'hard' error to kill the channel
This commit is contained in:
committed by
Rusty Russell
parent
1e3a411b74
commit
ec1b86d9d5
@@ -1846,6 +1846,11 @@ static void peer_in(struct peer *peer, const u8 *msg)
|
||||
{
|
||||
enum wire_type type = fromwire_peektype(msg);
|
||||
|
||||
/* Only count soft errors if the channel has locked-in already;
|
||||
* otherwise we can't cancel a channel before it has opened.
|
||||
*/
|
||||
bool soft_error = peer->funding_locked[REMOTE] || peer->funding_locked[LOCAL];
|
||||
|
||||
peer->last_recv = time_now();
|
||||
|
||||
/* Catch our own ping replies. */
|
||||
@@ -1859,7 +1864,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
|
||||
|
||||
/* Since LND seems to send errors which aren't actually fatal events,
|
||||
* we treat errors here as soft. */
|
||||
if (handle_peer_gossip_or_error(peer->pps, &peer->channel_id, true, msg))
|
||||
if (handle_peer_gossip_or_error(peer->pps, &peer->channel_id, soft_error, msg))
|
||||
return;
|
||||
|
||||
/* Must get funding_locked before almost anything. */
|
||||
@@ -2350,6 +2355,8 @@ static void peer_reconnect(struct peer *peer,
|
||||
sync_crypto_write(peer->pps, take(msg));
|
||||
|
||||
peer_billboard(false, "Sent reestablish, waiting for theirs");
|
||||
bool soft_error = peer->funding_locked[REMOTE]
|
||||
|| peer->funding_locked[LOCAL];
|
||||
|
||||
/* Read until they say something interesting (don't forward
|
||||
* gossip *to* them yet: we might try sending channel_update
|
||||
@@ -2358,7 +2365,7 @@ static void peer_reconnect(struct peer *peer,
|
||||
clean_tmpctx();
|
||||
msg = sync_crypto_read(tmpctx, peer->pps);
|
||||
} while (channeld_handle_custommsg(msg) ||
|
||||
handle_peer_gossip_or_error(peer->pps, &peer->channel_id, true,
|
||||
handle_peer_gossip_or_error(peer->pps, &peer->channel_id, soft_error,
|
||||
msg) ||
|
||||
capture_premature_msg(&premature_msgs, msg));
|
||||
|
||||
|
||||
@@ -1038,9 +1038,6 @@ def test_funding_external_wallet_corners(node_factory, bitcoind):
|
||||
# We can cancel channel after fundchannel_complete
|
||||
assert l1.rpc.fundchannel_cancel(l2.info['id'])['cancelled']
|
||||
|
||||
# l2 won't give up, since it considers error "soft".
|
||||
l2.rpc.dev_forget_channel(l1.info['id'])
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
l1.rpc.fundchannel_start(l2.info['id'], amount)['funding_address']
|
||||
assert l1.rpc.fundchannel_complete(l2.info['id'], prep['txid'], txout)['commitments_secured']
|
||||
|
||||
Reference in New Issue
Block a user