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