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

Function apply_policy

plugins/funder_policy.c:172–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172static struct amount_sat
173apply_policy(struct funder_policy *policy,
174 struct amount_sat their_funding,
175 struct amount_sat requested_lease,
176 struct amount_sat available_funds)
177{
178 struct amount_sat our_funding;
179
180 switch (policy->opt) {
181 case MATCH:
182 /* For matches, we use requested funding, if availalbe */
183 if (!amount_sat_zero(requested_lease))
184 their_funding = requested_lease;
185
186 /* if this fails, it implies ludicrous funding offer, *and*
187 * > 100% match. Just Say No, kids. */
188 if (!amount_sat_scale(&our_funding, their_funding,
189 policy->mod / 100.0))
190 our_funding = AMOUNT_SAT(0);
191 return our_funding;
192 case AVAILABLE:
193 /* Use the 'available_funds' as the starting
194 * point for your contribution */
195 if (!amount_sat_scale(&our_funding, available_funds,
196 policy->mod / 100.0))
197 abort();
198 return our_funding;
199 case FIXED:
200 /* Use a static amount */
201 return amount_sat(policy->mod);
202 }
203
204 abort();
205}
206
207const char *
208calculate_our_funding(struct funder_policy *policy,

Callers 1

calculate_our_fundingFunction · 0.85

Calls 4

amount_sat_zeroFunction · 0.85
amount_sat_scaleFunction · 0.85
abortFunction · 0.85
amount_satClass · 0.70

Tested by

no test coverage detected