mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 06:54:30 +01:00
lightningd: dev-reenable-commit RPC command to re-enable commit timer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1911,6 +1911,15 @@ static void handle_shutdown_cmd(struct peer *peer, const u8 *inmsg)
|
||||
start_commit_timer(peer);
|
||||
}
|
||||
|
||||
static void handle_dev_reenable_commit(struct peer *peer)
|
||||
{
|
||||
dev_suppress_commit = false;
|
||||
start_commit_timer(peer);
|
||||
status_trace("dev_reenable_commit");
|
||||
wire_sync_write(MASTER_FD,
|
||||
take(towire_channel_dev_reenable_commit_reply(peer)));
|
||||
}
|
||||
|
||||
static void req_in(struct peer *peer, const u8 *msg)
|
||||
{
|
||||
enum channel_wire_type t = fromwire_peektype(msg);
|
||||
@@ -1937,7 +1946,9 @@ static void req_in(struct peer *peer, const u8 *msg)
|
||||
case WIRE_CHANNEL_SEND_SHUTDOWN:
|
||||
handle_shutdown_cmd(peer, msg);
|
||||
goto out;
|
||||
|
||||
case WIRE_CHANNEL_DEV_REENABLE_COMMIT:
|
||||
handle_dev_reenable_commit(peer);
|
||||
goto out;
|
||||
case WIRE_CHANNEL_NORMAL_OPERATION:
|
||||
case WIRE_CHANNEL_INIT:
|
||||
case WIRE_CHANNEL_OFFER_HTLC_REPLY:
|
||||
@@ -1952,6 +1963,7 @@ static void req_in(struct peer *peer, const u8 *msg)
|
||||
case WIRE_CHANNEL_GOT_FUNDING_LOCKED:
|
||||
case WIRE_CHANNEL_GOT_SHUTDOWN:
|
||||
case WIRE_CHANNEL_SHUTDOWN_COMPLETE:
|
||||
case WIRE_CHANNEL_DEV_REENABLE_COMMIT_REPLY:
|
||||
break;
|
||||
}
|
||||
master_badmsg(-1, msg);
|
||||
|
||||
@@ -171,3 +171,7 @@ channel_got_shutdown,,scriptpubkey,scriptpubkey_len*u8
|
||||
# Shutdown is complete, ready for closing negotiation. + peer_fd & gossip_fd.
|
||||
channel_shutdown_complete,25
|
||||
channel_shutdown_complete,,crypto_state,struct crypto_state
|
||||
|
||||
# Re-enable commit timer.
|
||||
channel_dev_reenable_commit,26
|
||||
channel_dev_reenable_commit_reply,126
|
||||
|
||||
|
@@ -885,6 +885,58 @@ static const struct json_command dev_fail_command = {
|
||||
};
|
||||
AUTODATA(json_command, &dev_fail_command);
|
||||
|
||||
static bool dev_reenable_commit_finished(struct subd *channeld,
|
||||
const u8 *resp,
|
||||
const int *fds,
|
||||
struct command *cmd)
|
||||
{
|
||||
command_success(cmd, null_response(cmd));
|
||||
return true;
|
||||
}
|
||||
|
||||
static void json_dev_reenable_commit(struct command *cmd,
|
||||
const char *buffer, const jsmntok_t *params)
|
||||
{
|
||||
jsmntok_t *peertok;
|
||||
struct peer *peer;
|
||||
u8 *msg;
|
||||
|
||||
if (!json_get_params(buffer, params,
|
||||
"id", &peertok,
|
||||
NULL)) {
|
||||
command_fail(cmd, "Need id");
|
||||
return;
|
||||
}
|
||||
|
||||
peer = peer_from_json(cmd->ld, buffer, peertok);
|
||||
if (!peer) {
|
||||
command_fail(cmd, "Could not find peer with that id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!peer->owner) {
|
||||
command_fail(cmd, "Peer has no owner");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!streq(peer->owner->name, "lightning_channeld")) {
|
||||
command_fail(cmd, "Peer owned by %s", peer->owner->name);
|
||||
return;
|
||||
}
|
||||
|
||||
msg = towire_channel_dev_reenable_commit(peer);
|
||||
subd_req(peer, peer->owner, take(msg), -1, 0,
|
||||
dev_reenable_commit_finished, cmd);
|
||||
}
|
||||
|
||||
static const struct json_command dev_reenable_commit = {
|
||||
"dev-reenable-commit",
|
||||
json_dev_reenable_commit,
|
||||
"Reenable the commit timer on peer {id}",
|
||||
"Returns {} on success"
|
||||
};
|
||||
AUTODATA(json_command, &dev_reenable_commit);
|
||||
|
||||
struct log_info {
|
||||
enum log_level level;
|
||||
struct json_result *response;
|
||||
@@ -1919,9 +1971,11 @@ static int channel_msg(struct subd *sd, const u8 *msg, const int *fds)
|
||||
case WIRE_CHANNEL_GOT_REVOKE_REPLY:
|
||||
case WIRE_CHANNEL_SENDING_COMMITSIG_REPLY:
|
||||
case WIRE_CHANNEL_SEND_SHUTDOWN:
|
||||
case WIRE_CHANNEL_DEV_REENABLE_COMMIT:
|
||||
/* Replies go to requests. */
|
||||
case WIRE_CHANNEL_OFFER_HTLC_REPLY:
|
||||
case WIRE_CHANNEL_PING_REPLY:
|
||||
case WIRE_CHANNEL_DEV_REENABLE_COMMIT_REPLY:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user