diff --git a/doc/lightning-listfunds.7 b/doc/lightning-listfunds.7 index a9fb6a0c1..6a1629a65 100644 --- a/doc/lightning-listfunds.7 +++ b/doc/lightning-listfunds.7 @@ -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 is mainly responsible\. diff --git a/doc/lightning-listfunds.7.md b/doc/lightning-listfunds.7.md index a3267f2d9..c475d1b42 100644 --- a/doc/lightning-listfunds.7.md +++ b/doc/lightning-listfunds.7.md @@ -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. diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index 189c97a08..ca3650b77 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -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 */