If chains is NULL, max_num_chains is ignored */
| 11 | |
| 12 | /* If chains is NULL, max_num_chains is ignored */ |
| 13 | static 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 | |
| 45 | bool bolt12_chain_matches(const struct bitcoin_blkid *chain, |
| 46 | const struct chainparams *must_be_chain) |
no test coverage detected