mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
openingd: use a lower feerate for first commitment tx for anchors.
We need to know both, because in theory we could negotiate a non-anchor channel even if they support it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e45bf14300
commit
96e198f751
6 changed files with 29 additions and 7 deletions
|
@ -36,8 +36,9 @@ limit, currently set to 546, nor more than 16777215 satoshi (unless large
|
|||
channels were negotiated with the peer).
|
||||
|
||||
*feerate* is an optional feerate used for the opening transaction and
|
||||
as initial feerate for commitment and HTLC transactions (see NOTES in
|
||||
lightning-feerates(7)). The default is *normal*.
|
||||
(unless *option\_anchors\_zero\_fee\_htlc\_tx* is negotiated), as initial feerate
|
||||
for commitment and HTLC transactions (see NOTES in lightning-feerates(7)).
|
||||
The default is *normal*.
|
||||
|
||||
*announce* is an optional flag that triggers whether to announce this
|
||||
channel or not. Defaults to `true`. An unannounced channel is considered
|
||||
|
|
|
@ -19,7 +19,9 @@ value MUST be accurate, otherwise the negotiated commitment transactions
|
|||
will not encompass the correct channel value.
|
||||
|
||||
*feerate* is an optional field. Sets the feerate for subsequent
|
||||
commitment transactions: see **fundchannel**.
|
||||
commitment transactions: see **fundchannel**. Note that this is ignored
|
||||
for channels with *option\_anchors\_zero\_fee\_htlc\_tx* (we always use a low
|
||||
commitment fee for these).
|
||||
|
||||
*announce* whether or not to announce this channel.
|
||||
|
||||
|
|
|
@ -1276,6 +1276,7 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
|||
fc->our_upfront_shutdown_script,
|
||||
upfront_shutdown_script_wallet_index,
|
||||
*feerate_per_kw,
|
||||
unilateral_feerate(cmd->ld->topology, true),
|
||||
&tmp_channel_id,
|
||||
fc->channel_flags,
|
||||
fc->uc->reserve);
|
||||
|
|
|
@ -326,7 +326,8 @@ static bool intuit_scid_alias_type(struct state *state, u8 channel_flags,
|
|||
|
||||
/* We start the 'open a channel' negotation with the supplied peer, but
|
||||
* stop when we get to the part where we need the funding txid */
|
||||
static u8 *funder_channel_start(struct state *state, u8 channel_flags)
|
||||
static u8 *funder_channel_start(struct state *state, u8 channel_flags,
|
||||
u32 nonanchor_feerate, u32 anchor_feerate)
|
||||
{
|
||||
u8 *msg;
|
||||
u8 *funding_output_script;
|
||||
|
@ -374,6 +375,14 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
|
|||
channel_type_set_scid_alias(state->channel_type);
|
||||
}
|
||||
|
||||
/* 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)) {
|
||||
state->feerate_per_kw = anchor_feerate;
|
||||
} else {
|
||||
state->feerate_per_kw = nonanchor_feerate;
|
||||
}
|
||||
|
||||
open_tlvs = tlv_open_channel_tlvs_new(tmpctx);
|
||||
open_tlvs->upfront_shutdown_script
|
||||
= state->upfront_shutdown_script[LOCAL];
|
||||
|
@ -1437,6 +1446,7 @@ static u8 *handle_master_in(struct state *state)
|
|||
u8 channel_flags;
|
||||
struct bitcoin_txid funding_txid;
|
||||
u16 funding_txout;
|
||||
u32 nonanchor_feerate, anchor_feerate;
|
||||
|
||||
switch (t) {
|
||||
case WIRE_OPENINGD_FUNDER_START:
|
||||
|
@ -1445,12 +1455,13 @@ static u8 *handle_master_in(struct state *state)
|
|||
&state->push_msat,
|
||||
&state->upfront_shutdown_script[LOCAL],
|
||||
&state->local_upfront_shutdown_wallet_index,
|
||||
&state->feerate_per_kw,
|
||||
&nonanchor_feerate,
|
||||
&anchor_feerate,
|
||||
&state->channel_id,
|
||||
&channel_flags,
|
||||
&state->reserve))
|
||||
master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
|
||||
msg = funder_channel_start(state, channel_flags);
|
||||
msg = funder_channel_start(state, channel_flags, nonanchor_feerate, anchor_feerate);
|
||||
|
||||
/* We want to keep openingd alive, since we're not done yet */
|
||||
if (msg)
|
||||
|
|
|
@ -82,6 +82,7 @@ msgdata,openingd_funder_start,len_upfront,u16,
|
|||
msgdata,openingd_funder_start,upfront_shutdown_script,u8,len_upfront
|
||||
msgdata,openingd_funder_start,upfront_shutdown_wallet_index,?u32,
|
||||
msgdata,openingd_funder_start,feerate_per_kw,u32,
|
||||
msgdata,openingd_funder_start,anchor_feerate_per_kw,u32,
|
||||
msgdata,openingd_funder_start,temporary_channel_id,channel_id,
|
||||
msgdata,openingd_funder_start,channel_flags,u8,
|
||||
msgdata,openingd_funder_start,reserve,?amount_sat,
|
||||
|
|
|
|
@ -2182,7 +2182,13 @@ def test_no_anchor_liquidity_ads(node_factory, bitcoind):
|
|||
def test_commitment_feerate(bitcoind, node_factory):
|
||||
l1, l2 = node_factory.get_nodes(2)
|
||||
|
||||
opening_feerate = commitment_feerate = 2000
|
||||
opening_feerate = 2000
|
||||
if anchor_expected():
|
||||
# anchors use lowball fees
|
||||
commitment_feerate = 3750
|
||||
else:
|
||||
commitment_feerate = opening_feerate
|
||||
|
||||
l1.fundwallet(10**8)
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
l1.rpc.fundchannel(l2.info['id'], 10**6,
|
||||
|
|
Loading…
Add table
Reference in a new issue