Include PaymentId in payer metadata
[rust-lightning] / lightning / src / ln / inbound_payment.rs
index 25e79e3bc15db59fab2d05b7edd33bd8a6b9a7d9..f9e10880afbe5f5eae122d48220f5b8e5dcd9757 100644 (file)
@@ -86,6 +86,13 @@ impl ExpandedKey {
                hmac.input(&nonce.0);
                hmac
        }
+
+       /// Encrypts or decrypts the given `bytes`. Used for data included in an offer message's
+       /// metadata (e.g., payment id).
+       pub(crate) fn crypt_for_offer(&self, mut bytes: [u8; 32], nonce: Nonce) -> [u8; 32] {
+               ChaCha20::encrypt_single_block_in_place(&self.offers_encryption_key, &nonce.0, &mut bytes);
+               bytes
+       }
 }
 
 /// A 128-bit number used only once.