mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +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:
committed by
Christian Decker
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:
|
Each entry in \fIoutputs\fR will include:
|
||||||
|
|
||||||
|
.RS
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
\fItxid\fR
|
\fItxid\fR
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
@@ -33,10 +34,14 @@ appended)
|
|||||||
\fIaddress\fR
|
\fIaddress\fR
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
\fIstatus\fR (whether \fIunconfirmed\fR, \fIconfirmed\fR, or \fIspent\fR)
|
\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:
|
Each entry in \fIchannels\fR will include:
|
||||||
|
|
||||||
|
.RS
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
\fIpeer_id\fR - the peer with which the channel is opened\.
|
\fIpeer_id\fR - the peer with which the channel is opened\.
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
@@ -66,6 +71,7 @@ transaction\.
|
|||||||
\fIstate\fR - the channel state, in particular \fICHANNELD_NORMAL\fR means the
|
\fIstate\fR - the channel state, in particular \fICHANNELD_NORMAL\fR means the
|
||||||
channel can be used normally\.
|
channel can be used normally\.
|
||||||
|
|
||||||
|
.RE
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
|
|
||||||
Felix \fI<fixone@gmail.com\fR> is mainly responsible\.
|
Felix \fI<fixone@gmail.com\fR> is mainly responsible\.
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Each entry in *outputs* will include:
|
|||||||
appended)
|
appended)
|
||||||
- *address*
|
- *address*
|
||||||
- *status* (whether *unconfirmed*, *confirmed*, or *spent*)
|
- *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:
|
Each entry in *channels* will include:
|
||||||
- *peer\_id* - the peer with which the channel is opened.
|
- *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);
|
AUTODATA(json_command, &listaddrs_command);
|
||||||
|
|
||||||
static struct command_result *json_listfunds(struct command *cmd,
|
static struct command_result *json_outputs(struct command *cmd,
|
||||||
const char *buffer,
|
struct json_stream *response,
|
||||||
const jsmntok_t *obj UNNEEDED,
|
struct utxo **utxos)
|
||||||
const jsmntok_t *params)
|
|
||||||
{
|
{
|
||||||
struct json_stream *response;
|
|
||||||
struct peer *p;
|
|
||||||
struct utxo **utxos;
|
|
||||||
char* out;
|
char* out;
|
||||||
struct pubkey funding_pubkey;
|
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++) {
|
for (size_t i = 0; i < tal_count(utxos); i++) {
|
||||||
json_object_start(response, NULL);
|
json_object_start(response, NULL);
|
||||||
json_add_txid(response, "txid", &utxos[i]->txid);
|
json_add_txid(response, "txid", &utxos[i]->txid);
|
||||||
@@ -850,8 +840,38 @@ static struct command_result *json_listfunds(struct command *cmd,
|
|||||||
} else
|
} else
|
||||||
json_add_string(response, "status", "unconfirmed");
|
json_add_string(response, "status", "unconfirmed");
|
||||||
|
|
||||||
|
json_add_bool(response, "reserved",
|
||||||
|
utxos[i]->status == output_state_reserved);
|
||||||
json_object_end(response);
|
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);
|
json_array_end(response);
|
||||||
|
|
||||||
/* Add funds that are allocated to channels */
|
/* Add funds that are allocated to channels */
|
||||||
|
|||||||
Reference in New Issue
Block a user