mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-05 23:24:21 +01:00
lightningd: remove (most) functions to search channels by status.
This is generally verboten now, since there can be multiple. There are a few exceptions: 1. We sometimes want to know if there are *any* active channels. 2. Some dev commands still take peer id when they mean channel_id. 3. We still allow peer id when it's fully determined. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Changed: JSON-RPC: `close` by peer id will fail if there is more than one live channel (use `channel_id` or `short_channel_id` as id arg).
This commit is contained in:
@@ -1782,7 +1782,7 @@ static void accepter_got_offer(struct subd *dualopend,
|
||||
{
|
||||
struct openchannel2_payload *payload;
|
||||
|
||||
if (peer_active_channel(channel->peer)) {
|
||||
if (peer_any_active_channel(channel->peer, NULL)) {
|
||||
subd_send_msg(dualopend,
|
||||
take(towire_dualopend_fail(NULL,
|
||||
"Already have active channel")));
|
||||
@@ -2584,13 +2584,13 @@ static struct command_result *json_openchannel_init(struct command *cmd,
|
||||
return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer");
|
||||
}
|
||||
|
||||
channel = peer_active_channel(peer);
|
||||
channel = peer_any_active_channel(peer, NULL);
|
||||
if (channel) {
|
||||
return command_fail(cmd, LIGHTNINGD, "Peer already %s",
|
||||
channel_state_name(channel));
|
||||
}
|
||||
|
||||
channel = peer_unsaved_channel(peer);
|
||||
channel = peer_any_unsaved_channel(peer, NULL);
|
||||
if (!channel) {
|
||||
channel = new_unsaved_channel(peer,
|
||||
peer->ld->config.fee_base,
|
||||
@@ -2839,18 +2839,6 @@ static void handle_commit_received(struct subd *dualopend,
|
||||
total_funding);
|
||||
|
||||
if (channel->state == DUALOPEND_OPEN_INIT) {
|
||||
if (peer_active_channel(channel->peer)) {
|
||||
channel_saved_err_broken_reconn(channel,
|
||||
"Already have active"
|
||||
" channel with %s",
|
||||
type_to_string(tmpctx,
|
||||
struct node_id,
|
||||
&channel->peer->id));
|
||||
channel->open_attempt
|
||||
= tal_free(channel->open_attempt);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(inflight = wallet_commit_channel(ld, channel,
|
||||
remote_commit,
|
||||
&remote_commit_sig,
|
||||
@@ -3091,15 +3079,8 @@ static struct command_result *json_queryrates(struct command *cmd,
|
||||
return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
|
||||
"Peer not connected");
|
||||
|
||||
/* We can't query rates for a peer we have a channel with */
|
||||
channel = peer_active_channel(peer);
|
||||
if (channel)
|
||||
return command_fail(cmd, LIGHTNINGD, "Peer in state %s,"
|
||||
" can't query peer's rates if already"
|
||||
" have a channel",
|
||||
channel_state_name(channel));
|
||||
|
||||
channel = peer_unsaved_channel(peer);
|
||||
/* FIXME: This is wrong: we should always create a new channel? */
|
||||
channel = peer_any_unsaved_channel(peer, NULL);
|
||||
if (!channel) {
|
||||
channel = new_unsaved_channel(peer,
|
||||
peer->ld->config.fee_base,
|
||||
|
||||
Reference in New Issue
Block a user