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

Function bolt12_chains_match

common/bolt12.c:13–43  ·  view source on GitHub ↗

If chains is NULL, max_num_chains is ignored */

Source from the content-addressed store, hash-verified

11
12/* If chains is NULL, max_num_chains is ignored */
13static bool bolt12_chains_match(const struct bitcoin_blkid *chains,
14 size_t max_num_chains,
15 const struct chainparams *must_be_chain)
16{
17 /* BOLT-offers #12:
18 * - if the chain for the invoice is not solely bitcoin:
19 * - MUST specify `chains` the offer is valid for.
20 * - otherwise:
21 * - the bitcoin chain is implied as the first and only entry.
22 */
23 /* BOLT-offers #12:
24 * The reader of an invoice_request:
25 *...
26 * - if `chain` is not present:
27 * - MUST fail the request if bitcoin is not a supported chain.
28 * - otherwise:
29 * - MUST fail the request if `chain` is not a supported chain.
30 */
31 if (!chains) {
32 max_num_chains = 1;
33 chains = &chainparams_for_network("bitcoin")->genesis_blockhash;
34 }
35
36 for (size_t i = 0; i < max_num_chains; i++) {
37 if (bitcoin_blkid_eq(&chains[i],
38 &must_be_chain->genesis_blockhash))
39 return true;
40 }
41
42 return false;
43}
44
45bool bolt12_chain_matches(const struct bitcoin_blkid *chain,
46 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