mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-02 18:35:00 +01:00
dual-fund: on witness failure, route through dualopend
We want to notify the peer that we've failed and why, as a courtesy.
This commit is contained in:
parent
ff164cf8b3
commit
d5bf6bb994
2 changed files with 40 additions and 15 deletions
|
@ -1456,15 +1456,21 @@ static void handle_peer_tx_sigs_sent(struct subd *dualopend,
|
||||||
* transaction `feerate`
|
* transaction `feerate`
|
||||||
*/
|
*/
|
||||||
if (!feerate_satisfied(inflight->funding_psbt,
|
if (!feerate_satisfied(inflight->funding_psbt,
|
||||||
inflight->funding->feerate))
|
inflight->funding->feerate)) {
|
||||||
channel_fail_permanent(channel,
|
char *errmsg = tal_fmt(tmpctx,
|
||||||
REASON_PROTOCOL,
|
"Witnesses lower effective"
|
||||||
"Agreed feerate %dperkw not"
|
" feerate below agreed upon rate"
|
||||||
" met with witnesses %s",
|
" of %dperkw. Failing channel."
|
||||||
|
" Offending PSBT: %s",
|
||||||
inflight->funding->feerate,
|
inflight->funding->feerate,
|
||||||
type_to_string(tmpctx,
|
type_to_string(tmpctx,
|
||||||
struct wally_psbt,
|
struct wally_psbt,
|
||||||
inflight->funding_psbt));
|
inflight->funding_psbt));
|
||||||
|
|
||||||
|
/* Notify the peer we're failing */
|
||||||
|
subd_send_msg(dualopend,
|
||||||
|
take(towire_dualopend_fail(NULL, errmsg)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1778,15 +1784,21 @@ static void handle_peer_tx_sigs_msg(struct subd *dualopend,
|
||||||
* transaction `feerate`
|
* transaction `feerate`
|
||||||
*/
|
*/
|
||||||
if (!feerate_satisfied(inflight->funding_psbt,
|
if (!feerate_satisfied(inflight->funding_psbt,
|
||||||
inflight->funding->feerate))
|
inflight->funding->feerate)) {
|
||||||
channel_fail_permanent(channel,
|
char *errmsg = tal_fmt(tmpctx,
|
||||||
REASON_PROTOCOL,
|
"Witnesses lower effective"
|
||||||
"Agreed feerate %dperkw not"
|
" feerate below agreed upon rate"
|
||||||
" met with witnesses %s",
|
" of %dperkw. Failing channel."
|
||||||
|
" Offending PSBT: %s",
|
||||||
inflight->funding->feerate,
|
inflight->funding->feerate,
|
||||||
type_to_string(tmpctx,
|
type_to_string(tmpctx,
|
||||||
struct wally_psbt,
|
struct wally_psbt,
|
||||||
inflight->funding_psbt));
|
inflight->funding_psbt));
|
||||||
|
|
||||||
|
/* Notify the peer we're failing */
|
||||||
|
subd_send_msg(dualopend,
|
||||||
|
take(towire_dualopend_fail(NULL, errmsg)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send notification with peer's signed PSBT */
|
/* Send notification with peer's signed PSBT */
|
||||||
|
|
|
@ -436,6 +436,17 @@ static void handle_our_shutdown(struct state *state, u8 *msg)
|
||||||
billboard_update(state);
|
billboard_update(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_failure_fatal(struct state *state, u8 *msg)
|
||||||
|
{
|
||||||
|
char *err;
|
||||||
|
|
||||||
|
if (!fromwire_dualopend_fail(msg, msg, &err))
|
||||||
|
master_badmsg(fromwire_peektype(msg), msg);
|
||||||
|
|
||||||
|
/* We're gonna fail here */
|
||||||
|
open_err_fatal(state, "%s", err);
|
||||||
|
}
|
||||||
|
|
||||||
static void check_channel_id(struct state *state,
|
static void check_channel_id(struct state *state,
|
||||||
struct channel_id *id_in,
|
struct channel_id *id_in,
|
||||||
struct channel_id *orig_id)
|
struct channel_id *orig_id)
|
||||||
|
@ -3267,12 +3278,14 @@ static u8 *handle_master_in(struct state *state)
|
||||||
case WIRE_DUALOPEND_SEND_SHUTDOWN:
|
case WIRE_DUALOPEND_SEND_SHUTDOWN:
|
||||||
handle_our_shutdown(state, msg);
|
handle_our_shutdown(state, msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
case WIRE_DUALOPEND_FAIL:
|
||||||
|
handle_failure_fatal(state, msg);
|
||||||
|
return NULL;
|
||||||
|
|
||||||
/* Handled inline */
|
/* Handled inline */
|
||||||
case WIRE_DUALOPEND_INIT:
|
case WIRE_DUALOPEND_INIT:
|
||||||
case WIRE_DUALOPEND_REINIT:
|
case WIRE_DUALOPEND_REINIT:
|
||||||
case WIRE_DUALOPEND_DEV_MEMLEAK_REPLY:
|
case WIRE_DUALOPEND_DEV_MEMLEAK_REPLY:
|
||||||
case WIRE_DUALOPEND_FAIL:
|
|
||||||
case WIRE_DUALOPEND_PSBT_UPDATED:
|
case WIRE_DUALOPEND_PSBT_UPDATED:
|
||||||
case WIRE_DUALOPEND_GOT_OFFER_REPLY:
|
case WIRE_DUALOPEND_GOT_OFFER_REPLY:
|
||||||
case WIRE_DUALOPEND_GOT_RBF_OFFER_REPLY:
|
case WIRE_DUALOPEND_GOT_RBF_OFFER_REPLY:
|
||||||
|
|
Loading…
Add table
Reference in a new issue