Merge pull request #2682 from jkczyz/2023-09-bolt12-test-vectors
[rust-lightning] / lightning / src / offers / invoice_request.rs
index fb0b0205bd689e1356b65ae5f7c79690479a55f5..bd6d58371a9f316cccf6b362cc4825f27171f177 100644 (file)
@@ -179,8 +179,16 @@ impl<'a, 'b, P: PayerIdStrategy, T: secp256k1::Signing> InvoiceRequestBuilder<'a
        /// by the offer.
        ///
        /// Successive calls to this method will override the previous setting.
-       pub fn chain(mut self, network: Network) -> Result<Self, Bolt12SemanticError> {
-               let chain = ChainHash::using_genesis_block(network);
+       pub fn chain(self, network: Network) -> Result<Self, Bolt12SemanticError> {
+               self.chain_hash(ChainHash::using_genesis_block(network))
+       }
+
+       /// Sets the [`InvoiceRequest::chain`] for paying an invoice. If not called, the chain hash of
+       /// [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported by the
+       /// offer.
+       ///
+       /// Successive calls to this method will override the previous setting.
+       pub(crate) fn chain_hash(mut self, chain: ChainHash) -> Result<Self, Bolt12SemanticError> {
                if !self.offer.supports_chain(chain) {
                        return Err(Bolt12SemanticError::UnsupportedChain);
                }