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

Function bolt12_chains_match

common/bolt12.c:14–46  ·  view source on GitHub ↗

If chains is NULL, max_num_chains is ignored */

Source from the content-addressed store, hash-verified

12
13/* If chains is NULL, max_num_chains is ignored */
14bool bolt12_chains_match(const struct bitcoin_blkid *chains,
15 size_t max_num_chains,
16 const struct chainparams *must_be_chain)
17{
18 /* BOLT #12:
19 * - if the chain for the invoice is not solely bitcoin:
20 * - MUST specify `offer_chains` the offer is valid for.
21 * - otherwise:
22 * - SHOULD omit `offer_chains`, implying that bitcoin is only chain.
23 */
24 /* BOLT #12:
25 * A reader of an offer:
26 *...
27 * - if `offer_chains` is not set:
28 * - if the node does not accept bitcoin invoices:
29 * - MUST NOT respond to the offer
30 * - otherwise: (`offer_chains` is set):
31 * - if the node does not accept invoices for at least one of the `chains`:
32 * - MUST NOT respond to the offer
33 */
34 if (!chains) {
35 max_num_chains = 1;
36 chains = &chainparams_for_network("bitcoin")->genesis_blockhash;
37 }
38
39 for (size_t i = 0; i < max_num_chains; i++) {
40 if (bitcoin_blkid_eq(&chains[i],
41 &must_be_chain->genesis_blockhash))
42 return true;
43 }
44
45 return false;
46}
47
48bool bolt12_chain_matches(const struct bitcoin_blkid *chain,
49 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