mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
jsonrpc: Add mindepth
argument to fundchannel and multifundchannel
This will eventually enable us to specify 0 for zeroconf channels. Changelog-Added: JSON-RPC: Added `mindepth` argument to specify the number of confirmations we require for `fundchannel` and `multifundchannel`
This commit is contained in:
parent
6d07f4ed85
commit
185cd81be4
10 changed files with 49 additions and 12 deletions
|
@ -703,7 +703,8 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||
|
||||
def fundchannel(self, node_id, amount, feerate=None, announce=True,
|
||||
minconf=None, utxos=None, push_msat=None, close_to=None,
|
||||
request_amt=None, compact_lease=None):
|
||||
request_amt=None, compact_lease=None,
|
||||
mindepth: Optional[int] = None):
|
||||
"""
|
||||
Fund channel with {id} using {amount} satoshis with feerate
|
||||
of {feerate} (uses default feerate if unset).
|
||||
|
@ -728,11 +729,12 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||
"close_to": close_to,
|
||||
"request_amt": request_amt,
|
||||
"compact_lease": compact_lease,
|
||||
"mindepth": mindepth,
|
||||
}
|
||||
return self.call("fundchannel", payload)
|
||||
|
||||
def fundchannel_start(self, node_id, amount, feerate=None, announce=True,
|
||||
close_to=None):
|
||||
close_to=None, mindepth: Optional[int] = None):
|
||||
"""
|
||||
Start channel funding with {id} for {amount} satoshis
|
||||
with feerate of {feerate} (uses default feerate if unset).
|
||||
|
@ -748,6 +750,7 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||
"feerate": feerate,
|
||||
"announce": announce,
|
||||
"close_to": close_to,
|
||||
"mindepth": mindepth,
|
||||
}
|
||||
return self.call("fundchannel_start", payload)
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ On success, an object is returned, containing:
|
|||
- **outnum** (u32): The 0-based output index showing which output funded the channel
|
||||
- **channel_id** (hex): The channel_id of the resulting channel (always 64 characters)
|
||||
- **close_to** (hex, optional): The raw scriptPubkey which mutual close will go to; only present if *close_to* parameter was specified and peer supports `option_upfront_shutdown_script`
|
||||
- **mindepth** (u32, optional): Number of confirmations before we consider the channel active.
|
||||
|
||||
[comment]: # (GENERATE-FROM-SCHEMA-END)
|
||||
|
||||
|
@ -113,4 +114,4 @@ RESOURCES
|
|||
|
||||
Main web site: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[comment]: # ( SHA256STAMP:4a8d7c524cfe257f961531929d14d3589efb6ecd182a33e92aade30af90406f8)
|
||||
[comment]: # ( SHA256STAMP:4bde4785d98f4fdb74ea2415b89ddc864fdf09bd9a30f8056a376aaa668a84b8)
|
||||
|
|
|
@ -46,6 +46,7 @@ On success, an object is returned, containing:
|
|||
- **funding_address** (string): The address to send funding to for the channel. DO NOT SEND COINS TO THIS ADDRESS YET.
|
||||
- **scriptpubkey** (hex): The raw scriptPubkey for the address
|
||||
- **close_to** (hex, optional): The raw scriptPubkey which mutual close will go to; only present if *close_to* parameter was specified and peer supports `option_upfront_shutdown_script`
|
||||
- **mindepth** (u32, optional): Number of confirmations before we consider the channel active.
|
||||
|
||||
The following warnings may also be returned:
|
||||
- **warning_usage**: A warning not to prematurely broadcast the funding transaction (always present!)
|
||||
|
@ -82,4 +83,4 @@ RESOURCES
|
|||
|
||||
Main web site: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[comment]: # ( SHA256STAMP:acbd9ffb07219bc10e06e8f8bc6772d12ec62650bd30b6ee1084a24f53da2ac2)
|
||||
[comment]: # ( SHA256STAMP:6dc3dd4d3d65baa617b285fd3f6e746d62e2806635a8f8852fd3a94ef6fe3e6a)
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
"close_to": {
|
||||
"type": "hex",
|
||||
"description": "The raw scriptPubkey which mutual close will go to; only present if *close_to* parameter was specified and peer supports `option_upfront_shutdown_script`"
|
||||
},
|
||||
"mindepth": {
|
||||
"type": "u32",
|
||||
"description": "Number of confirmations before we consider the channel active."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
"warning_usage": {
|
||||
"type": "string",
|
||||
"description": "A warning not to prematurely broadcast the funding transaction (always present!)"
|
||||
},
|
||||
"mindepth": {
|
||||
"type": "u32",
|
||||
"description": "Number of confirmations before we consider the channel active."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,13 @@ new_uncommitted_channel(struct peer *peer)
|
|||
|
||||
uc->fc = NULL;
|
||||
uc->our_config.id = 0;
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The sender:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it considers
|
||||
* reasonable to avoid double-spending of the funding transaction.
|
||||
*/
|
||||
uc->minimum_depth = ld->config.anchor_confirms;
|
||||
|
||||
memset(&uc->cid, 0xFF, sizeof(uc->cid));
|
||||
|
||||
|
|
|
@ -891,13 +891,6 @@ bool peer_start_openingd(struct peer *peer, struct peer_fd *peer_fd)
|
|||
&max_to_self_delay,
|
||||
&min_effective_htlc_capacity);
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The sender:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it considers
|
||||
* reasonable to avoid double-spending of the funding transaction.
|
||||
*/
|
||||
uc->minimum_depth = peer->ld->config.anchor_confirms;
|
||||
|
||||
msg = towire_openingd_init(NULL,
|
||||
chainparams,
|
||||
|
@ -1057,7 +1050,7 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
|||
struct node_id *id;
|
||||
struct peer *peer;
|
||||
bool *announce_channel;
|
||||
u32 *feerate_per_kw;
|
||||
u32 *feerate_per_kw, *mindepth;
|
||||
|
||||
struct amount_sat *amount;
|
||||
struct amount_msat *push_msat;
|
||||
|
@ -1077,6 +1070,7 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
|||
p_opt_def("announce", param_bool, &announce_channel, true),
|
||||
p_opt("close_to", param_bitcoin_address, &fc->our_upfront_shutdown_script),
|
||||
p_opt("push_msat", param_msat, &push_msat),
|
||||
p_opt_def("mindepth", param_u32, &mindepth, cmd->ld->config.anchor_confirms),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
|
@ -1167,6 +1161,15 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
|||
peer->uncommitted_channel->fc = tal_steal(peer->uncommitted_channel, fc);
|
||||
fc->uc = peer->uncommitted_channel;
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The sender:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it considers
|
||||
* reasonable to avoid double-spending of the funding transaction.
|
||||
*/
|
||||
assert(mindepth != NULL);
|
||||
fc->uc->minimum_depth = *mindepth;
|
||||
|
||||
/* Needs to be stolen away from cmd */
|
||||
if (fc->our_upfront_shutdown_script)
|
||||
fc->our_upfront_shutdown_script
|
||||
|
|
|
@ -44,6 +44,7 @@ json_fundchannel(struct command *cmd,
|
|||
const jsmntok_t *close_to;
|
||||
const jsmntok_t *request_amt;
|
||||
const jsmntok_t *compact_lease;
|
||||
const jsmntok_t *mindepth;
|
||||
|
||||
struct out_req *req;
|
||||
|
||||
|
@ -58,6 +59,7 @@ json_fundchannel(struct command *cmd,
|
|||
p_opt("close_to", param_tok, &close_to),
|
||||
p_opt("request_amt", param_tok, &request_amt),
|
||||
p_opt("compact_lease", param_tok, &compact_lease),
|
||||
p_opt("mindepth", param_tok, &mindepth),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
|
@ -84,6 +86,10 @@ json_fundchannel(struct command *cmd,
|
|||
json_add_tok(req->js, "request_amt", request_amt, buf);
|
||||
json_add_tok(req->js, "compact_lease", compact_lease, buf);
|
||||
}
|
||||
|
||||
if (mindepth)
|
||||
json_add_tok(req->js, "mindepth", mindepth, buf);
|
||||
|
||||
json_object_end(req->js);
|
||||
json_array_end(req->js);
|
||||
if (feerate)
|
||||
|
|
|
@ -1113,12 +1113,16 @@ fundchannel_start_dest(struct multifundchannel_destination *dest)
|
|||
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",
|
||||
fmt_amount_msat(tmpctx, dest->push_msat));
|
||||
if (dest->close_to_str)
|
||||
json_add_string(req->js, "close_to", dest->close_to_str);
|
||||
|
||||
if (dest->mindepth)
|
||||
json_add_u32(req->js, "mindepth", *dest->mindepth);
|
||||
|
||||
send_outreq(cmd->plugin, req);
|
||||
}
|
||||
|
||||
|
@ -1890,6 +1894,7 @@ param_destinations_array(struct command *cmd, const char *name,
|
|||
p_opt_def("request_amt", param_sat, &request_amt,
|
||||
AMOUNT_SAT(0)),
|
||||
p_opt("compact_lease", param_lease_hex, &rates),
|
||||
p_opt("mindepth", param_u32, &dest->mindepth),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
|
|
|
@ -149,6 +149,9 @@ struct multifundchannel_destination {
|
|||
|
||||
/* Channel lease rates that we expect the peer to respond with */
|
||||
struct lease_rates *rates;
|
||||
|
||||
/* Number of blocks to wait before sending `channel_ready`. */
|
||||
u32 *mindepth;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue