diff --git a/Cargo.lock b/Cargo.lock index 6a2945d8..54b76ba3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,6 +73,28 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "aws-lc-rs" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ec2f1fc3ec205783a5da9a7e6c1509cc69dedf09a1949e412c1e18469326d00" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a2f9779ce85b93ab6170dd940ad0169b5766ff848247aff13bb788b832fe3f4" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + [[package]] name = "axum" version = "0.6.20" @@ -165,9 +187,9 @@ dependencies = [ [[package]] name = "bdk_electrum" -version = "0.23.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b59a3f7fbe678874fa34354097644a171276e02a49934c13b3d61c54610ddf39" +checksum = "00a9846105bf6e751adbb6946b000ff919ce24a15a941cbfe68485549b552a9c" dependencies = [ "bdk_core", "electrum-client", @@ -272,7 +294,7 @@ checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf" [[package]] name = "bitcoin-payment-instructions" version = "0.6.0" -source = "git+https://github.com/jkczyz/bitcoin-payment-instructions?rev=679dac50cc0d81ec4d31da94b93d467e5308f16a#679dac50cc0d81ec4d31da94b93d467e5308f16a" +source = "git+https://github.com/tnull/bitcoin-payment-instructions?rev=ed8657dee284f987b6791cd291d0f0f18811ee76#ed8657dee284f987b6791cd291d0f0f18811ee76" dependencies = [ "bitcoin", "dnssec-prover", @@ -367,6 +389,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "739eb0f94557554b3ca9a86d2d37bebd49c5e6d0c1d2bda35ba5bdac830befc2" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -388,6 +412,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b4b0fc281743d80256607bd65e8beedc42cb0787ea119c85b81b4c0eab85e5f" +[[package]] +name = "chacha20-poly1305" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad28386ab70dd960294556a76aaab6da2994fec47d650fd725b3012f062052a" + [[package]] name = "chrono" version = "0.4.42" @@ -448,6 +478,15 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +dependencies = [ + "cc", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -485,6 +524,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "either" version = "1.15.0" @@ -493,9 +538,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "electrum-client" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7b07e2578a6df0093b101915c79dca0119d7f7810099ad9eef11341d2ae57" +checksum = "1970c5d7bd9de6d4041cbfc3e46faa3e85fe7efcea2b0eb06750d3ae1ef577b7" dependencies = [ "bitcoin", "byteorder", @@ -592,6 +637,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.31" @@ -1184,6 +1235,16 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + [[package]] name = "js-sys" version = "0.3.82" @@ -1203,7 +1264,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "ldk-node" version = "0.8.0+git" -source = "git+https://github.com/lightningdevkit/ldk-node?rev=16eaa6f46308965f501904506be3ceecd293f358#16eaa6f46308965f501904506be3ceecd293f358" +source = "git+https://github.com/lightningdevkit/ldk-node?rev=47dad6d909af0fbb53e76d07740c04df5abdde3b#47dad6d909af0fbb53e76d07740c04df5abdde3b" dependencies = [ "async-trait", "base64 0.22.1", @@ -1357,10 +1418,11 @@ dependencies = [ [[package]] name = "lightning" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bech32", "bitcoin", + "chacha20-poly1305 0.2.0", "dnssec-prover", "hashbrown 0.13.2", "libm", @@ -1373,7 +1435,7 @@ dependencies = [ [[package]] name = "lightning-background-processor" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bitcoin", "bitcoin-io", @@ -1387,7 +1449,7 @@ dependencies = [ [[package]] name = "lightning-block-sync" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bitcoin", "bitreq", @@ -1399,7 +1461,7 @@ dependencies = [ [[package]] name = "lightning-dns-resolver" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "dnssec-prover", "lightning", @@ -1410,7 +1472,7 @@ dependencies = [ [[package]] name = "lightning-invoice" version = "0.35.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bech32", "bitcoin", @@ -1421,9 +1483,10 @@ dependencies = [ [[package]] name = "lightning-liquidity" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bitcoin", + "bitreq", "chrono", "lightning", "lightning-invoice", @@ -1436,7 +1499,7 @@ dependencies = [ [[package]] name = "lightning-macros" version = "0.2.2+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "proc-macro2", "quote", @@ -1446,7 +1509,7 @@ dependencies = [ [[package]] name = "lightning-net-tokio" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bitcoin", "lightning", @@ -1456,7 +1519,7 @@ dependencies = [ [[package]] name = "lightning-persister" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bitcoin", "lightning", @@ -1467,7 +1530,7 @@ dependencies = [ [[package]] name = "lightning-rapid-gossip-sync" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bitcoin", "bitcoin-io", @@ -1478,7 +1541,7 @@ dependencies = [ [[package]] name = "lightning-transaction-sync" version = "0.3.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bitcoin", "electrum-client", @@ -1491,7 +1554,7 @@ dependencies = [ [[package]] name = "lightning-types" version = "0.4.0+git" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "bitcoin", ] @@ -1650,7 +1713,7 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "possiblyrandom" version = "0.2.0" -source = "git+https://github.com/lightningdevkit/rust-lightning?rev=369a2cf9c8ef810deea0cd2b4cf6ed0691b78144#369a2cf9c8ef810deea0cd2b4cf6ed0691b78144" +source = "git+https://github.com/lightningdevkit/rust-lightning?rev=090e09f3992694040d3a55c1c798b3a92fb77182#090e09f3992694040d3a55c1c798b3a92fb77182" dependencies = [ "getrandom 0.2.16", ] @@ -2061,6 +2124,7 @@ version = "0.23.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a9586e9ee2b4f8fab52a0048ca7334d7024eef48e2cb9407e3497bb7cab7fa7" dependencies = [ + "aws-lc-rs", "log", "once_cell", "ring", @@ -2105,6 +2169,7 @@ version = "0.103.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -2716,7 +2781,7 @@ dependencies = [ "bitcoin", "bitcoin_hashes 0.14.0", "bitreq", - "chacha20-poly1305", + "chacha20-poly1305 0.1.2", "log", "prost", "prost-build", diff --git a/ldk-server-grpc/build.rs b/ldk-server-grpc/build.rs index 14a35806..b5171a0c 100644 --- a/ldk-server-grpc/build.rs +++ b/ldk-server-grpc/build.rs @@ -46,10 +46,6 @@ fn generate_protos() { "types.Bolt11.secret", "#[cfg_attr(feature = \"serde\", serde(serialize_with = \"crate::serde_utils::serialize_opt_bytes_hex\"))]", ) - .field_attribute( - "types.Bolt11Jit.secret", - "#[cfg_attr(feature = \"serde\", serde(serialize_with = \"crate::serde_utils::serialize_opt_bytes_hex\"))]", - ) .field_attribute( "types.Bolt12Offer.secret", "#[cfg_attr(feature = \"serde\", serde(serialize_with = \"crate::serde_utils::serialize_opt_bytes_hex\"))]", diff --git a/ldk-server-grpc/src/proto/types.proto b/ldk-server-grpc/src/proto/types.proto index f753d9d5..064aa6ef 100644 --- a/ldk-server-grpc/src/proto/types.proto +++ b/ldk-server-grpc/src/proto/types.proto @@ -30,10 +30,12 @@ message Payment { } message PaymentKind { + reserved 3; + reserved "bolt11_jit"; + oneof kind { Onchain onchain = 1; Bolt11 bolt11 = 2; - Bolt11Jit bolt11_jit = 3; Bolt12Offer bolt12_offer = 4; Bolt12Refund bolt12_refund = 5; Spontaneous spontaneous = 6; @@ -81,32 +83,19 @@ message Bolt11 { // The secret used by the payment. optional bytes secret = 3; -} - -// Represents a BOLT 11 payment intended to open an LSPS 2 just-in-time channel. -message Bolt11Jit { - // The payment hash, i.e., the hash of the preimage. - string hash = 1; - - // The pre-image used by the payment. - optional string preimage = 2; - - // The secret used by the payment. - optional bytes secret = 3; - - // Limits applying to how much fee we allow an LSP to deduct from the payment amount. - // - // Allowing them to deduct this fee from the first inbound payment will pay for the LSP’s channel opening fees. - // - // See [`LdkChannelConfig::accept_underpaying_htlcs`](https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.accept_underpaying_htlcs) - // for more information. - LSPFeeLimits lsp_fee_limits = 4; // The value, in thousands of a satoshi, that was deducted from this payment as an extra // fee taken by our channel counterparty. // - // Will only be `Some` once we received the payment. - optional uint64 counterparty_skimmed_fee_msat = 5; + // Replaces the former `PaymentKind.bolt11_jit.counterparty_skimmed_fee_msat` + // representation. JIT payments are now represented as regular BOLT 11 payments with this + // field set when applicable. + // + // Will only ever be `Some` for inbound payments received via an [bLIP-52 / LSPS 2] + // just-in-time channel, and only after the payment is observed; `None` otherwise. + // + // [bLIP-52 / LSPS 2]: https://github.com/lightning/blips/blob/master/blip-0052.md + optional uint64 counterparty_skimmed_fee_msat = 4; } // Represents a BOLT 12 ‘offer’ payment, i.e., a payment for an Offer. @@ -219,27 +208,58 @@ enum Network { REGTEST = 4; } +// Identifies the channel and counterparty that an HTLC was processed with. +message HtlcLocator { + // The channel that the HTLC was sent or received on. + string channel_id = 1; + + // The `user_channel_id` for the channel. + // This can be unset for older serialized events or if the payment was settled on-chain. + optional string user_channel_id = 2; + + // The node id of the counterparty for this HTLC. + // This can be unset for older serialized events. + optional string node_id = 3; +} + // A forwarded payment through our node. +// +// A forwarded payment can involve multiple incoming and outgoing HTLCs, e.g. when acting as a +// trampoline router. The `prev_htlcs` and `next_htlcs` fields are the canonical representation of +// the HTLCs associated with this forwarding event. Their indices do not imply pairwise +// correspondence. +// // See more: https://docs.rs/ldk-node/latest/ldk_node/enum.Event.html#variant.PaymentForwarded message ForwardedPayment{ // The channel id of the incoming channel between the previous node and us. + // Deprecated: use `prev_htlcs` instead. This is populated from `prev_htlcs[0]` + // only and may omit additional incoming HTLCs. string prev_channel_id = 1; // The channel id of the outgoing channel between the next node and us. + // Deprecated: use `next_htlcs` instead. This is populated from `next_htlcs[0]` + // only and may omit additional outgoing HTLCs. string next_channel_id = 2; // The `user_channel_id` of the incoming channel between the previous node and us. + // Deprecated: use `prev_htlcs` instead. This is populated from `prev_htlcs[0]` + // only and may omit additional incoming HTLCs. string prev_user_channel_id = 3; // The node id of the previous node. + // Deprecated: use `prev_htlcs` instead. This is populated from `prev_htlcs[0]` + // only and may omit additional incoming counterparties. string prev_node_id = 9; // The node id of the next node. + // Deprecated: use `next_htlcs` instead. This is populated from `next_htlcs[0]` + // only and may omit additional outgoing counterparties. string next_node_id = 10; // The `user_channel_id` of the outgoing channel between the next node and us. - // This will be `None` if the payment was settled via an on-chain transaction. - // See the caveat described for the `total_fee_earned_msat` field. + // Deprecated: use `next_htlcs` instead. This is populated from `next_htlcs[0]` + // only and may omit additional outgoing HTLCs. This will be `None` if the first + // outgoing HTLC was settled via an on-chain transaction. optional string next_user_channel_id = 4; // The total fee, in milli-satoshis, which was earned as a result of the payment. @@ -268,6 +288,14 @@ message ForwardedPayment{ // The caveat described above the `total_fee_earned_msat` field applies here as well. optional uint64 outbound_amount_forwarded_msat = 8; + // The set of incoming HTLCs forwarded to our node that will be claimed by this forward. + // This is the canonical incoming HTLC representation. + repeated HtlcLocator prev_htlcs = 11; + + // The set of outgoing HTLCs forwarded by our node that have been claimed by this forward. + // This is the canonical outgoing HTLC representation. + repeated HtlcLocator next_htlcs = 12; + } message Channel { diff --git a/ldk-server-grpc/src/types.rs b/ldk-server-grpc/src/types.rs index 40e35667..469de453 100644 --- a/ldk-server-grpc/src/types.rs +++ b/ldk-server-grpc/src/types.rs @@ -54,7 +54,7 @@ pub struct Payment { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PaymentKind { - #[prost(oneof = "payment_kind::Kind", tags = "1, 2, 3, 4, 5, 6")] + #[prost(oneof = "payment_kind::Kind", tags = "1, 2, 4, 5, 6")] pub kind: ::core::option::Option, } /// Nested message and enum types in `PaymentKind`. @@ -68,8 +68,6 @@ pub mod payment_kind { Onchain(super::Onchain), #[prost(message, tag = "2")] Bolt11(super::Bolt11), - #[prost(message, tag = "3")] - Bolt11Jit(super::Bolt11Jit), #[prost(message, tag = "4")] Bolt12Offer(super::Bolt12Offer), #[prost(message, tag = "5")] @@ -158,40 +156,18 @@ pub struct Bolt11 { serde(serialize_with = "crate::serde_utils::serialize_opt_bytes_hex") )] pub secret: ::core::option::Option<::prost::bytes::Bytes>, -} -/// Represents a BOLT 11 payment intended to open an LSPS 2 just-in-time channel. -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] -#[cfg_attr(feature = "serde", serde(default))] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt11Jit { - /// The payment hash, i.e., the hash of the preimage. - #[prost(string, tag = "1")] - pub hash: ::prost::alloc::string::String, - /// The pre-image used by the payment. - #[prost(string, optional, tag = "2")] - pub preimage: ::core::option::Option<::prost::alloc::string::String>, - /// The secret used by the payment. - #[prost(bytes = "bytes", optional, tag = "3")] - #[cfg_attr( - feature = "serde", - serde(serialize_with = "crate::serde_utils::serialize_opt_bytes_hex") - )] - pub secret: ::core::option::Option<::prost::bytes::Bytes>, - /// Limits applying to how much fee we allow an LSP to deduct from the payment amount. - /// - /// Allowing them to deduct this fee from the first inbound payment will pay for the LSP’s channel opening fees. - /// - /// See \[`LdkChannelConfig::accept_underpaying_htlcs`\]() - /// for more information. - #[prost(message, optional, tag = "4")] - pub lsp_fee_limits: ::core::option::Option, /// The value, in thousands of a satoshi, that was deducted from this payment as an extra /// fee taken by our channel counterparty. /// - /// Will only be `Some` once we received the payment. - #[prost(uint64, optional, tag = "5")] + /// Replaces the former `PaymentKind.bolt11_jit.counterparty_skimmed_fee_msat` + /// representation. JIT payments are now represented as regular BOLT 11 payments with this + /// field set when applicable. + /// + /// Will only ever be `Some` for inbound payments received via an [bLIP-52 / LSPS 2] + /// just-in-time channel, and only after the payment is observed; `None` otherwise. + /// + /// [bLIP-52 / LSPS 2]: + #[prost(uint64, optional, tag = "4")] pub counterparty_skimmed_fee_msat: ::core::option::Option, } /// Represents a BOLT 12 ‘offer’ payment, i.e., a payment for an Offer. @@ -292,7 +268,32 @@ pub struct LspFeeLimits { #[prost(uint64, optional, tag = "2")] pub max_proportional_opening_fee_ppm_msat: ::core::option::Option, } +/// Identifies the channel and counterparty that an HTLC was processed with. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] +#[cfg_attr(feature = "serde", serde(default))] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HtlcLocator { + /// The channel that the HTLC was sent or received on. + #[prost(string, tag = "1")] + pub channel_id: ::prost::alloc::string::String, + /// The `user_channel_id` for the channel. + /// This can be unset for older serialized events or if the payment was settled on-chain. + #[prost(string, optional, tag = "2")] + pub user_channel_id: ::core::option::Option<::prost::alloc::string::String>, + /// The node id of the counterparty for this HTLC. + /// This can be unset for older serialized events. + #[prost(string, optional, tag = "3")] + pub node_id: ::core::option::Option<::prost::alloc::string::String>, +} /// A forwarded payment through our node. +/// +/// A forwarded payment can involve multiple incoming and outgoing HTLCs, e.g. when acting as a +/// trampoline router. The `prev_htlcs` and `next_htlcs` fields are the canonical representation of +/// the HTLCs associated with this forwarding event. Their indices do not imply pairwise +/// correspondence. +/// /// See more: #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] @@ -301,23 +302,34 @@ pub struct LspFeeLimits { #[derive(Clone, PartialEq, ::prost::Message)] pub struct ForwardedPayment { /// The channel id of the incoming channel between the previous node and us. + /// Deprecated: use `prev_htlcs` instead. This is populated from `prev_htlcs\[0\]` + /// only and may omit additional incoming HTLCs. #[prost(string, tag = "1")] pub prev_channel_id: ::prost::alloc::string::String, /// The channel id of the outgoing channel between the next node and us. + /// Deprecated: use `next_htlcs` instead. This is populated from `next_htlcs\[0\]` + /// only and may omit additional outgoing HTLCs. #[prost(string, tag = "2")] pub next_channel_id: ::prost::alloc::string::String, /// The `user_channel_id` of the incoming channel between the previous node and us. + /// Deprecated: use `prev_htlcs` instead. This is populated from `prev_htlcs\[0\]` + /// only and may omit additional incoming HTLCs. #[prost(string, tag = "3")] pub prev_user_channel_id: ::prost::alloc::string::String, /// The node id of the previous node. + /// Deprecated: use `prev_htlcs` instead. This is populated from `prev_htlcs\[0\]` + /// only and may omit additional incoming counterparties. #[prost(string, tag = "9")] pub prev_node_id: ::prost::alloc::string::String, /// The node id of the next node. + /// Deprecated: use `next_htlcs` instead. This is populated from `next_htlcs\[0\]` + /// only and may omit additional outgoing counterparties. #[prost(string, tag = "10")] pub next_node_id: ::prost::alloc::string::String, /// The `user_channel_id` of the outgoing channel between the next node and us. - /// This will be `None` if the payment was settled via an on-chain transaction. - /// See the caveat described for the `total_fee_earned_msat` field. + /// Deprecated: use `next_htlcs` instead. This is populated from `next_htlcs\[0\]` + /// only and may omit additional outgoing HTLCs. This will be `None` if the first + /// outgoing HTLC was settled via an on-chain transaction. #[prost(string, optional, tag = "4")] pub next_user_channel_id: ::core::option::Option<::prost::alloc::string::String>, /// The total fee, in milli-satoshis, which was earned as a result of the payment. @@ -346,6 +358,14 @@ pub struct ForwardedPayment { /// The caveat described above the `total_fee_earned_msat` field applies here as well. #[prost(uint64, optional, tag = "8")] pub outbound_amount_forwarded_msat: ::core::option::Option, + /// The set of incoming HTLCs forwarded to our node that will be claimed by this forward. + /// This is the canonical incoming HTLC representation. + #[prost(message, repeated, tag = "11")] + pub prev_htlcs: ::prost::alloc::vec::Vec, + /// The set of outgoing HTLCs forwarded by our node that have been claimed by this forward. + /// This is the canonical outgoing HTLC representation. + #[prost(message, repeated, tag = "12")] + pub next_htlcs: ::prost::alloc::vec::Vec, } #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] diff --git a/ldk-server/Cargo.toml b/ldk-server/Cargo.toml index bc39472f..5f28956d 100644 --- a/ldk-server/Cargo.toml +++ b/ldk-server/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["bitcoin", "lightning", "ldk", "server"] categories = ["cryptography::cryptocurrencies"] [dependencies] -ldk-node = { git = "https://github.com/lightningdevkit/ldk-node", rev = "16eaa6f46308965f501904506be3ceecd293f358" } +ldk-node = { git = "https://github.com/lightningdevkit/ldk-node", rev = "47dad6d909af0fbb53e76d07740c04df5abdde3b" } serde = { version = "1.0.203", default-features = false, features = ["derive"] } hyper = { version = "1", default-features = false, features = ["server", "http2"] } http-body-util = { version = "0.1", default-features = false } diff --git a/ldk-server/src/main.rs b/ldk-server/src/main.rs index 1d12cd21..91eedfa1 100644 --- a/ldk-server/src/main.rs +++ b/ldk-server/src/main.rs @@ -29,11 +29,10 @@ use ldk_node::config::Config; use ldk_node::lightning::events::ClosureReason; use ldk_node::lightning::ln::channelmanager::PaymentId; use ldk_node::lightning::ln::types::ChannelId; -use ldk_node::CustomTlvRecord; -use ldk_node::{Builder, Event, Node}; +use ldk_node::{Builder, CustomTlvRecord, Event, Node}; use ldk_server_grpc::events; use ldk_server_grpc::events::{event_envelope, EventEnvelope}; -use ldk_server_grpc::types::Payment; +use ldk_server_grpc::types::{HtlcLocator, Payment}; use log::{debug, error, info}; use prost::Message; use tokio::net::TcpListener; @@ -526,29 +525,41 @@ fn main() { ); }, Event::PaymentForwarded { - prev_channel_id, - next_channel_id, - prev_user_channel_id, - next_user_channel_id, - prev_node_id, - next_node_id, + prev_htlcs, + next_htlcs, total_fee_earned_msat, skimmed_fee_msat, claim_from_onchain_tx, outbound_amount_forwarded_msat } => { - - info!("PAYMENT_FORWARDED: with outbound_amount_forwarded_msat {}, total_fee_earned_msat: {}, inbound channel: {}, outbound channel: {}", - outbound_amount_forwarded_msat.unwrap_or(0), total_fee_earned_msat.unwrap_or(0), prev_channel_id, next_channel_id + info!( + "PAYMENT_FORWARDED: outbound_amount_forwarded_msat {}, total_fee_earned_msat: {}, inbound HTLCs: {}, outbound HTLCs: {}", + outbound_amount_forwarded_msat.unwrap_or(0), + total_fee_earned_msat.unwrap_or(0), + prev_htlcs.len(), + next_htlcs.len(), ); + let prev_htlcs = prev_htlcs + .into_iter() + .map(|htlc| HtlcLocator { + channel_id: htlc.channel_id.to_string(), + user_channel_id: htlc.user_channel_id.map(|u| u.0.to_string()), + node_id: htlc.node_id.map(|n| n.to_string()), + }) + .collect(); + let next_htlcs = next_htlcs + .into_iter() + .map(|htlc| HtlcLocator { + channel_id: htlc.channel_id.to_string(), + user_channel_id: htlc.user_channel_id.map(|u| u.0.to_string()), + node_id: htlc.node_id.map(|n| n.to_string()), + }) + .collect(); + let forwarded_payment = forwarded_payment_to_proto( - prev_channel_id, - next_channel_id, - prev_user_channel_id, - next_user_channel_id, - prev_node_id, - next_node_id, + prev_htlcs, + next_htlcs, total_fee_earned_msat, skimmed_fee_msat, claim_from_onchain_tx, diff --git a/ldk-server/src/util/entropy.rs b/ldk-server/src/util/entropy.rs index 5be7b97d..4b73d6ee 100644 --- a/ldk-server/src/util/entropy.rs +++ b/ldk-server/src/util/entropy.rs @@ -7,10 +7,9 @@ // You may not use this file except in accordance with one or both of these // licenses. -use std::fs; -use std::io; use std::path::Path; use std::str::FromStr; +use std::{fs, io}; use ldk_node::bip39::Mnemonic; use ldk_node::entropy::{generate_entropy_mnemonic, NodeEntropy}; @@ -49,10 +48,11 @@ pub(crate) fn load_or_generate_node_entropy(storage_dir: &Path) -> io::Result ldk_server_grpc::types::PaymentKind { - kind: Some(Bolt11(ldk_server_grpc::types::Bolt11 { - hash: hash.to_string(), - preimage: preimage.map(|p| p.to_string()), - secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), - })), - }, - PaymentKind::Bolt11Jit { - hash, - preimage, - secret, - lsp_fee_limits, - counterparty_skimmed_fee_msat, - } => ldk_server_grpc::types::PaymentKind { - kind: Some(Bolt11Jit(ldk_server_grpc::types::Bolt11Jit { - hash: hash.to_string(), - preimage: preimage.map(|p| p.to_string()), - secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), - lsp_fee_limits: Some(LspFeeLimits { - max_total_opening_fee_msat: lsp_fee_limits.max_total_opening_fee_msat, - max_proportional_opening_fee_ppm_msat: lsp_fee_limits - .max_proportional_opening_fee_ppm_msat, - }), - counterparty_skimmed_fee_msat, - })), + PaymentKind::Bolt11 { hash, preimage, secret, counterparty_skimmed_fee_msat } => { + ldk_server_grpc::types::PaymentKind { + kind: Some(Bolt11(ldk_server_grpc::types::Bolt11 { + hash: hash.to_string(), + preimage: preimage.map(|p| p.to_string()), + secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), + counterparty_skimmed_fee_msat, + })), + } }, PaymentKind::Bolt12Offer { hash, preimage, secret, offer_id, payer_note, quantity } => { ldk_server_grpc::types::PaymentKind { @@ -404,28 +386,29 @@ pub(crate) fn pending_sweep_balance_to_proto( } } -#[allow(clippy::too_many_arguments)] pub(crate) fn forwarded_payment_to_proto( - prev_channel_id: ChannelId, next_channel_id: ChannelId, - prev_user_channel_id: Option, next_user_channel_id: Option, - prev_node_id: Option, next_node_id: Option, - total_fee_earned_msat: Option, skimmed_fee_msat: Option, claim_from_onchain_tx: bool, + prev_htlcs: Vec, next_htlcs: Vec, total_fee_earned_msat: Option, + skimmed_fee_msat: Option, claim_from_onchain_tx: bool, outbound_amount_forwarded_msat: Option, ) -> ForwardedPayment { + let legacy_prev = prev_htlcs.first(); + let legacy_next = next_htlcs.first(); + ForwardedPayment { - prev_channel_id: prev_channel_id.to_string(), - next_channel_id: next_channel_id.to_string(), - prev_user_channel_id: prev_user_channel_id - .expect("prev_user_channel_id expected for ldk-server >=0.1") - .0 - .to_string(), - next_user_channel_id: next_user_channel_id.map(|u| u.0.to_string()), - prev_node_id: prev_node_id.expect("prev_node_id expected for ldk-server >=0.1").to_string(), - next_node_id: next_node_id.expect("next_node_id expected for ldk-node >=0.1").to_string(), + prev_channel_id: legacy_prev.map(|h| h.channel_id.to_string()).unwrap_or_default(), + next_channel_id: legacy_next.map(|h| h.channel_id.to_string()).unwrap_or_default(), + prev_user_channel_id: legacy_prev + .and_then(|h| h.user_channel_id.clone()) + .unwrap_or_default(), + next_user_channel_id: legacy_next.and_then(|h| h.user_channel_id.clone()), + prev_node_id: legacy_prev.and_then(|h| h.node_id.clone()).unwrap_or_default(), + next_node_id: legacy_next.and_then(|h| h.node_id.clone()).unwrap_or_default(), total_fee_earned_msat, skimmed_fee_msat, claim_from_onchain_tx, outbound_amount_forwarded_msat, + prev_htlcs, + next_htlcs, } }