mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-18 22:54:25 +01:00
option_anchor_outputs: wire into all the subdaemons.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -883,7 +883,7 @@ static struct bitcoin_signature *calc_commitsigs(const tal_t *ctx,
|
||||
txs[i+1]->wtx->inputs[0].index);
|
||||
msg = towire_hsm_sign_remote_htlc_tx(NULL, txs[i + 1], wscript,
|
||||
&peer->remote_per_commit,
|
||||
false /* FIXME-anchor */);
|
||||
peer->channel->option_anchor_outputs);
|
||||
|
||||
msg = hsm_req(tmpctx, take(msg));
|
||||
if (!fromwire_hsm_sign_tx_reply(msg, &htlc_sigs[i]))
|
||||
@@ -1320,7 +1320,8 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg)
|
||||
"Bad commit_sig %s", tal_hex(msg, msg));
|
||||
/* SIGHASH_ALL is implied. */
|
||||
commit_sig.sighash_type = SIGHASH_ALL;
|
||||
htlc_sigs = unraw_sigs(tmpctx, raw_sigs, false /* FIXME-anchor */);
|
||||
htlc_sigs = unraw_sigs(tmpctx, raw_sigs,
|
||||
peer->channel->option_anchor_outputs);
|
||||
|
||||
txs =
|
||||
channel_txs(tmpctx, &htlc_map, NULL,
|
||||
@@ -3273,6 +3274,7 @@ static void init_channel(struct peer *peer)
|
||||
&funding_pubkey[LOCAL],
|
||||
&funding_pubkey[REMOTE],
|
||||
option_static_remotekey,
|
||||
option_anchor_outputs,
|
||||
opener);
|
||||
|
||||
if (!channel_force_htlcs(peer->channel,
|
||||
|
||||
@@ -16,6 +16,7 @@ struct keyset;
|
||||
* @dust_limit: dust limit below which to trim outputs.
|
||||
* @option_anchor_outputs: does option_anchor_outputs apply to this channel?
|
||||
* @side: from which side's point of view
|
||||
* @option_anchor_outputs: does option_anchor_outputs apply to this channel?
|
||||
*
|
||||
* We need @side because HTLC fees are different for offered and
|
||||
* received HTLCs.
|
||||
@@ -43,6 +44,7 @@ size_t commit_tx_num_untrimmed(const struct htlc **htlcs,
|
||||
* @direct_outputs: If non-NULL, fill with pointers to the direct (non-HTLC) outputs (or NULL if none).
|
||||
* @option_anchor_outputs: does option_anchor_outputs apply to this channel?
|
||||
* @side: side to generate commitment transaction for.
|
||||
* @option_anchor_outputs: does option_anchor_outputs apply to this channel?
|
||||
*
|
||||
* We need to be able to generate the remote side's tx to create signatures,
|
||||
* but the BOLT is expressed in terms of generating our local commitment
|
||||
|
||||
@@ -103,6 +103,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
||||
const struct pubkey *local_funding_pubkey,
|
||||
const struct pubkey *remote_funding_pubkey,
|
||||
bool option_static_remotekey,
|
||||
bool option_anchor_outputs,
|
||||
enum side opener)
|
||||
{
|
||||
struct channel *channel = new_initial_channel(ctx,
|
||||
@@ -118,6 +119,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
||||
local_funding_pubkey,
|
||||
remote_funding_pubkey,
|
||||
option_static_remotekey,
|
||||
option_anchor_outputs,
|
||||
opener);
|
||||
|
||||
if (channel) {
|
||||
@@ -247,23 +249,28 @@ static void add_htlcs(struct bitcoin_tx ***txs,
|
||||
|
||||
if (htlc_owner(htlc) == side) {
|
||||
ripemd160(&ripemd, htlc->rhash.u.u8, sizeof(htlc->rhash.u.u8));
|
||||
wscript = htlc_offered_wscript(tmpctx, &ripemd, keyset, false /* FIXME-anchor */);
|
||||
wscript = htlc_offered_wscript(tmpctx, &ripemd, keyset,
|
||||
channel->option_anchor_outputs);
|
||||
tx = htlc_timeout_tx(*txs, chainparams, &txid, i,
|
||||
wscript,
|
||||
htlc->amount,
|
||||
htlc->expiry.locktime,
|
||||
channel->config[!side].to_self_delay,
|
||||
feerate_per_kw,
|
||||
keyset, false /* FIXME-anchor */);
|
||||
keyset,
|
||||
channel->option_anchor_outputs);
|
||||
} else {
|
||||
ripemd160(&ripemd, htlc->rhash.u.u8, sizeof(htlc->rhash.u.u8));
|
||||
wscript = htlc_received_wscript(tmpctx, &ripemd, &htlc->expiry, keyset, false /* FIXME-anchor */);
|
||||
wscript = htlc_received_wscript(tmpctx, &ripemd,
|
||||
&htlc->expiry, keyset,
|
||||
channel->option_anchor_outputs);
|
||||
tx = htlc_success_tx(*txs, chainparams, &txid, i,
|
||||
wscript,
|
||||
htlc->amount,
|
||||
channel->config[!side].to_self_delay,
|
||||
feerate_per_kw,
|
||||
keyset, false /* FIXME-anchor */);
|
||||
keyset,
|
||||
channel->option_anchor_outputs);
|
||||
}
|
||||
|
||||
/* Append to array. */
|
||||
@@ -313,7 +320,7 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
channel->config[side].dust_limit, channel->view[side].owed[side],
|
||||
channel->view[side].owed[!side], committed, htlcmap, direct_outputs,
|
||||
commitment_number ^ channel->commitment_number_obscurer,
|
||||
false /* FIXME-anchor */,
|
||||
channel->option_anchor_outputs,
|
||||
side);
|
||||
|
||||
/* Set the remote/local pubkeys on the commitment tx psbt */
|
||||
@@ -396,11 +403,11 @@ static struct amount_sat fee_for_htlcs(const struct channel *channel,
|
||||
size_t untrimmed;
|
||||
|
||||
untrimmed = num_untrimmed_htlcs(side, dust_limit, feerate,
|
||||
false /* FIXME-anchor */,
|
||||
channel->option_anchor_outputs,
|
||||
committed, adding, removing);
|
||||
|
||||
return commit_tx_base_fee(feerate, untrimmed,
|
||||
false /* FIXME-anchor */);
|
||||
channel->option_anchor_outputs);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -444,13 +451,13 @@ static bool local_opener_has_fee_headroom(const struct channel *channel,
|
||||
* only *reduce* this number, so use current feerate here! */
|
||||
untrimmed = num_untrimmed_htlcs(LOCAL, channel->config[LOCAL].dust_limit,
|
||||
feerate,
|
||||
false /* FIXME-anchor */,
|
||||
channel->option_anchor_outputs,
|
||||
committed, adding, removing);
|
||||
|
||||
/* Now, how much would it cost us if feerate increases 100% and we added
|
||||
* another HTLC? */
|
||||
fee = commit_tx_base_fee(2 * feerate, untrimmed + 1,
|
||||
false /* FIXME-anchor */);
|
||||
channel->option_anchor_outputs);
|
||||
if (amount_msat_greater_eq_sat(remainder, fee))
|
||||
return true;
|
||||
|
||||
@@ -642,7 +649,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
|
||||
* of 330 sats from the funder (either `to_local` or
|
||||
* `to_remote`).
|
||||
*/
|
||||
if (false /* FIXME-anchor */
|
||||
if (channel->option_anchor_outputs
|
||||
&& channel->opener == sender
|
||||
&& !amount_msat_sub_sat(&remainder, remainder, AMOUNT_SAT(660)))
|
||||
return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED;
|
||||
@@ -676,7 +683,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
|
||||
&remainder))
|
||||
return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED;
|
||||
|
||||
if (false /* FIXME-anchor */
|
||||
if (channel->option_anchor_outputs
|
||||
&& channel->opener != sender
|
||||
&& !amount_msat_sub_sat(&remainder, remainder, AMOUNT_SAT(660)))
|
||||
return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED;
|
||||
@@ -1015,7 +1022,7 @@ u32 approx_max_feerate(const struct channel *channel)
|
||||
/* Assume none are trimmed; this gives lower bound on feerate. */
|
||||
num = tal_count(committed) + tal_count(adding) - tal_count(removing);
|
||||
|
||||
weight = commit_tx_base_weight(num, false /* FIXME-anchor */);
|
||||
weight = commit_tx_base_weight(num, channel->option_anchor_outputs);
|
||||
|
||||
/* Available is their view */
|
||||
avail = amount_msat_to_sat_round_down(channel->view[!channel->opener].owed[channel->opener]);
|
||||
@@ -1026,7 +1033,7 @@ u32 approx_max_feerate(const struct channel *channel)
|
||||
* of 330 sats from the funder (either `to_local` or
|
||||
* `to_remote`).
|
||||
*/
|
||||
if (false /* FIXME-anchor */
|
||||
if (channel->option_anchor_outputs
|
||||
&& !amount_sat_sub(&avail, avail, AMOUNT_SAT(660))) {
|
||||
avail = AMOUNT_SAT(0);
|
||||
} else {
|
||||
@@ -1049,17 +1056,17 @@ bool can_opener_afford_feerate(const struct channel *channel, u32 feerate_per_kw
|
||||
&committed, &removing, &adding);
|
||||
|
||||
untrimmed = commit_tx_num_untrimmed(committed, feerate_per_kw, dust_limit,
|
||||
false /* FIXME-anchor */,
|
||||
channel->option_anchor_outputs,
|
||||
!channel->opener)
|
||||
+ commit_tx_num_untrimmed(adding, feerate_per_kw, dust_limit,
|
||||
false /* FIXME-anchor */,
|
||||
channel->option_anchor_outputs,
|
||||
!channel->opener)
|
||||
- commit_tx_num_untrimmed(removing, feerate_per_kw, dust_limit,
|
||||
false /* FIXME-anchor */,
|
||||
channel->option_anchor_outputs,
|
||||
!channel->opener);
|
||||
|
||||
fee = commit_tx_base_fee(feerate_per_kw, untrimmed,
|
||||
false /* FIXME-anchor */);
|
||||
channel->option_anchor_outputs);
|
||||
|
||||
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1:
|
||||
* If `option_anchor_outputs` applies to the commitment
|
||||
@@ -1067,7 +1074,7 @@ bool can_opener_afford_feerate(const struct channel *channel, u32 feerate_per_kw
|
||||
* of 330 sats from the funder (either `to_local` or
|
||||
* `to_remote`).
|
||||
*/
|
||||
if (false /* FIXME-anchor */
|
||||
if (channel->option_anchor_outputs
|
||||
&& !amount_sat_add(&fee, fee, AMOUNT_SAT(660)))
|
||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||
"Cannot add 660 sats to %s for anchor",
|
||||
|
||||
@@ -25,6 +25,7 @@ struct existing_htlc;
|
||||
* @local_fundingkey: local funding key
|
||||
* @remote_fundingkey: remote funding key
|
||||
* @option_static_remotekey: use `option_static_remotekey`.
|
||||
* @option_anchor_outputs: use `option_anchor_outputs`.
|
||||
* @opener: which side initiated it.
|
||||
*
|
||||
* Returns state, or NULL if malformed.
|
||||
@@ -43,6 +44,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
||||
const struct pubkey *local_funding_pubkey,
|
||||
const struct pubkey *remote_funding_pubkey,
|
||||
bool option_static_remotekey,
|
||||
bool option_anchor_outputs,
|
||||
enum side opener);
|
||||
|
||||
/**
|
||||
|
||||
@@ -490,7 +490,7 @@ int main(int argc, const char *argv[])
|
||||
&localbase, &remotebase,
|
||||
&local_funding_pubkey,
|
||||
&remote_funding_pubkey,
|
||||
false, LOCAL);
|
||||
false, false, LOCAL);
|
||||
rchannel = new_full_channel(tmpctx,
|
||||
&funding_txid, funding_output_index, 0,
|
||||
funding_amount, to_remote,
|
||||
@@ -501,7 +501,7 @@ int main(int argc, const char *argv[])
|
||||
&remotebase, &localbase,
|
||||
&remote_funding_pubkey,
|
||||
&local_funding_pubkey,
|
||||
false, REMOTE);
|
||||
false, false, REMOTE);
|
||||
|
||||
/* BOLT #3:
|
||||
*
|
||||
|
||||
@@ -93,7 +93,8 @@ struct bitcoin_tx *htlc_success_tx(const tal_t *ctx,
|
||||
to_self_delay,
|
||||
&keyset->self_revocation_key,
|
||||
&keyset->self_delayed_payment_key,
|
||||
htlc_success_fee(feerate_per_kw, false /* FIXME-anchor */),
|
||||
htlc_success_fee(feerate_per_kw,
|
||||
option_anchor_outputs),
|
||||
0,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
@@ -145,7 +146,8 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx,
|
||||
commit_wscript, htlc_msatoshi, to_self_delay,
|
||||
&keyset->self_revocation_key,
|
||||
&keyset->self_delayed_payment_key,
|
||||
htlc_timeout_fee(feerate_per_kw, false /* FIXME-anchor */),
|
||||
htlc_timeout_fee(feerate_per_kw,
|
||||
option_anchor_outputs),
|
||||
cltv_expiry,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
||||
const struct pubkey *local_funding_pubkey,
|
||||
const struct pubkey *remote_funding_pubkey,
|
||||
bool option_static_remotekey,
|
||||
bool option_anchor_outputs,
|
||||
enum side opener)
|
||||
{
|
||||
struct channel *channel = tal(ctx, struct channel);
|
||||
@@ -64,6 +65,9 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
||||
&channel->basepoints[!opener].payment);
|
||||
|
||||
channel->option_static_remotekey = option_static_remotekey;
|
||||
channel->option_anchor_outputs = option_anchor_outputs;
|
||||
if (option_anchor_outputs)
|
||||
assert(option_static_remotekey);
|
||||
return channel;
|
||||
}
|
||||
|
||||
@@ -111,7 +115,7 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
|
||||
0 ^ channel->commitment_number_obscurer,
|
||||
direct_outputs,
|
||||
side,
|
||||
false /* FIXME-anchor */,
|
||||
channel->option_anchor_outputs,
|
||||
err_reason);
|
||||
|
||||
if (init_tx) {
|
||||
|
||||
@@ -62,6 +62,9 @@ struct channel {
|
||||
|
||||
/* Is this using option_static_remotekey? */
|
||||
bool option_static_remotekey;
|
||||
|
||||
/* Is this using option_anchor_outputs? */
|
||||
bool option_anchor_outputs;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -79,6 +82,8 @@ struct channel {
|
||||
* @remote_basepoints: remote basepoints.
|
||||
* @local_fundingkey: local funding key
|
||||
* @remote_fundingkey: remote funding key
|
||||
* @option_static_remotekey: was this created with option_static_remotekey?
|
||||
* @option_anchor_outputs: was this created with option_anchor_outputs?
|
||||
* @opener: which side initiated it.
|
||||
*
|
||||
* Returns channel, or NULL if malformed.
|
||||
@@ -97,6 +102,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
|
||||
const struct pubkey *local_funding_pubkey,
|
||||
const struct pubkey *remote_funding_pubkey,
|
||||
bool option_static_remotekey,
|
||||
bool option_anchor_outputs,
|
||||
enum side opener);
|
||||
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ int main(int argc, char *argv[])
|
||||
const struct htlc **htlcmap;
|
||||
struct privkey local_htlc_privkey, remote_htlc_privkey;
|
||||
struct pubkey local_htlc_pubkey, remote_htlc_pubkey;
|
||||
bool option_static_remotekey = false;
|
||||
bool option_static_remotekey = false, option_anchor_outputs = false;
|
||||
struct sha256_double hash;
|
||||
|
||||
setup_locale();
|
||||
@@ -300,6 +300,9 @@ int main(int argc, char *argv[])
|
||||
opt_register_noarg("--option-static-remotekey", opt_set_bool,
|
||||
&option_static_remotekey,
|
||||
"Use option_static_remotekey generation rules");
|
||||
opt_register_noarg("--option-anchor-outputs", opt_set_bool,
|
||||
&option_anchor_outputs,
|
||||
"Use option_anchor_outputs generation rules");
|
||||
opt_register_version();
|
||||
|
||||
opt_parse(&argc, argv, opt_log_stderr_exit);
|
||||
@@ -339,6 +342,10 @@ int main(int argc, char *argv[])
|
||||
if (!amount_sat_sub_msat(&remote_msat, funding_amount, local_msat))
|
||||
errx(1, "Can't afford local_msat");
|
||||
|
||||
if (option_anchor_outputs) {
|
||||
printf("Using option-anchor-outputs\n");
|
||||
option_static_remotekey = true;
|
||||
}
|
||||
if (option_static_remotekey)
|
||||
printf("Using option-static-remotekey\n");
|
||||
|
||||
@@ -389,6 +396,7 @@ int main(int argc, char *argv[])
|
||||
&localbase, &remotebase,
|
||||
&funding_localkey, &funding_remotekey,
|
||||
option_static_remotekey,
|
||||
option_anchor_outputs,
|
||||
fee_payer);
|
||||
|
||||
if (!channel_force_htlcs(channel,
|
||||
|
||||
@@ -219,11 +219,11 @@ void peer_start_closingd(struct channel *channel,
|
||||
final_commit_feerate = get_feerate(channel->channel_info.fee_states,
|
||||
channel->opener, LOCAL);
|
||||
feelimit = commit_tx_base_fee(final_commit_feerate, 0,
|
||||
false /* FIXME-anchor */);
|
||||
channel->option_anchor_outputs);
|
||||
|
||||
/* Pick some value above slow feerate (or min possible if unknown) */
|
||||
minfee = commit_tx_base_fee(feerate_min(ld, NULL), 0,
|
||||
false /* FIXME-anchor */);
|
||||
channel->option_anchor_outputs);
|
||||
|
||||
/* If we can't determine feerate, start at half unilateral feerate. */
|
||||
feerate = mutual_close_feerate(ld->topology);
|
||||
@@ -233,7 +233,7 @@ void peer_start_closingd(struct channel *channel,
|
||||
feerate = feerate_floor();
|
||||
}
|
||||
startfee = commit_tx_base_fee(feerate, 0,
|
||||
false /* FIXME-anchor */);
|
||||
channel->option_anchor_outputs);
|
||||
|
||||
if (amount_sat_greater(startfee, feelimit))
|
||||
startfee = feelimit;
|
||||
|
||||
@@ -1063,6 +1063,9 @@ void peer_start_openingd(struct peer *peer,
|
||||
feature_negotiated(peer->ld->our_features,
|
||||
peer->their_features,
|
||||
OPT_STATIC_REMOTEKEY),
|
||||
feature_negotiated(peer->ld->our_features,
|
||||
peer->their_features,
|
||||
OPT_ANCHOR_OUTPUTS),
|
||||
send_msg,
|
||||
IFDEV(peer->ld->dev_force_tmp_channel_id, NULL),
|
||||
IFDEV(peer->ld->dev_fast_gossip, false));
|
||||
|
||||
@@ -472,7 +472,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,
|
||||
false /* FIXME-anchor */))
|
||||
channel->option_anchor_outputs))
|
||||
json_add_bool(response, "local_trimmed", true);
|
||||
json_object_end(response);
|
||||
}
|
||||
@@ -494,7 +494,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,
|
||||
false /* FIXME-anchor */))
|
||||
channel->option_anchor_outputs))
|
||||
json_add_bool(response, "local_trimmed", true);
|
||||
json_object_end(response);
|
||||
}
|
||||
@@ -537,7 +537,7 @@ static struct amount_sat commit_txfee(const struct channel *channel,
|
||||
|
||||
/* Assume we tried to add "amount" */
|
||||
if (!htlc_is_trimmed(side, amount, feerate, dust_limit, side,
|
||||
false /* FIXME-anchor */))
|
||||
channel->option_anchor_outputs))
|
||||
num_untrimmed_htlcs++;
|
||||
|
||||
for (hin = htlc_in_map_first(&ld->htlcs_in, &ini);
|
||||
@@ -547,7 +547,7 @@ static struct amount_sat commit_txfee(const struct channel *channel,
|
||||
continue;
|
||||
if (!htlc_is_trimmed(!side, hin->msat, feerate, dust_limit,
|
||||
side,
|
||||
false /* FIXME-anchor */))
|
||||
channel->option_anchor_outputs))
|
||||
num_untrimmed_htlcs++;
|
||||
}
|
||||
for (hout = htlc_out_map_first(&ld->htlcs_out, &outi);
|
||||
@@ -557,7 +557,7 @@ static struct amount_sat commit_txfee(const struct channel *channel,
|
||||
continue;
|
||||
if (!htlc_is_trimmed(side, hout->msat, feerate, dust_limit,
|
||||
side,
|
||||
false /* FIXME-anchor */))
|
||||
channel->option_anchor_outputs))
|
||||
num_untrimmed_htlcs++;
|
||||
}
|
||||
|
||||
@@ -575,9 +575,9 @@ static struct amount_sat commit_txfee(const struct channel *channel,
|
||||
* recommended to ensure predictability.
|
||||
*/
|
||||
fee = commit_tx_base_fee(2 * feerate, num_untrimmed_htlcs + 1,
|
||||
false /* FIXME-anchor */);
|
||||
channel->option_anchor_outputs);
|
||||
|
||||
if (false /* FIXME-anchor */) {
|
||||
if (channel->option_anchor_outputs) {
|
||||
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1:
|
||||
* If `option_anchor_outputs` applies to the commitment
|
||||
* transaction, also subtract two times the fixed anchor size
|
||||
|
||||
@@ -588,7 +588,7 @@ static u8 *remote_htlc_to_us(const tal_t *ctx,
|
||||
return towire_hsm_sign_remote_htlc_to_us(ctx,
|
||||
remote_per_commitment_point,
|
||||
tx, wscript,
|
||||
false /* FIXME-anchor */);
|
||||
option_anchor_outputs);
|
||||
}
|
||||
|
||||
static u8 *penalty_to_us(const tal_t *ctx,
|
||||
@@ -693,7 +693,7 @@ static void hsm_sign_local_htlc_tx(struct bitcoin_tx *tx,
|
||||
{
|
||||
u8 *msg = towire_hsm_sign_local_htlc_tx(NULL, commit_num,
|
||||
tx, wscript,
|
||||
false /* FIXME-anchor */);
|
||||
option_anchor_outputs);
|
||||
|
||||
if (!wire_sync_write(HSM_FD, take(msg)))
|
||||
status_failed(STATUS_FAIL_HSM_IO,
|
||||
@@ -1698,7 +1698,7 @@ static void handle_preimage(struct tracked_output **outs,
|
||||
htlc_amount,
|
||||
to_self_delay[LOCAL],
|
||||
0,
|
||||
keyset, false /* FIXME-anchor */);
|
||||
keyset, option_anchor_outputs);
|
||||
set_htlc_success_fee(tx, outs[i]->remote_htlc_sig,
|
||||
outs[i]->wscript);
|
||||
hsm_sign_local_htlc_tx(tx, outs[i]->wscript, &sig);
|
||||
@@ -1887,7 +1887,8 @@ static u8 **derive_htlc_scripts(const struct htlc_stub *htlcs, enum side side)
|
||||
if (htlcs[i].owner == side)
|
||||
htlc_scripts[i] = htlc_offered_wscript(htlc_scripts,
|
||||
&htlcs[i].ripemd,
|
||||
keyset, false /* FIXME-anchor */);
|
||||
keyset,
|
||||
option_anchor_outputs);
|
||||
else {
|
||||
/* FIXME: remove abs_locktime */
|
||||
struct abs_locktime ltime;
|
||||
@@ -1899,7 +1900,8 @@ static u8 **derive_htlc_scripts(const struct htlc_stub *htlcs, enum side side)
|
||||
htlc_scripts[i] = htlc_received_wscript(htlc_scripts,
|
||||
&htlcs[i].ripemd,
|
||||
<ime,
|
||||
keyset, false /* FIXME-anchor */);
|
||||
keyset,
|
||||
option_anchor_outputs);
|
||||
}
|
||||
}
|
||||
return htlc_scripts;
|
||||
@@ -1941,7 +1943,8 @@ static size_t resolve_our_htlc_ourcommit(struct tracked_output *out,
|
||||
&out->txid, out->outnum,
|
||||
htlc_scripts[matches[i]], htlc_amount,
|
||||
htlcs[matches[i]].cltv_expiry,
|
||||
to_self_delay[LOCAL], 0, keyset, false /* FIXME-anchor */);
|
||||
to_self_delay[LOCAL], 0, keyset,
|
||||
option_anchor_outputs);
|
||||
|
||||
if (set_htlc_timeout_fee(tx, out->remote_htlc_sig,
|
||||
htlc_scripts[matches[i]]))
|
||||
|
||||
@@ -25,6 +25,7 @@ msgdata,opening_init,max_feerate,u32,
|
||||
msgdata,opening_init,lfeatures_len,u16,
|
||||
msgdata,opening_init,lfeatures,u8,lfeatures_len
|
||||
msgdata,opening_init,option_static_remotekey,bool,
|
||||
msgdata,opening_init,option_anchor_outputs,bool,
|
||||
# Optional msg to send.
|
||||
msgdata,opening_init,len,u16,
|
||||
msgdata,opening_init,msg,u8,len
|
||||
|
||||
|
@@ -115,6 +115,7 @@ struct state {
|
||||
struct channel *channel;
|
||||
|
||||
bool option_static_remotekey;
|
||||
bool option_anchor_outputs;
|
||||
|
||||
struct feature_set *our_features;
|
||||
};
|
||||
@@ -243,6 +244,18 @@ static bool check_config_bounds(struct state *state,
|
||||
return false;
|
||||
}
|
||||
|
||||
/* If they're opener, they must pay for anchor outputs, so include
|
||||
* that in "reserve". */
|
||||
if (state->option_anchor_outputs
|
||||
&& !am_opener
|
||||
&& !amount_sat_add(&reserve, reserve, AMOUNT_SAT(660))) {
|
||||
negotiation_failed(state, am_opener,
|
||||
"cannot add anchors to reserve %s",
|
||||
type_to_string(tmpctx, struct amount_sat,
|
||||
&reserve));
|
||||
return false;
|
||||
}
|
||||
|
||||
/* If reserves are larger than total sat, we fail. */
|
||||
if (!amount_sat_sub(&capacity, state->funding, reserve)) {
|
||||
negotiation_failed(state, am_opener,
|
||||
@@ -686,6 +699,7 @@ static bool funder_finalize_channel_setup(struct state *state,
|
||||
&state->our_funding_pubkey,
|
||||
&state->their_funding_pubkey,
|
||||
state->option_static_remotekey,
|
||||
state->option_anchor_outputs,
|
||||
/* Opener is local */
|
||||
LOCAL);
|
||||
/* We were supposed to do enough checks above, but just in case,
|
||||
@@ -1167,6 +1181,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
||||
&state->our_funding_pubkey,
|
||||
&their_funding_pubkey,
|
||||
state->option_static_remotekey,
|
||||
state->option_anchor_outputs,
|
||||
REMOTE);
|
||||
/* We don't expect this to fail, but it does do some additional
|
||||
* internal sanity checks. */
|
||||
@@ -1519,6 +1534,7 @@ int main(int argc, char *argv[])
|
||||
&state->min_feerate, &state->max_feerate,
|
||||
&state->their_features,
|
||||
&state->option_static_remotekey,
|
||||
&state->option_anchor_outputs,
|
||||
&inner,
|
||||
&force_tmp_channel_id,
|
||||
&dev_fast_gossip))
|
||||
|
||||
Reference in New Issue
Block a user