mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
common: add 2 specific error codes wrt funding
Add "peer not connected" and "unknown peer" as error codes, so that users can check against numeric error codes instead of textual error messages. Will ease https://github.com/ElementsProject/lightning/issues/3366 Changelog-None
This commit is contained in:
parent
e1ef902db4
commit
11da88a281
2 changed files with 9 additions and 5 deletions
|
@ -41,6 +41,8 @@
|
||||||
#define FUND_OUTPUT_IS_DUST 302
|
#define FUND_OUTPUT_IS_DUST 302
|
||||||
#define FUNDING_BROADCAST_FAIL 303
|
#define FUNDING_BROADCAST_FAIL 303
|
||||||
#define FUNDING_STILL_SYNCING_BITCOIN 304
|
#define FUNDING_STILL_SYNCING_BITCOIN 304
|
||||||
|
#define FUNDING_PEER_NOT_CONNECTED 305
|
||||||
|
#define FUNDING_UNKNOWN_PEER 306
|
||||||
|
|
||||||
/* Errors from `invoice` command */
|
/* Errors from `invoice` command */
|
||||||
#define INVOICE_LABEL_ALREADY_EXISTS 900
|
#define INVOICE_LABEL_ALREADY_EXISTS 900
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ static struct command_result *json_fund_channel_complete(struct command *cmd,
|
||||||
funding_txout = *funding_txout_num;
|
funding_txout = *funding_txout_num;
|
||||||
peer = peer_by_id(cmd->ld, id);
|
peer = peer_by_id(cmd->ld, id);
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
return command_fail(cmd, LIGHTNINGD, "Unknown peer");
|
return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer");
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = peer_active_channel(peer);
|
channel = peer_active_channel(peer);
|
||||||
|
@ -1033,7 +1033,8 @@ static struct command_result *json_fund_channel_complete(struct command *cmd,
|
||||||
channel_state_name(channel));
|
channel_state_name(channel));
|
||||||
|
|
||||||
if (!peer->uncommitted_channel)
|
if (!peer->uncommitted_channel)
|
||||||
return command_fail(cmd, LIGHTNINGD, "Peer not connected");
|
return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
|
||||||
|
"Peer not connected");
|
||||||
|
|
||||||
if (!peer->uncommitted_channel->fc || !peer->uncommitted_channel->fc->inflight)
|
if (!peer->uncommitted_channel->fc || !peer->uncommitted_channel->fc->inflight)
|
||||||
return command_fail(cmd, LIGHTNINGD, "No channel funding in progress.");
|
return command_fail(cmd, LIGHTNINGD, "No channel funding in progress.");
|
||||||
|
@ -1071,7 +1072,7 @@ static struct command_result *json_fund_channel_cancel(struct command *cmd,
|
||||||
|
|
||||||
peer = peer_by_id(cmd->ld, id);
|
peer = peer_by_id(cmd->ld, id);
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
return command_fail(cmd, LIGHTNINGD, "Unknown peer");
|
return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer->uncommitted_channel) {
|
if (peer->uncommitted_channel) {
|
||||||
|
@ -1185,7 +1186,7 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
|
||||||
|
|
||||||
peer = peer_by_id(cmd->ld, id);
|
peer = peer_by_id(cmd->ld, id);
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
return command_fail(cmd, LIGHTNINGD, "Unknown peer");
|
return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer");
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = peer_active_channel(peer);
|
channel = peer_active_channel(peer);
|
||||||
|
@ -1195,7 +1196,8 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!peer->uncommitted_channel) {
|
if (!peer->uncommitted_channel) {
|
||||||
return command_fail(cmd, LIGHTNINGD, "Peer not connected");
|
return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
|
||||||
|
"Peer not connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer->uncommitted_channel->fc) {
|
if (peer->uncommitted_channel->fc) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue