MCPcopy Create free account
hub / github.com/ElementsProject/lightning / parse_lease_rates

Function parse_lease_rates

plugins/funder.c:1320–1373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1318}
1319
1320static struct command_result *
1321parse_lease_rates(struct command *cmd, const char *buffer,
1322 const jsmntok_t *tok,
1323 struct funder_policy *policy,
1324 struct funder_policy *current_policy,
1325 u32 *lease_fee_basis,
1326 struct amount_sat *lease_fee_sats,
1327 u32 *funding_weight,
1328 u32 *channel_fee_max_proportional_thousandths,
1329 struct amount_msat *chan_fee_msats)
1330
1331{
1332 /* If there's already rates set, we start with those */
1333 if (!lease_rates_empty(current_policy->rates))
1334 policy->rates = tal_dup(policy, struct lease_rates,
1335 current_policy->rates);
1336 else if (lease_fee_basis
1337 || lease_fee_sats
1338 || funding_weight
1339 || channel_fee_max_proportional_thousandths
1340 || chan_fee_msats)
1341 policy->rates = default_lease_rates(policy);
1342 else
1343 policy->rates = NULL;
1344
1345 /* Sometimes a local macro is neater than the alternative */
1346#define ASSIGN_OR_RETURN_FAIL(type, member) \
1347 do { \
1348 if (member && \
1349 !assign_overflow_##type(&policy->rates->member, *member)) \
1350 return command_fail_badparam(cmd, #member, \
1351 buffer, tok, "overflow"); \
1352} while(0)
1353
1354 ASSIGN_OR_RETURN_FAIL(u16, lease_fee_basis);
1355 ASSIGN_OR_RETURN_FAIL(u16, funding_weight);
1356 ASSIGN_OR_RETURN_FAIL(u16, channel_fee_max_proportional_thousandths);
1357#undef ASSIGN_OR_RETURN_FAIL
1358
1359 if (chan_fee_msats
1360 && !assign_overflow_u32(&policy->rates->channel_fee_max_base_msat,
1361 chan_fee_msats->millisatoshis /* Raw: conversion */)) {
1362 return command_fail_badparam(cmd, "channel_fee_max_base_msat",
1363 buffer, tok, "overflow");
1364 }
1365 if (lease_fee_sats
1366 && !assign_overflow_u32(&policy->rates->lease_fee_base_sat,
1367 lease_fee_sats->satoshis /* Raw: conversion */)) {
1368 return command_fail_badparam(cmd, "lease_fee_base_sat",
1369 buffer, tok, "overflow");
1370 }
1371
1372 return NULL;
1373}
1374
1375static struct command_result *
1376leaserates_set(struct command *cmd,

Callers 1

json_funderupdateFunction · 0.85

Calls 4

lease_rates_emptyFunction · 0.85
default_lease_ratesFunction · 0.85
assign_overflow_u32Function · 0.85
command_fail_badparamFunction · 0.50

Tested by

no test coverage detected