Skip to content

Commit 73a8df6

Browse files
Drop need to store pending inbound payments
and replace payment_secret with encrypted metadata See docs on verify_inbound_payment for details Also add min_value checks to all create_inbound_payment* methods
1 parent 0ab7b70 commit 73a8df6

File tree

5 files changed

+268
-25
lines changed

5 files changed

+268
-25
lines changed

lightning-invoice/src/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ where
6363
let (payment_hash, payment_secret) = channelmanager.create_inbound_payment(
6464
amt_msat,
6565
DEFAULT_EXPIRY_TIME.try_into().unwrap(),
66-
);
66+
).unwrap();
6767
let our_node_pubkey = channelmanager.get_our_node_id();
6868
let mut invoice = InvoiceBuilder::new(network)
6969
.description(description)

lightning/src/chain/keysinterface.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use ln::script::ShutdownScript;
4040

4141
use prelude::*;
4242
use core::sync::atomic::{AtomicUsize, Ordering};
43-
use io::{self, Error};
43+
use io::{self, Error, Read};
4444
use ln::msgs::{DecodeError, MAX_VALUE_MSAT};
4545

4646
/// Used as initial key material, to be expanded into multiple secret keys (but not to be used
@@ -49,6 +49,19 @@ use ln::msgs::{DecodeError, MAX_VALUE_MSAT};
4949
#[derive(Hash, Copy, Clone, PartialEq, Eq, Debug)]
5050
pub struct KeyMaterial(pub [u8; 32]);
5151

52+
impl Writeable for KeyMaterial {
53+
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
54+
self.0.write(w)
55+
}
56+
}
57+
58+
impl Readable for KeyMaterial {
59+
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
60+
let buf: [u8; 32] = Readable::read(r)?;
61+
Ok(KeyMaterial(buf))
62+
}
63+
}
64+
5265
/// Information about a spendable output to a P2WSH script. See
5366
/// SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
5467
#[derive(Clone, Debug, PartialEq)]

0 commit comments

Comments
 (0)