mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
listfunds: also list reserved outputs
Currently 'listfunds' lies, a teensy eeinsy bit, in that it doesn't list all of the funds in a wallet (it omits reserved wallet UTXOs). This change makes the reserved outputs visible by listing them in the 'outputs' section along with a new field, 'reserved', which denotes the UTXO's state Changelog-Changed: JSON-RPC: `listfunds` 'outputs' now includes reserved outputs, designated as 'reserved' = true
This commit is contained in:
parent
5bb1fd4205
commit
431463b57a
6
doc/lightning-listfunds.7
generated
6
doc/lightning-listfunds.7
generated
@ -20,6 +20,7 @@ channels\.
|
||||
|
||||
Each entry in \fIoutputs\fR will include:
|
||||
|
||||
.RS
|
||||
.IP \[bu]
|
||||
\fItxid\fR
|
||||
.IP \[bu]
|
||||
@ -33,10 +34,14 @@ appended)
|
||||
\fIaddress\fR
|
||||
.IP \[bu]
|
||||
\fIstatus\fR (whether \fIunconfirmed\fR, \fIconfirmed\fR, or \fIspent\fR)
|
||||
.IP \[bu]
|
||||
\fIreserved\fR (whether this is UTXO is currently reserved for an in-flight tx)
|
||||
|
||||
.RE
|
||||
|
||||
Each entry in \fIchannels\fR will include:
|
||||
|
||||
.RS
|
||||
.IP \[bu]
|
||||
\fIpeer_id\fR - the peer with which the channel is opened\.
|
||||
.IP \[bu]
|
||||
@ -66,6 +71,7 @@ transaction\.
|
||||
\fIstate\fR - the channel state, in particular \fICHANNELD_NORMAL\fR means the
|
||||
channel can be used normally\.
|
||||
|
||||
.RE
|
||||
.SH AUTHOR
|
||||
|
||||
Felix \fI<fixone@gmail.com\fR> is mainly responsible\.
|
||||
|
@ -28,6 +28,7 @@ Each entry in *outputs* will include:
|
||||
appended)
|
||||
- *address*
|
||||
- *status* (whether *unconfirmed*, *confirmed*, or *spent*)
|
||||
- *reserved* (whether this is UTXO is currently reserved for an in-flight tx)
|
||||
|
||||
Each entry in *channels* will include:
|
||||
- *peer\_id* - the peer with which the channel is opened.
|
||||
|
@ -797,23 +797,13 @@ static const struct json_command listaddrs_command = {
|
||||
};
|
||||
AUTODATA(json_command, &listaddrs_command);
|
||||
|
||||
static struct command_result *json_listfunds(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *obj UNNEEDED,
|
||||
const jsmntok_t *params)
|
||||
static struct command_result *json_outputs(struct command *cmd,
|
||||
struct json_stream *response,
|
||||
struct utxo **utxos)
|
||||
{
|
||||
struct json_stream *response;
|
||||
struct peer *p;
|
||||
struct utxo **utxos;
|
||||
char* out;
|
||||
struct pubkey funding_pubkey;
|
||||
|
||||
if (!param(cmd, buffer, params, NULL))
|
||||
return command_param_failed();
|
||||
|
||||
utxos = wallet_get_utxos(cmd, cmd->ld->wallet, output_state_available);
|
||||
response = json_stream_success(cmd);
|
||||
json_array_start(response, "outputs");
|
||||
for (size_t i = 0; i < tal_count(utxos); i++) {
|
||||
json_object_start(response, NULL);
|
||||
json_add_txid(response, "txid", &utxos[i]->txid);
|
||||
@ -850,8 +840,38 @@ static struct command_result *json_listfunds(struct command *cmd,
|
||||
} else
|
||||
json_add_string(response, "status", "unconfirmed");
|
||||
|
||||
json_add_bool(response, "reserved",
|
||||
utxos[i]->status == output_state_reserved);
|
||||
json_object_end(response);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct command_result *json_listfunds(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *obj UNNEEDED,
|
||||
const jsmntok_t *params)
|
||||
{
|
||||
struct json_stream *response;
|
||||
struct peer *p;
|
||||
struct utxo **utxos, **reserved_utxos;
|
||||
struct command_result *ret;
|
||||
|
||||
if (!param(cmd, buffer, params, NULL))
|
||||
return command_param_failed();
|
||||
|
||||
response = json_stream_success(cmd);
|
||||
|
||||
utxos = wallet_get_utxos(cmd, cmd->ld->wallet, output_state_available);
|
||||
reserved_utxos = wallet_get_utxos(cmd, cmd->ld->wallet, output_state_reserved);
|
||||
json_array_start(response, "outputs");
|
||||
ret = json_outputs(cmd, response, utxos);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = json_outputs(cmd, response, reserved_utxos);
|
||||
if (ret)
|
||||
return ret;
|
||||
json_array_end(response);
|
||||
|
||||
/* Add funds that are allocated to channels */
|
||||
|
Loading…
Reference in New Issue
Block a user