Browse Source

lightningd: dev-reenable-commit RPC command to re-enable commit timer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
ab8251c214
  1. 14
      channeld/channel.c
  2. 4
      channeld/channel_wire.csv
  3. 54
      lightningd/peer_control.c

14
channeld/channel.c

@ -1911,6 +1911,15 @@ static void handle_shutdown_cmd(struct peer *peer, const u8 *inmsg)
start_commit_timer(peer); 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) static void req_in(struct peer *peer, const u8 *msg)
{ {
enum channel_wire_type t = fromwire_peektype(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: case WIRE_CHANNEL_SEND_SHUTDOWN:
handle_shutdown_cmd(peer, msg); handle_shutdown_cmd(peer, msg);
goto out; goto out;
case WIRE_CHANNEL_DEV_REENABLE_COMMIT:
handle_dev_reenable_commit(peer);
goto out;
case WIRE_CHANNEL_NORMAL_OPERATION: case WIRE_CHANNEL_NORMAL_OPERATION:
case WIRE_CHANNEL_INIT: case WIRE_CHANNEL_INIT:
case WIRE_CHANNEL_OFFER_HTLC_REPLY: 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_FUNDING_LOCKED:
case WIRE_CHANNEL_GOT_SHUTDOWN: case WIRE_CHANNEL_GOT_SHUTDOWN:
case WIRE_CHANNEL_SHUTDOWN_COMPLETE: case WIRE_CHANNEL_SHUTDOWN_COMPLETE:
case WIRE_CHANNEL_DEV_REENABLE_COMMIT_REPLY:
break; break;
} }
master_badmsg(-1, msg); master_badmsg(-1, msg);

4
channeld/channel_wire.csv

@ -171,3 +171,7 @@ channel_got_shutdown,,scriptpubkey,scriptpubkey_len*u8
# Shutdown is complete, ready for closing negotiation. + peer_fd & gossip_fd. # Shutdown is complete, ready for closing negotiation. + peer_fd & gossip_fd.
channel_shutdown_complete,25 channel_shutdown_complete,25
channel_shutdown_complete,,crypto_state,struct crypto_state channel_shutdown_complete,,crypto_state,struct crypto_state
# Re-enable commit timer.
channel_dev_reenable_commit,26
channel_dev_reenable_commit_reply,126

Can't render this file because it has a wrong number of fields in line 2.

54
lightningd/peer_control.c

@ -885,6 +885,58 @@ static const struct json_command dev_fail_command = {
}; };
AUTODATA(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 { struct log_info {
enum log_level level; enum log_level level;
struct json_result *response; 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_GOT_REVOKE_REPLY:
case WIRE_CHANNEL_SENDING_COMMITSIG_REPLY: case WIRE_CHANNEL_SENDING_COMMITSIG_REPLY:
case WIRE_CHANNEL_SEND_SHUTDOWN: case WIRE_CHANNEL_SEND_SHUTDOWN:
case WIRE_CHANNEL_DEV_REENABLE_COMMIT:
/* Replies go to requests. */ /* Replies go to requests. */
case WIRE_CHANNEL_OFFER_HTLC_REPLY: case WIRE_CHANNEL_OFFER_HTLC_REPLY:
case WIRE_CHANNEL_PING_REPLY: case WIRE_CHANNEL_PING_REPLY:
case WIRE_CHANNEL_DEV_REENABLE_COMMIT_REPLY:
break; break;
} }

Loading…
Cancel
Save