mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
chore: add optional peer output pointer to command_find_channel function
This commit is contained in:
committed by
Rusty Russell
parent
8594f6e369
commit
ac0f925dee
@@ -1034,7 +1034,7 @@ AUTODATA(json_command, &listpeers_command);
|
|||||||
static struct command_result *
|
static struct command_result *
|
||||||
command_find_channel(struct command *cmd,
|
command_find_channel(struct command *cmd,
|
||||||
const char *buffer, const jsmntok_t *tok,
|
const char *buffer, const jsmntok_t *tok,
|
||||||
struct channel **channel)
|
struct channel **channel, struct peer **peer_out)
|
||||||
{
|
{
|
||||||
struct lightningd *ld = cmd->ld;
|
struct lightningd *ld = cmd->ld;
|
||||||
struct channel_id cid;
|
struct channel_id cid;
|
||||||
@@ -1050,8 +1050,10 @@ command_find_channel(struct command *cmd,
|
|||||||
derive_channel_id(&channel_cid,
|
derive_channel_id(&channel_cid,
|
||||||
&(*channel)->funding_txid,
|
&(*channel)->funding_txid,
|
||||||
(*channel)->funding_outnum);
|
(*channel)->funding_outnum);
|
||||||
if (channel_id_eq(&channel_cid, &cid))
|
if (channel_id_eq(&channel_cid, &cid)) {
|
||||||
|
if (peer_out) *peer_out = peer;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
"Channel ID not found: '%.*s'",
|
"Channel ID not found: '%.*s'",
|
||||||
@@ -1064,8 +1066,10 @@ command_find_channel(struct command *cmd,
|
|||||||
if (!*channel)
|
if (!*channel)
|
||||||
continue;
|
continue;
|
||||||
if ((*channel)->scid
|
if ((*channel)->scid
|
||||||
&& (*channel)->scid->u64 == scid.u64)
|
&& (*channel)->scid->u64 == scid.u64) {
|
||||||
|
if (peer_out) *peer_out = peer;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
"Short channel ID not found: '%.*s'",
|
"Short channel ID not found: '%.*s'",
|
||||||
@@ -1104,7 +1108,7 @@ static struct command_result *json_close(struct command *cmd,
|
|||||||
channel = peer_active_channel(peer);
|
channel = peer_active_channel(peer);
|
||||||
else {
|
else {
|
||||||
struct command_result *res;
|
struct command_result *res;
|
||||||
res = command_find_channel(cmd, buffer, idtok, &channel);
|
res = command_find_channel(cmd, buffer, idtok, &channel, NULL);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user