openingd: remove unnecessary is_err flag.

It probably doesn't matter to "fundchannel_cancel" exactly why the
fundchannel didn't work (though it can read the error msg), and we
should always fail any pending fundchannel_complete command.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-06-13 13:56:56 +09:30
committed by neil saitug
parent 280bd60988
commit 9fdcb1a122
3 changed files with 11 additions and 23 deletions

View File

@@ -678,9 +678,8 @@ static void opening_funder_failed(struct subd *openingd, const u8 *msg,
struct uncommitted_channel *uc)
{
char *desc;
bool is_err;
if (!fromwire_opening_funder_failed(msg, msg, &desc, &is_err)) {
if (!fromwire_opening_funder_failed(msg, msg, &desc)) {
log_broken(uc->log,
"bad OPENING_FUNDER_FAILED %s",
tal_hex(tmpctx, msg));
@@ -693,18 +692,11 @@ static void opening_funder_failed(struct subd *openingd, const u8 *msg,
/* Tell anyone who was trying to cancel */
for (size_t i = 0; i < tal_count(uc->fc->cancels); i++) {
if (is_err)
was_pending(command_fail(uc->fc->cancels[i], LIGHTNINGD,
"Funding failed anyway: %s",
desc));
else {
struct json_stream *response;
struct json_stream *response;
response = json_stream_success(uc->fc->cancels[i]);
json_add_string(response, "cancelled", desc);
was_pending(command_success(uc->fc->cancels[i],
response));
}
response = json_stream_success(uc->fc->cancels[i]);
json_add_string(response, "cancelled", desc);
was_pending(command_success(uc->fc->cancels[i], response));
}
/* Tell any fundchannel_complete or fundchannel command */

View File

@@ -104,7 +104,6 @@ opening_funder_cancel,6013
# Openingd->master: we failed to negotiation channel
opening_funder_failed,6004
opening_funder_failed,,reason,wirestring
opening_funder_failed,,is_err,bool
# Openingd->master: they offered channel.
# This gives their txid and info, means we can send funding_signed: we're done.
1 #include <common/cryptomsg.h>
104 opening_fundee,,first_commit_sig,struct bitcoin_signature opening_fundee,,pps,struct per_peer_state
105 opening_fundee,,pps,struct per_peer_state opening_fundee,,revocation_basepoint,struct pubkey
106 opening_fundee,,revocation_basepoint,struct pubkey opening_fundee,,payment_basepoint,struct pubkey
opening_fundee,,payment_basepoint,struct pubkey
107 opening_fundee,,htlc_basepoint,struct pubkey
108 opening_fundee,,delayed_payment_basepoint,struct pubkey
109 opening_fundee,,their_per_commit_point,struct pubkey

View File

@@ -120,7 +120,7 @@ static const u8 *dev_upfront_shutdown_script(const tal_t *ctx)
/*~ If we can't agree on parameters, we fail to open the channel. If we're
* the funder, we need to tell lightningd, otherwise it never really notices. */
static void negotiation_aborted(struct state *state, bool am_funder,
const char *why, bool is_err)
const char *why)
{
status_debug("aborted opening negotiation: %s", why);
/*~ The "billboard" (exposed as "status" in the JSON listpeers RPC
@@ -133,7 +133,7 @@ static void negotiation_aborted(struct state *state, bool am_funder,
/* If necessary, tell master that funding failed. */
if (am_funder) {
u8 *msg = towire_opening_funder_failed(NULL, why, is_err);
u8 *msg = towire_opening_funder_failed(NULL, why);
wire_sync_write(REQ_FD, take(msg));
}
@@ -159,7 +159,7 @@ static void negotiation_failed(struct state *state, bool am_funder,
"You gave bad parameters: %s", errmsg);
sync_crypto_write(state->pps, take(msg));
negotiation_aborted(state, am_funder, errmsg, true);
negotiation_aborted(state, am_funder, errmsg);
}
/*~ This is the key function that checks that their configuration is reasonable:
@@ -403,8 +403,7 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state,
if (all_channels) {
if (am_funder) {
msg = towire_opening_funder_failed(NULL,
err,
true);
err);
wire_sync_write(REQ_FD, take(msg));
}
peer_failed_received_errmsg(state->pps, err,
@@ -412,8 +411,7 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state,
}
negotiation_aborted(state, am_funder,
tal_fmt(tmpctx, "They sent error %s",
err),
true);
err));
/* Return NULL so caller knows to stop negotiating. */
return NULL;
}
@@ -1690,8 +1688,7 @@ static u8 *handle_master_in(struct state *state)
msg = towire_errorfmt(NULL, &state->channel_id, "Channel open canceled by us");
sync_crypto_write(state->pps, take(msg));
negotiation_aborted(state, true,
"Channel open canceled by RPC", false);
negotiation_aborted(state, true, "Channel open canceled by RPC");
return NULL;
case WIRE_OPENING_DEV_MEMLEAK:
#if DEVELOPER