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

Function apply_policy

plugins/funder_policy.c:184–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184static struct amount_sat
185apply_policy(struct funder_policy *policy,
186 struct amount_sat their_funding,
187 struct amount_sat requested_lease,
188 struct amount_sat available_funds)
189{
190 struct amount_sat our_funding;
191
192 switch (policy->opt) {
193 case MATCH:
194 /* For matches, we use requested funding, if availalbe */
195 if (!amount_sat_is_zero(requested_lease))
196 their_funding = requested_lease;
197
198 /* if this fails, it implies ludicrous funding offer, *and*
199 * > 100% match. Just Say No, kids. */
200 if (!amount_sat_scale(&our_funding, their_funding,
201 policy->mod / 100.0))
202 our_funding = AMOUNT_SAT(0);
203 return our_funding;
204 case AVAILABLE:
205 /* Use the 'available_funds' as the starting
206 * point for your contribution */
207 if (!amount_sat_scale(&our_funding, available_funds,
208 policy->mod / 100.0))
209 abort();
210 return our_funding;
211 case FIXED:
212 /* Use a static amount */
213 return amount_sat(policy->mod);
214 }
215
216 abort();
217}
218
219const char *
220calculate_our_funding(struct funder_policy *policy,

Callers 1

calculate_our_fundingFunction · 0.85

Calls 4

amount_sat_is_zeroFunction · 0.85
amount_sat_scaleFunction · 0.85
abortFunction · 0.85
amount_satClass · 0.70

Tested by

no test coverage detected