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

Function bolt12_chains_match

common/bolt12.c:225–257  ·  view source on GitHub ↗

If chains is NULL, max_num_chains is ignored */

Source from the content-addressed store, hash-verified

223
224/* If chains is NULL, max_num_chains is ignored */
225bool bolt12_chains_match(const struct bitcoin_blkid *chains,
226 size_t max_num_chains,
227 const struct chainparams *must_be_chain)
228{
229 /* BOLT #12:
230 * - if the chain for the invoice is not solely bitcoin:
231 * - MUST specify `offer_chains` the offer is valid for.
232 * - otherwise:
233 * - SHOULD omit `offer_chains`, implying that bitcoin is only chain.
234 */
235 /* BOLT #12:
236 * A reader of an offer:
237 *...
238 * - if `offer_chains` is not set:
239 * - if the node does not accept bitcoin invoices:
240 * - MUST NOT respond to the offer
241 * - otherwise: (`offer_chains` is set):
242 * - if the node does not accept invoices for at least one of the `chains`:
243 * - MUST NOT respond to the offer
244 */
245 if (!chains) {
246 max_num_chains = 1;
247 chains = &chainparams_for_network("bitcoin")->genesis_blockhash;
248 }
249
250 for (size_t i = 0; i < max_num_chains; i++) {
251 if (bitcoin_blkid_eq(&chains[i],
252 &must_be_chain->genesis_blockhash))
253 return true;
254 }
255
256 return false;
257}
258
259bool bolt12_chain_matches(const struct bitcoin_blkid *chain,
260 const struct chainparams *must_be_chain)

Callers 2

bolt12_chain_matchesFunction · 0.85
check_features_and_chainFunction · 0.85

Calls 1

chainparams_for_networkFunction · 0.85

Tested by

no test coverage detected