Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ default = []
#lightning-macros = { version = "0.2.0" }
#lightning-dns-resolver = { version = "0.3.0" }

lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a" }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182" }
lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182" }

bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
Expand Down Expand Up @@ -81,13 +81,13 @@ async-trait = { version = "0.1", default-features = false }
vss-client = { package = "vss-client-ng", version = "0.5" }
prost = { version = "0.11.6", default-features = false}
#bitcoin-payment-instructions = { version = "0.6" }
bitcoin-payment-instructions = { git = "https://github.com/jkczyz/bitcoin-payment-instructions", rev = "c7d7ea849fcbe8cad385c93f8057cd68ecb994b7" }
bitcoin-payment-instructions = { git = "https://github.com/tnull/bitcoin-payment-instructions", rev = "ed8657dee284f987b6791cd291d0f0f18811ee76" }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "10608650d455f4d535cbac73921be329d814854a", features = ["std", "_test_utils"] }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "090e09f3992694040d3a55c1c798b3a92fb77182", features = ["std", "_test_utils"] }
rand = { version = "0.9.2", default-features = false, features = ["std", "thread_rng", "os_rng"] }
proptest = "1.0.0"
regex = "1.5.6"
Expand Down
22 changes: 14 additions & 8 deletions src/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,9 +1304,9 @@ where

// LSPS2 requires min_final_cltv_expiry_delta to be at least 2 more than usual.
let min_final_cltv_expiry_delta = MIN_FINAL_CLTV_EXPIRY_DELTA + 2;
let (payment_hash, payment_secret) = match payment_hash {
let (payment_hash, payment_secret, payment_metadata) = match payment_hash {
Some(payment_hash) => {
let payment_secret = self
let (payment_secret, payment_metadata) = self
.channel_manager
.create_inbound_payment_for_hash(
payment_hash,
Expand All @@ -1319,7 +1319,7 @@ where
log_error!(self.logger, "Failed to register inbound payment: {:?}", e);
Error::InvoiceCreationFailed
})?;
(payment_hash, payment_secret)
(payment_hash, payment_secret, payment_metadata)
},
None => self
.channel_manager
Expand Down Expand Up @@ -1353,15 +1353,21 @@ where
invoice_builder = invoice_builder.amount_milli_satoshis(amount_msat).basic_mpp();
}

invoice_builder
.build_signed(|hash| {
let invoice = if let Some(payment_metadata) = payment_metadata {
invoice_builder.payment_metadata(payment_metadata).build_signed(|hash| {
Secp256k1::new()
.sign_ecdsa_recoverable(hash, &self.keys_manager.get_node_secret_key())
})
.map_err(|e| {
log_error!(self.logger, "Failed to build and sign invoice: {}", e);
Error::InvoiceCreationFailed
} else {
invoice_builder.build_signed(|hash| {
Secp256k1::new()
.sign_ecdsa_recoverable(hash, &self.keys_manager.get_node_secret_key())
})
};
invoice.map_err(|e| {
log_error!(self.logger, "Failed to build and sign invoice: {}", e);
Error::InvoiceCreationFailed
})
}

pub(crate) async fn handle_channel_ready(
Expand Down
14 changes: 12 additions & 2 deletions src/payment/bolt11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,14 @@ impl Bolt11Payment {
let preimage = if manual_claim_payment_hash.is_none() {
// If the user hasn't registered a custom payment hash, we're positive ChannelManager
// will know the preimage at this point.
let mut payment_metadata = invoice.payment_metadata().cloned();
let res = self
.channel_manager
.get_payment_preimage(payment_hash, payment_secret.clone(), None)
.get_payment_preimage_decrypt_metadata(
payment_hash,
payment_secret.clone(),
payment_metadata.as_deref_mut(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely as a bump commit, I think this commit does a bit too much such as decrypting and discarding the metadata?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it does essenntially only adjust to the new APIs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking I think None could have been passed here because the decrypted value isn't used in this commit?

)
.ok();
debug_assert!(res.is_some(), "We just let ChannelManager create an inbound payment, it can't have forgotten the preimage by now.");
res
Expand Down Expand Up @@ -206,9 +211,14 @@ impl Bolt11Payment {
max_proportional_opening_fee_ppm_msat: lsp_prop_opening_fee,
};
let id = PaymentId(payment_hash.0);
let mut payment_metadata = invoice.payment_metadata().cloned();
let preimage = self
.channel_manager
.get_payment_preimage(payment_hash, payment_secret.clone(), None)
.get_payment_preimage_decrypt_metadata(
payment_hash,
payment_secret.clone(),
payment_metadata.as_deref_mut(),
)
.ok();
let kind = PaymentKind::Bolt11Jit {
hash: payment_hash,
Expand Down