Browse Source

mfc: Add a `commitment_feerate` optional parameter to multifundchannel

Technically there *are* two feerates that we need to know:
  - the feerate to use for the funding transaction, and
  - the feerate to tell our peer to use for our commitment txs/htlc txs

As written, `multifundchannel` uses the same feerate for both. This
optional parameter will allow us to differentiate between the two, which
will be exceedingly handy for anchor output worlds. ;)

FIXME: test this

Changelog-Added: JSON API: `multifundchannel` has a new optional argument, 'commitment_feerate', which can be used to differentiate between the funding feerate and the channel's initial commitment feerate
travis-experimental
niftynei 4 years ago
committed by Rusty Russell
parent
commit
e66937e012
  1. 13
      doc/lightning-multifundchannel.7
  2. 10
      doc/lightning-multifundchannel.7.md
  3. 19
      plugins/spender/multifundchannel.c

13
doc/lightning-multifundchannel.7

@ -3,7 +3,7 @@
lightning-multifundchannel - Command for establishing many lightning channels
.SH SYNOPSIS
\fBmultifundchannel\fR \fIdestinations\fR [\fIfeerate\fR] [\fIminconf\fR] [\fIutxos\fR] [\fIminchannels\fR]
\fBmultifundchannel\fR \fIdestinations\fR [\fIfeerate\fR] [\fIminconf\fR] [\fIutxos\fR] [\fIminchannels\fR] [\fIcommitment_feerate\fR]
.SH DESCRIPTION
@ -65,8 +65,9 @@ There must be at least one entry in \fIdestinations\fR;
it cannot be an empty array\.
\fIfeerate\fR is an optional feerate used for the opening transaction and as
initial feerate for commitment and HTLC transactions\. It can be one of
\fIfeerate\fR is an optional feerate used for the opening transaction and, if
\fIcommitment_feerate\fR is not set, as the initial feerate for
commitment and HTLC transactions\. It can be one of
the strings \fIurgent\fR (aim for next block), \fInormal\fR (next 4 blocks or
so) or \fIslow\fR (next 100 blocks or so) to use lightningd’s internal
estimates: \fInormal\fR is the default\.
@ -91,6 +92,10 @@ this many peers remain (must not be zero)\.
The \fBmultifundchannel\fR command will only fail if too many peers fail
the funding process\.
\fIcommitment_feerate\fR is the initial feerate for commitment and HTLC
transactions\. See \fIfeerate\fR for valid values\.
.SH RETURN VALUE
On success, the \fItx\fR and \fItxid\fR of the signed and broadcsted funding
@ -172,4 +177,4 @@ ZmnSCPxj \fI<ZmnSCPxj@protonmail.com\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:70be8ab919df4a69f18103dcf3d1067e4b1d7466eb69ca474ffae3ea1f8d0ae1
\" SHA256STAMP:45015c53c73dc4d84850c84cb753d62739288365746b47f0403fb67e5f65d582

10
doc/lightning-multifundchannel.7.md

@ -4,7 +4,7 @@ lightning-multifundchannel -- Command for establishing many lightning channels
SYNOPSIS
--------
**multifundchannel** *destinations* \[*feerate*\] \[*minconf*\] \[*utxos*\] \[*minchannels*\]
**multifundchannel** *destinations* \[*feerate*\] \[*minconf*\] \[*utxos*\] \[*minchannels*\] \[*commitment_feerate*\]
DESCRIPTION
-----------
@ -55,8 +55,9 @@ Readiness is indicated by **listpeers** reporting a *state* of
There must be at least one entry in *destinations*;
it cannot be an empty array.
*feerate* is an optional feerate used for the opening transaction and as
initial feerate for commitment and HTLC transactions. It can be one of
*feerate* is an optional feerate used for the opening transaction and, if
*commitment_feerate* is not set, as the initial feerate for
commitment and HTLC transactions. It can be one of
the strings *urgent* (aim for next block), *normal* (next 4 blocks or
so) or *slow* (next 100 blocks or so) to use lightningd’s internal
estimates: *normal* is the default.
@ -77,6 +78,9 @@ this many peers remain (must not be zero).
The **multifundchannel** command will only fail if too many peers fail
the funding process.
*commitment_feerate* is the initial feerate for commitment and HTLC
transactions. See *feerate* for valid values.
RETURN VALUE
------------

19
plugins/spender/multifundchannel.c

@ -147,8 +147,17 @@ struct multifundchannel_command {
*/
size_t pending;
/* The feerate desired by the user. */
/* The feerate desired by the user.
* If cmtmt_feerate_str is present, will only be used
* for the funding transaction. */
const char *feerate_str;
/* The feerate desired by the user for
* the channel commitment and HTLC txs.
* If not provided, defaults to the feerate_str
* value. */
const char *cmtmt_feerate_str;
/* The minimum number of confirmations for owned
UTXOs to be selected.
*/
@ -1164,7 +1173,9 @@ fundchannel_start_dest(struct multifundchannel_destination *dest)
json_add_string(req->js, "amount",
fmt_amount_sat(tmpctx, &dest->amount));
if (mfc->feerate_str)
if (mfc->cmtmt_feerate_str)
json_add_string(req->js, "feerate", mfc->cmtmt_feerate_str);
else if (mfc->feerate_str)
json_add_string(req->js, "feerate", mfc->feerate_str);
json_add_bool(req->js, "announce", dest->announce);
json_add_string(req->js, "push_msat",
@ -1988,7 +1999,7 @@ json_multifundchannel(struct command *cmd,
const jsmntok_t *params)
{
struct multifundchannel_destination *dests;
const char *feerate_str;
const char *feerate_str, *cmtmt_feerate_str;
u32 *minconf;
const jsmntok_t *utxos_tok;
u32 *minchannels;
@ -2001,6 +2012,7 @@ json_multifundchannel(struct command *cmd,
p_opt_def("minconf", param_number, &minconf, 1),
p_opt("utxos", param_tok, &utxos_tok),
p_opt("minchannels", param_positive_number, &minchannels),
p_opt("commitment_feerate", param_string, &cmtmt_feerate_str),
NULL))
return command_param_failed();
@ -2017,6 +2029,7 @@ json_multifundchannel(struct command *cmd,
mfc->destinations[i].mfc = mfc;
mfc->feerate_str = feerate_str;
mfc->cmtmt_feerate_str = cmtmt_feerate_str;
mfc->minconf = *minconf;
if (utxos_tok)
mfc->utxos_str = tal_strndup(mfc, json_tok_full(buf, utxos_tok),

Loading…
Cancel
Save