option_will_fund: print out lease rates in listnodes

Note that we use the names from the spec.

Changelog-Experimental: JSON-RPC: `listnodes` now includes the `lease_rates`, if available
This commit is contained in:
niftynei 2021-05-26 18:04:07 -05:00 committed by neil saitug
parent 876ff6821e
commit f668e72dd6
3 changed files with 25 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include <common/wireaddr.h> #include <common/wireaddr.h>
#include <errno.h> #include <errno.h>
#include <wally_psbt.h> #include <wally_psbt.h>
#include <wire/peer_wire.h>
bool json_to_bitcoin_amount(const char *buffer, const jsmntok_t *tok, bool json_to_bitcoin_amount(const char *buffer, const jsmntok_t *tok,
uint64_t *satoshi) uint64_t *satoshi)
@ -369,3 +370,16 @@ void json_add_preimage(struct json_stream *result, const char *fieldname,
json_add_hex(result, fieldname, preimage, sizeof(*preimage)); json_add_hex(result, fieldname, preimage, sizeof(*preimage));
} }
void json_add_lease_rates(struct json_stream *result,
const struct lease_rates *rates)
{
json_add_amount_sat_only(result, "lease_fee_base_msat",
amount_sat(rates->lease_fee_base_sat));
json_add_num(result, "lease_fee_basis", rates->lease_fee_basis);
json_add_num(result, "funding_weight", rates->funding_weight);
json_add_amount_msat_only(result,
"channel_fee_max_base_msat",
amount_msat(rates->channel_fee_max_base_msat));
json_add_num(result, "channel_fee_max_proportional_thousandths",
rates->channel_fee_max_proportional_thousandths);
}

View File

@ -11,6 +11,7 @@ struct amount_msat;
struct amount_sat; struct amount_sat;
struct bip340sig; struct bip340sig;
struct channel_id; struct channel_id;
struct lease_rates;
struct node_id; struct node_id;
struct preimage; struct preimage;
struct pubkey; struct pubkey;
@ -179,4 +180,8 @@ void json_add_psbt(struct json_stream *stream,
const char *fieldname, const char *fieldname,
const struct wally_psbt *psbt); const struct wally_psbt *psbt);
/* Add fields from the lease_rates to a json stream.
* Note that field names are set */
void json_add_lease_rates(struct json_stream *result,
const struct lease_rates *rates);
#endif /* LIGHTNING_COMMON_JSON_HELPERS_H */ #endif /* LIGHTNING_COMMON_JSON_HELPERS_H */

View File

@ -557,6 +557,12 @@ static void json_add_node(struct json_stream *js,
for (size_t i = 0; i < tal_count(addrs); i++) for (size_t i = 0; i < tal_count(addrs); i++)
json_add_address(js, NULL, &addrs[i]); json_add_address(js, NULL, &addrs[i]);
json_array_end(js); json_array_end(js);
if (na_tlvs->option_will_fund) {
json_object_start(js, "option_will_fund");
json_add_lease_rates(js, na_tlvs->option_will_fund);
json_object_end(js);
}
} }
out: out:
json_object_end(js); json_object_end(js);