mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 00:54:20 +01:00
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
This commit is contained in:
committed by
Vincenzo Palazzo
parent
96b3b40765
commit
195a2cf44b
@@ -2377,9 +2377,33 @@ json_openchannel_bump(struct command *cmd,
|
||||
type_to_string(tmpctx, struct amount_sat,
|
||||
&chainparams->max_funding));
|
||||
|
||||
if (!channel->owner)
|
||||
return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
|
||||
"Peer not connected.");
|
||||
/* It's possible that the last open failed/was aborted.
|
||||
* So now we restart the attempt! */
|
||||
if (!channel->owner) {
|
||||
int fds[2];
|
||||
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) {
|
||||
log_broken(channel->log,
|
||||
"Failed to create socketpair: %s",
|
||||
strerror(errno));
|
||||
return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
|
||||
"Unable to create socket: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (!peer_restart_dualopend(channel->peer,
|
||||
new_peer_fd(tmpctx, fds[0]),
|
||||
channel)) {
|
||||
close(fds[1]);
|
||||
return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
|
||||
"Peer not connected.");
|
||||
}
|
||||
subd_send_msg(cmd->ld->connectd,
|
||||
take(towire_connectd_peer_connect_subd(NULL,
|
||||
&channel->peer->id,
|
||||
channel->peer->connectd_counter,
|
||||
&channel->cid)));
|
||||
subd_send_fd(cmd->ld->connectd, fds[1]);
|
||||
}
|
||||
|
||||
if (channel->open_attempt)
|
||||
return command_fail(cmd, FUNDING_STATE_INVALID,
|
||||
|
||||
Reference in New Issue
Block a user