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

Function adjust_pending_out_ppm

plugins/spender/splice.c:1926–1962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1924}
1925
1926static struct command_result *adjust_pending_out_ppm(struct splice_script_result **actions,
1927 struct channel_id channel_id,
1928 struct amount_sat available_funds,
1929 struct splice_cmd *splice_cmd)
1930{
1931 for (size_t i = 0; i < tal_count(actions); i++) {
1932 if (!actions[i]->channel_id)
1933 continue;
1934 if (!channel_id_eq(actions[i]->channel_id, &channel_id))
1935 continue;
1936 /* Skip channels not using out_ppm */
1937 if (!actions[i]->out_ppm)
1938 continue;
1939
1940 /* For now max (asterisks) means 100% but that may change in the
1941 * future */
1942 if (actions[i]->out_ppm == UINT32_MAX)
1943 actions[i]->out_ppm = 1000000;
1944
1945 /* ppm percentage calculation:
1946 * action->out_sat = available_funds * out_ppm / 1000000 */
1947 if (!amount_sat_mul(&actions[i]->out_sat, available_funds,
1948 actions[i]->out_ppm))
1949 return command_fail(splice_cmd->cmd, JSONRPC2_INVALID_PARAMS,
1950 "Unable to mul sats(%s) &"
1951 " out_ppm(%"PRIu32") for channel id"
1952 " %s",
1953 fmt_amount_sat(tmpctx, available_funds),
1954 actions[i]->out_ppm,
1955 fmt_channel_id(tmpctx, &channel_id));
1956 actions[i]->out_sat = amount_sat_div(actions[i]->out_sat,
1957 1000000);
1958 actions[i]->out_ppm = 0;
1959 }
1960
1961 return NULL;
1962}
1963
1964static struct command_result *stfu_channels_get_result(struct command *cmd,
1965 const char *methodname,

Callers 1

stfu_channels_get_resultFunction · 0.85

Calls 5

amount_sat_mulFunction · 0.85
amount_sat_divFunction · 0.85
command_failFunction · 0.50
fmt_amount_satFunction · 0.50
fmt_channel_idFunction · 0.50

Tested by

no test coverage detected