mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
channeld: BOLT update, no longer allow creation of old (experimental-only!) non-zero-fee anchor channels.
These were removed from the spec. We still support existing ones, though we were the only implementation which ever did, and only in experimental mode, so we should be able to upgrade them and avoid a forced close, with a bit of engineering... Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b6d7ee1f11
commit
7d3d763b96
2
Makefile
2
Makefile
@ -26,7 +26,7 @@ CCANDIR := ccan
|
||||
|
||||
# Where we keep the BOLT RFCs
|
||||
BOLTDIR := ../bolts/
|
||||
DEFAULT_BOLTVERSION := 91f4bd2383cc2fc7a0a43b697e209f9eb9f5183c
|
||||
DEFAULT_BOLTVERSION := d745028f65bdc8ae43d4dce01ba1b7a82ca14b41
|
||||
# Can be overridden on cmdline.
|
||||
BOLTVERSION := $(DEFAULT_BOLTVERSION)
|
||||
|
||||
|
@ -5864,7 +5864,7 @@ static void init_channel(struct peer *peer)
|
||||
" option_anchor_outputs = %u"
|
||||
" option_anchors_zero_fee_htlc_tx = %u",
|
||||
channel_type_has(channel_type, OPT_STATIC_REMOTEKEY),
|
||||
channel_type_has(channel_type, OPT_ANCHOR_OUTPUTS),
|
||||
channel_type_has(channel_type, OPT_ANCHOR_OUTPUTS_DEPRECATED),
|
||||
channel_type_has(channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX));
|
||||
|
||||
/* Keeping an array of pointers is better since it allows us to avoid
|
||||
|
@ -241,7 +241,7 @@ static void add_htlcs(struct bitcoin_tx ***txs,
|
||||
{
|
||||
struct bitcoin_outpoint outpoint;
|
||||
u32 htlc_feerate_per_kw;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
if (channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX))
|
||||
@ -361,7 +361,7 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
channel->config[side].dust_limit, side_pay,
|
||||
other_side_pay, committed, htlcmap, direct_outputs,
|
||||
commitment_number ^ channel->commitment_number_obscurer,
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS),
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED),
|
||||
channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
side, other_anchor_outnum);
|
||||
|
||||
@ -462,7 +462,7 @@ static struct amount_sat fee_for_htlcs(const struct channel *channel,
|
||||
u32 feerate = channel_feerate(channel, side);
|
||||
struct amount_sat dust_limit = channel->config[side].dust_limit;
|
||||
size_t untrimmed;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
untrimmed = num_untrimmed_htlcs(side, dust_limit, feerate,
|
||||
@ -484,7 +484,7 @@ static bool htlc_dust(const struct channel *channel,
|
||||
struct amount_msat *trim_total)
|
||||
{
|
||||
struct amount_sat dust_limit = channel->config[side].dust_limit;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
struct amount_msat trim_rmvd = AMOUNT_MSAT(0);
|
||||
|
||||
@ -544,7 +544,7 @@ static bool local_opener_has_fee_headroom(const struct channel *channel,
|
||||
u32 feerate = channel_feerate(channel, LOCAL);
|
||||
size_t untrimmed;
|
||||
struct amount_sat fee;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
assert(channel->opener == LOCAL);
|
||||
@ -593,7 +593,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
|
||||
const struct htlc **committed, **adding, **removing;
|
||||
const struct channel_view *view;
|
||||
size_t htlc_count;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
u32 feerate, feerate_ceil;
|
||||
|
||||
@ -1217,7 +1217,7 @@ u32 approx_max_feerate(const struct channel *channel)
|
||||
struct amount_msat avail;
|
||||
struct balance balance;
|
||||
const struct htlc **committed, **adding, **removing;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
gather_htlcs(tmpctx, channel, !channel->opener,
|
||||
@ -1298,7 +1298,7 @@ bool can_opener_afford_feerate(const struct channel *channel, u32 feerate_per_kw
|
||||
struct amount_sat dust_limit = channel->config[!channel->opener].dust_limit;
|
||||
size_t untrimmed;
|
||||
const struct htlc **committed, **adding, **removing;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
struct balance balance;
|
||||
struct amount_msat available;
|
||||
|
@ -25,7 +25,6 @@ struct channel_type *channel_type_none_obsolete(const tal_t *ctx)
|
||||
*
|
||||
* The currently defined basic types are:
|
||||
* - `option_static_remotekey` (bit 12)
|
||||
* - `option_anchor_outputs` and `option_static_remotekey` (bits 20 and 12)
|
||||
* - `option_anchors_zero_fee_htlc_tx` and `option_static_remotekey` (bits 22
|
||||
* and 12)
|
||||
*
|
||||
@ -40,12 +39,12 @@ struct channel_type *channel_type_static_remotekey(const tal_t *ctx)
|
||||
return type;
|
||||
}
|
||||
|
||||
struct channel_type *channel_type_anchor_outputs(const tal_t *ctx)
|
||||
struct channel_type *channel_type_anchor_outputs_obsolete(const tal_t *ctx)
|
||||
{
|
||||
struct channel_type *type = new_channel_type(ctx);
|
||||
|
||||
set_feature_bit(&type->features,
|
||||
COMPULSORY_FEATURE(OPT_ANCHOR_OUTPUTS));
|
||||
COMPULSORY_FEATURE(OPT_ANCHOR_OUTPUTS_DEPRECATED));
|
||||
set_feature_bit(&type->features,
|
||||
COMPULSORY_FEATURE(OPT_STATIC_REMOTEKEY));
|
||||
return type;
|
||||
@ -85,25 +84,12 @@ struct channel_type *default_channel_type(const tal_t *ctx,
|
||||
* - otherwise:
|
||||
* - if `option_anchors_zero_fee_htlc_tx` was negotiated:
|
||||
* - the `channel_type` is `option_anchors_zero_fee_htlc_tx` and `option_static_remotekey` (bits 22 and 12)
|
||||
* - otherwise, if `option_anchor_outputs` was negotiated:
|
||||
* - the `channel_type` is `option_anchor_outputs` and
|
||||
* `option_static_remotekey` (bits 20 and 12)
|
||||
* - otherwise:
|
||||
* - the `channel_type` is `option_static_remotekey` (bit 12)
|
||||
*/
|
||||
if (feature_negotiated(our_features, their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX))
|
||||
return channel_type_anchors_zero_fee_htlc(ctx);
|
||||
if (feature_negotiated(our_features, their_features,
|
||||
OPT_ANCHOR_OUTPUTS))
|
||||
return channel_type_anchor_outputs(ctx);
|
||||
else if (feature_negotiated(our_features, their_features,
|
||||
OPT_DUAL_FUND))
|
||||
/* OPT_DUAL_FUND implies static remotekey */
|
||||
return channel_type_static_remotekey(ctx);
|
||||
/* BOLT #2:
|
||||
* - otherwise:
|
||||
* - the `channel_type` is `option_static_remotekey` (bit 12)
|
||||
*/
|
||||
else
|
||||
return channel_type_static_remotekey(ctx);
|
||||
}
|
||||
|
||||
@ -114,7 +100,7 @@ bool channel_type_has(const struct channel_type *type, int feature)
|
||||
|
||||
bool channel_type_has_anchors(const struct channel_type *type)
|
||||
{
|
||||
return feature_offered(type->features, OPT_ANCHOR_OUTPUTS)
|
||||
return feature_offered(type->features, OPT_ANCHOR_OUTPUTS_DEPRECATED)
|
||||
|| feature_offered(type->features, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
}
|
||||
|
||||
@ -149,7 +135,6 @@ struct channel_type *channel_type_accept(const tal_t *ctx,
|
||||
proposed.features = tal_dup_talarr(tmpctx, u8, t);
|
||||
|
||||
static const size_t feats[] = {
|
||||
OPT_ANCHOR_OUTPUTS,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX,
|
||||
OPT_STATIC_REMOTEKEY,
|
||||
OPT_SCID_ALIAS,
|
||||
@ -190,8 +175,7 @@ struct channel_type *channel_type_accept(const tal_t *ctx,
|
||||
if (channel_type_eq(&proposed,
|
||||
channel_type_static_remotekey(tmpctx)) ||
|
||||
channel_type_eq(&proposed,
|
||||
channel_type_anchors_zero_fee_htlc(tmpctx)) ||
|
||||
channel_type_eq(&proposed, channel_type_anchor_outputs(tmpctx))) {
|
||||
channel_type_anchors_zero_fee_htlc(tmpctx))) {
|
||||
/* At this point we know it matches, and maybe has
|
||||
* a couple of extra options. So let's just reply
|
||||
* with their proposal. */
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
/* Explicit channel types */
|
||||
struct channel_type *channel_type_static_remotekey(const tal_t *ctx);
|
||||
struct channel_type *channel_type_anchor_outputs(const tal_t *ctx);
|
||||
struct channel_type *channel_type_anchors_zero_fee_htlc(const tal_t *ctx);
|
||||
|
||||
/* channel_type variants */
|
||||
@ -47,4 +46,5 @@ const char **channel_type_name(const tal_t *ctx, const struct channel_type *t);
|
||||
|
||||
/* Obsolete channels can exist in db still */
|
||||
struct channel_type *channel_type_none_obsolete(const tal_t *ctx);
|
||||
struct channel_type *channel_type_anchor_outputs_obsolete(const tal_t *ctx);
|
||||
#endif /* LIGHTNING_COMMON_CHANNEL_TYPE_H */
|
||||
|
@ -77,10 +77,6 @@ static const struct feature_style feature_styles[] = {
|
||||
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
|
||||
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
|
||||
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
|
||||
{ OPT_ANCHOR_OUTPUTS,
|
||||
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
|
||||
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
|
||||
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT } },
|
||||
{ OPT_ANCHORS_ZERO_FEE_HTLC_TX,
|
||||
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
|
||||
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
|
||||
@ -170,18 +166,6 @@ static const struct dependency feature_deps[] = {
|
||||
{ OPT_GOSSIP_QUERIES_EX, OPT_GOSSIP_QUERIES },
|
||||
{ OPT_PAYMENT_SECRET, OPT_VAR_ONION },
|
||||
{ OPT_BASIC_MPP, OPT_PAYMENT_SECRET },
|
||||
/* BOLT #9:
|
||||
* Name | Description | Context | Dependencies |
|
||||
*...
|
||||
* `option_anchor_outputs` | ... | ... | `option_static_remotekey`
|
||||
*/
|
||||
{ OPT_ANCHOR_OUTPUTS, OPT_STATIC_REMOTEKEY },
|
||||
/* BOLT #9:
|
||||
* Name | Description | Context | Dependencies |
|
||||
*...
|
||||
* `option_anchors_zero_fee_htlc_tx` | ... | ... | `option_static_remotekey`
|
||||
*/
|
||||
{ OPT_ANCHORS_ZERO_FEE_HTLC_TX, OPT_STATIC_REMOTEKEY },
|
||||
/* BOLT #9:
|
||||
* Name | Description | Context | Dependencies |
|
||||
* ...
|
||||
|
@ -112,7 +112,6 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
|
||||
* | 14/15 | `payment_secret` |... IN9 ...
|
||||
* | 16/17 | `basic_mpp` |... IN9 ...
|
||||
* | 18/19 | `option_support_large_channel` |... IN ...
|
||||
* | 20/21 | `option_anchor_outputs` |... IN ...
|
||||
* | 22/23 | `option_anchors_zero_fee_htlc_tx` |... IN ...
|
||||
* | 24/25 | `option_route_blinding` |...IN9 ...
|
||||
* | 26/27 | `option_shutdown_anysegwit` |... IN ...
|
||||
@ -133,7 +132,6 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
|
||||
#define OPT_PAYMENT_SECRET 14
|
||||
#define OPT_BASIC_MPP 16
|
||||
#define OPT_LARGE_CHANNELS 18
|
||||
#define OPT_ANCHOR_OUTPUTS 20
|
||||
#define OPT_ANCHORS_ZERO_FEE_HTLC_TX 22
|
||||
#define OPT_ROUTE_BLINDING 24
|
||||
#define OPT_SHUTDOWN_ANYSEGWIT 26
|
||||
@ -144,6 +142,10 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
|
||||
#define OPT_PAYMENT_METADATA 48
|
||||
#define OPT_ZEROCONF 50
|
||||
|
||||
/* The old pre-zero-fee-anchors were deprecated, and we never supported them
|
||||
* outside experimental options */
|
||||
#define OPT_ANCHOR_OUTPUTS_DEPRECATED 20
|
||||
|
||||
/* BOLT-splice #9:
|
||||
* | 62/63 | `option_splice` | ... IN ...
|
||||
*/
|
||||
|
@ -23,14 +23,14 @@ static inline struct amount_sat htlc_timeout_fee(u32 feerate_per_kw,
|
||||
* - If `option_anchors_zero_fee_htlc_tx` applies:
|
||||
* 1. MUST be 0.
|
||||
* - Otherwise, MUST be calculated to match:
|
||||
* 1. Multiply `feerate_per_kw` by 663 (666 if `option_anchor_outputs`
|
||||
* applies) and divide by 1000 (rounding down).
|
||||
* 1. Multiply `feerate_per_kw` by 663 and divide by 1000 (rounding down).
|
||||
*/
|
||||
u32 base;
|
||||
|
||||
if (option_anchors_zero_fee_htlc_tx)
|
||||
return AMOUNT_SAT(0);
|
||||
|
||||
/* FIXME: Older bolt had "(666 if `option_anchor_outputs` applies)" */
|
||||
if (option_anchor_outputs)
|
||||
base = 666;
|
||||
else
|
||||
@ -49,14 +49,14 @@ static inline struct amount_sat htlc_success_fee(u32 feerate_per_kw,
|
||||
* - If `option_anchors_zero_fee_htlc_tx` applies:
|
||||
* 1. MUST be 0.
|
||||
* - Otherwise, MUST be calculated to match:
|
||||
* 1. Multiply `feerate_per_kw` by 703 (706 if `option_anchor_outputs`
|
||||
* applies) and divide by 1000 (rounding down).
|
||||
* 1. Multiply `feerate_per_kw` by 703 and divide by 1000 (rounding down).
|
||||
*/
|
||||
u32 base;
|
||||
|
||||
if (option_anchors_zero_fee_htlc_tx)
|
||||
return AMOUNT_SAT(0);
|
||||
|
||||
/* FIXME: older bolt used to say "(706 if `option_anchor_outputs` applies) */
|
||||
if (option_anchor_outputs)
|
||||
base = 706;
|
||||
else
|
||||
|
@ -133,7 +133,7 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
|
||||
0 ^ channel->commitment_number_obscurer,
|
||||
direct_outputs,
|
||||
side, csv_lock,
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS),
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED),
|
||||
channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
err_reason);
|
||||
|
||||
@ -209,8 +209,8 @@ struct channel_type *channel_desired_type(const tal_t *ctx,
|
||||
return channel_type_anchors_zero_fee_htlc(ctx);
|
||||
|
||||
/* We don't actually want to downgrade anchors! */
|
||||
if (channel_has(channel, OPT_ANCHOR_OUTPUTS))
|
||||
return channel_type_anchor_outputs(ctx);
|
||||
if (channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED))
|
||||
return channel_type_anchor_outputs_obsolete(ctx);
|
||||
|
||||
/* For now, we just want option_static_remotekey */
|
||||
return channel_type_static_remotekey(ctx);
|
||||
|
@ -122,8 +122,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
assert_names_eq(channel_type_name(tmpctx, channel_type_static_remotekey(tmpctx)),
|
||||
"static_remotekey/even");
|
||||
assert_names_eq(channel_type_name(tmpctx, channel_type_anchor_outputs(tmpctx)),
|
||||
"static_remotekey/even anchor_outputs/even");
|
||||
assert_names_eq(channel_type_name(tmpctx, channel_type_anchors_zero_fee_htlc(tmpctx)),
|
||||
"static_remotekey/even anchors_zero_fee_htlc_tx/even");
|
||||
|
||||
t.features = tal_arr(tmpctx, u8, 0);
|
||||
set_feature_bit(&t.features, 1000);
|
||||
|
@ -303,7 +303,7 @@ int main(int argc, char *argv[])
|
||||
"Use option_static_remotekey generation rules");
|
||||
opt_register_noarg("--option-anchor-outputs", opt_set_bool,
|
||||
&option_anchor_outputs,
|
||||
"Use option_anchor_outputs generation rules");
|
||||
"Use option_anchors_zero_fee_htlc_tx generation rules");
|
||||
opt_register_version();
|
||||
|
||||
opt_parse(&argc, argv, opt_log_stderr_exit);
|
||||
@ -391,7 +391,7 @@ int main(int argc, char *argv[])
|
||||
derive_channel_id(&cid, &funding);
|
||||
|
||||
if (option_anchor_outputs)
|
||||
channel_type = channel_type_anchor_outputs(NULL);
|
||||
channel_type = channel_type_anchors_zero_fee_htlc(NULL);
|
||||
else if (option_static_remotekey)
|
||||
channel_type = channel_type_static_remotekey(NULL);
|
||||
else
|
||||
|
@ -732,7 +732,7 @@ static struct command_result *json_feerates(struct command *cmd,
|
||||
/* It actually is negotiated per-channel... */
|
||||
bool anchor_outputs
|
||||
= feature_offered(cmd->ld->our_features->bits[INIT_FEATURE],
|
||||
OPT_ANCHOR_OUTPUTS)
|
||||
OPT_ANCHOR_OUTPUTS_DEPRECATED)
|
||||
|| feature_offered(cmd->ld->our_features->bits[INIT_FEATURE],
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
|
@ -1156,7 +1156,7 @@ static void peer_got_shutdown(struct channel *channel, const u8 *msg)
|
||||
OPT_SHUTDOWN_ANYSEGWIT);
|
||||
bool anchors = feature_negotiated(ld->our_features,
|
||||
channel->peer->their_features,
|
||||
OPT_ANCHOR_OUTPUTS)
|
||||
OPT_ANCHOR_OUTPUTS_DEPRECATED)
|
||||
|| feature_negotiated(ld->our_features,
|
||||
channel->peer->their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
@ -364,7 +364,7 @@ void peer_start_closingd(struct channel *channel, struct peer_fd *peer_fd)
|
||||
int hsmfd;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
u32 final_commit_feerate;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
if (!channel->shutdown_scriptpubkey[REMOTE]) {
|
||||
|
@ -157,7 +157,7 @@ void json_add_unsaved_channel(struct json_stream *response,
|
||||
|
||||
if (feature_negotiated(channel->peer->ld->our_features,
|
||||
channel->peer->their_features,
|
||||
OPT_ANCHOR_OUTPUTS))
|
||||
OPT_ANCHOR_OUTPUTS_DEPRECATED))
|
||||
json_add_string(response, NULL, "option_anchor_outputs");
|
||||
|
||||
if (feature_negotiated(channel->peer->ld->our_features,
|
||||
@ -1527,7 +1527,7 @@ static void handle_peer_wants_to_close(struct subd *dualopend,
|
||||
OPT_SHUTDOWN_ANYSEGWIT);
|
||||
bool anchors = feature_negotiated(ld->our_features,
|
||||
channel->peer->their_features,
|
||||
OPT_ANCHOR_OUTPUTS)
|
||||
OPT_ANCHOR_OUTPUTS_DEPRECATED)
|
||||
|| feature_negotiated(ld->our_features,
|
||||
channel->peer->their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
@ -1196,7 +1196,7 @@ static void handle_onchaind_spend_htlc_success(struct channel *channel,
|
||||
u8 **witness;
|
||||
struct bitcoin_signature sig;
|
||||
const struct onchain_witness_element **welements;
|
||||
const bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
const bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
const bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
info = new_signing_info(msg, channel, WIRE_ONCHAIND_SPEND_HTLC_SUCCESS);
|
||||
@ -1277,7 +1277,7 @@ static void handle_onchaind_spend_htlc_timeout(struct channel *channel,
|
||||
u8 **witness;
|
||||
struct bitcoin_signature sig;
|
||||
const struct onchain_witness_element **welements;
|
||||
const bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
const bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
const bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
info = new_signing_info(msg, channel, WIRE_ONCHAIND_SPEND_HTLC_TIMEOUT);
|
||||
@ -1630,7 +1630,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
|
||||
&channel->channel_info.remote_fundingkey,
|
||||
channel->static_remotekey_start[LOCAL],
|
||||
channel->static_remotekey_start[REMOTE],
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS),
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED),
|
||||
channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
feerate_min(ld, NULL));
|
||||
subd_send_msg(channel->owner, take(msg));
|
||||
|
@ -71,11 +71,6 @@ void json_add_uncommitted_channel(struct json_stream *response,
|
||||
OPT_STATIC_REMOTEKEY))
|
||||
json_add_string(response, NULL, "option_static_remotekey");
|
||||
|
||||
if (feature_negotiated(uc->peer->ld->our_features,
|
||||
uc->peer->their_features,
|
||||
OPT_ANCHOR_OUTPUTS))
|
||||
json_add_string(response, NULL, "option_anchor_outputs");
|
||||
|
||||
if (feature_negotiated(uc->peer->ld->our_features,
|
||||
uc->peer->their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX))
|
||||
@ -151,14 +146,6 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
*
|
||||
* Both peers:
|
||||
* ...
|
||||
* - if `option_anchors_zero_fee_htlc_tx` was negotiated:
|
||||
* - the `channel_type` is `option_anchors_zero_fee_htlc_tx` and
|
||||
* `option_static_remotekey` (bits 22 and 12)
|
||||
* - otherwise, if `option_anchor_outputs` was negotiated:
|
||||
* - the `channel_type` is `option_anchor_outputs` and
|
||||
* `option_static_remotekey` (bits 20 and 12)
|
||||
* - otherwise:
|
||||
* - the `channel_type` is `option_static_remotekey` (bit 12)
|
||||
* - MUST use that `channel_type` for all commitment transactions.
|
||||
*/
|
||||
/* i.e. We set it now for the channel permanently. */
|
||||
|
@ -581,7 +581,7 @@ static void json_add_htlcs(struct lightningd *ld,
|
||||
htlc_state_name(hin->hstate));
|
||||
if (htlc_is_trimmed(REMOTE, hin->msat, local_feerate,
|
||||
channel->our_config.dust_limit, LOCAL,
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS),
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED),
|
||||
channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX)))
|
||||
json_add_bool(response, "local_trimmed", true);
|
||||
if (hin->status != NULL)
|
||||
@ -605,7 +605,7 @@ static void json_add_htlcs(struct lightningd *ld,
|
||||
htlc_state_name(hout->hstate));
|
||||
if (htlc_is_trimmed(LOCAL, hout->msat, local_feerate,
|
||||
channel->our_config.dust_limit, LOCAL,
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS),
|
||||
channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED),
|
||||
channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX)))
|
||||
json_add_bool(response, "local_trimmed", true);
|
||||
json_object_end(response);
|
||||
@ -629,7 +629,7 @@ static struct amount_sat commit_txfee(const struct channel *channel,
|
||||
channel->opener, side);
|
||||
struct amount_sat dust_limit;
|
||||
struct amount_sat fee;
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
|
||||
bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
|
||||
bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
||||
if (side == LOCAL)
|
||||
@ -1005,7 +1005,7 @@ static void NON_NULL_ARGS(1, 2, 4, 5) json_add_channel(struct lightningd *ld,
|
||||
json_array_start(response, "features");
|
||||
if (channel_has(channel, OPT_STATIC_REMOTEKEY))
|
||||
json_add_string(response, NULL, "option_static_remotekey");
|
||||
if (channel_has(channel, OPT_ANCHOR_OUTPUTS))
|
||||
if (channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED))
|
||||
json_add_string(response, NULL, "option_anchor_outputs");
|
||||
if (channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX))
|
||||
json_add_string(response, NULL, "option_anchors_zero_fee_htlc_tx");
|
||||
|
@ -422,7 +422,6 @@ static bool grind_htlc_tx_fee(struct amount_sat *fee,
|
||||
* 1. MUST be 0.
|
||||
* - Otherwise, MUST be calculated to match:
|
||||
* 1. Multiply `feerate_per_kw` by 663
|
||||
* (666 if `option_anchor_outputs` applies)
|
||||
* and divide by 1000 (rounding down).
|
||||
*
|
||||
* The fee for an HTLC-success transaction:
|
||||
@ -430,7 +429,6 @@ static bool grind_htlc_tx_fee(struct amount_sat *fee,
|
||||
* 1. MUST be 0.
|
||||
* - Otherwise, MUST be calculated to match:
|
||||
* 1. Multiply `feerate_per_kw` by 703
|
||||
* (706 if `option_anchor_outputs` applies)
|
||||
* and divide by 1000 (rounding down).
|
||||
*/
|
||||
struct amount_sat out;
|
||||
@ -476,14 +474,14 @@ static bool set_htlc_timeout_fee(struct bitcoin_tx *tx,
|
||||
* - If `option_anchors_zero_fee_htlc_tx` applies:
|
||||
* 1. MUST be 0.
|
||||
* - Otherwise, MUST be calculated to match:
|
||||
* 1. Multiply `feerate_per_kw` by 663 (666 if `option_anchor_outputs`
|
||||
* applies) and divide by 1000 (rounding down).
|
||||
* 1. Multiply `feerate_per_kw` by 663 and divide by 1000 (rounding down).
|
||||
*/
|
||||
if (option_anchors_zero_fee_htlc_tx) {
|
||||
fee = AMOUNT_SAT(0);
|
||||
goto set_amount;
|
||||
}
|
||||
|
||||
/* FIXME: older bolt used to say (666 if `option_anchor_outputs` applies) */
|
||||
if (option_anchor_outputs)
|
||||
weight = 666;
|
||||
else
|
||||
@ -551,9 +549,9 @@ static struct amount_sat get_htlc_success_fee(struct tracked_output *out)
|
||||
* - If `option_anchors_zero_fee_htlc_tx` applies:
|
||||
* 1. MUST be 0.
|
||||
* - Otherwise, MUST be calculated to match:
|
||||
* 1. Multiply `feerate_per_kw` by 703 (706 if `option_anchor_outputs`
|
||||
* applies) and divide by 1000 (rounding down).
|
||||
* 1. Multiply `feerate_per_kw` by 703 and divide by 1000 (rounding down).
|
||||
*/
|
||||
/* FIXME: Older bolt used to say (706 if `option_anchor_outputs` applies) */
|
||||
if (option_anchor_outputs)
|
||||
weight = 706;
|
||||
else
|
||||
|
@ -19,7 +19,6 @@ bool check_config_bounds(const tal_t *ctx,
|
||||
struct amount_msat min_effective_htlc_capacity,
|
||||
const struct channel_config *remoteconf,
|
||||
const struct channel_config *localconf,
|
||||
bool option_anchor_outputs,
|
||||
bool option_anchors_zero_fee_htlc_tx,
|
||||
char **err_reason)
|
||||
{
|
||||
@ -71,7 +70,7 @@ bool check_config_bounds(const tal_t *ctx,
|
||||
* `to_remote_anchor` above its reserve.
|
||||
*/
|
||||
/* (We simply include in "reserve" here if they opened). */
|
||||
if ((option_anchor_outputs || option_anchors_zero_fee_htlc_tx)
|
||||
if (option_anchors_zero_fee_htlc_tx
|
||||
&& !amount_sat_add(&reserve, reserve, AMOUNT_SAT(660))) {
|
||||
*err_reason = tal_fmt(ctx,
|
||||
"cannot add anchors to reserve %s",
|
||||
@ -92,7 +91,7 @@ bool check_config_bounds(const tal_t *ctx,
|
||||
/* They have to pay for fees, too. Assuming HTLC is dust, though,
|
||||
* we don't account for an HTLC output. */
|
||||
fee = commit_tx_base_fee(feerate_per_kw, 0,
|
||||
option_anchor_outputs,
|
||||
false,
|
||||
option_anchors_zero_fee_htlc_tx);
|
||||
if (!amount_sat_sub(&capacity, capacity, fee)) {
|
||||
*err_reason = tal_fmt(ctx, "channel_reserve_satoshis %s"
|
||||
@ -200,7 +199,7 @@ bool anchors_negotiated(struct feature_set *our_features,
|
||||
const u8 *their_features)
|
||||
{
|
||||
return feature_negotiated(our_features, their_features,
|
||||
OPT_ANCHOR_OUTPUTS)
|
||||
OPT_ANCHOR_OUTPUTS_DEPRECATED)
|
||||
|| feature_negotiated(our_features,
|
||||
their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX);
|
||||
|
@ -16,7 +16,6 @@ bool check_config_bounds(const tal_t *ctx,
|
||||
struct amount_msat min_effective_htlc_capacity,
|
||||
const struct channel_config *remoteconf,
|
||||
const struct channel_config *localconf,
|
||||
bool option_anchor_outputs,
|
||||
bool option_anchors_zero_fee_htlc_tx,
|
||||
char **err_reason);
|
||||
|
||||
|
@ -2652,12 +2652,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
state->min_effective_htlc_capacity,
|
||||
&tx_state->remoteconf,
|
||||
&tx_state->localconf,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
&err_reason)) {
|
||||
negotiation_failed(state, "%s", err_reason);
|
||||
return;
|
||||
@ -3334,12 +3329,7 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
state->min_effective_htlc_capacity,
|
||||
&tx_state->remoteconf,
|
||||
&tx_state->localconf,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
&err_reason)) {
|
||||
negotiation_failed(state, "%s", err_reason);
|
||||
return;
|
||||
@ -3655,12 +3645,7 @@ static void rbf_local_start(struct state *state, u8 *msg)
|
||||
state->min_effective_htlc_capacity,
|
||||
&tx_state->remoteconf,
|
||||
&tx_state->localconf,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
&err_reason)) {
|
||||
open_abort(state, "%s", err_reason);
|
||||
return;
|
||||
@ -3811,12 +3796,7 @@ static void rbf_remote_start(struct state *state, const u8 *rbf_msg)
|
||||
state->min_effective_htlc_capacity,
|
||||
&tx_state->remoteconf,
|
||||
&tx_state->localconf,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
&err_reason)) {
|
||||
negotiation_failed(state, "%s", err_reason);
|
||||
goto free_rbf_ctx;
|
||||
|
@ -352,8 +352,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags,
|
||||
}
|
||||
|
||||
/* Which feerate do we use? (We can lowball fees if using anchors!) */
|
||||
if (channel_type_has(state->channel_type, OPT_ANCHOR_OUTPUTS)
|
||||
|| channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX)) {
|
||||
if (channel_type_has_anchors(state->channel_type)) {
|
||||
state->feerate_per_kw = anchor_feerate;
|
||||
} else {
|
||||
state->feerate_per_kw = nonanchor_feerate;
|
||||
@ -552,12 +551,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags,
|
||||
state->min_effective_htlc_capacity,
|
||||
&state->remoteconf,
|
||||
&state->localconf,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
channel_type_has(state->channel_type, OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
&err_reason)) {
|
||||
negotiation_failed(state, "%s", err_reason);
|
||||
return NULL;
|
||||
@ -1071,11 +1065,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
||||
state->min_effective_htlc_capacity,
|
||||
&state->remoteconf,
|
||||
&state->localconf,
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
feature_negotiated(state->our_features,
|
||||
state->their_features,
|
||||
channel_type_has(state->channel_type,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX),
|
||||
&err_reason)) {
|
||||
negotiation_failed(state, "%s", err_reason);
|
||||
|
@ -65,7 +65,7 @@ void run(const uint8_t *data, size_t size)
|
||||
option_anchor_outputs = fromwire_bool(&data, &size);
|
||||
|
||||
if (option_anchor_outputs)
|
||||
channel_type = channel_type_anchor_outputs(tmpctx);
|
||||
channel_type = channel_type_anchors_zero_fee_htlc(tmpctx);
|
||||
else
|
||||
channel_type = channel_type_static_remotekey(tmpctx);
|
||||
|
||||
|
@ -1682,7 +1682,7 @@ static void migrate_fill_in_channel_type(struct lightningd *ld,
|
||||
|
||||
if (db_col_int(stmt, "option_anchor_outputs")) {
|
||||
db_col_ignore(stmt, "local_static_remotekey_start");
|
||||
type = channel_type_anchor_outputs(tmpctx);
|
||||
type = channel_type_anchor_outputs_obsolete(tmpctx);
|
||||
} else if (db_col_u64(stmt, "local_static_remotekey_start") != 0x7FFFFFFFFFFFFFFFULL)
|
||||
type = channel_type_static_remotekey(tmpctx);
|
||||
else
|
||||
|
@ -1423,7 +1423,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
|
||||
assert(parse_wireaddr_internal(tmpctx, "localhost:1234", 0, false, &addr) == NULL);
|
||||
channel.peer = new_peer(ld, 0, &id, &addr, NULL, false);
|
||||
channel.dbid = 1;
|
||||
channel.type = channel_type_anchor_outputs(tmpctx);
|
||||
channel.type = channel_type_anchors_zero_fee_htlc(tmpctx);
|
||||
memset(&u.outpoint, 3, sizeof(u.outpoint));
|
||||
CHECK_MSG(wallet_add_onchaind_utxo(w, &u.outpoint,
|
||||
u.scriptPubkey,
|
||||
|
Loading…
Reference in New Issue
Block a user