mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 09:40:19 +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`
|
||||
*/
|
||||
if (!feerate_satisfied(inflight->funding_psbt,
|
||||
inflight->funding->feerate))
|
||||
channel_fail_permanent(channel,
|
||||
REASON_PROTOCOL,
|
||||
"Agreed feerate %dperkw not"
|
||||
" met with witnesses %s",
|
||||
inflight->funding->feerate)) {
|
||||
char *errmsg = tal_fmt(tmpctx,
|
||||
"Witnesses lower effective"
|
||||
" feerate below agreed upon rate"
|
||||
" of %dperkw. Failing channel."
|
||||
" Offending PSBT: %s",
|
||||
inflight->funding->feerate,
|
||||
type_to_string(tmpctx,
|
||||
struct wally_psbt,
|
||||
inflight->funding_psbt));
|
||||
struct wally_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`
|
||||
*/
|
||||
if (!feerate_satisfied(inflight->funding_psbt,
|
||||
inflight->funding->feerate))
|
||||
channel_fail_permanent(channel,
|
||||
REASON_PROTOCOL,
|
||||
"Agreed feerate %dperkw not"
|
||||
" met with witnesses %s",
|
||||
inflight->funding->feerate)) {
|
||||
char *errmsg = tal_fmt(tmpctx,
|
||||
"Witnesses lower effective"
|
||||
" feerate below agreed upon rate"
|
||||
" of %dperkw. Failing channel."
|
||||
" Offending PSBT: %s",
|
||||
inflight->funding->feerate,
|
||||
type_to_string(tmpctx,
|
||||
struct wally_psbt,
|
||||
inflight->funding_psbt));
|
||||
struct wally_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 */
|
||||
|
|
|
@ -436,6 +436,17 @@ static void handle_our_shutdown(struct state *state, u8 *msg)
|
|||
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,
|
||||
struct channel_id *id_in,
|
||||
struct channel_id *orig_id)
|
||||
|
@ -3267,12 +3278,14 @@ static u8 *handle_master_in(struct state *state)
|
|||
case WIRE_DUALOPEND_SEND_SHUTDOWN:
|
||||
handle_our_shutdown(state, msg);
|
||||
return NULL;
|
||||
case WIRE_DUALOPEND_FAIL:
|
||||
handle_failure_fatal(state, msg);
|
||||
return NULL;
|
||||
|
||||
/* Handled inline */
|
||||
case WIRE_DUALOPEND_INIT:
|
||||
case WIRE_DUALOPEND_REINIT:
|
||||
case WIRE_DUALOPEND_DEV_MEMLEAK_REPLY:
|
||||
case WIRE_DUALOPEND_FAIL:
|
||||
case WIRE_DUALOPEND_PSBT_UPDATED:
|
||||
case WIRE_DUALOPEND_GOT_OFFER_REPLY:
|
||||
case WIRE_DUALOPEND_GOT_RBF_OFFER_REPLY:
|
||||
|
|
Loading…
Add table
Reference in a new issue