2018-08-23 01:27:25 +02:00
|
|
|
#include <bitcoin/feerate.h>
|
2018-03-07 01:06:07 +01:00
|
|
|
#include <bitcoin/script.h>
|
2020-08-25 04:15:48 +02:00
|
|
|
#include <closingd/closingd_wiregen.h>
|
2018-02-20 21:59:09 +01:00
|
|
|
#include <common/close_tx.h>
|
2019-12-12 18:18:25 +01:00
|
|
|
#include <common/fee_states.h>
|
2018-02-20 21:59:09 +01:00
|
|
|
#include <common/initial_commit_tx.h>
|
2019-06-03 20:11:25 +02:00
|
|
|
#include <common/per_peer_state.h>
|
2018-02-20 21:59:09 +01:00
|
|
|
#include <common/utils.h>
|
|
|
|
#include <errno.h>
|
2020-08-25 04:05:45 +02:00
|
|
|
#include <gossipd/gossipd_wiregen.h>
|
2018-02-20 21:59:09 +01:00
|
|
|
#include <inttypes.h>
|
2019-05-06 20:45:43 +02:00
|
|
|
#include <lightningd/bitcoind.h>
|
2018-02-20 21:59:09 +01:00
|
|
|
#include <lightningd/chaintopology.h>
|
|
|
|
#include <lightningd/channel.h>
|
|
|
|
#include <lightningd/closing_control.h>
|
2018-07-23 04:23:03 +02:00
|
|
|
#include <lightningd/hsm_control.h>
|
2018-02-20 21:59:09 +01:00
|
|
|
#include <lightningd/lightningd.h>
|
|
|
|
#include <lightningd/log.h>
|
|
|
|
#include <lightningd/options.h>
|
|
|
|
#include <lightningd/peer_control.h>
|
|
|
|
#include <lightningd/subd.h>
|
|
|
|
|
2019-02-21 04:45:55 +01:00
|
|
|
static struct amount_sat calc_tx_fee(struct amount_sat sat_in,
|
|
|
|
const struct bitcoin_tx *tx)
|
|
|
|
{
|
2019-09-26 21:07:20 +02:00
|
|
|
struct amount_asset amt;
|
|
|
|
struct amount_sat fee = sat_in;
|
2019-05-09 18:51:39 +02:00
|
|
|
const u8 *oscript;
|
|
|
|
size_t scriptlen;
|
2019-03-25 11:35:56 +01:00
|
|
|
for (size_t i = 0; i < tx->wtx->num_outputs; i++) {
|
|
|
|
amt = bitcoin_tx_output_get_amount(tx, i);
|
2019-05-09 18:51:39 +02:00
|
|
|
oscript = bitcoin_tx_output_get_script(NULL, tx, i);
|
|
|
|
scriptlen = tal_bytelen(oscript);
|
|
|
|
tal_free(oscript);
|
|
|
|
|
2019-09-26 00:42:26 +02:00
|
|
|
if (chainparams->is_elements && scriptlen == 0)
|
2019-05-09 18:51:39 +02:00
|
|
|
continue;
|
|
|
|
|
2019-09-26 21:07:20 +02:00
|
|
|
/* Ignore outputs that are not denominated in our main
|
|
|
|
* currency. */
|
|
|
|
if (!amount_asset_is_main(&amt))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!amount_sat_sub(&fee, fee, amount_asset_to_sat(&amt)))
|
2019-02-21 04:45:55 +01:00
|
|
|
fatal("Tx spends more than input %s? %s",
|
|
|
|
type_to_string(tmpctx, struct amount_sat, &sat_in),
|
|
|
|
type_to_string(tmpctx, struct bitcoin_tx, tx));
|
|
|
|
}
|
|
|
|
return fee;
|
|
|
|
}
|
|
|
|
|
2020-02-28 16:11:22 +01:00
|
|
|
/* Assess whether a proposed closing fee is acceptable. */
|
|
|
|
static bool closing_fee_is_acceptable(struct lightningd *ld,
|
|
|
|
struct channel *channel,
|
|
|
|
const struct bitcoin_tx *tx)
|
2018-02-20 21:59:09 +01:00
|
|
|
{
|
2019-02-21 04:45:55 +01:00
|
|
|
struct amount_sat fee, last_fee, min_fee;
|
|
|
|
u64 weight;
|
2018-08-23 01:27:25 +02:00
|
|
|
u32 min_feerate;
|
|
|
|
bool feerate_unknown;
|
2018-02-20 21:59:09 +01:00
|
|
|
|
|
|
|
/* Calculate actual fee (adds in eliminated outputs) */
|
2019-02-21 04:45:55 +01:00
|
|
|
fee = calc_tx_fee(channel->funding, tx);
|
|
|
|
last_fee = calc_tx_fee(channel->funding, channel->last_tx);
|
2018-02-20 21:59:09 +01:00
|
|
|
|
2019-02-21 04:45:55 +01:00
|
|
|
log_debug(channel->log, "Their actual closing tx fee is %s"
|
|
|
|
" vs previous %s",
|
|
|
|
type_to_string(tmpctx, struct amount_sat, &fee),
|
|
|
|
type_to_string(tmpctx, struct amount_sat, &last_fee));
|
2018-02-20 21:59:09 +01:00
|
|
|
|
|
|
|
/* Weight once we add in sigs. */
|
2020-07-06 07:26:14 +02:00
|
|
|
weight = bitcoin_tx_weight(tx) + bitcoin_tx_input_sig_weight() * 2;
|
2018-02-20 21:59:09 +01:00
|
|
|
|
2018-08-23 01:27:25 +02:00
|
|
|
/* If we don't have a feerate estimate, this gives feerate_floor */
|
|
|
|
min_feerate = feerate_min(ld, &feerate_unknown);
|
|
|
|
|
2019-02-21 04:45:55 +01:00
|
|
|
min_fee = amount_tx_fee(min_feerate, weight);
|
|
|
|
if (amount_sat_less(fee, min_fee)) {
|
|
|
|
log_debug(channel->log, "... That's below our min %s"
|
|
|
|
" for weight %"PRIu64" at feerate %u",
|
|
|
|
type_to_string(tmpctx, struct amount_sat, &fee),
|
|
|
|
weight, min_feerate);
|
2018-02-20 21:59:09 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-28 16:11:22 +01:00
|
|
|
/* Prefer new over old: this covers the preference
|
2018-08-23 01:27:25 +02:00
|
|
|
* for a mutual close over a unilateral one. */
|
|
|
|
|
2020-02-28 16:11:22 +01:00
|
|
|
return true;
|
2018-02-20 21:59:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void peer_received_closing_signature(struct channel *channel,
|
|
|
|
const u8 *msg)
|
|
|
|
{
|
2018-12-03 00:15:06 +01:00
|
|
|
struct bitcoin_signature sig;
|
2018-02-20 21:59:09 +01:00
|
|
|
struct bitcoin_tx *tx;
|
2019-04-10 23:58:01 +02:00
|
|
|
struct bitcoin_txid tx_id;
|
2018-02-20 21:59:09 +01:00
|
|
|
struct lightningd *ld = channel->peer->ld;
|
|
|
|
|
2020-08-25 04:15:48 +02:00
|
|
|
if (!fromwire_closingd_received_signature(msg, msg, &sig, &tx)) {
|
2018-02-20 21:59:09 +01:00
|
|
|
channel_internal_error(channel, "Bad closing_received_signature %s",
|
|
|
|
tal_hex(msg, msg));
|
|
|
|
return;
|
|
|
|
}
|
2019-10-15 12:58:30 +02:00
|
|
|
tx->chainparams = chainparams;
|
2018-02-20 21:59:09 +01:00
|
|
|
|
|
|
|
/* FIXME: Make sure signature is correct! */
|
2020-02-28 16:11:22 +01:00
|
|
|
if (closing_fee_is_acceptable(ld, channel, tx)) {
|
2019-05-28 18:06:39 +02:00
|
|
|
channel_set_last_tx(channel, tx, &sig, TX_CHANNEL_CLOSE);
|
2018-02-20 21:59:09 +01:00
|
|
|
wallet_channel_save(ld->wallet, channel);
|
|
|
|
}
|
|
|
|
|
2019-04-10 23:58:01 +02:00
|
|
|
|
|
|
|
// Send back the txid so we can update the billboard on selection.
|
|
|
|
bitcoin_txid(channel->last_tx, &tx_id);
|
2018-02-20 21:59:09 +01:00
|
|
|
/* OK, you can continue now. */
|
|
|
|
subd_send_msg(channel->owner,
|
2020-08-25 04:15:48 +02:00
|
|
|
take(towire_closingd_received_signature_reply(channel, &tx_id)));
|
2018-02-20 21:59:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void peer_closing_complete(struct channel *channel, const u8 *msg)
|
|
|
|
{
|
2020-08-25 04:15:48 +02:00
|
|
|
if (!fromwire_closingd_complete(msg)) {
|
2018-02-20 21:59:09 +01:00
|
|
|
channel_internal_error(channel, "Bad closing_complete %s",
|
|
|
|
tal_hex(msg, msg));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-26 06:51:01 +02:00
|
|
|
/* Don't report spurious failure when closingd exits. */
|
2019-07-25 04:47:34 +02:00
|
|
|
channel_set_owner(channel, NULL);
|
2018-04-26 06:51:01 +02:00
|
|
|
/* Clear any transient negotiation messages */
|
|
|
|
channel_set_billboard(channel, false, NULL);
|
|
|
|
|
2018-02-20 21:59:09 +01:00
|
|
|
/* Retransmission only, ignore closing. */
|
|
|
|
if (channel->state == CLOSINGD_COMPLETE)
|
|
|
|
return;
|
|
|
|
|
2018-04-10 08:03:15 +02:00
|
|
|
/* Channel gets dropped to chain cooperatively. */
|
|
|
|
drop_to_chain(channel->peer->ld, channel, true);
|
feat: adds state change cause and message
This adds a `state_change` 'cause' to a channel.
A 'cause' is some initial 'reason' a channel was created or closed by:
/* Anything other than the reasons below. Should not happen. */
REASON_UNKNOWN,
/* Unconscious internal reasons, e.g. dev fail of a channel. */
REASON_LOCAL,
/* The operator or a plugin opened or closed a channel by intention. */
REASON_USER,
/* The remote closed or funded a channel with us by intention. */
REASON_REMOTE,
/* E.g. We need to close a channel because of bad signatures and such. */
REASON_PROTOCOL,
/* A channel was closed onchain, while we were offline. */
/* Note: This is very likely a conscious remote decision. */
REASON_ONCHAIN
If a 'cause' is known and a subsequent state change is made with
`REASON_UNKNOWN` the preceding cause will be used as reason, since a lot
(all `REASON_UNKNOWN`) state changes are a subsequent consequences of a prior
cause: local, user, remote, protocol or onchain.
Changelog-Added: Plugins: Channel closure resaon/cause to channel_state_changed notification
2020-10-28 11:46:12 +01:00
|
|
|
channel_set_state(channel,
|
|
|
|
CLOSINGD_SIGEXCHANGE,
|
|
|
|
CLOSINGD_COMPLETE,
|
|
|
|
REASON_UNKNOWN,
|
|
|
|
"Closing complete");
|
2018-02-20 21:59:09 +01:00
|
|
|
}
|
|
|
|
|
2018-03-05 17:40:50 +01:00
|
|
|
static unsigned closing_msg(struct subd *sd, const u8 *msg, const int *fds UNUSED)
|
2018-02-20 21:59:09 +01:00
|
|
|
{
|
2020-08-25 04:15:48 +02:00
|
|
|
enum closingd_wire t = fromwire_peektype(msg);
|
2018-02-20 21:59:09 +01:00
|
|
|
|
|
|
|
switch (t) {
|
2020-08-25 04:15:48 +02:00
|
|
|
case WIRE_CLOSINGD_RECEIVED_SIGNATURE:
|
2018-02-20 21:59:09 +01:00
|
|
|
peer_received_closing_signature(sd->channel, msg);
|
|
|
|
break;
|
|
|
|
|
2020-08-25 04:15:48 +02:00
|
|
|
case WIRE_CLOSINGD_COMPLETE:
|
2018-02-20 21:59:09 +01:00
|
|
|
peer_closing_complete(sd->channel, msg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* We send these, not receive them */
|
2020-08-25 04:15:48 +02:00
|
|
|
case WIRE_CLOSINGD_INIT:
|
|
|
|
case WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY:
|
2018-02-20 21:59:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void peer_start_closingd(struct channel *channel,
|
2019-06-03 20:11:25 +02:00
|
|
|
struct per_peer_state *pps,
|
2018-04-23 12:08:02 +02:00
|
|
|
bool reconnected,
|
|
|
|
const u8 *channel_reestablish)
|
2018-02-20 21:59:09 +01:00
|
|
|
{
|
2018-03-07 01:06:07 +01:00
|
|
|
u8 *initmsg;
|
2018-08-23 01:27:25 +02:00
|
|
|
u32 feerate;
|
2019-02-21 04:45:55 +01:00
|
|
|
struct amount_sat minfee, startfee, feelimit;
|
2018-02-20 21:59:09 +01:00
|
|
|
u64 num_revocations;
|
2019-02-21 04:45:55 +01:00
|
|
|
struct amount_msat their_msat;
|
2018-07-23 04:23:03 +02:00
|
|
|
int hsmfd;
|
2019-04-08 03:35:13 +02:00
|
|
|
struct secret last_remote_per_commit_secret;
|
2018-02-20 21:59:09 +01:00
|
|
|
struct lightningd *ld = channel->peer->ld;
|
2019-12-12 18:18:25 +01:00
|
|
|
u32 final_commit_feerate;
|
2018-02-20 21:59:09 +01:00
|
|
|
|
2019-09-29 09:35:45 +02:00
|
|
|
if (!channel->shutdown_scriptpubkey[REMOTE]) {
|
2018-02-20 21:59:09 +01:00
|
|
|
channel_internal_error(channel,
|
2018-03-07 01:06:07 +01:00
|
|
|
"Can't start closing: no remote info");
|
2018-02-20 21:59:09 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-23 04:23:03 +02:00
|
|
|
hsmfd = hsm_get_client_fd(ld, &channel->peer->id, channel->dbid,
|
2019-04-08 03:35:13 +02:00
|
|
|
HSM_CAP_SIGN_CLOSING_TX
|
|
|
|
| HSM_CAP_COMMITMENT_POINT);
|
2018-07-23 04:23:03 +02:00
|
|
|
|
2018-04-26 06:51:01 +02:00
|
|
|
channel_set_owner(channel,
|
|
|
|
new_channel_subd(ld,
|
2018-02-20 21:59:09 +01:00
|
|
|
"lightning_closingd",
|
2019-11-17 12:40:33 +01:00
|
|
|
channel, &channel->peer->id,
|
|
|
|
channel->log, true,
|
2020-08-25 04:15:48 +02:00
|
|
|
closingd_wire_name, closing_msg,
|
2018-02-20 21:59:09 +01:00
|
|
|
channel_errmsg,
|
2018-02-23 06:53:47 +01:00
|
|
|
channel_set_billboard,
|
2019-06-03 20:11:25 +02:00
|
|
|
take(&pps->peer_fd),
|
|
|
|
take(&pps->gossip_fd),
|
|
|
|
take(&pps->gossip_store_fd),
|
2018-07-23 04:23:03 +02:00
|
|
|
take(&hsmfd),
|
2019-07-25 04:47:34 +02:00
|
|
|
NULL));
|
2018-08-09 02:25:29 +02:00
|
|
|
|
2018-02-20 21:59:09 +01:00
|
|
|
if (!channel->owner) {
|
2020-03-25 05:26:44 +01:00
|
|
|
log_broken(channel->log, "Could not subdaemon closing: %s",
|
2018-02-20 21:59:09 +01:00
|
|
|
strerror(errno));
|
2019-07-26 04:11:18 +02:00
|
|
|
channel_fail_reconnect_later(channel,
|
|
|
|
"Failed to subdaemon closing");
|
2018-02-20 21:59:09 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
|
*
|
2018-06-17 12:13:44 +02:00
|
|
|
* The sending node:
|
|
|
|
* - MUST set `fee_satoshis` less than or equal to the base
|
|
|
|
* fee of the final commitment transaction, as calculated in
|
|
|
|
* [BOLT #3](03-transactions.md#fee-calculation).
|
2018-02-20 21:59:09 +01:00
|
|
|
*/
|
2020-09-17 03:58:59 +02:00
|
|
|
final_commit_feerate = get_feerate(channel->fee_states,
|
2019-09-09 18:11:24 +02:00
|
|
|
channel->opener, LOCAL);
|
2020-08-13 19:44:02 +02:00
|
|
|
feelimit = commit_tx_base_fee(final_commit_feerate, 0,
|
2020-08-14 03:30:41 +02:00
|
|
|
channel->option_anchor_outputs);
|
2018-02-20 21:59:09 +01:00
|
|
|
|
2018-08-23 01:27:25 +02:00
|
|
|
/* Pick some value above slow feerate (or min possible if unknown) */
|
2020-08-13 19:44:02 +02:00
|
|
|
minfee = commit_tx_base_fee(feerate_min(ld, NULL), 0,
|
2020-08-14 03:30:41 +02:00
|
|
|
channel->option_anchor_outputs);
|
2018-08-23 01:27:25 +02:00
|
|
|
|
|
|
|
/* If we can't determine feerate, start at half unilateral feerate. */
|
2018-08-24 04:22:48 +02:00
|
|
|
feerate = mutual_close_feerate(ld->topology);
|
2018-08-23 01:27:25 +02:00
|
|
|
if (!feerate) {
|
2019-12-12 18:18:25 +01:00
|
|
|
feerate = final_commit_feerate / 2;
|
2018-08-23 01:27:25 +02:00
|
|
|
if (feerate < feerate_floor())
|
|
|
|
feerate = feerate_floor();
|
|
|
|
}
|
2020-08-13 19:44:02 +02:00
|
|
|
startfee = commit_tx_base_fee(feerate, 0,
|
2020-08-14 03:30:41 +02:00
|
|
|
channel->option_anchor_outputs);
|
2018-02-20 21:59:09 +01:00
|
|
|
|
2019-02-21 04:45:55 +01:00
|
|
|
if (amount_sat_greater(startfee, feelimit))
|
2018-02-20 21:59:09 +01:00
|
|
|
startfee = feelimit;
|
2019-02-21 04:45:55 +01:00
|
|
|
if (amount_sat_greater(minfee, feelimit))
|
2018-02-20 21:59:09 +01:00
|
|
|
minfee = feelimit;
|
|
|
|
|
|
|
|
num_revocations
|
|
|
|
= revocations_received(&channel->their_shachain.chain);
|
|
|
|
|
|
|
|
/* BOLT #3:
|
|
|
|
*
|
2018-06-17 12:13:44 +02:00
|
|
|
* Each node offering a signature:
|
|
|
|
* - MUST round each output down to whole satoshis.
|
2018-02-20 21:59:09 +01:00
|
|
|
*/
|
|
|
|
/* What is not ours is theirs */
|
2019-02-21 04:45:55 +01:00
|
|
|
if (!amount_sat_sub_msat(&their_msat,
|
|
|
|
channel->funding, channel->our_msat)) {
|
|
|
|
log_broken(channel->log, "our_msat overflow funding %s minus %s",
|
|
|
|
type_to_string(tmpctx, struct amount_sat,
|
|
|
|
&channel->funding),
|
|
|
|
type_to_string(tmpctx, struct amount_msat,
|
|
|
|
&channel->our_msat));
|
feat: adds state change cause and message
This adds a `state_change` 'cause' to a channel.
A 'cause' is some initial 'reason' a channel was created or closed by:
/* Anything other than the reasons below. Should not happen. */
REASON_UNKNOWN,
/* Unconscious internal reasons, e.g. dev fail of a channel. */
REASON_LOCAL,
/* The operator or a plugin opened or closed a channel by intention. */
REASON_USER,
/* The remote closed or funded a channel with us by intention. */
REASON_REMOTE,
/* E.g. We need to close a channel because of bad signatures and such. */
REASON_PROTOCOL,
/* A channel was closed onchain, while we were offline. */
/* Note: This is very likely a conscious remote decision. */
REASON_ONCHAIN
If a 'cause' is known and a subsequent state change is made with
`REASON_UNKNOWN` the preceding cause will be used as reason, since a lot
(all `REASON_UNKNOWN`) state changes are a subsequent consequences of a prior
cause: local, user, remote, protocol or onchain.
Changelog-Added: Plugins: Channel closure resaon/cause to channel_state_changed notification
2020-10-28 11:46:12 +01:00
|
|
|
channel_fail_permanent(channel,
|
|
|
|
REASON_LOCAL,
|
|
|
|
"our_msat overflow on closing");
|
2019-02-21 04:45:55 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-04-08 03:35:13 +02:00
|
|
|
|
|
|
|
/* BOLT #2:
|
2019-08-02 05:24:25 +02:00
|
|
|
* - if `next_revocation_number` equals 0:
|
2019-04-08 03:35:13 +02:00
|
|
|
* - MUST set `your_last_per_commitment_secret` to all zeroes
|
|
|
|
* - otherwise:
|
|
|
|
* - MUST set `your_last_per_commitment_secret` to the last
|
|
|
|
* `per_commitment_secret` it received
|
|
|
|
*/
|
|
|
|
if (num_revocations == 0)
|
|
|
|
memset(&last_remote_per_commit_secret, 0,
|
|
|
|
sizeof(last_remote_per_commit_secret));
|
|
|
|
else if (!shachain_get_secret(&channel->their_shachain.chain,
|
|
|
|
num_revocations-1,
|
|
|
|
&last_remote_per_commit_secret)) {
|
|
|
|
channel_fail_permanent(channel,
|
feat: adds state change cause and message
This adds a `state_change` 'cause' to a channel.
A 'cause' is some initial 'reason' a channel was created or closed by:
/* Anything other than the reasons below. Should not happen. */
REASON_UNKNOWN,
/* Unconscious internal reasons, e.g. dev fail of a channel. */
REASON_LOCAL,
/* The operator or a plugin opened or closed a channel by intention. */
REASON_USER,
/* The remote closed or funded a channel with us by intention. */
REASON_REMOTE,
/* E.g. We need to close a channel because of bad signatures and such. */
REASON_PROTOCOL,
/* A channel was closed onchain, while we were offline. */
/* Note: This is very likely a conscious remote decision. */
REASON_ONCHAIN
If a 'cause' is known and a subsequent state change is made with
`REASON_UNKNOWN` the preceding cause will be used as reason, since a lot
(all `REASON_UNKNOWN`) state changes are a subsequent consequences of a prior
cause: local, user, remote, protocol or onchain.
Changelog-Added: Plugins: Channel closure resaon/cause to channel_state_changed notification
2020-10-28 11:46:12 +01:00
|
|
|
REASON_LOCAL,
|
2019-04-08 03:35:13 +02:00
|
|
|
"Could not get revocation secret %"PRIu64,
|
|
|
|
num_revocations-1);
|
|
|
|
return;
|
|
|
|
}
|
2020-08-25 04:15:48 +02:00
|
|
|
initmsg = towire_closingd_init(tmpctx,
|
2019-09-25 22:38:45 +02:00
|
|
|
chainparams,
|
2019-06-03 20:11:25 +02:00
|
|
|
pps,
|
2020-09-09 09:20:53 +02:00
|
|
|
&channel->cid,
|
2018-02-20 21:59:09 +01:00
|
|
|
&channel->funding_txid,
|
|
|
|
channel->funding_outnum,
|
2019-02-21 04:45:55 +01:00
|
|
|
channel->funding,
|
2018-07-23 04:23:03 +02:00
|
|
|
&channel->local_funding_pubkey,
|
2018-02-20 21:59:09 +01:00
|
|
|
&channel->channel_info.remote_fundingkey,
|
2019-09-09 18:11:24 +02:00
|
|
|
channel->opener,
|
2019-02-21 04:45:55 +01:00
|
|
|
amount_msat_to_sat_round_down(channel->our_msat),
|
|
|
|
amount_msat_to_sat_round_down(their_msat),
|
|
|
|
channel->our_config.dust_limit,
|
2018-02-20 21:59:09 +01:00
|
|
|
minfee, feelimit, startfee,
|
2019-09-29 10:53:26 +02:00
|
|
|
channel->shutdown_scriptpubkey[LOCAL],
|
2019-09-29 09:35:45 +02:00
|
|
|
channel->shutdown_scriptpubkey[REMOTE],
|
2020-01-03 14:08:29 +01:00
|
|
|
channel->closing_fee_negotiation_step,
|
|
|
|
channel->closing_fee_negotiation_step_unit,
|
2018-02-20 21:59:09 +01:00
|
|
|
reconnected,
|
|
|
|
channel->next_index[LOCAL],
|
|
|
|
channel->next_index[REMOTE],
|
|
|
|
num_revocations,
|
2018-10-29 04:37:11 +01:00
|
|
|
channel_reestablish,
|
2019-09-18 03:05:05 +02:00
|
|
|
&last_remote_per_commit_secret,
|
2019-09-26 04:00:20 +02:00
|
|
|
IFDEV(ld->dev_fast_gossip, false));
|
2018-02-20 21:59:09 +01:00
|
|
|
|
|
|
|
/* We don't expect a response: it will give us feedback on
|
|
|
|
* signatures sent and received, then closing_complete. */
|
|
|
|
subd_send_msg(channel->owner, take(initmsg));
|
2018-05-26 15:47:02 +02:00
|
|
|
|
|
|
|
/* Now tell gossipd that we're closing and that neither direction should
|
|
|
|
* be used. */
|
|
|
|
if (channel->scid)
|
|
|
|
subd_send_msg(channel->peer->ld->gossip,
|
2020-08-25 04:05:45 +02:00
|
|
|
take(towire_gossipd_local_channel_close(
|
2018-05-26 15:47:02 +02:00
|
|
|
tmpctx, channel->scid)));
|
2018-02-20 21:59:09 +01:00
|
|
|
}
|