Skip to content

Commit

Permalink
Drop need to store pending inbound payments
Browse files Browse the repository at this point in the history
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
  • Loading branch information
valentinewallace committed Dec 7, 2021
1 parent 7c30dc8 commit 61107f8
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lightning-invoice/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where
let (payment_hash, payment_secret) = channelmanager.create_inbound_payment(
amt_msat,
DEFAULT_EXPIRY_TIME.try_into().unwrap(),
);
).unwrap();
let our_node_pubkey = channelmanager.get_our_node_id();
let mut invoice = InvoiceBuilder::new(network)
.description(description)
Expand Down
15 changes: 14 additions & 1 deletion lightning/src/chain/keysinterface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use ln::script::ShutdownScript;

use prelude::*;
use core::sync::atomic::{AtomicUsize, Ordering};
use io::{self, Error};
use io::{self, Error, Read};
use ln::msgs::{DecodeError, MAX_VALUE_MSAT};

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

impl Writeable for KeyMaterial {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
self.0.write(w)
}
}

impl Readable for KeyMaterial {
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
let buf: [u8; 32] = Readable::read(r)?;
Ok(KeyMaterial(buf))
}
}

/// Information about a spendable output to a P2WSH script. See
/// SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
#[derive(Clone, Debug, PartialEq)]
Expand Down
Loading

0 comments on commit 61107f8

Please sign in to comment.