mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
jsonrpc: Expose the minconf parameter for fundchannel and withdraw
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
68fe5eacde
commit
c0d38aa99c
@ -31,4 +31,13 @@ struct command_result *wtx_select_utxos(struct wallet_tx *tx,
|
|||||||
u32 fee_rate_per_kw,
|
u32 fee_rate_per_kw,
|
||||||
size_t out_len,
|
size_t out_len,
|
||||||
u32 maxheight);
|
u32 maxheight);
|
||||||
|
|
||||||
|
static inline u32 minconf_to_maxheight(u32 minconf, struct lightningd *ld)
|
||||||
|
{
|
||||||
|
/* No confirmations is special, we need to disable the check in the
|
||||||
|
* selection */
|
||||||
|
if (minconf == 0)
|
||||||
|
return 0;
|
||||||
|
return ld->topology->tip->height - minconf + 1;
|
||||||
|
}
|
||||||
#endif /* LIGHTNING_COMMON_WALLET_TX_H */
|
#endif /* LIGHTNING_COMMON_WALLET_TX_H */
|
||||||
|
@ -830,7 +830,7 @@ static struct command_result *json_fund_channel(struct command *cmd,
|
|||||||
struct pubkey *id;
|
struct pubkey *id;
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
struct channel *channel;
|
struct channel *channel;
|
||||||
u32 *feerate_per_kw;
|
u32 *feerate_per_kw, *minconf, maxheight;
|
||||||
bool *announce_channel;
|
bool *announce_channel;
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
struct amount_sat max_funding_satoshi;
|
struct amount_sat max_funding_satoshi;
|
||||||
@ -845,6 +845,7 @@ static struct command_result *json_fund_channel(struct command *cmd,
|
|||||||
p_req("satoshi", param_wtx, &fc->wtx),
|
p_req("satoshi", param_wtx, &fc->wtx),
|
||||||
p_opt("feerate", param_feerate, &feerate_per_kw),
|
p_opt("feerate", param_feerate, &feerate_per_kw),
|
||||||
p_opt_def("announce", param_bool, &announce_channel, true),
|
p_opt_def("announce", param_bool, &announce_channel, true),
|
||||||
|
p_opt_def("minconf", param_number, &minconf, 0),
|
||||||
NULL))
|
NULL))
|
||||||
return command_param_failed();
|
return command_param_failed();
|
||||||
|
|
||||||
@ -890,8 +891,9 @@ static struct command_result *json_fund_channel(struct command *cmd,
|
|||||||
type_to_string(fc, struct pubkey, id));
|
type_to_string(fc, struct pubkey, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxheight = minconf_to_maxheight(*minconf, cmd->ld);
|
||||||
res = wtx_select_utxos(&fc->wtx, *feerate_per_kw,
|
res = wtx_select_utxos(&fc->wtx, *feerate_per_kw,
|
||||||
BITCOIN_SCRIPTPUBKEY_P2WSH_LEN, 0);
|
BITCOIN_SCRIPTPUBKEY_P2WSH_LEN, maxheight);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@ -917,9 +919,9 @@ static struct command_result *json_fund_channel(struct command *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct json_command fund_channel_command = {
|
static const struct json_command fund_channel_command = {
|
||||||
"fundchannel",
|
"fundchannel", json_fund_channel,
|
||||||
json_fund_channel,
|
"Fund channel with {id} using {satoshi} (or 'all') satoshis, at optional "
|
||||||
"Fund channel with {id} using {satoshi} (or 'all') satoshis, at optional {feerate}"
|
"{feerate}. Only use outputs that have {minconf} confirmations."
|
||||||
};
|
};
|
||||||
AUTODATA(json_command, &fund_channel_command);
|
AUTODATA(json_command, &fund_channel_command);
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ static struct command_result *json_withdraw(struct command *cmd,
|
|||||||
struct pubkey pubkey;
|
struct pubkey pubkey;
|
||||||
enum address_parse_result addr_parse;
|
enum address_parse_result addr_parse;
|
||||||
struct command_result *res;
|
struct command_result *res;
|
||||||
|
u32 *minconf, maxheight;
|
||||||
|
|
||||||
withdraw->cmd = cmd;
|
withdraw->cmd = cmd;
|
||||||
wtx_init(cmd, &withdraw->wtx, AMOUNT_SAT(-1ULL));
|
wtx_init(cmd, &withdraw->wtx, AMOUNT_SAT(-1ULL));
|
||||||
@ -109,6 +110,7 @@ static struct command_result *json_withdraw(struct command *cmd,
|
|||||||
p_req("destination", param_tok, &desttok),
|
p_req("destination", param_tok, &desttok),
|
||||||
p_req("satoshi", param_wtx, &withdraw->wtx),
|
p_req("satoshi", param_wtx, &withdraw->wtx),
|
||||||
p_opt("feerate", param_feerate, &feerate_per_kw),
|
p_opt("feerate", param_feerate, &feerate_per_kw),
|
||||||
|
p_opt_def("minconf", param_number, &minconf, 0),
|
||||||
NULL))
|
NULL))
|
||||||
return command_param_failed();
|
return command_param_failed();
|
||||||
|
|
||||||
@ -138,8 +140,9 @@ static struct command_result *json_withdraw(struct command *cmd,
|
|||||||
get_chainparams(cmd->ld)->network_name);
|
get_chainparams(cmd->ld)->network_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxheight = minconf_to_maxheight(*minconf, cmd->ld);
|
||||||
res = wtx_select_utxos(&withdraw->wtx, *feerate_per_kw,
|
res = wtx_select_utxos(&withdraw->wtx, *feerate_per_kw,
|
||||||
tal_count(withdraw->destination), 0);
|
tal_count(withdraw->destination), maxheight);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@ -180,10 +183,14 @@ static struct command_result *json_withdraw(struct command *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct json_command withdraw_command = {
|
static const struct json_command withdraw_command = {
|
||||||
"withdraw",
|
"withdraw", json_withdraw,
|
||||||
json_withdraw,
|
"Send to {destination} address {satoshi} (or 'all') amount via Bitcoin "
|
||||||
"Send to {destination} address {satoshi} (or 'all') amount via Bitcoin transaction, at optional {feerate}",
|
"transaction, at optional {feerate}",
|
||||||
false, "Send funds from the internal wallet to the specified address. Either specify a number of satoshis to send or 'all' to sweep all funds in the internal wallet to the address."
|
false,
|
||||||
|
"Send funds from the internal wallet to the specified address. Either "
|
||||||
|
"specify a number of satoshis to send or 'all' to sweep all funds in the "
|
||||||
|
"internal wallet to the address. Only use outputs that have at least "
|
||||||
|
"{minconf} confirmations."
|
||||||
};
|
};
|
||||||
AUTODATA(json_command, &withdraw_command);
|
AUTODATA(json_command, &withdraw_command);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user